Debian Edit Modify Build and Flash U-Boot

From Variscite Wiki
DART-MX8M - Debian U-Boot Customization


1 Making Changes to U-Boot

$ cd ~/var_mx8m_dart_debian/src/uboot-imx
$ gedit board/variscite/mx8m_var_dart/mx8m_var_dart.c
$ gedit include/configs/mx8m_var_dart.h

For example, we want to change the default environment variable,

"netargs=setenv bootargs ${jh_clk} console=${console} " \
		"root=/dev/nfs ${cma_size} " \
		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \

To

"netargs=setenv bootargs ${jh_clk} console=${console} " \
		"root=/dev/nfs ${cma_size} " \
		"ip=dhcp serverip=192.168.0.34 nfsroot=${serverip}:${nfsroot},v3,tcp\0" \

Here above example sets the serverip to 192.168.0.34,

2 Building Bootloader

To build a bootloader run below commands on host machine.

$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c bootloader


3 Flashing New Bootloader to Target

3.1 Flashing New Bootloader to target eMMC via network

Transfer the newly created bootloader file SPL and u-boot.img

From

~/var_mx8m_dart_debian/output/ to running target to flash it on the eMMC. 

For example

$scp ~/var_mx8m_dart_debian/output/SPL root@192.168.0.36:/tmp/
$scp ~/var_mx8m_dart_debian/output/u-boot.img root@192.168.0.36:/tmp/ 

Change 192.168.0.36 to your target board IP.
On target run below commands:

$ sudo dd if=/tmp/SPL of=/dev/mmcblk1 bs=1K seek=1; sync
$ sudo dd if=/tmp/u-boot.img of=/dev/mmcblk1 bs=1K seek=69; sync

3.2 Flashing New Bootloader to SD card

To flash the newly created bootloader on the SD Card if you are running your entire os from SD card.

$ sudo dd if=SPL of=/dev/sdX bs=1K seek=1; sync
$ sudo dd if=u-boot.img of=/dev/sdX bs=1K seek=69; sync
(Replace /dev/sdX with the correct device)

3.3 Flashing using recovery sdcard

If you want to use our recovery SD card to flash the built U-Boot to NAND flash/eMMC, then copy it to the appropriate location in the SD card:

$ sudo cp SPL /media/rootfs/opt/images/Debian/
$ sudo cp u-boot.img /media/rootfs/opt/images/Debian/

And eject the SD card gracefully from host machine.


Note: If you manually upgrade an existing U-Boot, and you have an old environment saved, it is a good idea to reset your environment to the new default (see Environment handling commands)