How to run C programs on the BeagleBone's PRU microcontroller
righto.com
righto.com
Oh god! Ack, ew, retch.
I've had to use CCS a few years ago, and it was a buggy monstrosity. I don't understand why silicon vendors have to wrap their dev tools into such horrid IDEs. One reason I loved working with AVRs is that I could get a gcc-like interface, so that I knew exactly which options and parameters were used rather than some godforsaken IDE do some magic for me and get in my way. Having to hunt down options in modal windows and tabs is enough to make my blood boil just thinking about it.
Embedded development requires very precise control and knowledge about what you're doing, and IDEs more often than not get in the way of doing that.
> Embedded development requires very precise control and knowledge about what you're doing, and IDEs more often than not get in the way of doing that.
Embedded development requires precise control and knowledge about what you're doing, and that's precisely why you would want to use the manufacturer's recommended IDE. Have you ever tried managing development with an RTOS? Or streaming data out of RAM while your code was running? Or fiddling with the processor registers when debugging? IDE's make all that much simpler, you may want to give CCS an other chance, it's a really powerful IDE.
Yes to all of the above, and had to script it too, which I couldn't do with an IDE at the time.
I indeed haven't used CCS-Eclipse in years. Has it finally eliminated its lag and RAM usage? I was always amazed how it managed to continuously stay just ahead of Moore's Law in terms of resource usage.
You're right, the lag was bad. Recently I haven't noticed it much, maybe I got used to it, or maybe it's been improved. Currently my instance of CCS 6.0.1 uses around 286MB of RAM, CCS 6.1.0 uses about 480MB of RAM. In comparison PyCharm (2016.1.4) is using 927MB of RAM :(
How did you debug code running on the hardware without an IDE? Is there an easy-ish way to do that?
gdb :)
Most in-system-debuggers expose a gdb-server interface, that a client gdb can then connect to. GDB is very scriptable.
I used to use ObjecTime, and it added random stuff to its C++/'C' code generation process that meant you were never fully SEI Level 2. We had to keep a Golden Build machine alive because of it.
(It was actually not bad; apps written in C++ with a Java-like class library which all ran inside a single process, targeted at fairly small devices. Our test hardware was this massive plastic brick with daughterboards poking out in all directions all wrapped round this utterly gorgeous curved OLED screen.)
You developed on it using a custom IDE which totally wasn't Eclipse (despite being Eclipse) which used gcc as the backend compiler and a bunch of custom tools to generate the deployment packages. Naturally, we ignored the IDE and just used makefiles, so that we could integrate the Bada build into our existing build automation.
...then one update they removed the custom tools and moved their functionality into Eclipse.
This meant that the only way to create applications was to open Eclipse, load the project, and then manually press the 'build' button.
Naturally, we complained, along with everyone else who used it, and never got an answer. The platform died soon after.
(Yes, I have tried CMake, and it is entirely the wrong kind of cross-platform.)
Surely not. Now, this may have been much more trouble than it was worth, but I very nearly guarantee there was a way to do it from a command line.
It's been a while since I Eclipsed, but I (probably erroneously) recall a "generate Makefile" option on most adaptations of it.
Eclipse + Embedded => Cancer
Retch indeed.
However --- good news! I've just found references from 2012 to a thing called MakePackage.jar, which seems to do exactly what we wanted. There certainly wasn't any such thing while I was working on it, so it looks like they changed their mind later. Which would be great, but we'd abandoned the platform by then.
Here's what seems to be left of the Bada documentation.
http://static.bada.com/contents/tutorials/bada_SDK_1.0.0/bad...
just give me a gcc and header files.
all those IDEs will do nothing other than drive away novice and experienced devs alike. only the ones that evaluated every other option and still think you hardware is the best will stick around. and for the beagle, a fully hobbyist board with no dream of being used in a product, that amounts to nobody.
Can you recommend any boards that allow embedded development without need for Windows (Microsoft or X11)?
The compiler can be coaxed, with some rather ridiculous clpru compiler-specific variable definitions, into referencing addresses from the constant table by a C number rather than loading up a general purpose register.
It is in the clpru compiler documentation under section 5.14.4 It is also discussed in some TI slides (flash required) in part 18 http://software-dl.ti.com/public/hpmp/software/pru_compiler_... PDF slides: http://software-dl.ti.com/public/hpmp/software/pru_compiler_... (PDF page 28)
TI states in their slides that this constant register table access "Barely counts as C code." I think they're right. It is, however, slightly faster. When trying to do cycle-perfect timing, such micro optimizations start to actually matter.
Reading the PWM register took 5 cycles, so I ended up with 25 nanoseconds of jitter, which caused bit errors in my Alto Ethernet emulator. Polling interrupts take 1 cycle, so I end up with no jitter. (Does anyone else think it's bizarre that TI calls them "interrupts" when you need to poll them?) You might think 1 cycle would cause 5 ns jitter, but the timer uses the same clock so everything is synchronized.
I considered using the constants table if I needed to shave off some cycles, but as you point out the code required is pretty hideous. And you also need to define all the constants in the linker file too? That's just crazy.
It provides a good reference on how to do complex tasks on the PRU.
Could you point to where the PRU compiler is located on the BeagleBone file tree? I'd like to try this out!
I'd recommend using the CCS IDE (as I describe in the article) rather than the command line compiler, but it's up to you. You'll still probably encounter frustration - it's not an Arduino experience for sure.
That doesn't mean others haven't, of course — I'm very much a software guy these days. Kinda wish I'd had a BeagleBone back when I was a kid, designing & soldering my own stuff: I bet it'd have been awesome. Can't even imagine what Forrest M. Mims could come up with using one of them as a platform!
Rather than using CCS, one can use gcc or clang targeted to cortex-m3 (gcc target: arm-none-eabi + `-march=cortex-m3`, clang:thumbv7-eabi) to build the code (with the usual caveats that you're targeting a bare metal system).
The PRU is just a cortex-m3 core which is connected in interesting ways to the cortex-a8 on which linux runs. Nothing too exotic.
Maybe you're thinking of the Cortex M3 that's on the chip for power management?
'R' for realtime.... in-order scheduing, highly optimised for determinism over performance.
(Having said that.... 'M' series is pretty good too really).
http://www.nxp.com/products/microcontrollers-and-processors/...
Th real problem with the PRU is that its more or less single vendor.