There's more...

Finally, we will reprogram the bootloader into the Wandboard's microSD card. We can do it either from the target or from your host computer.

From the host computer, we use dd to copy the new SPL image to an offset of 0x400, which is where the i.MX6 bootrom expects to find it:

$ sudo dd if=SPL of=/dev/sdN bs=1k seek=1 && sync  

This writes with an offset of two blocks, which, given a 512-byte block size, is 0x400 (1,024) bytes.

Then, we will program the U-Boot binary. The SPL looks for it at the offset configured in the CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR configuration variable, given in sectors. For the Wandboard, this is configured as 138 (0x8a) sectors, which with 512-byte sized sectors gives an offset of 69 KB. So we program the U-Boot image at that location with the following:

$ sudo dd if=u-boot.img of=/dev/sdN bs=1k seek=69 && sync  
Be careful when running the dd command, as it could harm your machine. You need to be absolutely sure that the sdN device corresponds to your microSD card and not a drive on your development machine.

From the device itself, we can use U-Boot's mmc command as follows:

  1. Load the SPL image to memory:
> env set ipaddr <target_ip>
> env set serverip <host_ip>
> tftp ${loadaddr} SPL  

The hexadecimal file size of the TFTP transfer is kept in the filesize environment variable, which we will use later on.

  1. Select the MMC device to operate on. You can use the mmc part to discover which is the correct device:
> mmc dev 0
> mmc part
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
1 8192 596378 05465984-01 83

We can see that partition 1 starts at sector 8192, leaving enough space to program both the SPL and U-Boot.

  1. With a 512-byte block size, we calculate the number of blocks as follows:
> setexpr filesizeblks $filesize / 0x200
> setexpr filesizeblks $filesizeblks + 1  
  1. We then write to an offset of two blocks with the number of blocks occupied by our image:
> mmc write ${loadaddr} 0x2 ${filesizeblks}  
  1. Now load the U-Boot image to memory:
> tftp ${loadaddr} u-boot.img 
  1. And similarly, program it with an offset of 69 KB. Calculate the number of 512-byte blocks to fit the U-Boot image we just loaded:
> setexpr filesizeblks $filesize / 0x200
> setexpr filesizeblks $filesizeblks + 1  
  1. And then write to an offset of 69 blocks the number of blocks we have just calculated for our image:
> mmc write ${loadaddr} 0x8A ${filesizeblks} 
  1. We can then perform source code modifications and reprogramming iteratively until the change is finished and has been tested. We can then commit the changes to the local Git repository:
$ git add --all .
$ git commit -s -m "Well thought commit message"  
  1. Generate a patch into the U-Boot recipe patch directory as follows:
$ git format-patch -1 -o /opt/yocto/fsl-community- 
bsp/sources/meta-bsp-custom/recipes-bsp/u-boot/u-boot-fslc-
v2017.11/

Finally, add the patch to the U-Boot recipe as explained before.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset