Open main menu

DAVE Developer's Wiki β

Changes

DESK-MX6UL-L/Deployment/Standalone boot

6,666 bytes removed, 09:20, 1 July 2021
no edit summary
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|X1.Y0.Z1|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Month YearJun 2021|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|TBD|-|-|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|[TBD_link X.Y.Z]|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Month Year|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|TBDFirst DESK release
|-
|}
==Standalone boot==
 
'''TBD: rifare tutti i dump con le versioni corrette '''
 
'''TBD: eliminare eventuali sezioni non pertinenti (es. eMMC) per il SOC '''
 
=== Introduction ===
<pre class="workstation-terminal">
=> run load
Using FEC FEC0 deviceTFTP from server 192.168.0.13125; our IP address is 192.168.0.89Filename 'sdvxdesk-mx-l/udesk-mx6ul-l-1.0.1_mx6uldesk_lynx_spi_SPL'.Load address: 0x80800000Loading: ############ 543.9 KiB/sdoneBytes transferred = 56320 (dc00 hex)=> run spi_update_splSF: Detected is25lp128 with page size 256 Bytes, erase size 64 KiB, total 16 MiBSF: 65536 bytes @ 0x0 Erased: OKdevice 0 offset 0x400, size 0xdc00SF: 56320 bytes @ 0x400 Written: OK=> run load_ubootUsing FEC0 deviceTFTP from server 192.168.0.125; our IP address is 192.168.0.89Filename 'desk-mx-bootl/sdvxdesk-mx6ul-l-1.0.0_mx6dl_sfczg_spi_u1_mx6uldesk_lynx_spi_u-boot.imximg'.Load address: 0x120000000x80800000
Loading: #################################################################
################################################################# ## 1.4 MiB584 KiB/s
done
Bytes transferred = 671788 512568 (a402c 7d238 hex)=> run spi_updatespi_update_ubootSF: Detected S25FL256S is25lp128 with page size 256 Bytes, erase size 64 KiB, total 32 16 MiBSF: 524288 bytes @ 0x10000 Erased: OKdevice 0 offset 0x10000, size 0x7d238SF: 512568 bytes @ 0x10000 Written: OK
=>
</pre>
<pre class="workstation-terminal">
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
SF: Detected S25FL256S is25lp128 with page size 256 Bytes, erase size 64 KiB, total 32 16 MiBUsing FEC FEC0 deviceTFTP from server 192.168.0.13125; our IP address is 192.168.0.9889Filename 'sdvxdesk-mx-l/linux/sdvxdesk-mx6ul-l-1.0.0_lite_uImage1_uImage'.Load address: 0x120000000x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################# 1################################################################# ################################################################# ################################################################# ############## 553.6 MiB7 KiB/s
done
Bytes transferred = 6437016 7056696 (623898 6bad38 hex)SF: 8388608 bytes @ 0x200000 Erased: OKdevice 0 offset 0x200000, size 0x6bad38SF: 7056696 bytes @ 0x200000 Written: OKUsing FEC FEC0 deviceTFTP from server 192.168.0.13125; our IP address is 192.168.0.89Filename 'sdvxdesk-mx-l/linux/sdvxdesk-mx6ul-l-1.0.0_lite_imx6dl1_imx6ul-sfczgaxelulite-cb0043cb003a.dtb'.Load address: 0x180000000x83000000Loading: ######### 1.2 MiB584 KiB/s
done
Bytes transferred = 42547 34095 (a633 852f hex)SF: 524288 bytes @ 0x180000 Erased: OKdevice 0 offset 0x180000, size 0x852fSF: 34095 bytes @ 0x180000 Written: OK
=>
</pre>
<pre class="workstation-terminal">
root@imx6qxelkdesk-mx6ul-axelulite:~# kobs-ng -x -v -w sdvxdesk-mx6ul-l-1.0.0_mx6dl_sfczg_nand_u-boot.imx2_mx6uldesk_axelulite_nand_SPL
MTD CONFIG:
chip_0_device_path = "/dev/mtd0"
mtd: The last page is not full : 1068
mtd: We write one page for save guard. *
root@imx6qxelkdesk-mx6ul-axelulite:~# flash_erase /dev/mtd1 0 0Erasing 128 Kibyte @ 5e0000 -- 100 % completeroot@desk-mx6ul-axelulite:~# nandwrite -p /dev/mtd1 desk-mx6ul-l-1.0.1_mx6uldesk_axelulite_nand_u-boot.imgWriting data to block 0 at offset 0x0Writing data to block 1 at offset 0x20000Writing data to block 2 at offset 0x40000Writing data to block 3 at offset 0x60000root@desk-mx6ul-axelulite:~#
</pre>
<pre class="workstation-terminal">
U-Boot => run loadk nand_updatek loadfdt nand_updatefdtUsing FEC FEC0 deviceTFTP from server 192.168.0.13125; our IP address is 192.168.0.9889Filename 'sdvxdesk-mx-l/linux/sdvxdesk-mx6ul-l-1.0.0_lite_uImage1_uImage'.Load address: 0x120000000x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################# 1################################################################# ############## 504.4 MiB9 KiB/s
done
Bytes transferred = 6437016 7056696 (623898 6bad38 hex)
NAND erase.part: device 0 offset 0xc00000, size 0x800000
OK
NAND write: device 0 offset 0xc00000, size 0x6238980x6bad38 6437016 7056696 bytes written: OKUsing FEC FEC0 deviceTFTP from server 192.168.0.13125; our IP address is 192.168.0.89Filename 'sdvxdesk-mx-l/linux/sdvxdesk-mx6ul-l-1.0.0_lite_imx6dl1_imx6ul-sfczgaxelulite-cb0043cb003a.dtb'.Load address: 0x180000000x83000000Loading: ######### 525.4 165 KiB/s
done
Bytes transferred = 42547 34095 (a633 852f hex)
NAND erase.part: device 0 offset 0xa00000, size 0x100000
OK
NAND write: device 0 offset 0xa00000, size 0xa6330x852f 42547 34095 bytes written: OK
=>
</pre>
=> setenv bootcmd run nand_nand
=> saveenv
</pre>
 
=== Program boot images into eMMC ===
 
====u-Boot====
Update to the latest u-boot version allows usage of u-boot environment variables available.
 
<pre>
mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}
</pre>
 
Load u-boot binary form a <code>tftp</code> server:
 
<pre class="workstation-terminal">
=> run load
Using FEC device
TFTP from server 192.168.0.13; our IP address is 192.168.0.89
Filename 'sdvx/u-boot/sdvx-1.0.0_mx6dl_sfczg_u-boot.imx'.
Load address: 0x12000000
Loading: #################################################################
#################################################################
##
1.5 MiB/s
done
Bytes transferred = 671788 (a402c hex)
=> run mmc_update
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
 
MMC write: dev # 2, block # 2, count 1313 ... 1313 blocks written: OK
=>
</pre>
 
Load u-boot binary form an <code>SD</code> card:
 
<pre class="workstation-terminal">
Hit ENTER within 1 seconds to stop autoboot
=> fatload mmc 0:1 ${loadaddr} sdvx-1.0.1_mx6dlaxel_u-boot.imx
reading sdvx-1.0.1_mx6dlaxel_u-boot.imx
671788 bytes read in 50 ms (12.8 MiB/s)
=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
=> run mmc_update
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
 
MMC write: dev # 2, block # 2, count 1313 ... 1313 blocks written: OK
=>
</pre>
 
====kernel image and device tree====
 
We assume that the following environment variables are present in u-boot:
 
<pre>
mmc_loadk=fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}
mmc_loadfdt=fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}
mmc_loadsplash=fatload mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}
mmcboot=run mmcargs addcons addmisc; if run mmc_loadk; then if run mmc_loadfdt; then if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi; fi; fi
</pre>
 
Using an SD card or an eMMC device assumes that <code>bootfile</code>, <code>fdtfile</code> and <code>splashfile</code> are stored into fist MMC device partition.
 
Then, u-boot uses the previous listed commands for reading the binary images and starting the linux bootstrap from the ''MMC part 2'' (which is reserved for the root-file system storage).
 
The following u-boot environment variables are present for this purposes:
<pre>
mmcargs=setenv bootargs root=${mmcroot}
mmcroot=/dev/mmcblk2p2 rootwait rw
</pre>
 
==== boot vars ====
 
The following environment variables should be configured for u-boot properly reading the boot files from the first SD card partition, e.g.
 
<pre class="workstation-terminal">
=> setenv normalboot mmcboot
=> setenv bootfile sdvx-1.0.1_lite_uImage
=> setenv fdtfile sdvx-1.0.1_lite_imx6dl-sdv03-cb002a.dtb
=> setenv splashfile splash_image.bmp
</pre>
 
then save the environment and reboot the system to apply the new configuration:
 
<pre class="workstation-terminal">
=> saveenv
Saving Environment to MMC...
Writing to MMC(2)... done
=> reset
</pre>
* By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for u-boot and kernel images. Here we won't modify this default configuration. The [[Memory Tecnology Device (MTD)|MTD]] partitions can be dumped with <code>/proc/mtd</code> (the partition's name should be self-explanatory)
<pre class="workstation-terminal">
root@sdvxdesk-litemx6ul-axelulite:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00800000 00200000 00020000 "nand-SPL"mtd1: 00600000 00020000 "nand-uboot"mtd1mtd2: 00100000 00020000 "nand-env1"mtd2mtd3: 00100000 00020000 "nand-env2"mtd3mtd4: 00100000 00020000 "nand-fdt"mtd4mtd5: 00100000 00020000 "nand-spare"mtd5mtd6: 00800000 00020000 "nand-kernel"mtd6mtd7: 00600000 00400000 00020000 "nand-splash"mtd7mtd8: 3e600000 06800000 00020000 "nand-ubi"mtd9: 00010000 00001000 "spi-SPL"mtd10: 000f0000 00001000 "spi-uboot"mtd11: 00040000 00001000 "spi-env1"mtd12: 00040000 00001000 "spi-env2"mtd13: 00080000 00001000 "spi-dtb"mtd14: 00800000 00001000 "spi-kernel"mtd15: 00400000 00001000 "spi-splash"mtd16: 00200000 00001000 "spi-free"root@sdvxdesk-mx6ul-liteaxelulite:~#
</pre>
<pre>
ubiformat /dev/mtd7mtd8ubiattach -m 78
ubimkvol /dev/ubi0 -N rootfs -m
</pre>
<pre class="workstation-terminal">
root@sdvxdesk-litemx6ul-axelulite:~# ubiformat /dev/mtd7mtd8ubiformat: mtd7 mtd8 (nand), size 1048576000 109051904 bytes (1000104.0 MiB), 8000 832 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytesli[ 52.440377] random: crng init done% complete[ 52.446177] random: 7 urandom warning(s) missed due to ratelimitinglibscan: scanning eraseblock 7999 831 -- 100 % completeubiformat: 8000 830 eraseblocks have valid erase counter, mean value is 10ubiformat: warning!: 2 of 832 eraseblocks contain non-UBI dataubiformat: continue? (y/N) yubiformat: formatting eraseblock 7999 831 -- 100 % completeroot@sdvxdesk-mx6ul-liteaxelulite:~# ubiattach -m 78[ 1714 68.823600203880] UBIubi0: attaching mtd7 to ubi0mtd8[ 1726 69.415587488529] UBIubi0: scanning is finished[ 1726 69.483765526881] UBIubi0: attached mtd7 mtd8 (name "nand-ubi", size 1000 104 MiB) to ubi0[ 1726 69.491062545319] UBIubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes[ 1726 69.498301552230] UBIubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048[ 1726 69.505030576138] UBIubi0: VID header offset: 2048 (aligned 2048), data offset: 4096[ 1726 69.512430587298] UBIubi0: good PEBs: 8000832, bad PEBs: 0, corrupted PEBs: 0[ 1726 69.518861594040] UBIubi0: user volume: 0, internal volumes: 1, max. volumes count: 128[ 1726 69.526025601292] UBIubi0: max/mean erase counter: 32/21, WL threshold: 4096, image sequence number: 6230702581623728395[ 1726 69.535433613873] UBIubi0: available PEBs: 7836808, total reserved PEBs: 16424, PEBs reserved for bad PEB handling: 16020[ 1726 69.545260623519] UBIubi0: background thread "ubi_bgt0d" started, PID 714264UBI device number 0, total 8000 832 LEBs (1015808000 105644032 bytes, 968100.8 7 MiB), available 7836 808 LEBs (994983936 102596608 bytes, 94897.9 8 MiB), LEB size 126976 bytes (124.0 KiB)root@sdvxdesk-mx6ul-liteaxelulite:~# ubimkvol /dev/ubi0 -N rootfs -mSet volume size to 994983936102596608Volume ID 0, size 7836 808 LEBs (994983936 102596608 bytes, 94897.9 8 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1root@desk-mx6ul-axelulite:~#
</pre>
<pre class="workstation-terminal">
root@sdvxdesk-litemx6ul-axelulite:~# mkdir -p /mnt/nandroot@sdvxdesk-litemx6ul-axelulite:~# mount -t ubifs ubi0_0 /mnt/nand[ 1810 104.301461646929] UBIFS(ubi0:0): default file-system created[ 1810 104.308952656524] UBIFS(ubi0:0): background thread "ubifs_bgt0_0" started, PID 717271[ 1810 104.452274795980] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"[ 1810 104.459421803631] UBIFS(ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes[ 1810 104.469398817174] UBIFS(ubi0:0): FS size: 992698368 101199872 bytes (946 96 MiB, 7818 797 LEBs), journal size 33521664 5079040 bytes (31 4 MiB, 264 40 LEBs)[ 1810 104.480976829554] UBIFS(ubi0:0): reserved for root: 4952683 4779919 bytes (4836 4667 KiB)[ 1810 104.487210838248] UBIFS(ubi0:0): media format: w4w5/r0 (latest is w4w5/r0), UUID 99D0F3C60687F325-59554ED1-4B30488F-9E2DB637-72202281BD3057FAEADE745E, small LPT modelroot@desk-mx6ul-axelulite:~#
</pre>
<pre>
tar xvjf sdvxtar xjf desk-mx6ul-l-1.0.1_image1_dave-image-devel-sdvxdesk-litemx6ul.tar.bz2 -C /mnt/nand
</pre>
<pre>
umount /mnt/nand/
ubidetach -m 78
</pre>
<pre class="workstation-terminal">
root@sdvxdesk-litemx6ul-axelulite:~# umount /mnt/nand/[ 24461264.743091460672] UBIFS(ubi0:0): un-mount UBI device 0, volume 0[ 24461264.749670465626] UBIFS(ubi0:0): background thread "ubifs_bgt0_0" stopsroot@sdvxdesk-mx6ul-liteaxelulite:~# ubidetach -m 78[ 24501270.738153298143] UBIubi0: detaching mtd7 from ubi0mtd8[ 24501270.759527316092] UBIubi0: mtd7 mtd8 is detached from ubi0root@desk-mx6ul-axelulite:~#
</pre>
<pre>
nand_argsnandargs=setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw ubi.mtd=7</pre> === Program root file system into eMMC flash === * Boot the system via SD or NFS as described in the e [[(<KIT>)#Quick_start_guide|Quick start guide]]* eMMC device has to be partitioned and properly formatted choosing the <code>file system</code> for each partition* an example of SD partitioning script is the following one: ==== FAT32 partition ====<pre>#!/bin/sh node=$1 # partition size in MBBOOTLOAD_RESERVE=8BOOT_ROM_SIZE=128RFS_SIZE=2048 # create the SDCARD partitionpart=""echo ${node} | grep mmcblk > /dev/nullif [ "$?" -eq "0" ]; then part="p"fi # print the SD total capacitytotal_size=`sfdisk -s ${node}`total_size=`expr ${total_size} / 1024`echo SD total size: ${total_size}KB # calculate partition sizesboot_start=`expr ${BOOTLOAD_RESERVE} \\* 1024 \\* 1024 / 512`boot_size=`expr ${BOOT_ROM_SIZE} \\* 1024 \\* 1024 / 512`rfs_start=`expr ${boot_size} + ${boot_start}`rfs_size=`expr ${RFS_SIZE} \\* 1024 \\* 1024 / 512` umount ${node}${part}1 > /dev/null 2>&1umount ${node}${part}2 > /dev/null 2>&1 # call sfdisk to create partition table{ echo ${boot_start},${boot_size},0c,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node} # format the SDCARD partitionecho "formatting boot"mkfs.vfat -F 32 -n boot ${node}${part}1echo "formatting rfs"mkfs.ext4 -F ${node}${part}2 -Lrfs</pre> E.g. <pre class="workstation-terminal">root@sdvx-lite:~# ./sdcard-partition.sh /dev/mmcblk2SD total size: 3776KB[ 1341.905014] mmcblk2: p1 p2Checking that no-one is using this disk right now ... OK Disk /dev/mmcblk2: 3.7 GiB, 3959422976 bytes, 7733248 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical):[ 1341.922729] mmcblk2: p1 p2 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0xa77eb3f0 Old situation: Device Boot Start End Sectors Size Id Type/dev/mmcblk2p1 2048 264191 262144 128M c W95 FAT32 (LBA)/dev/mmcblk2p2 264192 4458495 4194304 2G 83 Linux >>> Created a new DOS disklabel with disk identifier 0xcce0c36f.Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB./dev/mmcblk2p2: Created a new partition 2 of type 'Linux' and of size 2 GiB./dev/mmcblk2p3:New situation: Device Boot Start End Sectors Size Id Type/dev/mmcblk2p1 16384 278527 262144 128M c W95 FAT32 (LBA)/dev/mmcblk2p2 278528 4472831 4194304 2G 83 Linux The partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.formatting bootmkfs.fat 3.0.28 (2015-05-16)mkfs.fat: warning - lowercase labels might not work properly with DOS or Windowsformatting rfsmke2fs 1.43-WIP (18-May-2015)Discarding device blocks: doneCreating filesystem with 524288 4k blocks and 131072 inodesFilesystem UUID: 9a685543-1af2-4e39-83f3-b8a32248c021Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: doneWriting inode tables: doneCreating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: done root@sdvx-lite:~#</pre> * create a mount point and mount the first partition <pre>mkdir -p /mnt/emmcmount /dev/mmcblk2p1 /mnt/emmc</pre> * copy kernel, dtb and splash_image files <pre classubi0_0 rootfstype="workstation-terminal">root@sdvx-lite:~# mount /dev/mmcblk2p1 /mnt/emmc[ 40.988575] FAT-fs (mmcblk2p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.root@sdvx-lite:~# cd /mnt/emmcroot@sdvx-lite:/mnt/emmc# cp /tftpboot/sdvx/linux/sdvx-1.0.1*dtb .root@sdvx-lite:/mnt/emmc# cp /tftpboot/sdvx/linux/sdvx-1.0.1*uImage .root@sdvx-lite:/mnt/emmc# cp /tftpboot/sdvx/linux/splash_image.bmp .root@sdvx-lite:/mnt/emmc# cdroot@sdvx-lite:~# umount /mnt/emmc</pre> * now mount the EXT4 volume in the temporary directory E.g.: <pre class="workstation-terminal">root@sdvx-lite:~# mount /dev/mmcblk2p2 /mnt/emmc[ 1810.899327] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)root@sdvx-lite:~# cd /mnt/emmcroot@sdvx-lite:/mnt/emmc# </pre> * you can now extract the root file system into that directory <pre>tar xvjf sdvx-1.0.1_image-devel-sdvx-lite.tar.bz2</pre> * finally, you need to cleanly umount and safely reboot or turn off the system. <pre class="workstation-terminal">root@sdvx-lite:/mnt/emmc# cdroot@sdvx-lite:~# umount /mnt/emmcroot@sdvx-lite:~# reboot</pre> Reboot the system and configure U-Boot to apply the new configuration <pre class="workstation-terminal">=> setenv bootcmd run mmcboot=> saveenv</pre> ==== ext4 partition ====For using an <b>ext4</b> partition also for boot files, it is possibile to change the formatting script:  { echo ${boot_start},${boot_size},'''83''',-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node} and formatting the first partition using ''mkfs.ext4''  mkfs.ext4 -F ${node}${part}1 -Lboot then, the u-boot <code>environment</code> has to be properly configured: <pre class="workstation-terminal">=> setenv mmc_loadk 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'=> setenv mmc_loadfdt 'ext4load mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}'=> setenv mmc_loadsplash 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}'=> saveenvubifs rw
</pre>
8,226
edits