Changes

Jump to: navigation, search

Standalone boot (DIVELK)

3,607 bytes added, 10:37, 31 August 2018
History
!Notes
|-
|{{oldid|7655|3.0.0}}
|June 2017
|[[Diva_Embedded_Linux_Kit_(DIVELK)#DIVELK_3.0.0|DIVELK 3.0.0]]
|
|-
|4.0.0
|April 2018
|[[Diva_Embedded_Linux_Kit_(DIVELK)#DIVELK_4.0.0|DIVELK 4.0.0]]
|
|-
This document has been written and tested with the software/hardware combination described in the history table above. However it contains general concept that can be adapted on any DAVE Embedded Systems' Linux platform.
We'll explain how to program and configure a [[Category:DIVADiva|DIVADiva]] to boot in standalone mode, without the need of a system microSD card or a NFS server, with two options:
* booting with NOR + NAND
** U-Boot will fetch Linux kernel binary images (kernel + device tree) from on-board NOR flash memory, while later the OS will mount the root file system from a NAND partition.
* booting with NAND only
** in this configuration the whole system will boot without the need of a NOR storage, all images and the root file system will be fetch from NAND.
 
== Update u-boot NOR ==
<pre>
tftp ${loadaddr} diva/divelk-4.0.0_diva_spiboot_MLO.byteswap
sf probe 0:0; sf erase 0x0 0x40000; sf write ${loadaddr} 0x0 0x40000
tftp ${loadaddr} diva/divelk-4.0.0_diva_spiboot_u-boot.img
sf probe 0:0; sf erase 0x40000 0x100000; sf write ${loadaddr} 0x40000 0x100000
</pre>
<pre class="board-terminal">
=> tftp ${loadaddr} diva/divelk-4.0.0_diva_spiboot_MLO.byteswap
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'diva/divelk-4.0.0_diva_spiboot_MLO.byteswap'.
Load address: 0x82000000
Loading: #############
1.3 MiB/s
done
Bytes transferred = 65868 (1014c hex)
 
=> sf probe 0:0; sf erase 0x0 0x40000; sf write ${loadaddr} 0x0 0x40000
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 262144 bytes @ 0x0 Erased: OK
device 0 offset 0x0, size 0x40000
SF: 262144 bytes @ 0x0 Written: OK
 
=> tftp ${loadaddr} diva/divelk-4.0.0_diva_spiboot_u-boot.img
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'diva/divelk-4.0.0_diva_spiboot_u-boot.img'.
Load address: 0x82000000
Loading: #################################################################
#########################################
1.3 MiB/s
done
Bytes transferred = 540424 (83f08 hex)
 
=> sf probe 0:0; sf erase 0x40000 0x100000; sf write ${loadaddr} 0x40000 0x100000
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 1048576 bytes @ 0x40000 Erased: OK
device 0 offset 0x40000, size 0x100000
SF: 1048576 bytes @ 0x40000 Written: OK
 
</pre>
'''Note:''' Adjust the SYSBOOT pins to enable boot from spi.
 
== Update u-boot NAND ==
<pre>
tftp ${loadaddr} diva/divelk-4.0.0_diva_nandboot_MLO
nand erase.part nand-spl; nand write ${loadaddr} nand-spl ${filesize}
tftp ${loadaddr} diva/divelk-4.0.0_diva_nandboot_u-boot.img
nand erase.part nand-uboot; nand write ${loadaddr} nand-uboot ${filesize}
</pre>
 
<pre class="board-terminal">
=> tftp ${loadaddr} diva/divelk-4.0.0_diva_nandboot_MLO
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'diva/divelk-4.0.0_diva_nandboot_MLO'.
Load address: 0x82000000
Loading: #############
825.2 KiB/s
done
Bytes transferred = 61716 (f114 hex)
=> nand erase.part nand-spl; nand write ${loadaddr} nand-spl ${filesize}
 
NAND erase.part: device 0 offset 0x0, size 0x20000
Erasing at 0x0 -- 100% complete.
OK
 
NAND write: device 0 offset 0x0, size 0xf114
61716 bytes written: OK
 
=> tftp ${loadaddr} diva/divelk-4.0.0_diva_nandboot_u-boot.img
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'diva/divelk-4.0.0_diva_nandboot_u-boot.img'.
Load address: 0x82000000
Loading: #################################################################
#########################################
1 MiB/s
done
Bytes transferred = 539856 (83cd0 hex)
 
=> nand erase.part nand-uboot; nand write ${loadaddr} nand-uboot ${filesize}
 
NAND erase.part: device 0 offset 0x80000, size 0x1e0000
Erasing at 0x240000 -- 100% complete.
OK
 
NAND write: device 0 offset 0x80000, size 0x83cd0
539856 bytes written: OK
</pre>
'''Note:''' Adjust the SYSBOOT pins to enable boot from nand.
== Program root file system in NAND flash ==
This is a common step for both booting options.
* Boot the system via SD or NFS as described into the [[Diva_Embedded_Linux_Kit_(DIVELK)#Quick_start_guide|Quick_start_guide]]
* 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="board-terminal">
root@diva:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "spi-MLO"mtd1: 00080000 00100000 00010000 "uspi-bootuboot"mtd2: 00040000 00010000 "spi-env1"mtd3: 00040000 00010000 "spi-env2"mtd4: 00040000 00010000 "spi-fdt"mtd5: 00600000 00010000 "spi-kernel"mtd6: 00400000 00010000 "spi-splash"mtd7: 01480000 01400000 00010000 "spi-free"mtd8: 00020000 00020000 "NAND.SPLnand-spl"mtd9: 00020000 00020000 "NAND.SPLnand-spl.backup1"mtd10: 00020000 00020000 "NAND.SPLnand-spl.backup2"mtd11: 00020000 00020000 "NAND.SPLnand-spl.backup3"mtd12: 001e0000 00020000 "NAND.unand-bootuboot"mtd13: 00020000 00020000 "NAND.unand-bootuboot-env"mtd14: 00020000 00020000 "NAND.unand-bootuboot-env.backup1"mtd15: 00020000 00020000 "NAND.nand-fdt"mtd16: 00600000 00020000 "NAND.nand-kernel"mtd17: 00400000 00020000 "NAND.nand-splash"mtd18: 1f340000 3f340000 00020000 "NAND.filenand-systemfilesystem"root@diva:~#
</pre>
* Format and initialize ''nand-ubifilesystem'' partition, which in our case is <code>mtd18</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
<pre>
root@diva:~# ubiformat /dev/mtd18
ubiformat: mtd18 (nand), size 1060372480 bytes (1011.2 MiB), 8090 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 8089 -- 100 % complete 6 % complete
ubiformat: 8089 eraseblocks have valid erase counter, mean value is 1
ubiformat: 1 bad eraseblocks found, numbers: 17052991ubiformat: formatting eraseblock 8089 -- 100 % complete root@diva:~#
root@diva:~# ubiattach -m 18
[ 191932.278340829348] ubi0: attaching mtd18[ 193935.528706304512] ubi0: scanning is finished[ 193935.557104334456] ubi0: attached mtd18 (name "NAND.filenand-systemfilesystem", size 1011 MiB)[ 193935.564231341934] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes[ 193935.571629353377] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512[ 193935.578373362897] ubi0: VID header offset: 512 (aligned 512), data offset: 2048[ 193935.585716372570] ubi0: good PEBs: 8089, bad PEBs: 1, corrupted PEBs: 0[ 193935.591905381808] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128[ 193935.599445391863] ubi0: max/mean erase counter: 3/2, WL threshold: 4096, image sequence number: 15518799581786346429[ 193935.608622403777] ubi0: available PEBs: 7926, total reserved PEBs: 163, PEBs reserved for bad PEB handling: 159[ 193935.618708416248] ubi0: background thread "ubi_bgt0d" started, PID 10681025UBI device number 0, total 8089 LEBs (1043675136 bytes, 995.3 MiB), available 7926 LEBs (1022644224 bytes, 975.3 MiB), LEB size 129024 bytes (126.0 KiBbyte)root@divaaxel-lite:~# ubimkvol /dev/ubi0 -N diva-rootfs -m
Set volume size to 1022644224
Volume ID 0, size 7926 LEBs (1022644224 bytes, 975.3 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "diva-rootfs", alignment 1
root@diva:~#
</pre>
root@diva:~# mkdir -p /mnt/nand
root@diva:~# mount -t ubifs ubi0_0 /mnt/nand
[ 2321048.550330356596] UBIFS (ubi0:0): default file-system created[ 2321048.559955371923] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 10741033[ 2321048.618905436268] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "diva-rootfs"[ 2321048.626611443769] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes[ 2321048.637797459787] UBIFS (ubi0:0): FS size: 1020321792 bytes (973 MiB, 7908 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)[ 2321048.649164477979] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)[ 2321048.655844484678] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID 92010F4A506C48EC-9456890F-491C476F-A5DCBD40-9B0DE0E2599256141C521278, small LPT model
root@diva:~#
</pre>
<pre>
root@diva:~# tar zxvf xvJf divelk-4.0.0_divelk-image-matrix-diva.tar.gz xz -C /mnt/nand
</pre>
* finally, you need to cleanly umount and detach the MTD partition
 
<pre>
umount /mnt/nand/
ubidetach -m 18
</pre>
 
E.g.
<pre class="board-terminal">
root@diva:~# umount /mnt/nand/
[ 10331137.824165013852] UBIFS (ubi0:0): un-mount UBI device 0[ 10331137.829317027471] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
root@diva:~# ubidetach -m 18
[ 10471144.424806283392] ubi0: detaching mtd18[ 10471144.444423311866] ubi0: mtd18 is detachedroot@diva:~#
</pre>
<pre>
nand_argsnandargs=setenv bootargs ubi.mtd=nand-filesystem root=ubi0:rootfs rootfstype=ubifs rw ubi.mtdrootwait=181
</pre>
<pre>
spisrcaddrk=0x180000spisrcaddrfdt=0x140000loadk=tftp tftpboot ${kloadaddrloadaddr} ${serverip}:${bootfile}loadfdt=tftpboot ${fdtaddr} ${serverip}:${fdtfile}spi_updatek=sf probe 0:0; sf erase ${spisrcaddrk} 0x200000 0x600000; sf write ${kloadaddrloadaddr} 0x200000 ${spisrcaddrkfilesize} 0x600000spi_updatefdt=sf probe 0:0; sf erase ${spisrcaddrfdt} 0x1C0000 0x40000; sf write ${fdtaddr} 0x1C0000 ${spisrcaddrfdtfilesize} 0x40000spi_loadk=sf read ${kloadaddr} ${spisrcaddrkloadaddr} 0x200000 0x600000spi_loadfdt=sf read ${fdtaddr} ${spisrcaddrfdt} 0x1C0000 0x40000
spi_nand=sf probe; run spi_loadk spi_loadfdt nandargs addcons addmisc; if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi
</pre>
<pre class="board-terminal">
Usf probe; run loadk spi_updatek loadfdt spi_updatefdt</pre> E.g.: <pre class="board-Boot# terminal">=> sf probe; run loadk spi_updatek loadfdt spi_updatefdtSF: Detected S25FL256S_64K s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.2382; our IP address is 192.168.0.9483Filename 'diva/linux/divelk-3.0.0_uImageuImage'.Load address: 0x80007fc00x82000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################# 1##################################################### 1022.6 MiB5 KiB/s
done
Bytes transferred = 4148488 4593552 (3f4d08 461790 hex)SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiBSF: 6291456 bytes @ 0x180000 0x200000 Erased: OKdevice 0 offset 0x1800000x200000, size 0x6000000x461790SF: 6291456 4593552 bytes @ 0x180000 0x200000 Written: OK
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.2382; our IP address is 192.168.0.9483Filename 'diva/linux/divelk-3.0.0_am335xam335x-divelksbcd.dtb'.Load address: 0x80f800000x88000000Loading: ######### 918598.9 6 KiB/s
done
Bytes transferred = 39558 44754 (9a86 aed2 hex)SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiBSF: 262144 bytes @ 0x140000 0x1c0000 Erased: OKdevice 0 offset 0x1400000x1c0000, size 0x400000xaed2SF: 262144 44754 bytes @ 0x140000 0x1c0000 Written: OKU-Boot#
</pre>
</pre>
=== NAND flash ===
We assume that the following environment variables are present in u-boot:
<pre>
nand_updatek=nand erase.part NAND.nand-kernel; nand write ${kloadaddrloadaddr} NAND.nand-kernel ${filesize}nand_updatefdt=nand erase.part NAND.nand-fdt; nand write ${fdtaddr} NAND.nand-fdt ${filesize}nandargs=setenv bootargs ubi.mtd=NAND.file-system root=ubi0:diva-rootfs rootfstype=ubifs rw rootwait=1nand_nandnand_loadk=nand read ${kloadaddrloadaddr} NAND.nand-kernel; nand_loadfdt=nand read ${fdtaddr} NAND.nand-fdt; nand_nand=run nand_loadk nand_loadfdt nandargs addeth addcons addmisc ; if run configid_fixupfdt; then bootm ${kloadaddrloadaddr} - ${fdtaddr}; fi
</pre>
<pre class="board-terminal">
=> run loadk nand_updatek loadfdt nand_updatefdt
</pre>
<pre class="board-terminal">
U-Boot# => run loadk nand_updatek loadfdt nand_updatefdt
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.2382; our IP address is 192.168.0.9483Filename 'diva/linux/divelk-3.0.0_uImageuImage'.Load address: 0x80007fc00x82000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################# 1################################################################# ################################################################# ##################################################### 1010.6 MiB7 KiB/s
done
Bytes transferred = 3332840 4593552 (32dae8 461790 hex)
NAND erase.part: device 0 offset 0x2c0000, size 0x600000
OK
NAND write: device 0 offset 0x2c0000, size 0x32dae80x461790 3332840 4593552 bytes written: OK
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 192.168.0.2382; our IP address is 192.168.0.9483Filename 'diva/linux/divelk-3.0.0_am335xam335x-divelksbcd.dtb'.Load address: 0x80f800000x88000000Loading: ######### 954682.1 6 KiB/s
done
Bytes transferred = 37129 44754 (9109 aed2 hex)
NAND erase.part: device 0 offset 0x2a0000, size 0x20000
OK
NAND write: device 0 offset 0x2a0000, size 0x91090xaed2 37129 44754 bytes written: OKU-Boot#
</pre>
8,154
edits

Navigation menu