Recent Changes - Search:

Research

Notes

Architecture

Faults

System

Planning

Background

OS

Misc

edit SideBar

BBBRobot

Installing and Running PINT on a Beagle Bone Black.


June 27, 2015

Context

Want to replace my computer at the office with a BBB so that I can work at home. Does not need to be a perfect replacement; just being able to develop more from home would be great.

In the future may decide to simulate multiple robots, at which point BBB are a cheap alternative to having a bunch of computers.

RT Linux

The first step is installing the RT Patch on the BBB. I think I also want to switch over to Ubuntu from the default, because I know Ubuntu better.

Okay, this is getting a little complicated.

I want to create a image with Ubuntu and a patched kernel. I have no idea how to do any of this. Well, a little bit... maybe. I want the image to be flashed to the BeagleBoneBlack's internal 2GB of flash. This seems like the best solution for potentially having multiple BBBs; my first idea to build the kernel on the BBB itself would take a long time and have to be done on each individual board.

SD Disk Img

http://blog.logikonlabs.com/how-to-create-a-custom-microsd-card-image-for-the-beaglebone-black/

Create a image for the SD card:

  > dd if=/dev/zero of=cust_bbb.img bs=1M count=1000

Partition it

  > sudo sfdisk --in-order --Linux --unit M cust_bbb.img  << EOF
    > 1,48,0xE,*
    > ,,,-
    > EOF

[sudo] password for jcmarsh: Warning: cust_bbb.img is not a block device Disk cust_bbb.img: cannot get geometry

Disk cust_bbb.img: 130 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature

 cust_bbb.img: unrecognized partition table type

Old situation: No partitions found New situation: Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System

cust_bbb.img1 * 1 48 48 49152 e W95 FAT16 (LBA) cust_bbb.img2 49 1023 975 998400 83 Linux cust_bbb.img3 0 - 0 0 0 Empty cust_bbb.img4 0 - 0 0 0 Empty Successfully wrote the new partition table

Re-reading the partition table ... BLKRRPART: Inappropriate ioctl for device

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).)

  > sudo apt-get install kpartx
  > sudo kpartx -av cust_bbb.img

Mount the new partitions

  > sudo mkfs.vfat -F 16 /dev/mapper/loop0p1 -n boot
  > sudo mkfs.ext4 /dev/mapper/loop0p2 -L rootfs
  > mkdir -p tmpmnt/boot
  > mkdir -p tmpmnt/rootfs
  > sudo mount /dev/mapper/loop0p1 tmpmnt/boot/
  > sudo mount /dev/mapper/loop0p2 tmpmnt/rootfs/

Now files can be copied using normal utilities into tmpmnt/boot and tmpmnt/rootfs. But what files should be copied? I'm pretty sure I need to make those files now.

The Meat

Pulling all of this from: https://eewiki.net/display/linuxonarm/BeagleBone+Black

Cross-Compiler: I think I already have and arm compiler installed. We'll see.

Das U-Boot:

  > git clone git://git.denx.de/u-boot.git
  > cd u-boot/
  > git checkout v2015.07-rc2 -b tmp

Patches:

  > ~/u-boot
  > wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2015.07-rc2/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
  > patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Configure and Build:

  > ~/u-boot
  > make ARCH=arm CROSS_COMPILE=${CC} distclean
  > make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_defconfig
  > make ARCH=arm CROSS_COMPILE=${CC}

Last step fails with: error: bad value (armv5) for -march= switch

Looks like I don't have the correct cross compiler for bare-metal.

Cross-Compiler

  > wget -c https://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
  > tar xf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
  > export CC=`pwd`/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-

Test:

  > ${CC}gcc --version

  arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
  Copyright (C) 2014 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Redo

  > make ARCH=arm CROSS_COMPILE=${CC}

Great, U-Boot is built. Next onto...

The Beast (aka. the Kernel)

  > git clone https://github.com/RobertCNelson/bb-kernel
  > cd bb-kernel/
  > git checkout origin/am33x-v3.8 -b tmp

This is were I need to diverge from the eewiki instructions, which utilize a script to configure and build the kernel. I want a custom kernel with the RT Patch and a second small patch to fix the VMA chain problem.

The script provided looks nifty: takes care of configuring and making images and what not. Hmm... there is a folder called "patches." That seems like a good place to put patches.

Find the 3.8 patch.

  > wget https://www.kernel.org/pub/linux/kernel/projects/rt/3.8/patches-3.8.13.14-rt31.tar.xz
  > tar xf patches-3.8.13.14-rt31.tar.xz 
  > mkdir bb-kernel/patches/rt_preempt
  > mv patches/* ./bb-kernel/patches/rt_preempt/

I'm going to skip the vma chain patch for now... because I don't have a patch file for it. And don't know how to make one.

Couldn't find the RT options in the config menus... looks like it wasn't automatically applied. Could edit patch.sh to force it, or try running manually. The question is... do I apply to ignore/linux_src or KERNEL?

Well, that didn't seem to work. Let's take a closer look at patch.sh. Hopefully adding all of the RT patches won't mess anything up!

Okay, so that was hours wasted. Instead of the 3.8 version, use the 3.2 version from bb-kernel. It comes with a preempt patch, and just requires the option to be uncommented in build_kernel.sh.

TODO: Update previous instructions.

Moving on!

Filesystem

  > wget -c https://rcn-ee.com/rootfs/eewiki/minfs/ubuntu-14.04.2-minimal-armhf-2015-06-09.tar.xz
  > md5sum ubuntu-14.04.2-minimal-armhf-2015-06-09.tar.xz
  > tar xf ubuntu-14.04.2-minimal-armhf-2015-06-09.tar.xz

Copying files over:

  > sudo cp ./u-boot/MLO ./tmpmnt/boot/
  > sudo cp ./u-boot/u-boot.img ./tmpmnt/boot/

Backup u-boot files?

  > sudo mkdir -p ./tmpmnt/rootfs/opt/backup/uboot/
  > sudo cp ./u-boot/MLO ./tmpmnt/rootfs/opt/backup/uboot/
  > sudo cp ./u-boot/u-boot.img ./tmpmnt/rootfs/opt/backup/uboot/

  > export kernel_version=3.2.42

  > sudo tar xfvp ./ubuntu-14.04.2-minimal-armhf-2015-06-09/armhf-rootfs-ubuntu-trusty.tar -C ./tmpmnt/rootfs/

  > sudo sh -c "echo 'uname_r=${kernel_version}' >> ./tmpmnt/rootfs/boot/uEnv.txt"

Holy shit. Should have read the output from the build script: Failing out early because of some missing header files. Where are then? I don't know... so I copied them from http://apt-browse.org/browse/debian/wheezy/main/amd64/linux-headers-3.2.0-4-common-rt/3.2.65-1/ BUT the fancy copy and paste method lost just a few characters. Like tabs between a variable type and the name. This cause other problems. Obviously. Anyways, there were only 8 of them, so it didn't take too long to clean up the errors.

Why is deploy still empty?

Missing locallock.h.... how did the build finish?

Okay, we should have all the files we need, so back to the http://blog.logikonlabs.com/how-to-create-a-custom-microsd-card-image-for-the-beaglebone-black/ directions.

  > export kernel_version=3.2.42-psp27

I download the .deb of the files I wanted instead of copy and pasting from the web interface. Worked much better. Unpack .debs with dpkg -x whatever.deb dest_directory.

  > cp ../missing/usr/src/linux-headers-3.2.0-4-common-rt/include/linux/spinlock_types_raw.h ./KERNEL/include/linux/
  > cp ../missing/usr/src/linux-headers-3.2.0-4-common-rt/include/trace/events/latency_hist.h ./KERNEL/include/trace/events/
  > cp ../missing/usr/src/linux-headers-3.2.0-4-common-rt/include/trace/events/latency_hist.h ./KERNEL/include/trace/events/
  > cp ../missing/usr/src/linux-headers-3.2.0-4-common-rt/include/linux/wait-simple.h ./KERNEL/include/linux/

And a bunch of others... But ended up failing with warnings about wait-simple.h. I'm not sure that the

I give up on this. BUT it looks like the 4.0 version has RT patches... without a comment warning that they aren't supported. So

Wow. I wish I started with that.

  > export kernel_version=4.0.6-bone-rt-r6
  > sudo tar xfvp ./ubuntu-14.04.2-minimal-armhf-2015-06-09/armhf-rootfs-ubuntu-trusty.tar -C ./tmpmnt/rootfs/
  > sudo sh -c "echo 'uname_r=${kernel_version}' >> ./tmpmnt/rootfs/boot/uEnv.txt"
  > sudo cp -v ./bb-kernel/deploy/${kernel_version}.zImage ./tmpmnt/rootfs/boot/vmlinux-${kernel_version}
      ‘./bb-kernel/deploy/4.0.6-bone-rt-r6.zImage’ -> ‘./tmpmnt/rootfs/boot/vmlinux-4.0.6-bone-rt-r6’
  > sudo mkdir -p ./tmpmnt/rootfs/boot/dtbs/${kernel_version}/
  > sudo tar xfv ./bb-kernel/deploy/${kernel_version}-dtbs.tar.gz -C ./tmpmnt/rootfs/boot/dtbs/${kernel_version}/
  > sudo tar xfv ./bb-kernel/deploy/${kernel_version}-modules.tar.gz -C ./tmpmnt/rootfs/

I don't know what to do for the Files Systems Table part... so moving on... back to


Easy Way


My not so professional power source.

The board seems to be locked up (two LEDs on after power up, that's it), so I'm going to try out a pre-build image. This should let me know if the board is alright, and also give me an alternative fix if I am not able to get the custom image going.

http://elinux.org/BeagleBoardUbuntu#Method_1:_Download_a_Complete_Pre-Configured_Image

Hmm... this note seems relevant:

If only two LED's stay lit and nothing happens, the board has crashed due to lack of power. Retry with a 5Volt DC power supply connected.

I had tried with just USB (known to not be enough), and also a battery pack (which I should look up the current level on). I think the requirement is 2A at 5V. If only I had a wallwart...

I was able to rig up a suitable power supply using a power brick from a IDE to USB adapter and a barrel jack adapter (shown right).

Unfortunately this didn't solve the problem: the BBB is still freezing up. I hooked it up to a monitor, but nothing is displayed (not surprising; HDMI support is not available until late in the boot process).


Recovery

September 6, 2015

I went on a bit of a shopping spree, purchasing a new BBB (Rev. C, Debian) and a USB to serial adapter. The adapter should help me figure out what is wrong with my old BBB, and if not, I have the new one.

Method 2 (http://dave.cheney.net/2013/09/22/two-point-five-ways-to-access-the-serial-console-on-your-beaglebone-black) shows how to use the adapter. The warning: do not connect the red (power) wire.

I usually use minicom, but decided to give screen a try:

  > screen /dev/ttyUSB0 115200

And it works! I get the uboot console... if only I knew what to do with that.

Inside screen, hit Ctrl+a H to turn on logging.

  U-Boot SPL 2015.01-rc4-00002-g76c2d3b (Dec 30 2014 - 20:48:45)

  U-Boot 2015.01-rc4-00002-g76c2d3b (Dec 30 2014 - 20:48:45), Build: jenkins-github_Bootloader-Builder-85

       Watchdog enabled
  I2C:   ready
  DRAM:  512 MiB
  MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
  Using default environment

  Net:   <ethaddr> not set. Validating first E-fuse MAC
  cpsw
  Hit any key to stop autoboot:  0 
  gpio: pin 53 (gpio 53) value is 1
  switch to partitions #0, OK
  mmc0 is current device
  gpio: pin 54 (gpio 54) value is 1
  Checking for: /uEnv.txt ...
  1179 bytes read in 9 ms (127.9 KiB/s)
  gpio: pin 55 (gpio 55) value is 1
  Loaded environment from uEnv.txt
  Importing environment from mmc ...
  Checking if uenvcmd is set ...
  gpio: pin 56 (gpio 56) value is 1
  Running uenvcmd ...
  ** File not found /boot/uEnv.txt **
  debug: [/boot/vmlinuz-] ...
  ** File not found /boot/vmlinuz- **
  debug: [/boot/initrd.img-] ...
  ** File not found /boot/initrd.img- **
  debug: [/boot/dtbs//am335x-boneblack.dtb] ...
  ** File not found /boot/dtbs//am335x-boneblack.dtb **
  debug: [console=tty0 console=ttyO0,115200n8 root=/dev/mmcblk0p1 rootfstype=ext4 rootwait fixrtc] ...
  debug: [bootz 0x82000000 0x88080000:49b 0x88000000] ...
  Bad Linux ARM zImage magic!
  Checking if client_ip is set ...
  Checking for: /boot.scr ...
  Checking for: /boot/boot.scr ...
  Checking for: /boot/uEnv.txt ...
  ** Invalid partition 2 **
  ** Invalid partition 3 **
  ** Invalid partition 4 **
  ** Invalid partition 5 **
  ** Invalid partition 6 **
  ** Invalid partition 7 **
  gpio: pin 56 (gpio 56) value is 0
  gpio: pin 55 (gpio 55) value is 0
  gpio: pin 54 (gpio 54) value is 0
  switch to partitions #0, OK
  mmc1(part 0) is current device
  gpio: pin 54 (gpio 54) value is 1
  Failed to mount ext2 filesystem...
  ** Unrecognized filesystem type **
  Checking for: /uEnv.txt ...
  Failed to mount ext2 filesystem...
  ** Unrecognized filesystem type **
  Checking for: /boot.scr ...
  Failed to mount ext2 filesystem...
  ** Unrecognized filesystem type **
  Checking for: /boot/boot.scr ...
  Failed to mount ext2 filesystem...
  ** Unrecognized filesystem type **
  Checking for: /boot/uEnv.txt ...
  Failed to mount ext2 filesystem...
  ** Unrecognized filesystem type **
  ** Invalid partition 2 **
  ** Invalid partition 3 **
  ** Invalid partition 4 **
  ** Invalid partition 5 **
  ** Invalid partition 6 **
  ** Invalid partition 7 **
  ## Error: "nandboot" not defined
  U-Boot#

Lot's of error messages. But at least I can read them now. And U-Boot is running.

It looks like the booter gpio: pin 53 (gpio 53) value is 1 can select from different boot options by reading GPIO pins, which are likely connected to switches. However, when I boot with S2 depressed, the same values were returned. I wonder if the switch is broken... and if I can just jumper the header to ground to change the behavior. Wrong! GPIO_53-56 are the four LEDs.

Finally worked: http://elinux.org/Building_for_BeagleBone

Edit - History - Print - Recent Changes - Search
Page last modified on September 06, 2015, at 05:02 PM