We assume you have some experience with the Beagle and are here to learn about the PRU. This chapter discusses what Beagles are out there, how to load the latest software image on your Beagle, how to run the Visual Studio Code IDE and how to blink an LED. ======= latest software image on your Beagle, how to run the Visual Studio Code (VS Code) IDE and how to blink an LED.
If you already have your Beagle and know your way around it, you can find the code at https://git.beagleboard.org/beagleboard/pru-cookbook-code and book contents at https://git.beagleboard.org/docs/docs.beagleboard.io under the books/pru-cookbook directory.
Selecting a Beagle¶
Which Beagle should you use?
http://beagleboard.org/boards lists the many Beagles from which to choose. Here we’ll give examples for the venerable BeagleBone Black, the robotics BeagleBone Blue, tiny PockeBeagle and the powerful AI. All the examples should also run on the other Beagles too.
If you aren’t sure which Beagle to use, it’s hard to go wrong with the BeagleBone Black. It’s the most popular member of the open hardware Beagle family.
The Black has:
AM335x 1GHz ARM® Cortex-A8 processor
512MB DDR3 RAM
4GB 8-bit eMMC on-board flash storage
3D graphics accelerator
NEON floating-point accelerator
2x PRU 32-bit microcontrollers
USB client for power & communications
2x 46 pin headers
See http://beagleboard.org/black for more details.
The Blue is a good choice if you are doing robotics.
The Blue has everything the Black has except it has no Ethernet and no HDMI. But it also has:
Wireless: 802.11bgn, Bluetooth 4.1 and BLE
Battery support: 2-cell LiPo with balancing, LED state-of-charge monitor
Charger input: 9-18V
Motor control: 8 6V @ 4A servo out, 4 bidirectional DC motor out, 4 quadrature encoder in
Sensors: 9 axis IMU (accels, gyros, magnetometer), barometer, thermometer
User interface: 11 user programmable LEDs, 2 user programmable buttons
https://www.hackster.io/53815/controlling-edumip-with-ni-labview-2005f8 shows how to assemble the robot and control it from LabVIEW.
The PocketBeagle is the smallest member of the Beagle family. It is an ultra-tiny-yet-complete Beagle that is software compatible with the other Beagles.
The Pocket is based on the same processor as the Black and Blue and has:
8 analog inputs
44 digital I/Os and
numerous digital interface peripherals
See http://beagleboard.org/pocket for more details.
If you want to do deep learning, try the BeagleBone AI.
The AI has:
Dual Arm® Cortex®-A15 microprocessor subsystem
2 C66x floating-point VLIW DSPs
2.5MB of on-chip L3 RAM
2x dual Arm® Cortex®-M4 co-processors
4x Embedded Vision Engines (EVEs)
2x dual-core Programmable Real-Time Unit and Industrial Communication SubSystem (PRU-ICSS)
2D-graphics accelerator (BB2D) subsystem
Dual-core PowerVR® SGX544™ 3D GPU
IVA-HD subsystem (4K @ 15fps encode and decode support for H.264, 1080p60 for others)
BeagleBone Black mechanical and header compatibility
1GB RAM and 16GB on-board eMMC flash with high-speed interface
USB type-C for power and superspeed dual-role controller; and USB type-A host
Gigabit Ethernet, 2.4/5GHz WiFi, and Bluetooth
Zero-download out-of-box software experience with Debian GNU/Linux
Installing the Latest OS on Your Bone¶
You want to find the latest version of Debian that is available for your Bone.
On your host computer open a browser and go to http://www.beagleboard.org/distros.
This shows you two current choices of recent Debian images, one for the BeagleBone AI (AM5729 Debian 10.3 2020-04-06 8GB SD IoT TIDL) and one for all the other Beagles ( AM3358 Debian 10.3 2020-04-06 4GB SD IoT). Download the one for your Beagle.
It contains all the packages we’ll need.
Flashing a Micro SD Card¶
I’ve downloaded the image and need to flash my micro SD card.
Get a micro SD card that has at least 4GB and preferably 8GB.
There are many ways to flash the card, but the best seems to be Etcher by https://www.balena.io/. Go to https://www.balena.io/etcher/ and download the version for your host computer. Fire up Etcher, select the image you just downloaded (no need to uncompress it, Etcher does it for you), select the SD card and hit the Flash button and wait for it to finish.
Once the SD is flashed, insert it in the Beagle and power it up.
Visual Studio Code IDE¶
How do I manage and edit my files?
Just point the browser on your host computer to http://192.168.7.2:3000 and start exploring. You may also want to upgrade bb-code-server to pull in the latest updates. Another route to take is to apply this command to boot the service called bb-code-server.
sudo systemctl start bb-code-server.service
If you want the files in your home directory to appear in the tree structure click the settings gear and select Show Home in Favorites as shown in Visual Studio Code Showing Home files.
Just point the browser on your host computer to http://192.168.7.2:3000 and start exploring.
If you want to edit files beyond your home directory you can link to the root file system by:
bone:~$ cd bone:~$ ln -s / root bone:~$ cd root bone:~$ ls bbb-uEnv.txt boot etc ID.txt lost+found mnt opt root sbin sys usr bin dev home lib media nfs-uEnv.txt proc run srv tmp var
Now you can reach all the files from VS Code.
Getting Example Code¶
You are ready to start playing with the examples and need to find the code.
You can find the code on the PRU Cookbook Code project on git.beagleboard.org: https://git.beagleboard.org/beagleboard/pru-cookbook-code. Just clone it on your Beagle.
bone:~$ cd /opt/source bone:~$ git clone https://git.beagleboard.org/beagleboard/pru-cookbook-code bone:~$ cd pru-cookbook-code bone:~$ sudo ./install.sh bone:~$ ls -F 01case/ 03details/ 05blocks/ 07more/ README.md 02start/ 04details/ 06io/ 08ai/
Each chapter has its own directory that has all of the code.
bone:~$ cd 02start/ bone:~$ ls hello.pru0.c hello.pru1_1.c Makefile setup.sh ai.notes hello2.pru1_1.c hello2.pru2_1.c Makefile hello2.pru0.c hello2.pru1.c hello.pru0.c setup2.sh* hello2.pru1_0.c hello2.pru2_0.c hello.pru1_1.c setup.sh*
Go and explore.