
Understanding the BeagleBone’s built in microcontrollers (2016) - codezero
http://www.righto.com/2016/08/pru-tips-understanding-beaglebones.html
======
etaioinshrdlu
Why do the PRU's exist? Part of the reason is that real time programming is
kind of hard. It's much easier to reason about if you have dedicated
processors per task!

My experience with real time systems led me to believe that RTOS's are kind of
harmful and don't live up to expectations.

Using an RTOS felt basically like a regular OS but with cooperative
multitasking. I could never separate the time consumption of one task from
another and think about them in isolation.

What I really ended up wanting was preemptive multitasking.

But to instead divide the CPU time into fixed allocation of say 10 to 100
tasks, each with a dedicated slice of CPU time that never varies.

Then you can finally reason about tasks in isolation!

Interrupts are then disallowed.

It's basically equivalent to having a bunch of little CPUs communicating. (One
should try to use ring buffers for all communication, not shared memory.)

To me, this is the only real time architecture I feel smart enough to even
handle.

~~~
learc83
I designed a product once using a Parallax Propeller. I loved it because it
had 8 CPU cores that had rotating access to shared memory and no interrupts.
If I remember correctly I did implement a ring buffer to handle communication
between cores. I think the Propeller 2 is close to being released now that I
think about it.

~~~
etaioinshrdlu
Totally. Now that is a nice architecture. It looks like it may have trouble
attracting wide industry adoption as it is a little idiosyncratic with Spin
and custom languages for everything...

~~~
learc83
Yeah Spin is a definite barrier. Right when I was wrapping up my design,
Parallax was just starting to encourage people to use the C compiler in
production. I would guess the Prop 2 will be similar.

It's still different enough to scare a lot of people off, but I'll give it a
shot. I went poking around the forums and it looks like they just shipped out
the first 100 evaluation boards in December.

------
wybiral
I love the BeagleBone boards. Some of my favorite SBC's, especially the Octavo
OSD335x-based [1] PocketBeagle [2].

For anyone interested in more examples and explanation of PRU programming on
BeagleBone boards this repo is really good:
[https://github.com/MarkAYoder/PRUCookbook](https://github.com/MarkAYoder/PRUCookbook)

[1]
[https://octavosystems.com/octavo_products/osd335x/](https://octavosystems.com/octavo_products/osd335x/)

[2] [https://beagleboard.org/pocket](https://beagleboard.org/pocket)

~~~
Gibbon1
We use them at work. The NAND flash is really solid compared to what we were
using previously. However we also use a super cap to keep the lights on while
the system shuts down too.

Notable though the power controller for the BeagleBone has a serious issue
with brownouts/slow power application. If the power ramps up too slowly it'll
hang and needs to be manually reset. That's a not ready for prime time sort of
thing. We solve it with a small uP that monitors the BB and kicks it if it
fails to power up or hangs.

~~~
elcritch
You could add a voltage based trigger chip. Set it up to hold the reset line
on the BB until it reaches a sufficient voltage.

~~~
Gibbon1
You could, though I've found analog jungle logic to do things like this tends
to end in sorrow. With a watchdog uP you can also force the host to verify
it's actually functioning. Bonus is that cures 'failed to boot properly' Which
happens.

We do that to avoid having to send out a tech. Amusingly a friend maintains a
similar system on satellite hardware.

~~~
elcritch
Sending a tech out to fix a satellite would definitely be quite a trip.

------
hinkley
I put my BBBs aside for a bit and when I came back to them I could never get
the ROM flashing instructions to work again and gave up.

But I get a kick out of getting more oomph out of little devices than you’d
think you could, and one of the things I’d hoped to accomplish with the PRUs
was to get some streaming processing going.

If I understood correctly, if you wanted stable, high sampling rates on GPIO
you were going to want to do that on the PRU, and with 2 you could send and
receive in duplex. So I thought some sort of control or logging backplane to
remove traffic off of the underpowered ethernet port would be pretty cool.

And then the other idea was figuring out how to cross compile zlib to do
transport compression without hogging the CPU.

but now I’m off fiddling with NanoPi’s, and not even really as embedded
devices. With 1GB of memory and GigE ethernet I’m thinking of them as tiny
servers instead. I’m probably missing out, though.

~~~
smcl
Weird - I had the same problem, leaving the board untouched for a while (a
year) then trying again to reflash and failing completely. I just assumed I’d
messed something up accidentally

------
amelius
I think more boards should have a bunch of simple microcontrollers on board
(besides the main CPU) for real-time control.

~~~
kens
Just to clarify, an interesting thing about the BeagleBone is the
microcontrollers are _inside_ the main CPU chip.

~~~
petra
What's the big advantage it gives ?

~~~
wtracy
From a user/developer perspective, the advantage would be low latency.

I imagine that the more interesting advantages are from the perspective of the
board designer.

~~~
gmueckl
You can get several kinds of guarantees out of these combinations: the
microcontroller gives you an environment suitabke for guaranteed timings (not
just latency), but also a seperate domain to isolate your software in. So
stuff like highly safety critical code goes into the microcontoller (e.g.
tight monitoring and control loops) while the complex application fluff (UI,
networking, bells and whistles) goes on the main CPU with a big, convenient OS
to develop on. And both parts can barely influence each other in unintended
ways.

There are a lot of boards on the embedded systems market that use e.g. ARMs
big.LITTLE architecture for that.

~~~
wtracy
Sorry, I misunderstood the question to mean, "What is the advantage to having
the microcontroller on the CPU die, as opposed to having separate chips on the
same board."

~~~
gmueckl
There are software side advantages as the interconnect between the two can be
very different from bus interface like SPI or I2C. Some of these systems offer
shared memory between the cores, for example.

------
god_bless_texas
I feel like I constantly read things 2 weeks late on HN. I just got done
integrating a SAM32 with a raspi. Insulting to say, I have a BBB on the shelf,
in a box.

~~~
etaioinshrdlu
Did you program the little chip from the ras pi? I did it with OpenOCD and it
was rather easy. It was more reliable than Atmel's own tools which are garbage
:)

~~~
god_bless_texas
No both separately. But I'm going to look at OpenOCD now.

~~~
etaioinshrdlu
The one issue I ran into was that verification failed unless I padded the end
of the image to upload with 0xFF until it finished on a complete sector.

------
mch82
The cool thing about the BeagleBone in general is that it’s design is released
under a permissive open source license. Kind of like the “Apache 2.0” of
hardware.

A Raspberry Pi is closed source (though it can be designed in as a component
to a larger open source hardware system).

An Arduino is “share-alike”, so more restrictive like a GPL 2+ license.

------
rshm
One of the use case : 14-CHANNEL, 100MSPS LOGIC ANALYZER

[[https://hackaday.com/2015/02/19/turn-your-beagleboneblack-
in...](https://hackaday.com/2015/02/19/turn-your-beagleboneblack-in-
to-a-14-channel-100msps-logic-analyzer/)]

------
makomk
More recently, people have experimented with repurposing the ARISC power
management core on Allwinner H3-based boards like the Orange Pi for similar
realtime purposes: [https://github.com/orange-
cnc/h3_arisc_firmware](https://github.com/orange-cnc/h3_arisc_firmware) (It's
basically an outdated OpenRISC core with direct access to some GPIO pins
running at up to a few hundred megahertz.)

------
mutagen
I bought (or crowdfunded, don't remember) the
[https://bela.io/](https://bela.io/) cape for the BeagleBone and have it
sitting on the shelf waiting for me to free up some time to dig into the
existing ecosystem and try to take things further.

