RPI U-boot

From arrizza.org wiki

Jump to navigation Jump to search
RaspberryPi ⇫ Up RPI U-boot run s-rec application ⇨ Next Topic

Create the Project (do once)

 cd ~/projects
 cd uboot

get the U-boot source

  [see http://elinux.org/RPi_U-Boot for the link to the tarball]
  cd ~/Downloads
  tar xvf u-boot-pi-rpi.tar.gz
  mv u-boot-pi-rpi ~/projects/uboot
  
  [or get github source here: https://github.com/gonzoua/u-boot-pi/tree/rpi]

get the bcm2708 compiler

 cd ~/projects
 git clone git://github.com/raspberrypi/tools.git

create doit script

 #! /bin/bash
 
 source scripts/base-common
 #set -x
 
 # set up and create directories
 BUILDDIR=$CURRDIR/build
 mkdir -p sdimage
 mkdir -p $BUILDDIR
 
 # set up the log
 LOG=$CURRDIR/make.log
 rm -rf $LOG
 touch $LOG
 
 # build everything
 cd u-boot-pi-rpi
 make O=$BUILDDIR rpi_b_config 2>&1 | tee -a $LOG
 checkrc $? "make rpi_b_config"
 make O=$BUILDDIR rpi_b  2>&1 | tee -a $LOG
 checkrc $? "make rpi_b"
 
 #check if it worked 
 checkFileExists $BUILDDIR/u-boot.bin
 
 # convert to an img file named kernel.img
 cd $TOOLSDIR/mkimage
 ./imagetool-uncompressed.py $BUILDDIR/u-boot.bin
 checkFileExists kernel.img
 mv kernel.img $CURRDIR/sdimage
 checkrc $? "move kernel.img"
 # get all the files ready in the sdimage directory
 cd $CURRDIR
 checkFileExists sdimage/kernel.img
 cp sdcard-prebuilt/* sdimage

get common images

  • get the common binaries from the Raspberry Pi site
 2013-05-25-wheezy-raspbian.zip 
  • add them to sdcard-prebuilt
 cd ~/projects/uboot
 mkdir sdcard-prebuilt
 [ add the following files: ]
 -rw-rw-r-- 1 arrizza arrizza   17808 Jun 13 22:47 bootcode.bin
 -rw-r--r-- 1 arrizza arrizza     142 Jun 13 22:47 cmdline.txt
 -rw-r--r-- 1 arrizza arrizza    1212 Jun 13 22:47 config.txt
 -rw-r--r-- 1 arrizza arrizza    2012 Jun 13 22:47 fixup_cd.dat
 -rw-r--r-- 1 arrizza arrizza    5880 Jun 13 22:47 fixup.dat
 -rw-r--r-- 1 arrizza arrizza    8830 Jun 13 22:47 fixup_x.dat
 -rw-r--r-- 1 arrizza arrizza     137 Jun 13 22:47 issue.txt
 -rw-r--r-- 1 arrizza arrizza  467960 Jun 13 22:47 start_cd.elf
 -rw-rw-r-- 1 arrizza arrizza 2688564 Jun 13 22:47 start.elf
 -rw-r--r-- 1 arrizza arrizza 3655652 Jun 13 22:47 start_x.elf
  • edit config.txt. This is not strictly necessary.
 [add the following two lines to config.txt]
 boot_delay 5
 kernel=kernel.img

Create a helper script

  • create a scripts directory
 mkdir scripts
  • create a base-common script
 #!/bin/bash
 
 #------------------
 function pathadd() 
   {
   if [ -d "$1" ] && ":$PATH:" != *":$1:"* ; then
     export PATH="${PATH:+"$PATH:"}$1"
   fi
   }
 #------------------
 function checkrc
   {
   if [ $1 = 0 ]; then
     echo "OK   $2 worked"
   else
     echo "FAIL $2 did not work"
     exit
   fi
   }
 
 #------------------
 function checkFileExists
   {
   if [ -e $1 ]; then
     echo "OK   found $1"
   else
     echo "FAIL did not find $1"
     exit
   fi
   }
 #set up some variables and the PATH for the bcm compiler
 CURRDIR=`pwd`
 TOOLSDIR=~/projects/tools
 pathadd $TOOLSDIR/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin
 echo "OK   Found bin, added to path: $PATH"
 export CROSS_COMPILE=bcm2708-
 which ${CROSS_COMPILE}gcc
 checkrc $? "find ${CROSS_COMPILE}gcc"

Prepare the RPI (do once)

  • purchase the USB to TTL serial cable:
 http://www.adafruit.com/products/954?gclid=CIL-6qCZ77cCFVIV7AodKi0A5A
  • Align the RPI board SD card to the left, ethernet RJ-45 to the right, install the cable:
 (all pins are along the top row)
 red - pin2
 skip - pin4
 black - pin6
 white - pin8
 green - pin10
  • here's a good image of the board
 http://jeffskinnerbox.wordpress.com/2012/12/05/raspberry-pi-serial-communication/raspberry-pi-rev-1-gpio-pin-out-2/
  • create a "deployit" script
 #! /bin/bash
 
 cp sdimage/kernel.img /media/boot 
 if [ $? = 0 ]; then
   eject /media/boot 
 fi
 
 sync
  • create an SDHC card (2GB or more) as instructed on the RPI site
  • the main partition should be FAT32 and call it "boot"

get a terminal emulator (do once)

  • There are several: putty, minicom, gtkterm (my preference)
 sudo apt-get install gtkterm
  • use Dash Home to search for gtkterm
  • attach gtkterm to the Launcher
  • click Configuration | Port
 device      : /dev/ttyUSB0
 baudrate    : 115200
 parity      : none
 bits        : 8
 stop bits   : 1
 flow control: none

To Compile

  • run doit
 ./doit
  • the full set of pre-built images and u-boot image (renamed to kernel.img) will be in the sdimages directory

To Clean

  • create a cleanit script
 #! /bin/bash
 
 # dependencies (see doit)
 source scripts/base-common
 BUILDDIR=$CURRDIR/build
 
 rm -rf sdimage
 rm -f make.log
 
 cd u-boot-pi-rpi
 make O=$BUILDDIR mrproper
 checkrc $? "make mrproper"
  • run cleanit
 ./cleanit

To Run

  • insert the SD card into your laptop
  • run deployit
 ./deployit
  • remove the SD card from your laptop
  • insert it into the RPI
  • plug the USB plug into your laptop
  • start gtkterm
  • the uboot output should show up
  • if the screen is blank, press Enter

To Test

  • enter help; you should see a list of commands
  • enter version:
 U-Boot> version
 
 U-Boot 2013.01-rc1 (Jun 15 2013 - 17:10:11)
 bcm2708-gcc (crosstool-NG 1.15.2) 4.7.1 20120402 (prerelease)
 GNU ld (crosstool-NG 1.15.2) 2.22

The date will be the compilation date

  • put a multi-meter on pin 26 (GPIO 7), far right top row
  • put ground on pin 25, far right bottom row
  • toggle the pin
 gpio toggle 7
 
 U-Boot> gpio toggle 7
 gpio: pin 7 (gpio 7) value is 1
  • the multi-meter should toggle from 0V to 3.3V
Personal tools