http://dev.ardupilot.com/wiki/building-for-beaglebone-black-on-linux/
http://bettercommute.org/emblinux/projects/fall2013/Project_beagleboard_Aditya.pdf
http://wiki.beyondlogic.org/index.php/BeagleBoneBlack_Building_Kernel
http://bettercommute.org/emblinux/projects/fall2013/Project_beagleboard_Aditya.pdf
http://wiki.beyondlogic.org/index.php/BeagleBoneBlack_Building_Kernel
Contents
[hide]Compiling the BeagleBone Black Kernel
The following contains instructions for building the BeagleBone Black kernel on Ubuntu 14.04.
Prerequisites
ARM Cross Compiler
To compile the linux kernel for the BeagleBone Black, you must first have an ARM cross compiler installed. I use gcc version 4.7.3 that ships with Ubuntu 14.04. To install the compiler run:
sudo apt-get install gcc-arm-linux-gnueabi
GIT
The Beaglebone patches and build scripts are stored in a git repository. Install git:
sudo apt-get install git
And configure with your identity.
git config --global user.email "your.email@here.com"
lzop Compression
The Linux Kernel is compressed using lzo. Install the lzop parallel file compressor:
sudo apt-get install lzop
uBoot mkimage
The bootloader used on the BeagleBone black is U-Boot. U-Boot has a special image format called uImage. It includes parameters such as descriptions, the machine/architecture type, compression type, load address, checksums etc. To make these images, you need to have a mkimage tool that comes part of the U-Boot distribution. Download U-Boot, make and install the U-Boot tools:
wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2 tar -xjf u-boot-latest.tar.bz2 cd into u-boot directory make tools-only sudo install tools/mkimage /usr/local/bin
Compiling the BeagleBone Black Kernel
Here we compile the BeagleBone Black Kernel, and generate an uImage file with a DTB blob:
git clone git://github.com/beagleboard/kernel.git cd kernel git checkout 3.12 ./patch.sh cp configs/beaglebone kernel/arch/arm/configs/beaglebone_defconfig wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin cd kernel make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- beaglebone_defconfig -j4 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage dtbs LOADADDR=0x80008000 -j4
Now we build any kernel modules:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
And if you have your rootfs ready, you can install them:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/home/cpeacock/export/rootfs modules_install
Testing
TFTP Server
Rather than flashing your newly created kernel to find out it doesn't work or it is not quite configured correctly, a better way is to load the kernel into RAM and boot it from there. U-Boot allows kernel images to be loaded via TFTP.
To speed up development, I create an 'export' directory. A TFTP server is then configured to use this directory as the TFTP root.
From the export directory, add symbolic links to the kernel images. This way, you can recompile the Kernel and the new image is instantly available without having to move it.
ln -s /path to linux/arch/arm/boot/uImage uImage-BBB-3.12.1 ln -s /path to linux/arch/arm/boot/dts/am335x-boneblack.dtb am335x-boneblack.dtb
U-Boot tftpboot
To test your kernel, bring up a serial console to the BeagleBone Black. First we will need to configure the IP addresses. The ipaddr variable contains the IP address for the BeagleBone Black, while the serverip variable is the address of the TFTP server containing the kernel image.
setenv ipaddr 192.168.0.250 setenv serverip 192.168.0.251
These variables can be saved to non-volatile memory to speed up development.
Next load the Kernel image and device tree binary blob:
tftpboot ${fdtaddr} am335x-boneblack.dtb
tftpboot ${kloadaddr} uImage-BBB-3.12.1
Let's use the existing root filesystem, and send kernel messages to ttyO0:
setenv bootargs console=ttyO0,115200n8 quiet root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait
And boot from the memory location:
bootm ${kloadaddr} - ${fdtaddr}
Your BeagleBone Black should now boot your new Kernel:
## Booting kernel from Legacy Image at 80007fc0 ... Image Name: Linux-3.12.9-00110-g68acfc8-dirt Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 4563848 Bytes = 4.4 MiB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ... OK ## Flattened Device Tree blob at 80f80000 Booting using the fdt blob at 0x80f80000 XIP Kernel Image ... OK OK Using Device Tree in place at 80f80000, end 80f899de Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 3.12.9-00110-g68acfc8-dirty (cpeacock@ubuntu) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) ) #1 SMP Sun Jun 22 00:13:00 PDT 2014 [ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] Machine: Generic AM33XX (Flattened Device Tree), model: TI AM335x BeagleBone
The example shown is to use the filesystem already in place (i.e. ext4 on mmcblk0p2). The preferred option is to export a root NFS filesystem.
Booting from NFS
Booting from NFS has the added advantage that you can compile userland binaries on your development box, install them to the NFS export and have instant access to them on your target system.
This requires a root filesystem to be present on your development box with binaries that have been cross compiled for ARM. Various distributions exist to assist you with this. It is assumed a NFS Server is installed and configured properly to export this directory.
Angstrom BeagleBone demo files can be downloaded from here
Download the raw filesystem and decompress:
mkdir rootfs wget http://downloads.angstrom-distribution.org/demo/beaglebone/Angstrom-systemd-image-eglibc-ipk-v2012.12-beaglebone-2013.09.12.rootfs.tar.xz tar -xJf Angstrom-systemd-image-eglibc-ipk-v2012.12-beaglebone-2013.09.12.rootfs.tar.xz -C rootfs
At this point you will need to ensure your Kernel modules are present. If not, run the following from your Kernel folder to install the modules on your rootfs:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/home/cpeacock/export/rootfs modules_install
In U-Boot, you can now issue the following commands to load your Linux Kernel from TFTP and your rootfs over NFS:
setenv ipaddr 192.168.0.250
setenv serverip 192.168.0.251
tftpboot ${fdtaddr} am335x-boneblack.dtb
tftpboot ${kloadaddr} uImage-BBB-3.14.1
setenv bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=192.168.0.251:/home/cpeacock/export/rootfs ip=192.168.0.250:::::eth0
bootm ${kloadaddr} - ${fdtaddr}
NFS boot failures
If your NFS root freezes during boot with a message similar to:
nfs: server 192.168.0.251 not responding, still trying
Then it is possible the network connection used by the NFS connection has been re-configured. On Angstrom, this connection is re-established by the Connection Manager (ConnMan.) To quickly overcome this problem, remove /lib/systemd/system/connman.service from your rootFS.
ArduPilot on Beagle Bone Black
To start with, get your BeagleBone running Debian.
You will need a microSD card of 4GB or greater and a 5VDC power supply of 1A or higher. You can also use a powered USB hub. It is highly recommended that you not use the USB port on a laptop, which has current limitations.
Go to the BeagleBoard website and get the latest image http://beagleboard.org/latest-images. You may find multiple images on the page. For ArduPilot on BeagleBone Black you have to download the Debian (BeagleBone Black – 2GB eMMC) image. You can find it under BeagleBone Black (eMMC flasher) header.
For example, the current image is BBB-eMMC-flasher-debian-7.5-2014-05-14-2gb. The date (in this case 2014-05-14) and the version number (in this case 7.5) may change. Make sure you download the latest image.
On Ubuntu/Mac OS X
Verify Image with:
md5sum BBB-eMMC-flasher-debian-7.5-2014-05-14-2gb.img.xz 74615fb680af8f252c034d3807c9b4ae BBB-eMMC-flasher-debian-7.5-2014-05-14-2gb.img.xz
before plugging your SD card into your computer, type
df -h
this will list the current mounted drives.
Now plug in your SD card and type
df -h
and see what the drive that was added is called.
In my case it was /dev/sdd1
in which case in the command below, the it is writtern dd of=/dev/sdd replace this with the correct address for your SD card.
IF YOU GET THIS WRONG YOU CAN WIPE YOUR HDD……..
then xzcat it to your SD card in your Ubuntu/Mac OS X machine
xzcat BBB-eMMC-flasher-debian-7.1-2013-10-08.img.xz | dd of=/dev/sdd bs=1M
when this is finished, remove the SD Card and place it into your BBB.
On Windows
Download Win32 disk imager from here. Insert your SD card, then start the application that you downloaded.
Select the image that you downloaded and then press Write.
when this is finished, remove the SD Card and place it into your BBB.
Flashing the image to the eMMC
Place the SD card in your BBB. Make sure you have removed Ethernet and all other USB devices from your BBB. Connect it to a wall adapter (5VDC 1A) or a powered USB hub.
Press the boot button, and hold it down while booting, until all four blue lights are solid.
Let go, and wait. It will take around 15 mins.
The lights will flicker a lot at this stage, you will know it is complete when the four lights return to solid Blue (no flickering). Power down the BBB and remove the SD card.
Connect the BeagleBone Black to your machine using the USB cord that’s provided with it. Depending on your OS, install the required drivers.
Now ssh into the BeagleBone Black by typing
ssh root@192.168.7.2
There is no password for the root user on the Debian image
You could also connect the BBB to your local network over Ethernet and ssh to it.
Making the rt kernel
modified for the RT version, and to simplify.
Compiling the BeagleBone Black Kernel
The following contains instructions for building the BeagleBone Black kernel on your PC with Ubuntu 13.04 O.S. .
to make it simple, run
sudo su
you may need to put in your password here…
if you do not have this already, make the following directory
mkdir /home/YOUR_USERNAME/export
mkdir /home/YOUR_USERNAME/export/rootfs
Prerequisites
ARM Cross Compiler
To compile the linux kernel for the BeagleBone Black, you must first have an ARM cross compiler installed on your linux box. I use gcc-4.7-arm-linux-gnueabi-base that comes with Ubuntu 13.04. To install the compiler run:
apt-get install gcc-arm-linux-gnueabi
GIT
The Beaglebone patches and build scripts are stored in a git repository. Install git:
apt-get install git
And configure with your identity.
git config --global user.email "your.email@here.com"
lzop Compression
The kernel is compressed using lzo. Install the lzop parallel file compressor:
apt-get install lzop
uBoot mkimage
The bootloader used on the BeagleBone black is u-boot. u-boot has a special image format called uImage. It includes parameters such as descriptions, the machine/architecture type, compression type, load address, checksums etc. To make these images, you need to have a mkimage tool that comes part of the u-Boot distribution. Download u-boot, make and install the u-boot tools:
wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2 tar -xjf u-boot-latest.tar.bz2
cd u-boot-2013.10 (look to see what this is called, it may have changed)
make tools (don't work with last revision of u-boot need a revision) install tools/mkimage /usr/local/bin
Compiling the BeagleBone Black Kernel
Here we compile the BeagleBone Black Kernel, and generate an uImage file with the DTB blob appended to the kernel for ease of use.
git clone git://github.com/beagleboard/kernel.git
cd kernel
git checkout 3.8-rt
./patch.sh
cp configs/beaglebone kernel/arch/arm/configs/beaglebone_defconfig
wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin
cd kernel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- beaglebone_defconfig -j4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage dtbs -j4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage-dtb.am335x-boneblack -j4
Now we build any kernel modules:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
And if you have your rootfs ready, you can install them:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/home/YOUR_USERNAME/export/rootfs modules_install
Installing the RT kernel
After you have made the Linux kernel…
ensure you have Debian installed on the beaglebone and ssh into the Beaglebone from Linux….
ssh root@192.168.1.3
(my ip address, adjust for your beaglebone)
Go to folder /boot/uboot/
cd /boot/uboot/
make sure there is a backup folder there..
if not
mkdir backup
then backup your zImage
cp zImage uInitrd backup/
then
ls /lib/modules
it should show 3.8.13-bone28 or similar
now we need to go to our Ubuntu computers terminal
go to your export folder that you made
cd /home/YOUR_USER_NAME/export/rootfs/lib/modules
and run
rsync -avz 3* root@192.168.1.3:/lib/modules/
then run
rsync /home/proficnc/u-boot-2013.10/kernel/kernel/arch/arm/boot/zImage 192.168.1.3 :/boot/uboot/
back on your Beaglebone run the following
ls /lib/modules
you should now have both the old file and the new rt folder.
Now type
sync reboot
Some useful tips…..
Hooking up the sensors
When hooking up your Sensor board it connects as follows (using SHORT wires)
I2c Debug
To detect if the i2c is working, you can use the following command
i2cdetect -r 1
The numbers: 1e, 53, 69, 77 are the MAG, Gyro, Accel, and Baro.(not in that order)
Hooking up your GPS
To be added
Hooking up your Receiver
To be added
Hooking up your servos
To be added
Hooking up your Airspeed sensor
To be added
Devices tested so far
Responded with the Who Am I request on SPI
1. MPU6000
2. MPU9250 (may have compass issues due to soldering of jumper wire)
3. MS5611 (SPI)
1. MPU6000
2. MPU9250 (may have compass issues due to soldering of jumper wire)
3. MS5611 (SPI)
Not responding on SPI
1 LSM9DS0 ( soldering issue, no connection to I/O
1 LSM9DS0 ( soldering issue, no connection to I/O
Responded to I2C detect
1. CapeID EEPROM 0x54h AT24CS32
2. CapeID COA_OTP 0x5Ch AT24CS32
3. Crypto 0x64h ATSHA204
4. Airspeed 0x28h MS4525DO-DS3AIXXXDS
5. Compass Ext 0x1eh HMC5883L
6. Power management 0x24 TPS65217C
7. on-board EEProm 0x50h unknown
8. HDMI core…. unused, do not enable 0x34
1. CapeID EEPROM 0x54h AT24CS32
2. CapeID COA_OTP 0x5Ch AT24CS32
3. Crypto 0x64h ATSHA204
4. Airspeed 0x28h MS4525DO-DS3AIXXXDS
5. Compass Ext 0x1eh HMC5883L
6. Power management 0x24 TPS65217C
7. on-board EEProm 0x50h unknown
8. HDMI core…. unused, do not enable 0x34
Not responded to I2C test
1. MS5611 (I2C) 0x76h
2. RGB LED Driver 0x55h TCA62724 (is conflicting with non existent Cape eeprom)
1. MS5611 (I2C) 0x76h
2. RGB LED Driver 0x55h TCA62724 (is conflicting with non existent Cape eeprom)
Adjusting the BBB clock
cpufreq-info
shows your current frequency
Edit /etc/default/cpufrequtils (you might need to create it if it doesn’t exist). Specify the governor with the GOVERNOR variable:
nano /etc/default/cpufrequtils
add the following……
# valid values: userspace conservative powersave ondemand performance # get them from cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
GOVERNOR="performance"
CTRL-X to exit
Y to save
Reboot, and check to see that it has worked
Installing and Making ArduPilot on BBB
install git, make, gawk, g++, arduino-core on your BBB
apt-get install git make gawk g++ arduino-core git clone git://github.com/diydrones/ardupilot.git
then open
cd ardupilot/ArduPlane
or
cd ardupilot/ArduCopter
or
cd ardupilot/ArduRover2
then type
make configure
then
make linux
from this directory, run the tmp/ArduPlane.elf (or ArduCopter, or ArduRover)
tmp/ArduPlane.elf
Connecting to GCS
To be added……………
Status
The following table sumarizes the driver development status:
| MILESTONE | STATUS |
|---|---|
| ArduPilot running in the BBB (I2C connected sensors) | Ok |
| Device Tree for the PXF | WIP |
| MPU6000 SPI userspace driver | Ok |
| MPU9150 I2C userspace driver | Ok |
| LSM9DS0 SPI userspace driver | Coded |
| MPU9250 SPI userspace driver | Coded |
| MS5611 I2C/SPI userspace driver | Coded |
| GPIO userspace driver | WIP |
| I2CDriver multi-bus aware | WIP |
| AP_InertialSensor_Linux | ToDo |
| PRU PWM driver | Ok (issue with the PREEMPT_RT kernel) |
| MPU6000 SPI kernel driver | WIP |
| MPU9150 I2C kernel driver | ToDo |
| LSM9DS0 SPI kernel driver | ToDo |
| MPU9250 SPI kernel driver | ToDo |
| MS5611 I2C/SPI kernel driver | ToDo |
No comments:
Post a Comment