Thursday, December 04, 2008

Towards creating a beagleboard NAND recovery script

NOTE: This is a work in progress yet..

Get Code base:
git clone git://

u-boot-v1 - omap3:
git clone git://
cd u-boot-omap3
git checkout --track -b omap3-dev origin/omap3-dev
Updated: see here if this did not work..

git clone git://

git clone git://

signGP tool:

Cross compiler: arm-none-eabi-gcc: 2007q3-53 (4.2.1)
Host compiler: x64bit: (Ubuntu 4.3.2-1ubuntu11)

Build commands:
Before starting the build process, lets set up a simple alias command:
alias mymake='make ARCH=arm CROSS_COMPILE=arm-none-eabi- V=1'

mymake omap3_beagle_config

mymake omap3530_beagle_per_uart_defconfig

mymake omap3530beagle_config

[Update: 2008-12-13 - I completely forgot that we need to sign an image for it to boot from nand flash.. :(
once you have the x-load.bin, you need the signGP.c. Build this by the command:
gcc -o signgp signGP.c
Then run signgp from the same directory that x-load.bin is present. this generates a x-load.bin. Let me know if you feel signGP.c should be moved into omap-u-boot-utils..



Copy Images:
Assuming a directory structure as in:
omap-u-boot-utils u-boot-arm u-boot-v2 x-load-omap3
Run the following commands:
cp u-boot-arm/u-boot.bin omap-u-boot-utils/images/u-boot-v1.bin
cp x-load-omap3/x-load.bin omap-u-boot-utils/images/
cp u-boot-v2/uboot.bin omap-u-boot-utils/images/u-boot-v2-serial.bin

Execution script file:

if [ ! -w "$1" ]; then
echo "Usage: $0 path/to/ttyDevice"
exit 1
set -x
export PATH=$PATH:.
pserial -p $1 -f images/u-boot-v2-serial.bin
ucmd -p $1 -c "loadb -f /dev/ram0" -e "bps..."
ukermit -p $1 -f images/u-boot-v1.bin
ucmd -p $1 -c "go 0x80000000" -e "autoboot"
ucmd -p $1 -c "help" -e "#"
ucmd -p $1 -c "loadb 0x80000000" -e "bps..."
ukermit -p $1 -f images/x-load.bin.ift
ucmd -p $1 -c "nand unlock" -e "#"
ucmd -p $1 -c "nandecc hw" -e "#"
ucmd -p $1 -c "nand erase 0 80000" -e "#"
ucmd -p $1 -c "nand write 80000000 0 80000" -e "#"

[Note: 2008-12-04 22:50hrs:
1. I just started up my laptop and connected my usb2serial
connector -> just found that pserial did not work out of the box.. ran minicom once and it started working.. will debug this later..
2. The nand erase and nand write seems to tell me my entire nand is filled with badblocks.. need to debug this a little more :(
Update 2008-12-11: Khasim has a patch for u-boot-v1 here which is supposedly working now.

Update: 2008-12-13: it seems to work automatically for zoom MDK

Interesting note: on zoom MDK, nand unlock is required before doing a saveenv!! :( need to fix this sometime..

Things to do:
a) introduce hw ecc for x-loader.. it should simplify things a lot..
b) Dirk,Steve and others are planning on sending the u-boot patches for mainline tree this weekend.


Anonymous said...

Like to update/merge this with

? Dirk

Nishanth Menon said...

this is not ready yet.. once i get the basics worked out and tested, will update the link