Tuesday, December 21, 2010

Beagleboard-xM - Using TFTP To Load Images

All Beagleboard-xM's owners may already known, it's impossible using u-boot to load image into uSDCard or RAM, so far. This's no matter if you do not frequently changing the image but really a trouble if your job needs to do. So, if the u-boot cannot do, why don't let the kernel and busybox does. If you like it, please follow few steps below:

LAMP: By using:
o Kernel which supports mmc driver and ethernet driver
o tinyfs_loader which provides tftp command

Step 1: Setup environment
o A beagleboard-xm with uSDCard
o An tftp, nfs server

Step 2: Install kernel and tinyfs_loader (including busybox)
o A bootable uSDCard/vfat partion, x-loader & u-boot should be there. Still need u-boot, sure :D
o Download an uImage_loader and a tinyfs_loader from there
o Put the uImage_loader to uSDCard/vfat, tinyfs_loader to nfs server (extract tinyfs_loader as sudoers)

Step 3: Change as needed
o loadimage.tftp script in tinyfs_loader is called by init.rc
o Please modify this script as needed. At minimum you should change uImage name and tftp server IP
o By default, after loading image, loadimage.tftp calls to reboot

Step 4: In action
o For loading image, the bootcmd and bootargs should be something like this
# setenv bootcmd 'mmc init; fatload mmc 0 0x80000000 uImage_loader; bootm 0x80000000;'
# setenv bootargs console=ttyS2,115200n8 rootfs=/dev/nfs rw init=/init nfsroot=${SERVER_IP}:/srv/tinyfs_loader ip=${BOARD_IP}

EOL:
o Depend on your habit of using u-boot script, this loading ciruit could be very convenient and fast
o It's possible to get back the image from uSDCard to tftp server

6 comments:

/-\\lex said...

Hello, Hakun.

I have followed the instructions on your blog and I was able to remotely boot the Beagleboard XM using the provided uImage and tinyFS files. However, my aim is to use another custom-compiled Linux kernel with a remote filesystem over NFS. I 'll be very thankful if you provide me the kernel configuration options that you used when compiled the uImage.


Alex.

Hakun said...

Sorry I don't understand your question clearly. If you want to use uImage and booting from NFS. So, no special kernel configuration is required.

Unknown said...

Hi,

If I understood correctly, the purpose of this procedure is to use a linux kernel + mmc/ethernet drivers, to get a remote uImage by tftp and copy it into the mmc, and finally reset and boot from the mmc containing the new image.

My need is to load a remote uImage directly into RAM and execute it, as I could do if U-boot for beagleboard xM supported ethernet, which it does not.

Do you see a way for me to adapt your procedure to achieve this (tftp to RAM instead of mmc, then launch the loaded uimage ?)

Regards,

Yonggang Luo said...

The content of loadimage.tftp is

#!/bin/sh

IMAGE_NAME=uImageTouch
SERVER_IP=192.168.1.101

cd /mnt/bootdir
echo "" > /dev/ttyS2
echo "Loading $IMAGE_NAME@$SERVER_IP to /mnt/bootdir ..." > /dev/ttyS2
tftp -r $IMAGE_NAME -g $SERVER_IP
echo "Load done!" > /dev/ttyS2
echo "Going to reboot soon ..." > /dev/ttyS2
sleep 2
reboot -f

But I don't want it to reboot.
I want it direct loading $IMAGE_NAME, and then boot from nfs such
as $NFS_IP:/home/nfs_folder
How should I modify the script

Joel Fernandes said...

Your method seems to require an SD Card programming each time you load a new kernel (which can be very slow).

TFTP booting allows you to boot a kernel without having to program the SDCard everytime. If you're booting from SDCard, it cannot be called tftpboot technically even if you fetched the uImage through TFTP

Hakun said...

@Joel Fernandes:
So far beagleboard bootloader does not support tftp. FYI!