Tuesday, 16 January 2018

Creating a bootscript file for u-boot

I have created a boot script file to boot my Beaglebone via tftp. I did not want to change the default boot configuration in the headers as it would add changes to my u-boot code which would deviate from the mainline.

First we create a file called boot.cmd. I have the following in my boot.cmd file which can be reused.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
setenv bootargs console=${console} root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait
setenv fdtaddr 0x8C008000
setenv loadaddr 0x80008000
run findfdt
setenv tftp_fdt tftp ${fdtaddr} ${fdtfile}
setenv tftp_uimage tftp ${loadaddr} uImage
setenv sd_fdt fatload mmc 0:1 ${fdtaddr} ${fdtfile}
setenv sd_uimage fatload mmc 0:1 ${loadaddr} uImage
setenv tftpboot 'run tftp_fdt; run tftp_uimage; bootm ${loadaddr} - ${fdtaddr}'
setenv sdboot 'run sd_fdt; run sd_uimage; bootm ${loadaddr} - ${fdtaddr}'


We change this to boot.scr file by doing the following:

1
mkimage -C none -A arm -T script -d boot.cmd boot.scr

We keep this boot.scr in the first partition. We reset/reboot/boot the board and then we do the following:


1
2
3
4
5
fatload mmc 0:1 0x80000000 boot.scr
source 0x80000000
setenv serverip <yourtftp ip address>
setenv ipaddr <yourbeagleboneip>
run tftpboot

Basically the above would load the boot.scr file in 0x80000000 location and run the script from that location by doing a run <memory_address>.

I will improve on this script a little bit and will keep updating this blog post.

No comments:

Post a Comment