Derek Molloy’s site and book with companion site are great resources. The book especially is well laid out and ranges from very basic introductory material to very specific and advanced concepts. That said, my version of the book is from 2015 and some of the items are now a bit dated, often topics related to the BBB linux OS. I’ve noted some of the differences in the sections below.
Since the BBB runs a full linux distro, it’s certainly possible to download compilers and develop code directly on the BBB. However, it’s also nice to be able to perform cross-compiled development on a PC since you can use fully featured development environments and version control.
My install is broadly based on Derek Molloy’s tutorial video which is somewhat dated. At time of writing, I installed on Ubuntu Bionic Beaver on my PC and didn’t need to do any of the sources.list updates. The whole install was done with the following commands:
sudo dpkg --add-architecture armhf sudo apt-get update sudo apt-get install crossbuild-essential-armhf
The hint Derek gives about being able to install cross-compiled libraries using the
:armhf suffix is very useful. For example
sudo apt-get install libicu-dev:armhf
Rather than downloading eclipse directly as suggested in the tutorial video, I installed the version on offer from the Ubuntu software install tool. This ensures the eclipse version is compatible with whatever version of Java your machine is running. The only extra step was to install C++ GCC Cross Compile functionality within eclipse which wasn’t loaded by default. After that, creating the Hello World cross-compiler project works exactly as described in the tutorial video.
To enable the RSA, I had to install both Remote Systems User Actions and Remote Systems End-System Runtime within eclipse. Also, the terminal connection is now part of the TM Terminal package that needs to be installed and run separately from RSA. I might skip that next time since it’s easier to just run an ssh window outside of eclipse. The manual copying within RSA is also not that much more convenient than regular sftp but the post-compile scp copy of the binary directly to the BBB described in the tutorial is very handy.
To get the on-target debugging working, I needed to install C/C++ Remote Launch. I didn’t have the BeagleBone connection displayed by default like in the tutorial video and instead needed to create a new SSH connection with the BBB IP address and username. The key copying for automatic authentication described in the tutorial works well here and no password is required.
Once things are all set up, here’s a summary of the steps to create a new project:
ssh-keygenand leave the password blank.
Create a new project. Single name projects are best since that makes the executables easier to copy over. Select C++ Managed Build and then an empty Cross GCC project. Build Project should work straight away.
In project properties, select Build Steps in C/C++ Build Settings and enter the following command to copy the executable over to the BBB once it’s compiled:
scp <ExecutableName> <BbbUsername>@<BbbIpAddress>:<BbbHomeDir>/<BbbExecutableName>.
gdb-multiarch are installed on the BBB and your PC, respectively.
In your project directory, create a file called
.gdbinit that contains the line
set architecture arm.
Images for the BBB can be downloaded from here and a description of how to burn the image onto an SD card and then flash the onboard BBB memory with the OS is here. Note: If you want to burn the eMMC onboard memory with the OS, don’t forget to download a “flasher” image rather than the regular ones meant to run natively off of the SD card.
config-pincommand as part of the Universal IO project.
config-pinappears to still use device tree overlays under the hood so it can be nice to understand them to dig into the details. Some resources:
config-pin spiand the specific role of the pin on the SPI bus (clock, data pin, etc.) is determined from the pin-out table.
/sys/class/gpioas described in Molloy’s Chapter 6. Even setting pin values is performed by writing 1’s and 0’s to these files from within your C/C++ application.
config-pincan configure the pin as
gpio(no internal resistor),
gpio_pu(pull-up resistor) and
/sys/class/gpiowhere the pin directory number corresponds to the kernel GPIO ID.
direction: The pin is configured as an output/input by writing the string ‘out’/’in’ to it.
value: When the pin is an output, writing a 0/1 makes the pin go low/high. When the pin is an input, we can read from this file to determine the logic value present on the pin.
edge: An input can be configured to block a read until an event occurs. Valid strings that can be written to this file are ‘none’ (default behavior), ‘rising’, ‘falling’ and ‘both’. It’s possible to read from this file to query the current edge behavior.
active_low: Inverts the logic level on the pin. A voltage level of Vcc/Gnd corresponds to 1/0 if this file contains 0. A value of 1 inverts the logic levels.