XELK-AN-007: Migrating u-boot to SPL
Info Box
|
This application note has been validated starting from the XELK 3.0.x kit version. |
Contents
History[edit | edit source]
Version | Date | XELK version | Notes |
---|---|---|---|
1.0.0 | Aug 2019 | 3.5.0 | First SPL release |
Introduction[edit | edit source]
Starting from XELK 3.5.0 binary version, u-boot supports the SPL first-stage bootloader and second-stage bootloader (the proper u-boot complete binary).
It is then required to update the u-boot on AXEL LITE SoM using some new u-boot environment variables: those vars will be present and ready to be used on the new SPL default environment.
Here below, you can find a step-by-step user's guide for updating u-boot to the new SPL version.
u-boot commands[edit | edit source]
In order to program the uboot SPL binaries (SPL
and u-boot.img
) some new environment variables are useful for loading the binaries from a tftp server and store them on the storage boot device (i.e. NOR SPI and SD).
The load commands are:
=> pri load_spl load_spl=tftp ${loadaddr} ${spl} => pri load_uboot load_uboot=tftp ${loaddr} ${ubootimg} =>
and the related update commands are (for example for the SD card storage device):
=> pri mmc_update_spl mmc_update_spl=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks} => pri mmc_update_uboot mmc_update_uboot=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 0x8a ${blocks} =>
update u-boot on NOR SPI[edit | edit source]
In the following example, it is assumed that the u-boot binary files are present on the tftp server /tftpboot/ directory:
- create the SPL commands for loading and programming
=> setenv load_spl 'tftp ${loadaddr} ${spl}' => setenv load_uboot 'tftp ${loaddr} ${ubootimg}' => setenv spi_update_spl 'sf probe; sf erase 0 10000;sf write ${loadaddr} 400 ${filesize}' => setenv spi_update_uboot 'sf probe; sf erase 10000 f0000;sf write ${loadaddr} 10000 ${filesize}' => saveenv Saving Environment to SPI Flash... SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB Erasing SPI flash...Writing to SPI flash...done Valid environment: 1 =>
- configure the
spl
andubootimg
vars containing the SPL filenames to be loaded:
=> setenv spl 'axel/xelk-3.5.0_mx6qdlaxel_spi_SPL' => setenv ubootimg 'axel/xelk-3.5.0_mx6qdlaxel_spi_u-boot.img' => saveenv Saving Environment to SPI Flash... SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB Erasing SPI flash...Writing to SPI flash...done Valid environment: 2 =>
- load and program the SPL binaries (i.e. from the running tftp server on the XELK 3 VM):
=> run load_spl FEC Waiting for PHY auto negotiation to complete. done Using FEC device TFTP from server 192.168.0.125; our IP address is 192.168.0.96 Filename 'axel/xelk-3.5.0_mx6qdlaxel_spi_SPL'. Load address: 0x12000000 Loading: ############ 966.8 KiB/s done Bytes transferred = 60416 (ec00 hex) => run spi_update_spl SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB SF: 65536 bytes @ 0x0 Erased: OK device 0 offset 0x400, size 0xec00 SF: 60416 bytes @ 0x400 Written: OK => run load_uboot Using FEC device TFTP from server 192.168.0.125; our IP address is 192.168.0.96 Filename 'axel/xelk-3.5.0_mx6qdlaxel_spi_u-boot.img'. Load address: 0x12000000 Loading: ################################################################# ################################## 869.1 KiB/s done Bytes transferred = 502364 (7aa5c hex) => run spi_update_uboot SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB SF: 983040 bytes @ 0x10000 Erased: OK device 0 offset 0x10000, size 0x7aa5c SF: 502364 bytes @ 0x10000 Written: OK =>
Now, u-boot SPL are ready to be started issuing a reset command:
=> reset resetting ... U-Boot SPL 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:37:16) SOM ConfigID#: 00000003 Trying to boot from SPI U-Boot 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:37:16 +0200), Build: jenkins-XELK-u-boot-62 CPU: Freescale i.MX6Q rev1.5 996 MHz (running at 792 MHz) CPU: Automotive temperature grade (-40C to 125C) at 56C Reset cause: POR Environment: SPI Flash I2C: ready DRAM: 2 GiB Relocating to 8ff30000, new gd at 8df2feb8, sp at 8df2fe90 PMIC: PFUZE100 ID=0x10 NAND: 512 MiB MMC: FSL_SDHC: 0 SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB WARNING: CB ConfigID on block 0 is UNLOCKED Display: LDB-AM-800480STMQW-TA1-SBCX-REVB (800x480) SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB device 0 offset 0xa00000, size 0x400000 SF: 4194304 bytes @ 0xa00000 Read: OK Error: no valid bmp image at 20000002 In: serial Out: serial Err: serial SOM ConfigID#: 00000003 SOM UniqueID#: df646299:0b0579d4 CB ConfigID#: 00000012 CB UniqueID#: 3e00000c:de36b32d Board: MX6Q-AxelLite on SBCX Fastboot: unsupported boot devices SATA isn't buildin Net: FEC [PRIME] Warning: FEC (eth0) using random MAC address - 36:5c:b9:6e:08:8e Normal Boot Hit ENTER within 1 seconds to stop autoboot =>
update u-boot on SD card[edit | edit source]
- configure the
spl
andubootimg
vars containing the SPL filenames to be loaded:
=> setenv spl 'axel/xelk-3.5.0_mx6qdlaxel_SPL' => setenv ubootimg 'axel/xelk-3.5.0_mx6qdlaxel_u-boot.img' =>
- create the SPL commands for loading and programming
=> setenv load_spl 'tftp ${loadaddr} ${spl}' => setenv load_uboot 'tftp ${loaddr} ${ubootimg}' => setenv mmc_update_spl 'mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}' => setenv mmc_update_uboot 'mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 0x8a ${blocks}'
- load and program the SPL binaries (i.e. from the running tftp server on the XELK 3 VM):
=> run load_spl Using FEC device TFTP from server 192.168.0.125; our IP address is 192.168.0.96 Filename 'axel/xelk-3.5.0_mx6qdlaxel_SPL'. Load address: 0x12000000 Loading: ############ 1 MiB/s done Bytes transferred = 60416 (ec00 hex) => run mmc_update_spl switch to partitions #0, OK mmc0 is current device (SD) MMC write: dev # 0, block # 2, count 119 ... 119 blocks written: OK => run load_uboot Using FEC device TFTP from server 192.168.0.125; our IP address is 192.168.0.96 Filename 'axel/xelk-3.5.0_mx6qdlaxel_u-boot.img'. Load address: 0x12000000 Loading: ################################################################# ################################## 1.3 MiB/s done Bytes transferred = 502268 (7a9fc hex) => run mmc_update_uboot switch to partitions #0, OK mmc0 is current device (SD) MMC write: dev # 0, block # 138, count 981 ... 981 blocks written: OK =>
Insert the DIP header on the pin selecting the BOOT_MODE_SEL from SD card and reset the board:
=> reset resetting ... U-Boot SPL 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:36:21) SOM ConfigID#: 00000003 Trying to boot from MMC U-Boot 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:36:21 +0200), Build: jenkins-XELK-u-boot-62 CPU: Freescale i.MX6Q rev1.5 996 MHz (running at 792 MHz) CPU: Automotive temperature grade (-40C to 125C) at 57C Reset cause: POR Environment: MMC I2C: ready DRAM: 2 GiB Relocating to 8ff30000, new gd at 8df2feb8, sp at 8df2fe90 PMIC: PFUZE100 ID=0x10 NAND: 512 MiB MMC: FSL_SDHC: 0 WARNING: CB ConfigID on block 0 is UNLOCKED Display: LDB-AM-800480STMQW-TA1-SBCX-REVB (800x480) reading splash_image.bmp 1036854 bytes read in 73 ms (13.5 MiB/s) In: serial Out: serial Err: serial SOM ConfigID#: 00000003 SOM UniqueID#: df646299:0b0579d4 CB ConfigID#: 00000012 CB UniqueID#: 3e00000c:de36b32d Board: MX6Q-AxelLite on SBCX switch to partitions #0, OK mmc0 is current device (SD) flash target is MMC:0 Bad partition index:2 for partition:recovery Bad partition index:5 for partition:system Bad partition index:4 for partition:data Net: FEC [PRIME] Normal Boot Hit ENTER within 1 seconds to stop autoboot =>
As you can see, respect to the NOR SPI, the u-boot binaries for the SD card uses the environment on SD (labelled MMC on u-boot code):
Environment: MMC
update u-boot on NAND flash[edit | edit source]
The SPL and u-boot image, must be flashed on NAND using the NXP kobs-ng
utility. This tool is required for writing correct information needed by bootrom to identify the NAND as a boot device.
N.B. for programming the second stage, the nandwrite
command has to identify a proper mtd part witch correct size. For this reason, the mtdparts variable has to be modified for writing the complete u-boot image.
The following steps are therefore necessary:
- boot the system via SD on NFS
- uses a rfs with kobs-ng utility available on it (e.g. DAVE's rfs provided with XELK)
- copy the related u-boot ans SPL files on nfs /home/root (for example)
- execute kobs-ng passing the parameters for flashing the SPL on NAND
- execute nandwrite to flash uboot image on NAND
- configure the mtdparts
=> setenv mtdparts 'mtdparts=gpmi-nand:2M(nand-SPL),6M(nand-uboot),1M(nand-env1),1M(nand-env2),1M(nand-fdt),1M(nand-spare),8M(nand-kernel),4M(nand-splash),-(nand-ubi)'
- configure u-boot vars for booting from NFS
=> setenv bootfile axel/xelk-3.0.8_uImage => setenv fdtfile axel/xelk-3.0.8_imx6dl-sbcx-cb0012.dtb => setenv rootpath /home/dvdk/axel/rfs/axel/ => setenv serverip 192.168.0.125 => run net_nfs
- boot from NFS
=> run net_nfs Using FEC device TFTP from server 192.168.0.125; our IP address is 192.168.0.90 Filename 'axel/xelk-3.0.8_uImage'. Load address: 0x12000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################## 1.3 MiB/s done Bytes transferred = 6576424 (645928 hex) Using FEC device TFTP from server 192.168.0.125; our IP address is 192.168.0.90 Filename 'axel/xelk-3.0.8_imx6dl-sbcx-cb0012.dtb'. Load address: 0x18000000 Loading: ######### 764.6 KiB/s done Bytes transferred = 45457 (b191 hex) FDT: override 'som_uniqueid' with 'ea9ae213:041b71d4' FDT: override 'cb_uniqueid' with '3e00000c:de36b32d' ## Booting kernel from Legacy Image at 12000000 ... Image Name: Linux-4.1.15-xelk-3.0.8 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 6576360 Bytes = 6.3 MiB Load Address: 10008000 Entry Point: 10008000 Verifying Checksum ... OK ## Flattened Device Tree blob at 18000000 Booting using the fdt blob at 0x18000000 Loading Kernel Image ... OK reserving fdt memory region: addr=18000000 size=c000 Using Device Tree in place at 18000000, end 1800efff switch to ldo_bypass mode! Frame buffer: configure splashscreen reserved memory to 0x4e000000 (2 MiB) WARNING: could not find 2nd splashscreen reserved memory path Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.1.15-xelk-3.0.8 (jenkins@linuxserver2) (gcc version 5.2.0 (GCC) ) #1 SMP PREEMPT Mon Mar 18 23:38:48 CET 2019 [ 0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] Machine model: AxelLite DL on SBCX CB0012 [ 0.000000] Reserved memory: created ipuv3_fb memory pool at 0x4e000000, size 2 MiB [ 0.000000] Reserved memory: initialized node splashscreen, compatible id fsl,ipuv3-fb [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] PERCPU: Embedded 12 pages/cpu @bf7bc000 s16960 r8192 d24000 u49152 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 259584 [ 0.000000] Kernel command line: root=/dev/nfs rw nfsroot=192.168.0.125:/home/dvdk/axel/rfs/axel/,v3,tcp ip=192.168.0.90:192.168.0.125::255.255.255.0:xelk:eth0:off panic=1 console=ttymxc2,115200 vmalloc=400M mtdparts=gpmi-nand:8M(nand-uboot),1M(nand-env1),1M(nand-env2),1M(nand-fdt),1M(nand-spare),8M(nand-kernel),4M(nand-splash),-(nand-ubi);spi0.0:1M(spi-uboot),256k(spi-env1),256k(spi-env2),512k(spi-dtb),8M(spi-kernel),4M(spi-splash),-(spi-free) ... ... ... Starting Linux NFC daemon Starting crond: OK Running local boot scripts (/etc/rc.local). Freescale i.MX Release Distro 4.1.15-2.0.1 imx6qxelk /dev/ttymxc2 imx6qxelk login: root root@imx6qxelk:~#
- on the VM, copy the NAND u-boot binaries on the /home/root NFS directory:
dvdk@vagrant-ubuntu-trusty-64:~$ sudo cp /tftpboot/axel/xelk-3.5.0_mx6qdlaxel_nand_* /home/dvdk/axel/rfs/axel/home/root/ [sudo] password for dvdk: dvdk@vagrant-ubuntu-trusty-64:~$ sudo ls -la /home/dvdk/axel/rfs/axel/home/root/ total 568 drwx------ 2 root root 4096 Aug 13 10:34 . drwxr-xr-x 3 root root 4096 Nov 9 2017 .. -rw-r--r-- 1 root root 51 Nov 9 2017 .profile -rw------- 1 root root 2 Nov 21 2017 .python-history -rw-r--r-- 1 root root 60416 Aug 13 10:34 xelk-3.5.0_mx6qdlaxel_nand_SPL -rw-r--r-- 1 root root 502780 Aug 13 10:34 xelk-3.5.0_mx6qdlaxel_nand_u-boot.img dvdk@vagrant-ubuntu-trusty-64:~$
- execute
kobs-ng
for u-boot SPL programming
root@imx6qxelk:~# kobs-ng -x -v -w xelk-3.5.0_mx6qdlaxel_nand_SPL MTD CONFIG: chip_0_device_path = "/dev/mtd0" chip_1_device_path = "(null)" search_exponent = 2 data_setup_time = 80 data_hold_time = 60 address_setup_time = 25 data_sample_time = 6 row_address_size = 3 column_address_size = 2 read_command_code1 = 0 read_command_code2 = 48 boot_stream_major_version = 1 boot_stream_minor_version = 0 boot_stream_sub_version = 0 ncb_version = 3 boot_stream_1_address = 0 boot_stream_2_address = 0 -- We add the 1k-padding to the uboot. .tmp_kobs_ng: verifying using key '00000000000000000000000000000000' .tmp_kobs_ng: is a valid bootstream for key '00000000000000000000000000000000' mtd: use new bch layout raw access mode mtd: opening: "/dev/mtd0" NFC geometry : ECC Strength : 2 Page Size in Bytes : 2071 Metadata size : 10 ECC Chunk Size in byte : 512 ECC Chunk count : 4 Block Mark Byte Offset : 2028 Block Mark Bit Offset : 2 ==================================================== mtd: opened '/dev/mtd0' - '(null)' mtd: max_boot_stream_size_in_bytes = 3670016 mtd: boot_stream_size_in_bytes = 61440 mtd: boot_stream_size_in_pages = 30 mtd: #1 0x00100000 - 0x00480000 (0x0010f000) mtd: #2 0x00480000 - 0x00800000 (0x0048f000) FCB m_u32Checksum = 0x00000000 m_u32FingerPrint = 0x20424346 m_u32Version = 0x01000000 m_NANDTiming.m_u8DataSetup = 80 m_NANDTiming.m_u8DataHold = 60 m_NANDTiming.m_u8AddressSetup = 25 m_NANDTiming.m_u8DSAMPLE_TIME = 6 m_u32PageDataSize = 2048 m_u32TotalPageSize = 2112 m_u32SectorsPerBlock = 64 m_u32NumberOfNANDs = 0 m_u32TotalInternalDie = 0 m_u32CellType = 0 m_u32EccBlockNEccType = 1 m_u32EccBlock0Size = 512 m_u32EccBlockNSize = 512 m_u32EccBlock0EccType = 1 m_u32MetadataBytes = 10 m_u32NumEccBlocksPerPage = 3 m_u32EccBlockNEccLevelSDK = 0 m_u32EccBlock0SizeSDK = 0 m_u32EccBlockNSizeSDK = 0 m_u32EccBlock0EccLevelSDK = 0 m_u32NumEccBlocksPerPageSDK = 0 m_u32MetadataBytesSDK = 0 m_u32EraseThreshold = 0 m_u32Firmware1_startingPage = 512 m_u32Firmware2_startingPage = 2304 m_u32PagesInFirmware1 = 30 m_u32PagesInFirmware2 = 30 m_u32DBBTSearchAreaStartAddress = 256 m_u32BadBlockMarkerByte = 2028 m_u32BadBlockMarkerStartBit = 2 m_u32BBMarkerPhysicalOffset = 2048 m_u32BCHType = 0 m_NANDTMTiming.m_u32TMTiming2_ReadLatency = 0 m_NANDTMTiming.m_u32TMTiming2_PreambleDelay = 0 m_NANDTMTiming.m_u32TMTiming2_CEDelay = 0 m_NANDTMTiming.m_u32TMTiming2_PostambleDelay = 0 m_NANDTMTiming.m_u32TMTiming2_CmdAddPause = 0 m_NANDTMTiming.m_u32TMTiming2_DataPause = 0 m_NANDTMTiming.m_u32TMSpeed = 0 m_NANDTMTiming.m_u32TMTiming1_BusyTimeout = 0 m_u32DISBBM = 0 m_u32BBMarkerPhysicalOffsetInSpareData = 0 DBBT m_u32Checksum = 0x00000000 m_u32FingerPrint = 0x54424244 m_u32Version = 0x01000000 m_u32DBBTNumOfPages = 0 Firmware: image #0 @ 0x100000 size 0xf000 - available 0x380000 Firmware: image #1 @ 0x480000 size 0xf000 - available 0x380000 -------------- Start to write the [ FCB ] ----- mtd: erasing @0:0x0-0x20000 mtd: Writing FCB0 [ @0:0x0 ] (840) * mtd: erasing @0:0x20000-0x40000 mtd: Writing FCB1 [ @0:0x20000 ] (840) * mtd: erasing @0:0x40000-0x60000 mtd: Writing FCB2 [ @0:0x40000 ] (840) * mtd: erasing @0:0x60000-0x80000 mtd: Writing FCB3 [ @0:0x60000 ] (840) * mtd_commit_bcb(FCB): status 0 -------------- Start to write the [ DBBT ] ----- mtd: erasing @0:0x80000-0xa0000 mtd: Writing DBBT0 [ @0:0x80000 ] (800) * mtd: erasing @0:0xa0000-0xc0000 mtd: Writing DBBT1 [ @0:0xa0000 ] (800) * mtd: erasing @0:0xc0000-0xe0000 mtd: Writing DBBT2 [ @0:0xc0000 ] (800) * mtd: erasing @0:0xe0000-0x100000 mtd: Writing DBBT3 [ @0:0xe0000 ] (800) * mtd_commit_bcb(DBBT): status 0 ---------- Start to write the [ .tmp_kobs_ng ]---- mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x0010f000 mtd: erasing @0:0x100000-0x120000 mtd: We write one page for save guard. * mtd: Writting .tmp_kobs_ng: #1 @0: 0x00480000 - 0x0048f000 mtd: erasing @0:0x480000-0x4a0000 mtd: We write one page for save guard. * root@imx6qxelk:~#
- erase the mtd part with
flash_erase
root@imx6qxelk:~# flash_erase /dev/mtd1 0 0
- execute
nandwrite
for second stage programming
root@imx6qxelk:~# nandwrite -p /dev/mtd1 xelk-3.5.0_mx6qdlaxel_nand_u-boot.img Writing data to block 0 at offset 0x0 Writing data to block 1 at offset 0x20000 Writing data to block 2 at offset 0x40000 Writing data to block 3 at offset 0x60000 root@imx6qxelk:~#
- reboot and starts SPL fron NAND
root@imx6qxelk:~# reboot Broadcast message from root@imx6qxelk (ttymxc2) (Thu Nov 9 06:08:11 2017): The system is going down for reboot NOW! ... ... ... Rebooting... [ 515.784981] reboot: Restarting system U-Boot SPL 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:37:42) SOM ConfigID#: 00000001 Trying to boot from NAND NAND : 1024 MiB U-Boot 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:37:42 +0200), Build: jenkins-XELK-u-boot-62 CPU: Freescale i.MX6DL rev1.3 at 792MHz CPU: Industrial temperature grade (-40C to 105C) at 56C Reset cause: POR Environment: NAND I2C: ready DRAM: 1 GiB Relocating to 4ff30000, new gd at 4df2feb8, sp at 4df2fe90 PMIC: PFUZE100 ID=0x10 NAND: 1024 MiB MMC: FSL_SDHC: 0 WARNING: CB ConfigID on block 0 is UNLOCKED Display: LDB-AM-800480STMQW-TA1-SBCX-REVB (800x480) NAND read: device 0 offset 0x1400000, size 0x1c2036 1843254 bytes read: OK In: serial Out: serial Err: serial SOM ConfigID#: 00000001 SOM UniqueID#: ea9ae213:041b71d4 CB ConfigID#: 00000012 CB UniqueID#: 3e00000c:de36b32d Board: MX6DL-AxelLite on SBCX Fastboot: unsupported boot devices Net: FEC [PRIME] Warning: FEC (eth0) using random MAC address - a6:1d:61:82:c9:0f Normal Boot Hit ENTER within 1 seconds to stop autoboot =>
As you can see, the SPL code recognizes the NAND flash and properly loads the correct u-boot second-stage for its execution:
U-Boot SPL 2016.03-xelk-3.5.0 (Apr 19 2019 - 23:37:42) SOM ConfigID#: 00000001 Trying to boot from NAND NAND : 1024 MiB