Instructions for developing software for Beaglebone Black running Ubuntu Precise (12.04), on a Ubuntu Precise (12.04) development machine.
Just install the cross-compiler toolchain:
$ sudo apt-get install gcc-arm-linux-gnueabihf $ sudo apt-get install g++-arm-linux-gnueabihf
It will install the cross-compiler, and the necessary binaries, headers and libraries for ARM development, which are stored under
In short, you only need to provide an additional command-line argument to CMake, specifying the name of a Toolchain script. You can use this script for the Beaglebone Black:
# this one is important SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_PROCESSOR arm) #this one not so much SET(CMAKE_SYSTEM_VERSION 1) # specify the cross compiler SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) # where is the target environment SET(CMAKE_FIND_ROOT_PATH <bb_fs_folder>) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
where <bb_fs> is a path to the folder containing local beaglebone file system.
Store it as Toolchain-beaglebone-black.cmake together with your top-level CMakeLists.txt and invoke CMake with:
$ cmake .. -DCMAKE_TOOLCHAIN_SCRIPT=Toolchain-beaglebone-black.cmake
If you are using any third-party libraries, you need to have them on your build machine. Copy the relevant parts of the Beaglebone filesystem, that is the whole
/usr/include /usr/lib /lib/arm-linux/gnueabihf
folders to the <bb_fs_folder> on your development machine (i.e. in the local beaaglebone filesystem folder).
For a more permanent solution, we should probably get familiar with the multiarch packages (see the Resources section for hints).
For complete instructions on sharing the internet connection from an Ubuntu workstation with the Beaglebone, see the ubuntu community help center.
Add the line
in the file
Note: This method is supposedly obsolete, possibly prolongs the boot time, and should be replaced by a script in /etc/init.d as soon as we figure out how to write those properly %)
Here we show how to enable i2c peripheral devices (similar procedure can be used to enable other peripheral devices such as uart or spi). We demonstrate how to enable i2c1 bus (pins 17 and 18 on header 9).
Device tree overlay files (peripheral devices config files) are located in /lib/firmware. Most of the prebuilt images for the BealgeBone Black come with the prebuilt device tree overlay files (extension .dtbo). In this tutorial we assume that there is a compiled file BB-I2C1-00A0.dtbo in /lib/firmware folder. First check /dev folder for i2c devices:
$ ls /dev/i2c*
Under assumption that i2c0 i i2c2 are enabled (this was the case on images we used) there should be /dev/i2c-0 and /dev/i2c-1 files. To start i2c1 device type
$ sudo -s $ echo BB-I2C1 > /sys/devices/bone_capemgr.*/slots
To check if the enabling succeeded:
$ cat /sys/devices/bone_capemgr.*/slots
(on Beaglebone Green the file is /sys/devices/platform/bone_capemgr/slots).
Under the slot list there should be a slot with the name containing BB-I2C1 string.
The last check is to list again /dev folder. Now there should be dev/i2c-0, /dev/i2c-1 and /dev/i2c-2 files. These files are enumerated by the order they were enabled. Hence, in our case i2c1 device can be accessed through /dev/i2c-2 file.
To enable the i2c1 device at boot, switch to the boot partition and find uEnv.txt file. This is a config file for u-Boot. Under optional arguments add the list of peripheral devices that should be disabled or enabled at boot (sudo privileges needed):
$ optargs = quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN capemgr.enable_partno=BB-BONE-I2C1,BB-BONE-SPI1
In this case we have disabled HDMI and HDMIN capes and enabled i2c1 and spi1 devices.
Finally, to be able to open and use /dev/i2c-2 in user space, add your user to i2c group and reboot:
$ usermod -a -G i2c <user> $ shutdown -r now
Migrate Beaglebone development page here.
Migrate BeagleBone Black page here.