Difference between revisions of "Standalone boot (BELK/BXELK)"

From DAVE Developer's Wiki
Jump to: navigation, search
(Use case #2)
(69 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
{{Applies To Bora}}
 
{{Applies To Bora}}
 
{{Applies To BoraX}}
 
{{Applies To BoraX}}
{{Applies To BoraLite}}
 
 
{{InfoBoxBottom}}
 
{{InfoBoxBottom}}
 
 
{{ImportantMessage|text=For the sake of simplicity, this document does not address the reliability of the partitioning schemes described. This matter is beyond the scope of this document and should take into account several factors such as the intrinsic reliability of NOR/NAND flashes, the estimated usage in terms of read/write operations, etc. For more information related to this subject, please contact [mailto:support-bora@dave.eu the technical support].}}
 
 
  
 
== History ==
 
== History ==
Line 14: Line 9:
 
!Version
 
!Version
 
!Date
 
!Date
 +
!BXELK version
 +
!Hardware Part Nr
 
!Notes
 
!Notes
 
|-
 
|-
 
|1.0.0
 
|1.0.0
 
|December 2016
 
|December 2016
|Initial release
+
|[[BELK/BXELK_software_components#BELK_3.0.1_.2F_BXELK_1.0.0|BXELK 1.0.0]]
|-
+
|DBXF4110D2R<br />EVBBX0000C0R
|2.0.0
+
|
|March 2019
 
|Added use case #2
 
|-
 
|2.0.1
 
|March 2019
 
|Added warning about realiability<br>
 
Added images of case #1's partitioning scheme
 
|-
 
|{{oldid|9151|2.0.2}}
 
|June 2019
 
|Fixed definition of <code>nandboot2</code> variable<br>
 
Fixed dump related to the download of the bitstream file
 
 
|-
 
|-
|3.0.0
 
|Jan 2020
 
|Update for BELK/BXELK 4.1.0
 
 
|}
 
|}
  
<section begin=BELK/>
+
== Introduction ==
== Standalone boot==
 
This document shows some examples related to configuring Bora/BoraX/BoraLite for standalone operativity.
 
 
 
We'll explain how to program and configure a [[BORA Xpress SOM|BORA Xpress]]-based system to boot in standalone mode, without the need of a system microSD card or an NFS server. Only the flash memories available on the SoM itself will be used to store persistently all the software required.
 
 
 
The examples here documented are valid for [[BORA SOM|BORA]] and for [[BORA Lite SOM|BORA Lite]] as well.
 
 
 
{{ImportantMessage|text=It is worth remembering that the examples shown in this article don't make use of any image script. This technique is used by the bootable microSD card delivered along with the kit, instead. For more details, please refer to [[Working_with_the_Yocto_build_system#bootscript|this section]].}}
 
 
 
===Use case #1===
 
====Introduction====
 
This configuration makes use of one of the most common partitioning schemes, that is:
 
*The NOR flash acts as boot memory; as such, it contains
 
**bootrom header and FSBL (or header+U-Boot SPL)
 
**U-Boot
 
**U-Boot redundant environment
 
**Even though these images are not strictly required to boot the system, the NOR flash also contains:
 
***The Linux kernel image
 
***The Linux Device Tree Blob (DTB)
 
***The bitstream file for the Programmable Logic (PL).
 
*The NAND flash contains a partition devoted to a read/write UBIFS root filesystem.
 
 
 
The resulting flash memory layout is illustrated in the following pictures.
 
 
 
 
 
[[File:BELK-NOR-flash-partitioning-case1.png|thumb|center|600px|NOR flash partitioning scheme]]
 
 
 
 
 
[[File:BELK-NAND-flash-partitioning-case1.png|thumb|center|600px|NAND flash partitioning scheme]]
 
  
 +
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.
  
In essence, the bootstrap sequence looks like this:
+
We'll explain how to program and configure a [[Category:BoraX|BoraX]] to boot in standalone mode, without the need of a system microSD card or a NFS server, with two options:
*U-Boot fetches and programs the PL bitstream  
+
* booting with NOR + NAND
*Then it fetches the Linux kernel binary images (kernel and DTB) from the on-board NOR flash memory
+
** U-Boot will fetch and program PL bitstream and then 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.
*Once started, the Linux kernel mount the root filesystem from a NAND partition.
 
  
=====Testbed=====
+
==Use case #1==
This configuration was tested with the following testbed:
 
*SOM: DBXF4110D2R
 
*carrier board: EVBBX0000C0R
 
*software: [[BELK/BXELK_software_components#BELK_3.0.1_.2F_BXELK_1.0.0|BXELK 1.0.0]]
 
  
==== Program the root filesystem in NAND flash ====
+
=== Program root file system in NAND flash ===
  
 
This is a common step for both booting options.
 
This is a common step for both booting options.
  
* Boot the system via SD or NFS as described into the [[BORA_SOM/BELK-L/Development/How_to_create_a_bootable_microSD_card|System boot and recovery via microSD card]] and [[BORA_SOM/BELK-L/General/Booting_from_NFS|Booting the system via NFS]]
+
* Boot the system via SD or NFS as described into the [[System_boot_and_recovery_via_microSD_card_(BELK/BXELK)|System boot and recovery via microSD card]] and [[Booting_the_system_via_NFS_(BELK/BXELK)|Booting the system via NFS]]
 
* By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for FSBL, 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)
 
* By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for FSBL, 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">
 
<pre class="board-terminal">
 
root@bora:~# cat /proc/mtd
 
root@bora:~# cat /proc/mtd
 
dev:    size  erasesize  name
 
dev:    size  erasesize  name
mtd0: 00040000 00020000 "spl"
+
mtd0: 00080000 00020000 "nand-SPL"
mtd1: 000c0000 00020000 "uboot"
+
mtd1: 00080000 00020000 "nand-uboot"
mtd2: 00040000 00020000 "env1"
+
mtd2: 00040000 00020000 "nand-uboot-env1"
mtd3: 00040000 00020000 "env2"
+
mtd3: 00040000 00020000 "nand-uboot-env2"
mtd4: 00600000 00020000 "fpga"
+
mtd4: 00440000 00020000 "nand-bitstream"
mtd5: 00080000 00020000 "fdt"
+
mtd5: 00040000 00020000 "nand-device-tree"
mtd6: 00800000 00020000 "kernel"
+
mtd6: 00400000 00020000 "nand-linux"
mtd7: 3f000000 00020000 "nand-ubi"
+
mtd7: 1f600000 00020000 "nand-rootfs"
 
</pre>
 
</pre>
  
{{ImportantMessage|text=Please note that MTD partition index may change depending on flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside <code>/proc/mtd</code> to match your specific layout}}
+
{{ImportantMessage|text=Please note that MTD partition index may change depending of flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside <code>/proc/mtd</code> to match your specific layout}}
  
  
 
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
 
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
  
<pre class="board-terminal">
+
<pre>
 
ubiformat /dev/mtd7
 
ubiformat /dev/mtd7
 
ubiattach -m 7
 
ubiattach -m 7
Line 117: Line 67:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
root@bora:~# ubiformat /dev/mtd7
 
root@bora:~# ubiformat /dev/mtd7
ubiformat /dev/mtd7
+
ubiformat: mtd7 (nand), size 526385152 bytes (502.0 MiB), 4016 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
ubiformat: mtd7 (nand), size 1056964608 bytes (1008.0 MiB), 8064 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
+
libscan: scanning eraseblock 4015 -- 100 % complete
libscan: scanning eraseblock 8063 -- 100 % complete
+
ubiformat: 4016 eraseblocks have valid erase counter, mean value is 2
ubiformat: 8060 eraseblocks have valid erase counter, mean value is 1
+
ubiformat: formatting eraseblock 4015 -- 100 % complete
ubiformat: 4 bad eraseblocks found, numbers: 8060, 8061, 8062, 8063
 
ubiformat: formatting eraseblock 8063 -- 100 % complete
 
 
root@bora:~# ubiattach -m 7
 
root@bora:~# ubiattach -m 7
[ 275.247791] ubi0: attaching mtd7
+
[   95.732434] UBI: attaching mtd7 to ubi0
280.486952] ubi0: scanning is finished
+
100.930047] UBI: scanning is finished
280.520370] ubi0: attached mtd7 (name "nand-ubi", size 1008 MiB)
+
100.954932] UBI: attached mtd7 (name "nand-rootfs", size 502 MiB) to ubi0
280.526302] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
+
100.961772] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
280.533222] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
+
100.968534] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
280.539860] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
+
100.975248] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
280.546610] ubi0: good PEBs: 8060, bad PEBs: 4, corrupted PEBs: 0
+
100.982129] UBI: good PEBs: 4016, bad PEBs: 0, corrupted PEBs: 0
280.552720] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
+
100.988100] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
280.559908] ubi0: max/mean erase counter: 3/2, WL threshold: 4096, image sequence number: 857573235
+
100.995271] UBI: max/mean erase counter: 4/3, WL threshold: 4096, image sequence number: 1955579947
280.568946] ubi0: available PEBs: 7900, total reserved PEBs: 160, PEBs reserved for bad PEB handling: 156
+
101.004308] UBI: available PEBs: 3852, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
280.578486] ubi0: background thread "ubi_bgt0d" started, PID 983
+
101.013959] UBI: background thread "ubi_bgt0d" started, PID 913
UBI device number 0, total 8060 LEBs (1039933440 bytes, 991.8 MiB), available 7900 LEBs (1019289600 bytes, 972.1 MiB), LEB size 129024 bytes (126.0 KiB)
+
UBI device number 0, total 4016 LEBs (509935616 bytes, 486.3 MiB), available 3852 LEBs (489111552 bytes, 466.5 MiB), LEB size 126976 bytes (124.0 KiB)
 
root@bora:~# ubimkvol /dev/ubi0 -N rootfs -m
 
root@bora:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 1019289600
+
Set volume size to 489111552
Volume ID 0, size 7900 LEBs (1019289600 bytes, 972.1 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs", alignment 1
+
Volume ID 0, size 3852 LEBs (489111552 bytes, 466.5 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
root@bora:~#
 
 
</pre>
 
</pre>
  
 
* Now mount the UBI volume using [[Memory Tecnology Device (MTD)#UBIFS|UBIFS]] in a temporary directory
 
* Now mount the UBI volume using [[Memory Tecnology Device (MTD)#UBIFS|UBIFS]] in a temporary directory
  
<pre class="board-terminal">
+
<pre>
 
mkdir -p /mnt/nand
 
mkdir -p /mnt/nand
 
mount -t ubifs ubi0_0 /mnt/nand
 
mount -t ubifs ubi0_0 /mnt/nand
Line 154: Line 101:
 
root@bora:~# mkdir -p /mnt/nand
 
root@bora:~# mkdir -p /mnt/nand
 
root@bora:~# mount -t ubifs ubi0_0 /mnt/nand
 
root@bora:~# mount -t ubifs ubi0_0 /mnt/nand
327.559316] UBIFS (ubi0:0): default file-system created
+
151.397013] UBIFS: default file-system created
327.565925] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 990
+
151.402858] UBIFS: background thread "ubifs_bgt0_0" started, PID 918
327.694738] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
+
151.529438] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
327.702090] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
+
151.535395] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
327.711995] UBIFS (ubi0:0): FS size: 1016967168 bytes (969 MiB, 7882 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)
+
151.544507] UBIFS: FS size: 487079936 bytes (464 MiB, 3836 LEBs), journal size 24379392 bytes (23 MiB, 192 LEBs)
327.722998] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
+
151.554646] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
327.729608] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID 0D33F80E-E80A-43F7-BE9E-C2D24C4FCD14, small LPT model
+
151.560452] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 447F1480-E173-4BE9-B5BE-A3EC1267F99E, small LPT model
 
</pre>
 
</pre>
  
 
* you can now extract the root file system into that directory
 
* you can now extract the root file system into that directory
  
<pre class="board-terminal">
+
<pre>
tar jxvf dave-image-devel-bora.tar.bz2 . -C /mnt/nand
+
tar zxvf belk-3.0.1_bora-image-devel-bora.tar.gz -C /mnt/nand
 
</pre>
 
</pre>
  
 
* finally, you need to cleanly umount and detach the MTD partition
 
* finally, you need to cleanly umount and detach the MTD partition
  
<pre class="board-terminal">
+
<pre>
 
umount /mnt/nand/
 
umount /mnt/nand/
 
ubidetach -m 7
 
ubidetach -m 7
Line 180: Line 127:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
root@bora:~# umount /mnt/nand/
 
root@bora:~# umount /mnt/nand/
417.604700] UBIFS (ubi0:0): un-mount UBI device 0
+
385.604146] UBIFS: un-mount UBI device 0, volume 0
417.609362] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
+
385.608892] UBIFS: background thread "ubifs_bgt0_0" stops
 
root@bora:~# ubidetach -m 7
 
root@bora:~# ubidetach -m 7
424.230219] ubi0: detaching mtd7
+
387.671411] UBI: detaching mtd7 from ubi0
424.238132] ubi0: mtd7 is detached
+
387.677554] UBI: mtd7 is detached from ubi0
 
root@bora:~#
 
root@bora:~#
 +
 
</pre>
 
</pre>
  
 
You can now safely reboot or turn off the system.
 
You can now safely reboot or turn off the system.
  
==== Program the boot images in NOR flash====
+
=== Program boot images ===
It is assumed that the following U-Boot's environment variables are defined:
+
 
 +
==== NOR flash ====
 +
 
 +
We assume that the following environment variables are present in u-boot:
  
<pre class="board-terminal">
+
<pre>
 
fdt_base=0x00780000
 
fdt_base=0x00780000
 
fpga_base=0x00180000
 
fpga_base=0x00180000
Line 206: Line 157:
 
spi_loadfdt=sf read ${fdtaddr} ${fdt_base} 0x80000
 
spi_loadfdt=sf read ${fdtaddr} ${fdt_base} 0x80000
 
spi_loadfpga=sf read ${loadaddr} ${fpga_base} 0x600000
 
spi_loadfpga=sf read ${loadaddr} ${fpga_base} 0x600000
spi_programfpga=run spi_loadfpga; fpga load 0 ${loadaddr} 0x600000
+
program_fpga=run spi_loadfpga;fpga load 0 ${loadaddr} 0x5b3f0c
 
</pre>
 
</pre>
  
Line 283: Line 234:
 
</pre>
 
</pre>
  
In U-Boot environment please verify that the following default variables are set in order to be able to boot from NOR + NAND
 
  
<pre class="board-terminal">
+
In U-Boot environment please set the following variables in order to be able to boot from NOR + NAND
 +
 
 +
<pre>
 
nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
 
nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
spi_nand=sf probe; run spi_programfpga spi_loadk spi_loadfdt nandargs addcons addmisc; bootm ${loadaddr} - ${fdtaddr}
+
spi_nand=sf probe; run program_fpga spi_loadk spi_loadfdt nandargs addcons addmisc; bootm ${loadaddr} - ${fdtaddr}
 
</pre>
 
</pre>
  
Line 297: Line 249:
 
=> saveenv
 
=> saveenv
 
</pre>
 
</pre>
 +
==Use case #2==
  
===Use case #2===
 
====Introduction====
 
This configuration makes use the most common partitioning schemes for booting completely from NAND flash, that is:
 
*The NAND flash acts as boot memory and root file system storage; as such, it contains
 
**bootrom header and U-Boot SPL
 
**U-Boot
 
**U-Boot redundant environment
 
**The Linux kernel image
 
**The Linux Device Tree Blob (DTB)
 
**The bitstream file for the Programmable Logic (PL).
 
**The read/write UBIFS root filesystem.
 
 
The resulting flash memory layout is illustrated in the following pictures.
 
 
[[File:BELK-NAND-flash-partitioning-case-boot-NAND.png|thumb|center|600px|NAND flash partitioning scheme]]
 
 
In essence, the bootstrap sequence looks like this:
 
*U-Boot fetches and programs the PL bitstream
 
*Then it fetches the Linux kernel binary images (kernel and DTB) from the on-board NAND flash memory
 
*The Linux kernel mount the root filesystem from a NAND partition.
 
 
=====Testbed=====
 
This configuration was tested with the following testbed:
 
*SOM: DBTD4111I0R
 
*carrier board: EVBBX0000C0R
 
*software: [[BELK/BXELK_software_components#BELK_4.1.0|BELK 4.1.0]]
 
 
==== Program the root filesystem in NAND flash ====
 
 
This step can be followed in the same way as described [[BORA_SOM/BELK-L/Deployment/Standalone_boot#Program_the_root_filesystem_in_NAND_flash | before]]
 
 
==== Program the boot images in NAND flash from U-Boot ====
 
It is assumed that the following U-Boot's environment variables are defined:
 
  
<pre class="board-terminal">
 
fdt_base=0x00780000
 
fpga_base=0x00180000
 
kernel_base=0x00800000
 
loadk=tftpboot ${loadaddr} ${bootfile}
 
loadfdt=tftpboot ${fdtaddr} ${fdtfile}
 
loadfpga=tftpboot ${loadaddr} ${fpgafile}
 
nand_updatek=nand erase.part kernel; nand write ${loadaddr} kernel ${filesize}
 
nand_updatefdt=nand erase.part fdt; nand write ${fdtaddr} fdt ${filesize}
 
nand_updatefpga=nand erase.part fpga; nand write ${loadaddr} fpga ${filesize}
 
nand_loadk=nand read ${loadaddr} kernel
 
nand_loadfdt=nand read ${fdtaddr} fdt
 
nand_loadfpga=nand read ${loadaddr} fpga
 
nand_programfpga=run nand_loadfpga; fpga load 0 ${loadaddr} 0x${filesize}
 
</pre>
 
 
* Update the <code>bootfile</code>, <code>fdtfile</code> and <code>fpgafile</code> environment variables to fit the filename as found inside the TFTP server.
 
* Program kernel and device tree on NAND flash with the following U-Boot command
 
 
<pre class="board-terminal">
 
Bora> run loadfpga nand_updatefpga loadk nand_updatek loadfdt nand_updatefdt
 
</pre>
 
 
E.g.:
 
 
<pre class="board-terminal">
 
Bora> run loadfpga nand_updatefpga loadk nand_updatek loadfdt nand_updatefdt
 
Using ethernet@e000b000 device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
 
Filename 'bora/belk-4.1.0_bora_BASE_fpga.bin'.
 
Load address: 0x2080000
 
Loading: #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        ###########
 
        1.3 MiB/s
 
done
 
Bytes transferred = 4045564 (3dbafc hex)
 
 
NAND erase.part: device 0 offset 0x180000, size 0x600000
 
Erasing at 0x760000 -- 100% complete.
 
OK
 
 
NAND write: device 0 offset 0x180000, size 0x3dbafc
 
4045564 bytes written: OK
 
Using ethernet@e000b000 device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
 
Filename 'bora/linux/belk-4.1.0_uImage'.
 
Load address: 0x2080000
 
Loading: #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        ###########################
 
        1.3 MiB/s
 
done
 
Bytes transferred = 3796168 (39ecc8 hex)
 
 
NAND erase.part: device 0 offset 0x800000, size 0x800000
 
Erasing at 0xfe0000 -- 100% complete.
 
OK
 
 
NAND write: device 0 offset 0x800000, size 0x39ecc8
 
3796168 bytes written: OK
 
Using ethernet@e000b000 device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
 
Filename 'bora/linux/belk-4.1.0_bora.dtb'.
 
Load address: 0x2000000
 
Loading: ##
 
        655.3 KiB/s
 
done
 
Bytes transferred = 10073 (2759 hex)
 
 
NAND erase.part: device 0 offset 0x780000, size 0x80000
 
Erasing at 0x7e0000 -- 100% complete.
 
OK
 
 
NAND write: device 0 offset 0x780000, size 0x2759
 
10073 bytes written: OK
 
Bora>
 
</pre>
 
 
In U-Boot environment please verify that the following default variables are set in order to be able to boot from NAND
 
 
<pre class="board-terminal">
 
nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
 
mtdparts=mtdparts=pl35x-nand:256K(spl),768K(uboot),256K(env1),256K(env2),6M(fpga),512K(fdt),8M(kernel),-(nand-ubi)
 
addmisc=setenv bootargs ${bootargs} cma=16M ${mtdparts}
 
nand_nand=run nand_programfpga nand_loadk nand_loadfdt nandargs addcons addmisc; bootm ${loadaddr} - ${fdtaddr}
 
</pre>
 
 
Reboot the system and configure U-Boot to apply the new configuration
 
 
<pre class="board-terminal">
 
=> setenv bootcmd run nand_nand
 
=> saveenv
 
</pre>
 
 
==== Program the boot images in NAND flash from Linux ====
 
 
* Get kernel and device tree images with the following <code>tftp</code> commands
 
 
E.g.:
 
 
<pre class="board-terminal">
 
root@bora:~# tftp -g -r bora/linux/belk-4.1.0_uImage 192.168.0.23
 
root@bora:~# tftp -g -r bora/linux/belk-4.1.0_bora.dtb 192.168.0.23
 
root@bora:~# tftp -g -r bora/belk-4.1.0_bora_BASE_fpga.bin 192.168.0.23
 
root@bora:~# ls -la
 
root@bora:~# ls -la
 
drwxr-xr-x    2 root    root          4096 Mar  5  2021 .
 
drwxrwxrwx    6 root    root          4096 Mar  5  2021 ..
 
-rw-r--r--    1 root    root        10073 Mar  5  2021 belk-4.1.0_bora.dtb
 
-rw-r--r--    1 root    root      4045564 Mar  5  2021 belk-4.1.0_bora_BASE_fpga.bin
 
-rw-r--r--    1 root    root      3796168 Mar  5  2021 belk-4.1.0_uImage
 
root@bora:~#
 
</pre>
 
* now the binary images have been retrieved form the ''tftp'' server (like the U-Boot tftp download)
 
* check the mtd partitioning for identifying the proper <code>/dev/mtdX</code> device
 
<pre class="board-terminal">
 
root@bora:~# cat /proc/mtd
 
dev:    size  erasesize  name
 
mtd0: 00040000 00020000 "nand-SPL"
 
mtd1: 000c0000 00020000 "nand-uboot"
 
mtd2: 00040000 00020000 "nand-uboot-env1"
 
mtd3: 00040000 00020000 "nand-uboot-env2"
 
mtd4: 00600000 00020000 "nand-bitstream"
 
mtd5: 00080000 00020000 "nand-device-tree"
 
mtd6: 00800000 00020000 "nand-linux"
 
mtd7: 1f000000 00020000 "nand-rootfs"
 
root@bora:~#
 
</pre>
 
It is possible to see the mtd partition for the NAND flash: i.e. <code>mtd4</code> for the fpga bitstream, <code>mtd5</code> for the device tree and <code>mtd6</code> for the kernel
 
* using the mtd partitioning, program the binary images in the proper <code>/dev/mtdX</code> device
 
* the <code>mtd-utils</code> commands <code>flash_erase</code> and <code>nandwrite</code> can be used for this purposes: see [https://bootlin.com/blog/managing-flash-storage-with-linux here] for more information
 
 
<pre>
 
<pre>
root@bora:~# flash_erase --help
+
llandre@linuxserver2:/tftpboot/borax/elt$ python /devel/dave/bora-DBRx/fpga/fpga-bit-to-bin.py -f bitstream.bit bitstream.bin
Usage: flash_erase [options] MTD_DEVICE <start offset> <block count>
+
Design name: TOP_LEVEL;UserID=0XFFFFFFFF;Version=2017.4
Erase blocks of the specified MTD device.
 
Specify a count of 0 to erase to end of device.
 
 
 
  -j, --jffs2      format the device for jffs2
 
  -N, --noskipbad  don't skip bad blocks
 
  -u, --unlock      unlock sectors before erasing
 
  -q, --quiet      do not display progress messages
 
      --silent      same as --quiet
 
      --help        display this help and exit
 
      --version    output version information and exit
 
root@bora:~# nandwrite --help
 
Usage: nandwrite [OPTION] MTD_DEVICE [INPUTFILE|-]
 
Writes to the specified MTD device.
 
 
 
  -a, --autoplace        Use auto OOB layout
 
  -m, --markbad          Mark blocks bad if write fails
 
  -n, --noecc            Write without ecc
 
  -N, --noskipbad        Write without bad block skipping
 
  -o, --oob              Input contains oob data
 
  -O, --onlyoob          Input contains oob data and only write the oob part
 
  -s addr, --start=addr  Set output start address (default is 0)
 
  -p, --pad              Pad writes to page size
 
  -b, --blockalign=1|2|4  Set multiple of eraseblocks to align to
 
      --input-skip=length Skip |length| bytes of the input file
 
      --input-size=length Only read |length| bytes of the input file
 
  -q, --quiet            Don't display progress messages
 
  -h, --help              Display this help and exit
 
      --version          Output version information and exit
 
root@bora:~#
 
</pre>
 
* program the binary images in each mtd device
 
<pre class="board-terminal">
 
root@bora:~# flash_erase /dev/mtd4 0 0
 
Erasing 128 Kibyte @ 5e0000 -- 100 % complete
 
root@bora:~# nandwrite -p /dev/mtd4 belk-4.1.0_bora_BASE_fpga.bin
 
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
 
Writing data to block 4 at offset 0x80000
 
Writing data to block 5 at offset 0xa0000
 
Writing data to block 6 at offset 0xc0000
 
Writing data to block 7 at offset 0xe0000
 
Writing data to block 8 at offset 0x100000
 
Writing data to block 9 at offset 0x120000
 
Writing data to block 10 at offset 0x140000
 
Writing data to block 11 at offset 0x160000
 
Writing data to block 12 at offset 0x180000
 
Writing data to block 13 at offset 0x1a0000
 
Writing data to block 14 at offset 0x1c0000
 
Writing data to block 15 at offset 0x1e0000
 
Writing data to block 16 at offset 0x200000
 
Writing data to block 17 at offset 0x220000
 
Writing data to block 18 at offset 0x240000
 
Writing data to block 19 at offset 0x260000
 
Writing data to block 20 at offset 0x280000
 
Writing data to block 21 at offset 0x2a0000
 
Writing data to block 22 at offset 0x2c0000
 
Writing data to block 23 at offset 0x2e0000
 
Writing data to block 24 at offset 0x300000
 
Writing data to block 25 at offset 0x320000
 
Writing data to block 26 at offset 0x340000
 
Writing data to block 27 at offset 0x360000
 
Writing data to block 28 at offset 0x380000
 
Writing data to block 29 at offset 0x3a0000
 
Writing data to block 30 at offset 0x3c0000
 
root@bora:~# flash_erase /dev/mtd5 0 0
 
Erasing 128 Kibyte @ 60000 -- 100 % complete
 
root@bora:~# nandwrite -p /dev/mtd5 belk-4.1.0_bora.dtb
 
Writing data to block 0 at offset 0x0
 
root@bora:~# flash_erase /dev/mtd6 0 0
 
Erasing 128 Kibyte @ 7e0000 -- 100 % complete
 
root@bora:~# nandwrite -p /dev/mtd6 belk-4.1.0_uImage
 
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
 
Writing data to block 4 at offset 0x80000
 
Writing data to block 5 at offset 0xa0000
 
Writing data to block 6 at offset 0xc0000
 
Writing data to block 7 at offset 0xe0000
 
Writing data to block 8 at offset 0x100000
 
Writing data to block 9 at offset 0x120000
 
Writing data to block 10 at offset 0x140000
 
Writing data to block 11 at offset 0x160000
 
Writing data to block 12 at offset 0x180000
 
Writing data to block 13 at offset 0x1a0000
 
Writing data to block 14 at offset 0x1c0000
 
Writing data to block 15 at offset 0x1e0000
 
Writing data to block 16 at offset 0x200000
 
Writing data to block 17 at offset 0x220000
 
Writing data to block 18 at offset 0x240000
 
Writing data to block 19 at offset 0x260000
 
Writing data to block 20 at offset 0x280000
 
Writing data to block 21 at offset 0x2a0000
 
Writing data to block 22 at offset 0x2c0000
 
Writing data to block 23 at offset 0x2e0000
 
Writing data to block 24 at offset 0x300000
 
Writing data to block 25 at offset 0x320000
 
Writing data to block 26 at offset 0x340000
 
Writing data to block 27 at offset 0x360000
 
Writing data to block 28 at offset 0x380000
 
root@bora:~#
 
</pre>
 
* once rebooted, configure U-Boot to apply the new configuration in NAND
 
<pre class="board-terminal">
 
...
 
...
 
Hit ENTER within 3 seconds to stop autoboot
 
Bora> setenv bootcmd 'run nand_nand'
 
Bora> saveenv
 
Saving Environment to SPI Flash...
 
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 64 MiB
 
Erasing SPI flash...Writing to SPI flash...done
 
Valid environment: 1
 
Bora>
 
</pre>
 
 
 
* the system is then ready to boot retrieving the storage binary images from NAND
 
<pre class="board-terminal">
 
Bora> boot
 
NAND read: device 0 offset 0x180000, size 0x600000
 
6291456 bytes read: OK
 
 
 
NAND read: device 0 offset 0x800000, size 0x800000
 
8388608 bytes read: OK
 
 
 
NAND read: device 0 offset 0x780000, size 0x80000
 
524288 bytes read: OK
 
## Booting kernel from Legacy Image at 02080000 ...
 
  Image Name:  Linux-4.9.0-belk-4.1.0-xilinx
 
  Image Type:  ARM Linux Kernel Image (uncompressed)
 
  Data Size:    3796104 Bytes = 3.6 MiB
 
  Load Address: 00008000
 
  Entry Point:  00008000
 
  Verifying Checksum ... OK
 
## Flattened Device Tree blob at 02000000
 
  Booting using the fdt blob at 0x2000000
 
  Loading Kernel Image ... OK
 
  Loading Device Tree to 1effa000, end 1efff758 ... OK
 
Switching to NAND storage before starting Linux
 
 
 
Starting kernel ...
 
 
 
Uncompressing Linux... done, booting the kernel.
 
[    0.000000] Booting Linux on physical CPU 0x0
 
[    0.000000] Linux version 4.9.0-belk-4.1.0-xilinx (jenkins@linuxserver2) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #1 SMP PREEMPT Tue Dec 24 11:34:28 CET 2019
 
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
 
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
 
[    0.000000] OF: fdt:Machine model: Bora
 
[    0.000000] bootconsole [earlycon0] enabled
 
[    0.000000] cma: Reserved 16 MiB at 0x3f000000
 
[    0.000000] Memory policy: Data cache writealloc
 
[    0.000000] On node 0 totalpages: 262144
 
[    0.000000] free_area_init_node: node 0, pgdat c0a2ddc0, node_mem_map ef7f7000
 
[    0.000000]  Normal zone: 1536 pages used for memmap
 
[    0.000000]  Normal zone: 0 pages reserved
 
[    0.000000]  Normal zone: 196608 pages, LIFO batch:31
 
...
 
...
 
</pre>
 
 
 
====Full bootstrap procedure====
 
For the reader's convenience, the following box shows the full bootstrap procedure (please, click on the "Expand" link):
 
 
 
<pre class="board-terminal mw-collapsible mw-collapsed">
 
U-Boot SPL 2017.01-belk-4.1.1 (Jan 08 2020 - 16:52:16)
 
nand boot
 
Trying to boot from NAND
 
1024 MiB
 
 
 
 
 
U-Boot 2017.01-belk-4.1.1 (Jan 08 2020 - 16:52:16 +0100), Build: belk-4.1.1
 
 
 
Model: Bora
 
Board: Xilinx Zynq
 
I2C:  ready
 
DRAM:  ECC disabled 1 GiB
 
Relocating to 3ff14000, new gd at 3ead3ee8, sp at 3ead3ec0
 
NAND:  1024 MiB
 
MMC:  sdhci@e0100000: 0 (SD)
 
In:    serial@e0001000
 
Out:  serial@e0001000
 
Err:  serial@e0001000
 
Model: Bora
 
Board: Xilinx Zynq
 
SOM ConfigID#: 00000008
 
SOM UniqueID#: 01234567:89abcdef
 
CB ConfigID CRC mismatch for 0x00000000 (was 0x00000000, expected 0x2144df1c) at block 3 (offset 96): using default
 
CB ConfigID#: ffffffff
 
CB UniqueID#: 00000000:00000000
 
Net:  ZYNQ GEM: e000b000, phyaddr 7, interface rgmii-id
 
eth0: ethernet@e000b000
 
Hit ENTER within 3 seconds to stop autoboot
 
 
 
NAND read: device 0 offset 0x180000, size 0x600000
 
6291456 bytes read: OK
 
 
 
NAND read: device 0 offset 0x800000, size 0x800000
 
8388608 bytes read: OK
 
 
 
NAND read: device 0 offset 0x780000, size 0x80000
 
524288 bytes read: OK
 
## Booting kernel from Legacy Image at 02080000 ...
 
  Image Name:  Linux-4.9.0-belk-4.1.0-xilinx
 
  Image Type:  ARM Linux Kernel Image (uncompressed)
 
  Data Size:    3796104 Bytes = 3.6 MiB
 
  Load Address: 00008000
 
  Entry Point:  00008000
 
  Verifying Checksum ... OK
 
## Flattened Device Tree blob at 02000000
 
  Booting using the fdt blob at 0x2000000
 
  Loading Kernel Image ... OK
 
  Loading Device Tree to 1effa000, end 1efff758 ... OK
 
Switching to NAND storage before starting Linux
 
 
 
Starting kernel ...
 
 
 
Uncompressing Linux... done, booting the kernel.
 
[    0.000000] Booting Linux on physical CPU 0x0
 
[    0.000000] Linux version 4.9.0-belk-4.1.0-xilinx (jenkins@linuxserver2) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #1 SMP PREEMPT Tue Dec 24 11:34:28 CET 2019
 
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
 
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
 
[    0.000000] OF: fdt:Machine model: Bora
 
[    0.000000] bootconsole [earlycon0] enabled
 
[    0.000000] cma: Reserved 16 MiB at 0x3f000000
 
[    0.000000] Memory policy: Data cache writealloc
 
[    0.000000] On node 0 totalpages: 262144
 
[    0.000000] free_area_init_node: node 0, pgdat c0a2ddc0, node_mem_map ef7f7000
 
[    0.000000]  Normal zone: 1536 pages used for memmap
 
[    0.000000]  Normal zone: 0 pages reserved
 
[    0.000000]  Normal zone: 196608 pages, LIFO batch:31
 
[    0.000000]  HighMem zone: 65536 pages, LIFO batch:15
 
[    0.000000] percpu: Embedded 14 pages/cpu @ef7d2000 s26124 r8192 d23028 u57344
 
[    0.000000] pcpu-alloc: s26124 r8192 d23028 u57344 alloc=14*4096
 
[    0.000000] pcpu-alloc: [0] 0 [0] 1
 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260608
 
[    0.000000] Kernel command line: ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw console=ttyPS0,115200n8 debug earlyprintk cma=16M mtdparts=pl35x-nand:256K(spl),768K(uboot),256K(env1),256K(env2),6M(fpga),512K(fdt),8M(kernel),-(nand-ubi)
 
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
 
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
 
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
 
[    0.000000] Memory: 1012740K/1048576K available (6144K kernel code, 234K rwdata, 1532K rodata, 1024K init, 323K bss, 19452K reserved, 16384K cma-reserved, 245760K highmem)
 
[    0.000000] Virtual kernel memory layout:
 
[    0.000000]    vector  : 0xffff0000 - 0xffff1000  (  4 kB)
 
[    0.000000]    fixmap  : 0xffc00000 - 0xfff00000  (3072 kB)
 
[    0.000000]    vmalloc : 0xf0800000 - 0xff800000  ( 240 MB)
 
[    0.000000]    lowmem  : 0xc0000000 - 0xf0000000  ( 768 MB)
 
[    0.000000]    pkmap  : 0xbfe00000 - 0xc0000000  (  2 MB)
 
[    0.000000]    modules : 0xbf000000 - 0xbfe00000  (  14 MB)
 
[    0.000000]      .text : 0xc0008000 - 0xc0700000  (7136 kB)
 
[    0.000000]      .init : 0xc0900000 - 0xc0a00000  (1024 kB)
 
[    0.000000]      .data : 0xc0a00000 - 0xc0a3aa38  ( 235 kB)
 
[    0.000000]        .bss : 0xc0a3aa38 - 0xc0a8b834  ( 324 kB)
 
[    0.000000] Preemptible hierarchical RCU implementation.
 
[    0.000000]  Build-time adjustment of leaf fanout to 32.
 
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
 
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
 
[    0.000000] NR_IRQS:16 nr_irqs:16 16
 
[    0.000000] efuse mapped to f0802000
 
[    0.000000] slcr mapped to f0804000
 
[    0.000000] L2C: platform modifies aux control register: 0x02060000 -> 0x02460000
 
[    0.000000] L2C: DT/platform modifies aux control register: 0x02060000 -> 0x02460000
 
[    0.000000] L2C-310 erratum 769419 enabled
 
[    0.000000] L2C-310 enabling early BRESP for Cortex-A9
 
[    0.000000] L2C-310 full line of zeros enabled for Cortex-A9
 
[    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
 
[    0.000000] L2C-310 cache controller enabled, 8 ways, 512 kB
 
[    0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46460001
 
[    0.000000] zynq_clock_init: clkc starts at f0804100
 
[    0.000000] Zynq clock init
 
[    0.000000] ps_clk frequency not specified, using 33 MHz.
 
[    0.000011] sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
 
[    0.007869] clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
 
[    0.018886] Switching to timer-based delay loop, resolution 3ns
 
[    0.024888] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
 
[    0.033935] timer #0 at f080c000, irq=17
 
[    0.038267] Console: colour dummy device 80x30
 
[    0.042597] Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
 
[    0.053077] pid_max: default: 32768 minimum: 301
 
[    0.057856] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
 
[    0.064361] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
 
[    0.071995] CPU: Testing write buffer coherency: ok
 
[    0.076917] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
 
[    0.082505] Setting up static identity map for 0x100000 - 0x100058
 
[    0.258338] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
 
[    0.258442] Brought up 2 CPUs
 
[    0.266978] SMP: Total of 2 processors activated (1333.33 BogoMIPS).
 
[    0.273357] CPU: All CPU(s) started in SVC mode.
 
[    0.278942] devtmpfs: initialized
 
[    0.285309] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
 
[    0.293073] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
 
[    0.303701] pinctrl core: initialized pinctrl subsystem
 
[    0.310076] NET: Registered protocol family 16
 
[    0.316253] DMA: preallocated 256 KiB pool for atomic coherent allocations
 
[    0.358392] cpuidle: using governor ladder
 
[    0.398350] cpuidle: using governor menu
 
[    0.415353] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
 
[    0.423248] hw-breakpoint: maximum watchpoint size is 4 bytes.
 
[    0.429192] zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0xf0880000
 
[    0.436053] zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
 
[    0.456378] vgaarb: loaded
 
[    0.459737] SCSI subsystem initialized
 
[    0.463985] usbcore: registered new interface driver usbfs
 
[    0.470006] usbcore: registered new interface driver hub
 
[    0.475316] usbcore: registered new device driver usb
 
[    0.481323] pps_core: LinuxPPS API ver. 1 registered
 
[    0.486156] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
 
[    0.495401] PTP clock support registered
 
[    0.501389] clocksource: Switched to clocksource arm_global_timer
 
[    0.522421] NET: Registered protocol family 2
 
[    0.527491] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
 
[    0.534572] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
 
[    0.541005] TCP: Hash tables configured (established 8192 bind 8192)
 
[    0.547324] UDP hash table entries: 512 (order: 2, 16384 bytes)
 
[    0.553249] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
 
[    0.559717] NET: Registered protocol family 1
 
[    0.564419] RPC: Registered named UNIX socket transport module.
 
[    0.570203] RPC: Registered udp transport module.
 
[    0.574963] RPC: Registered tcp transport module.
 
[    0.579663] RPC: Registered tcp NFSv4.1 backchannel transport module.
 
[    0.586132] PCI: CLS 0 bytes, default 64
 
[    0.590711] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
 
[    0.600381] futex hash table entries: 512 (order: 3, 32768 bytes)
 
[    0.607298] workingset: timestamp_bits=30 max_order=18 bucket_order=0
 
[    0.614340] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
 
[    0.622267] bounce: pool size: 64 pages
 
[    0.625984] io scheduler noop registered
 
[    0.629938] io scheduler deadline registered
 
[    0.634284] io scheduler cfq registered (default)
 
[    0.641598] dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
 
[    0.648161] dma-pl330 f8003000.dmac:        DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
 
[    0.657287] e0000000.serial: ttyPS1 at MMIO 0xe0000000 (irq = 145, base_baud = 3125000) is a xuartps
 
[    0.666733] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 146, base_baud = 3125000) is a xuartps
 
à[    0.675856] console [ttyPS0] enabled
 
[    0.675856] console [ttyPS0] enabled
 
[    0.682949] bootconsole [earlycon0] disabled
 
[    0.682949] bootconsole [earlycon0] disabled
 
[    0.692174] xdevcfg f8007000.devcfg: ioremap 0xf8007000 to f086f000
 
[    0.699073] [drm] Initialized
 
[    0.714985] brd: module loaded
 
[    0.725471] loop: module loaded
 
[    0.730823] libphy: Fixed MDIO Bus: probed
 
[    0.737912] libphy: mdio_driver_register: xgmiitorgmii
 
[    0.743111] CAN device driver interface
 
[    0.749380] libphy: MACB_mii_bus: probed
 
[    0.852145] macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 148 (00:50:c2:1e:af:e0)
 
[    0.862019] Micrel KSZ9031 Gigabit PHY e000b000.etherne:07: attached PHY driver [Micrel KSZ9031 Gigabit PHY] (mii_bus:phy_addr=e000b000.etherne:07, irq=-1)
 
[    0.876204] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
 
[    0.881981] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
 
[    0.888875] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
 
[    0.895372] ehci-pci: EHCI PCI platform driver
 
[    0.899915] usbcore: registered new interface driver usb-storage
 
[    0.906105] e0002000.usb supply vbus not found, using dummy regulator
 
[    0.912795] ULPI transceiver vendor/product ID 0x0424/0x0006
 
[    0.918368] Found SMSC USB331x ULPI transceiver.
 
[    0.923003] ULPI integrity check: passed.
 
[    0.928808] mousedev: PS/2 mouse device common for all mice
 
[    0.934751] i2c /dev entries driver
 
[    0.938424] cdns-i2c e0004000.i2c: 100 kHz mmio e0004000 irq 142
 
[    0.948144] rtc-ds3232 0-0068: rtc core: registered ds3232 as rtc0
 
[    0.955792] ina2xx 0-0041: power monitor ina226 (Rshunt = 10000 uOhm)
 
[    0.962591] tmp421 0-004f: Could not read configuration register (-6)
 
[    0.970543] cpufreq: cpufreq_online: CPU0: Running at unlisted freq: 666666 KHz
 
[    0.977828] cpufreq: cpufreq_online: CPU0: Unlisted initial frequency changed to: 666667 KHz
 
[    0.986424] Xilinx Zynq CpuIdle Driver started
 
[    0.991294] sdhci: Secure Digital Host Controller Interface driver
 
[    0.997421] sdhci: Copyright(c) Pierre Ossman
 
[    1.001749] sdhci-pltfm: SDHCI platform and OF driver helper
 
[    1.061455] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using DMA
 
[    1.069084] usbcore: registered new interface driver usbhid
 
[    1.075634] usbhid: USB HID core driver
 
[    1.082573] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xd3
 
[    1.088843] nand: Unknown W29N08GV
 
[    1.092292] nand: 1024 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
 
[    1.100596] Bad block table found at page 524224, version 0x01
 
[    1.107676] Bad block table found at page 524160, version 0x01
 
[    1.114266] 8 cmdlinepart partitions found on MTD device pl35x-nand
 
[    1.120470] Creating 8 MTD partitions on "pl35x-nand":
 
[    1.125608] 0x000000000000-0x000000040000 : "spl"
 
[    1.142605] 0x000000040000-0x000000100000 : "uboot"
 
[    1.158482] 0x000000100000-0x000000140000 : "env1"
 
[    1.174374] 0x000000140000-0x000000180000 : "env2"
 
[    1.184974] mmc0: new high speed SDHC card at address 59b4
 
[    1.190236] 0x000000180000-0x000000780000 : "fpga"
 
[    1.201439] 0x000000780000-0x000000800000 : "fdt"
 
[    1.205848] mmcblk0: mmc0:59b4 USDU1 14.9 GiB
 
[    1.211140]  mmcblk0: p1 p2
 
[    1.211772] 0x000000800000-0x000001000000 : "kernel"
 
[    1.222910] 0x000001000000-0x000040000000 : "nand-ubi"
 
[    1.247391] NET: Registered protocol family 17
 
[    1.251856] can: controller area network core (rev 20120528 abi 9)
 
[    1.258008] NET: Registered protocol family 29
 
[    1.262407] can: raw protocol (rev 20120528)
 
[    1.266628] can: broadcast manager protocol (rev 20161123 t)
 
[    1.272303] can: netlink gateway (rev 20130117) max_hops=1
 
[    1.278132] Registering SWP/SWPB emulation handler
 
[    1.288204] ubi0: attaching mtd7
 
[    6.527574] ubi0: scanning is finished
 
[    6.559907] ubi0: attached mtd7 (name "nand-ubi", size 1008 MiB)
 
[    6.565877] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
 
[    6.572720] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
 
[    6.579380] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
 
[    6.586165] ubi0: good PEBs: 8060, bad PEBs: 4, corrupted PEBs: 0
 
[    6.592244] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
 
[    6.599432] ubi0: max/mean erase counter: 4/2, WL threshold: 4096, image sequence number: 857573235
 
[    6.608473] ubi0: available PEBs: 0, total reserved PEBs: 8060, PEBs reserved for bad PEB handling: 156
 
[    6.617868] ubi0: background thread "ubi_bgt0d" started, PID 679
 
[    6.618911] rtc-ds3232 0-0068: hctosys: unable to read the hardware clock
 
[    6.632658] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 681
 
[    6.715428] UBIFS (ubi0:0): recovery needed
 
[    6.965346] UBIFS (ubi0:0): recovery completed
 
[    6.969793] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
 
[    6.977129] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
 
[    6.987017] UBIFS (ubi0:0): FS size: 1016967168 bytes (969 MiB, 7882 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)
 
[    6.998035] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
 
[    7.004636] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID 0D33F80E-E80A-43F7-BE9E-C2D24C4FCD14, small LPT model
 
[    7.017320] VFS: Mounted root (ubifs filesystem) on device 0:12.
 
[    7.025315] devtmpfs: mounted
 
[    7.031335] Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
 
INIT: version 2.88 booting
 
Starting udev
 
[    9.081287] udevd[710]: starting version 3.2
 
[    9.111284] random: udevd: uninitialized urandom read (16 bytes read)
 
[    9.122792] random: udevd: uninitialized urandom read (16 bytes read)
 
[    9.129255] random: udevd: uninitialized urandom read (16 bytes read)
 
[    9.176143] udevd[711]: starting eudev-3.2
 
[    9.321128] random: udevd: uninitialized urandom read (16 bytes read)
 
[  10.176226] random: dd: uninitialized urandom read (512 bytes read)
 
Mon Dec 30 23:37:37 UTC 2019
 
INIT: Entering runlevel: 5
 
Configuring network interfaces... udhcpc (v1.24.1) started
 
Sending discover...
 
[  12.601808] macb e000b000.ethernet eth0: link up (100/Full)
 
Sending discover...
 
Sending discover...
 
No lease, forking to background
 
done.
 
Starting system message bus: [  19.305403] random: dbus-daemon: uninitialized urandom read (12 bytes read)
 
[  19.405678] random: dbus-daemon: uninitialized urandom read (12 bytes read)
 
dbus.
 
Starting Dropbear SSH server: [  19.538175] random: dropbear: uninitialized urandom read (32 bytes read)
 
dropbear.
 
Starting rpcbind daemon...done.
 
starting statd: done
 
Starting atd: OK
 
exportfs: can't open /etc/exports for reading
 
NFS daemon support not enabled in kernel
 
Starting system log daemon...0
 
Starting kernel log daemon...0
 
Starting internet superserver: xinetd.
 
* Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon
 
[  20.449120] random: avahi-daemon: uninitialized urandom read (4 bytes read)
 
[  20.551133] random: avahi-daemon: uninitialized urandom read (4 bytes [ ok ]
 
Starting crond: OK
 
Starting tcf-agent: OK
 
 
 
Poky (Yocto Project Reference Distro) 2.2.1 bora /dev/ttyPS0
 
 
 
bora login: root
 
root@bora:~#
 
</pre>
 
 
 
===Use case #3===
 
====Introduction====
 
This example makes use of the partitioning scheme illustrated in the following images.
 
 
 
 
 
[[File:BELK-NOR-flash-partitioning.png|thumb|center|600px|NOR flash partitioning scheme]]
 
 
 
 
 
[[File:BELK-NAND-flash-partitioning-case3.png|thumb|center|600px|NAND flash partitioning scheme]]
 
 
 
 
 
In this case, the NOR flash is only used to store U-Boot and its environment. All the other images are stored onto the NAND flash. Specifically, the NAND flash has four partitions that are used to store respectively:
 
*The <code>uImage</code> binary image, which, in turn, consists of the Linux kernel and a [http://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html <code>initramfs</code> image], as per [[BELK-TN-006:_Using_PetaLinux_to_Build_BELK/BXELK_Software_Components|PetaLinux]]'s default configuration.
 
**This partition is associated with the device file <code>/dev/mtd0</code>
 
*The PL bitstream
 
**This partition is associated with the device file <code>/dev/mtd1</code>
 
*The Device Tree Blob
 
**This partition is associated with the device file <code>/dev/mtd2</code>
 
*An auxiliary read/write filesystem used by the user-space applications for several purposes such as data logging
 
**This partition is associated with the device file <code>/dev/mtd3</code>.
 
 
 
The resulting bootstrap sequence is like the following:
 
#U-Boot is retrieved from the NOR flash and copied into the SDRAM memory
 
#U-boot, in turn, reads from the NAND memory the <code>uImage</code>, the bitstream, the DTB, and copies them into the SDRAM memory
 
#U-Boot starts the Linux kernel
 
#Finally, the Linux kernel mounts the root filesystem from the SDRAM memory and starts user-space applications and daemons.
 
 
 
It is worth remembering that <code>mtd0</code>,<code>mtd1</code>, and <code>mtd2</code> are used as raw partitions while <code>mtd3</code> is associated with a block device in order to mount a filesystem, specifically ''UBIFS''. To handle such filesystem, the Linux kernel must be built with the UBI/UBIFS support enabled and the root filesystem must include the <code>mtd-utils-ubifs</code> package (see the following image).
 
 
 
 
 
[[File:PetaLinux-mtd-utils-ubifs.png|thumb|center|600px|Selecting the <code>mtd-utils-ubifs</code> package in PataLinux root filesystem configuration]]
 
 
 
 
 
To setup the desired standalone configuration, several operations need to be carried out. They are detailed in the following sections. It is assumed that the SOM can boot from the NOR flash. If not, please see [[BORA_SOM/BELK-L/Deployment/Restoring_U-Boot_on_NOR_flash|this page]].
 
 
 
=====Testbed=====
 
The testbed used to test this configuration consists of the following boards:
 
*SOM: DBXD4110S2R
 
*Carrier board: EVBBX0000C0R
 
*Software: BXELK 4.0.0 + PetaLinux 2017.1
 
 
 
====Storing the images onto the raw partitions of the NAND memory====
 
Before storing the images into the NAND flash, the bitstream must be converted. For more details, please refer to [[BELK-AN-008: Programming the FPGA Bitstream with U-Boot|this page]]:
 
<pre class="board-terminal">
 
$ python /devel/dave/bora-DBRx/fpga/fpga-bit-to-bin.py -f bitstream.bit bitstream.bin
 
Design name: prj1;UserID=0XFFFFFFFF;Version=2017.4
 
 
Partname 7z030sbg485
 
Partname 7z030sbg485
 
Date 2019/02/01
 
Date 2019/02/01
Line 1,001: Line 262:
  
  
Once the U-Boot console is available, the binary files to be stored into the NAND flash can be downloaded via TFTP. The size of the partitions illustrated in the previous image determine the offsets to use with the <code>nand erase/write</code> commands. The following box shows the full procedure.
 
  
The first file to be stored is <code>uImage</code>:
+
<pre>
<pre class="board-terminal">
 
 
Bora> nand info
 
Bora> nand info
  
Line 1,014: Line 273:
 
   options    0x      0
 
   options    0x      0
 
   bbt options 0x  20000
 
   bbt options 0x  20000
Bora> tftpboot ${loadaddr} borax/uImage
 
Using ethernet@e000b000 device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
 
Filename 'borax/uImage'.
 
Load address: 0x2080000
 
Loading: #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        ##################################################
 
        2.5 MiB/s
 
done
 
Bytes transferred = 9904184 (972038 hex)
 
 
Bora> nand erase 0 3000000
 
Bora> nand erase 0 3000000
  
Line 1,057: Line 278:
 
Erasing at 0x2fe0000 -- 100% complete.
 
Erasing at 0x2fe0000 -- 100% complete.
 
OK
 
OK
Bora> nand write ${loadaddr} 0 ${filesize}
+
Bora> nand write ${loadaddr} 0 <INTERRUPT>
 
+
Bora> print ${filesize}
NAND write: device 0 offset 0x0, size 0x972038
+
## Error: "8fc790" not defined
9904184 bytes written: OK
 
Bora>
 
</pre>
 
 
 
 
 
Downloading and flashing of the bitstream file:
 
<pre class="board-terminal">
 
Bora> tftpboot ${loadaddr} borax/bitstream.bin
 
Using ethernet@e000b000 device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
 
Filename 'borax/bitstream.bin'.
 
Load address: 0x2080000
 
Loading: #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        ###############################################################
 
        2.5 MiB/s
 
done
 
Bytes transferred = 5979916 (5b3f0c hex)
 
Bora> nand erase 3000000 f00000
 
 
 
NAND erase: device 0 offset 0x3000000, size 0xf00000
 
Erasing at 0x3ee0000 -- 100% complete.
 
OK
 
Bora> nand write ${loadaddr} 3000000 ${filesize}
 
 
 
NAND write: device 0 offset 0x3000000, size 0x5b3f75
 
5980021 bytes written: OK
 
</pre>
 
 
 
 
 
Downloading and flashing of the DTB:
 
<pre class="board-terminal">
 
Bora> tftpboot ${loadaddr} borax/bora.dtb
 
Using ethernet@e000b000 device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
 
Filename 'borax/bora.dtb'.
 
Load address: 0x2080000
 
Loading: ###
 
        746.1 KiB/s
 
done
 
Bytes transferred = 15280 (3bb0 hex)
 
Bora> nand erase 3f00000 100000
 
 
 
NAND erase: device 0 offset 0x3f00000, size 0x100000
 
Erasing at 0x3fe0000 -- 100% complete.
 
OK
 
Bora> nand write ${loadaddr} 3f00000 ${filesize}
 
 
 
NAND write: device 0 offset 0x3f00000, size 0x3bb0
 
15280 bytes written: OK
 
</pre>
 
 
 
===Setting up the U-Boot environment===
 
In order to boot the system as desired, the U-Boot environment must be configured properly. The most important variable is <code>nandboot2</code> that can be created as follows:
 
<pre class="board-terminal">
 
Bora> setenv nandboot2 'run program_fpga2 loadunand loadfdtnand nandargs2 addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}'
 
Bora> savee
 
Saving Environment to SPI Flash...
 
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
 
Erasing SPI flash...Writing to SPI flash...done
 
Valid environment: 1
 
</pre>
 
 
 
 
 
Another important variable that needs to be changed is <code>mtdparts</code>. It must be set like this in order to tell the kernel how the NAND flash is partitioned:
 
<pre class="board-terminal">
 
mtdparts=mtdparts=pl35x-nand:48M(data0),15M(data1),1M(data2),-(data3)
 
</pre>
 
 
 
 
 
Similarly, other variables need to be created such as <code>loadunand</code> and <code>loadfdtnand</code>. The resulting environment should look like this:
 
<pre class="board-terminal">
 
 
Bora> print
 
Bora> print
 
DBXx_test_result=test_passed
 
DBXx_test_result=test_passed
Line 1,154: Line 288:
 
baudrate=115200
 
baudrate=115200
 
bootaddr=0x101100
 
bootaddr=0x101100
bootargs=ip=192.168.0.81:192.168.0.13:192.168.0.254:255.255.255.0:bora:eth0 console=ttyPS0,115200n8 debug earlyprintk cma=16M mtdparts=pl35x-nand:48M(data0),15M(data1),1M(data2),-(data3)
+
bootcmd=run net_nfs
bootcmd=run nandboot2
 
 
bootdelay=3
 
bootdelay=3
 
bootfile=bora/linux/belk-4.0.0_uImage
 
bootfile=bora/linux/belk-4.0.0_uImage
Line 1,168: Line 301:
 
fdt_base=0x00780000
 
fdt_base=0x00780000
 
fdt_high=0x1F000000
 
fdt_high=0x1F000000
fdtaddr=1f00000
+
fdtaddr=2000000
 
fdtcontroladdr=3ffa0a90
 
fdtcontroladdr=3ffa0a90
 
fdtfile=bora/linux/belk-4.0.0_bora.dtb
 
fdtfile=bora/linux/belk-4.0.0_bora.dtb
 +
fileaddr=2080000
 +
filesize=8fc790
 
fpga_base=0x00180000
 
fpga_base=0x00180000
 
fpgafile=bora/bora.bin
 
fpgafile=bora/bora.bin
Line 1,184: Line 319:
 
loadbootscript=fatload ${recoverydev} 0:1 ${loadaddr} ${script};
 
loadbootscript=fatload ${recoverydev} 0:1 ${loadaddr} ${script};
 
loadfdt=tftpboot ${fdtaddr} ${fdtfile}
 
loadfdt=tftpboot ${fdtaddr} ${fdtfile}
loadfdtnand=nand read ${fdtaddr} 3f00000 100000
 
 
loadfpga=tftpboot ${loadaddr} ${fpgafile}
 
loadfpga=tftpboot ${loadaddr} ${fpgafile}
loadfpga2=nand read ${loadaddr} 3000000 f00000
 
 
loadfsbl=tftpboot ${loadaddr} bora/bora_fsbl.bin
 
loadfsbl=tftpboot ${loadaddr} bora/bora_fsbl.bin
 
loadhdr=tftpboot ${loadaddr} bora/boot_header
 
loadhdr=tftpboot ${loadaddr} bora/boot_header
 
loadk=tftpboot ${loadaddr} ${bootfile}
 
loadk=tftpboot ${loadaddr} ${bootfile}
loadunand=nand read ${loadaddr} 0 3000000
 
 
loadvx=tftpboot ${loadaddr} ${vxfile}
 
loadvx=tftpboot ${loadaddr} ${vxfile}
 
mmcargs=setenv bootargs root=/dev/mmcblk0p${mmcpart} rootwait rw
 
mmcargs=setenv bootargs root=/dev/mmcblk0p${mmcpart} rootwait rw
Line 1,200: Line 332:
 
mtdparts=mtdparts=pl35x-nand:48M(data0),15M(data1),1M(data2),-(data3)
 
mtdparts=mtdparts=pl35x-nand:48M(data0),15M(data1),1M(data2),-(data3)
 
mtdparts1=mtdparts=pl353-nand:512K(spl),512K(uboot),256K(env1),256K(env2),4M(fpga),256K(fdt),4M(kernel),-(nand-ubi)
 
mtdparts1=mtdparts=pl353-nand:512K(spl),512K(uboot),256K(env1),256K(env2),4M(fpga),256K(fdt),4M(kernel),-(nand-ubi)
 +
nand_erasesize=20000
 
nand_loadk=nand read ${loadaddr} kernel
 
nand_loadk=nand read ${loadaddr} kernel
 +
nand_oobsize=40
 
nand_updatek=nand erase.part kernel; nand write ${loadaddr} nand-kernel ${filesize}
 
nand_updatek=nand erase.part kernel; nand write ${loadaddr} nand-kernel ${filesize}
 +
nand_writesize=800
 
nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
 
nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
nandargs2=setenv bootargs 'root=/dev/nfs rw nfsroot=${serverip}:${rootpath},tcp'
 
nandboot2=run program_fpga2 loadunand loadfdtnand nandargs2 addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}
 
 
net_nfs=ping ${serverip};run loadk loadfdt nfsargs addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}
 
net_nfs=ping ${serverip};run loadk loadfdt nfsargs addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}
 
net_vx=run loadvx vxargs; bootvx ${loadaddr}
 
net_vx=run loadvx vxargs; bootvx ${loadaddr}
Line 1,211: Line 344:
 
normalboot=net_nfs
 
normalboot=net_nfs
 
program_fpga=run loadfpga;fpga load 0 ${loadaddr} 0x${filesize}
 
program_fpga=run loadfpga;fpga load 0 ${loadaddr} 0x${filesize}
program_fpga2=run loadfpga2; fpga load 0 ${loadaddr} f00000
 
 
qspiboot=echo Booting from QSPI: use net_nfs && run net_nfs
 
qspiboot=echo Booting from QSPI: use net_nfs && run net_nfs
 
ramdisk_size=0x200000
 
ramdisk_size=0x200000
Line 1,235: Line 367:
 
vxfile=bora/vxWorks
 
vxfile=bora/vxWorks
  
Environment size: 4342/262139 bytes
+
Environment size: 3823/262139 bytes
 +
Bora> nand write ${loadaddr} 0 ${filesize}
 +
 
 +
NAND write: device 0 offset 0x0, size 0x8fc790
 +
9422736 bytes written: OK
 +
Bora> tftpboot ${loadaddr} borax/elt/bitstream.bit
 +
Using ethernet@e000b000 device
 +
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
 +
Filename 'borax/elt/bitstream.bit'.
 +
Load address: 0x2080000
 +
Loading: #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        #################################################################
 +
        ###############################################################
 +
        2.6 MiB/s
 +
done
 +
Bytes transferred = 5980021 (5b3f75 hex)
 +
Bora> nand erase 3000000 f00000
 +
 
 +
NAND erase: device 0 offset 0x3000000, size 0xf00000
 +
Erasing at 0x3ee0000 -- 100% complete.
 +
OK
 +
Bora> nand write ${loadaddr} 3000000 ${filesize}
 +
 
 +
NAND write: device 0 offset 0x3000000, size 0x5b3f75
 +
5980021 bytes written: OK
 +
Bora> nand erase 3f00000 100000
 +
 
 +
NAND erase: device 0 offset 0x3f00000, size 0x100000
 +
Erasing at 0x3fe0000 -- 100% complete.
 +
OK
 +
Bora> tftpboot ${loadaddr} borax/elt/bora.dtb
 +
Using ethernet@e000b000 device
 +
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
 +
Filename 'borax/elt/bora.dtb'.
 +
Load address: 0x2080000
 +
Loading: ###
 +
        746.1 KiB/s
 +
done
 +
Bytes transferred = 15280 (3bb0 hex)
 +
Bora> nand write ${loadaddr} 3f00000 ${filesize}
 +
 
 +
NAND write: device 0 offset 0x3f00000, size 0x3bb0
 +
15280 bytes written: OK
 +
Bora>
 +
 
 
</pre>
 
</pre>
  
  
Please note that the variable <code>bootcmd</code> is set to run the desired boot sequence (<code>nandboot2</code>).
 
  
====Formatting the fourth partition of the NAND memory (<code>mtd3</code>)====
 
After setting up the U-Boot environment, it is possible to start a full bootstrap sequence by issuing the  <code>boot</code> command. Please refer to [[#Full bootstrap procedure|this section]] to see the dump of the serial console during the full bootstrap sequence.
 
  
Once the system has completed the bootstrap procedure, it is possible to format the <code>mtd3</code> partition in order to store a ''UBIFS'' filesystem.
 
  
First of all, check that the NAND's partitions are defined properly:
+
<pre>
<pre class="board-terminal">
+
root@bora:~# cat /proc/mtd
root@bora-ubi:~# cat /proc/mtd
 
 
dev:    size  erasesize  name
 
dev:    size  erasesize  name
 
mtd0: 03000000 00020000 "data0"
 
mtd0: 03000000 00020000 "data0"
Line 1,254: Line 440:
 
mtd2: 00100000 00020000 "data2"
 
mtd2: 00100000 00020000 "data2"
 
mtd3: 3c000000 00020000 "data3"
 
mtd3: 3c000000 00020000 "data3"
</pre>
+
root@bora:~# ubiformat /dev/mtd3
 
 
 
 
To format the partition and to mount the newly created filesystem, issue the following commands:
 
<pre class="board-terminal">
 
root@bora-ubi:~# ubiformat /dev/mtd3
 
 
ubiformat: mtd3 (nand), size 1006632960 bytes (960.0 MiB), 7680 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
 
ubiformat: mtd3 (nand), size 1006632960 bytes (960.0 MiB), 7680 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
 
libscan: scanning eraseblock 7679 -- 100 % complete
 
libscan: scanning eraseblock 7679 -- 100 % complete
ubiformat: 7676 eraseblocks have valid erase counter, mean value is 0
+
ubiformat: 7676 eraseblocks are supposedly empty
 
ubiformat: 4 bad eraseblocks found, numbers: 7676, 7677, 7678, 7679
 
ubiformat: 4 bad eraseblocks found, numbers: 7676, 7677, 7678, 7679
 
ubiformat: formatting eraseblock 7679 -- 100 % complete
 
ubiformat: formatting eraseblock 7679 -- 100 % complete
root@bora-ubi:~# ubiattach -m 3
+
root@bora:~# ubiattach -m 3
[ 6543.803993] ubi0: attaching mtd3
+
[ 1149.075187] ubi0: attaching mtd3
[ 6549.149717] ubi0: scanning is finished
+
[ 1154.062660] ubi0: scanning is finished
[ 6549.180746] ubi0: attached mtd3 (name "data3", size 960 MiB)
+
[ 1154.093813] ubi0: attached mtd3 (name "data3", size 960 MiB)
[ 6549.186339] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
+
[ 1154.099516] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[ 6549.194291] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
+
[ 1154.106479] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[ 6549.201006] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
+
[ 1154.113172] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[ 6549.207708] ubi0: good PEBs: 7676, bad PEBs: 4, corrupted PEBs: 0
+
[ 1154.120026] ubi0: good PEBs: 7676, bad PEBs: 4, corrupted PEBs: 0
[ 6549.213824] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
+
[ 1154.126302] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 6549.221038] ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 2065859155
+
[ 1154.133591] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 248135964
[ 6549.232175] ubi0: available PEBs: 7516, total reserved PEBs: 160, PEBs reserved for bad PEB handling: 156
+
[ 1154.142667] ubi0: available PEBs: 7516, total reserved PEBs: 160, PEBs reserved for bad PEB handling: 156
[ 6549.244741] ubi0: background thread "ubi_bgt0d" started, PID 1456
+
[ 1154.152304] ubi0: background thread "ubi_bgt0d" started, PID 870
 
UBI device number 0, total 7676 LEBs (990388224 bytes, 944.5 MiB), available 7516 LEBs (969744384 bytes, 924.8 MiB), LEB size 129024 bytes (126.0 KiB)
 
UBI device number 0, total 7676 LEBs (990388224 bytes, 944.5 MiB), available 7516 LEBs (969744384 bytes, 924.8 MiB), LEB size 129024 bytes (126.0 KiB)
root@bora-ubi:~# ubimkvol /dev/ubi0 -N data3 -m
+
root@bora:~# ubimkvol /dev/ubi0 -N data3 -m
 
Set volume size to 969744384
 
Set volume size to 969744384
 
Volume ID 0, size 7516 LEBs (969744384 bytes, 924.8 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "data3", alignment 1
 
Volume ID 0, size 7516 LEBs (969744384 bytes, 924.8 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "data3", alignment 1
root@bora-ubi:~# mkdir -p /mnt/data3
+
root@bora:~# ls -la /mnt/
root@bora-ubi:~# mount -t ubifs ubi0_0 /mnt/data3
+
total 16
[ 6634.342953] UBIFS (ubi0:0): default file-system created
+
drwxr-xr-x    4 root    root          4096 Mar 19  2018 .
[ 6634.349787] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 1473
+
drwxrwxr-x  16 541      502          4096 Jul  9 21:11 ..
[ 6634.536639] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "data3"
+
drwxr-xr-x    2 root    root          4096 Mar 19  2018 tftpvideo
[ 6634.543901] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
+
drwxr-xr-x    2 root    root          4096 Mar 19  2018 ubifs
[ 6634.553858] UBIFS (ubi0:0): FS size: 967421952 bytes (922 MiB, 7498 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)
+
root@bora:~# mkdir -p /mnt/data3
[ 6634.564767] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
+
root@bora:~# mount -t ubifs ubi0_0 /mnt/data3
[ 6634.571363] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID 8B1F86F2-F2C3-4292-845F-77D3BF3E212A, small LPT model
+
[ 1238.777228] UBIFS (ubi0:0): default file-system created
</pre>
+
[ 1238.783887] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 878
 
+
[ 1238.913347] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "data3"
 
+
[ 1238.920577] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
It is now possible to verify that the filesystem was mounted properly:
+
[ 1238.930509] UBIFS (ubi0:0): FS size: 967421952 bytes (922 MiB, 7498 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)
<pre class="board-terminal">
+
[ 1238.941440] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
root@bora-ubi:~# mount
+
[ 1238.948006] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID B4CA7F10-B2AE-4C89-B2E1-59B38879E564, small LPT model
rootfs on / type rootfs (rw)
+
root@bora:~# mount
 +
192.168.0.13:/opt/nfsroot/bora/belk-4.0.0 on / type nfs (rw,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=1,mountproto=tcp,local_lock=all,addr=192.168.0.13)
 +
devtmpfs on /dev type devtmpfs (rw,relatime,size=506608k,nr_inodes=126652,mode=755)
 
proc on /proc type proc (rw,relatime)
 
proc on /proc type proc (rw,relatime)
 
sysfs on /sys type sysfs (rw,relatime)
 
sysfs on /sys type sysfs (rw,relatime)
 
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
 
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=503536k,nr_inodes=125884,mode=755)
 
 
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
 
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
 
tmpfs on /var/volatile type tmpfs (rw,relatime)
 
tmpfs on /var/volatile type tmpfs (rw,relatime)
 
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
 
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
 
ubi0_0 on /mnt/data3 type ubifs (rw,relatime)
 
ubi0_0 on /mnt/data3 type ubifs (rw,relatime)
</pre>
+
root@bora:~# df
 
 
 
 
As expected, the available space on the <code>ubi0_0</code> is less than the raw size of the partition:
 
<pre class="board-terminal">
 
root@bora-ubi:~# df
 
 
Filesystem          1K-blocks      Used Available Use% Mounted on
 
Filesystem          1K-blocks      Used Available Use% Mounted on
devtmpfs                503536         0    503536   0% /dev
+
192.168.0.13:/opt/nfsroot/bora/belk-4.0.0
tmpfs                  515312        36   515276   0% /run
+
                    103080204  95026920  2810460  97% /
tmpfs                  515312        40   515272   0% /var/volatile
+
devtmpfs                506608         0    506608   0% /dev
 +
tmpfs                  515312        48   515264   0% /run
 +
tmpfs                  515312        48   515264   0% /var/volatile
 
ubi0_0                  887868        16    883016  0% /mnt/data3
 
ubi0_0                  887868        16    883016  0% /mnt/data3
 +
root@bora:~#
 
</pre>
 
</pre>
  
====Full bootstrap procedure====
 
For the reader's convenience, the following box shows the full bootstrap procedure (please, click on the "Expand" link):
 
  
<pre class="board-terminal mw-collapsible mw-collapsed">
 
U-Boot SPL 2017.01-belk-4.0.1 (Jul 13 2017 - 16:08:49)
 
qspi boot
 
Trying to boot from SPI
 
 
 
U-Boot 2017.01-belk-4.0.1 (Jul 13 2017 - 16:08:49 +0200), Build: jenkins-BELK_u-boot-11
 
 
Model: Bora
 
Board: Xilinx Zynq
 
I2C:  ready
 
DRAM:  ECC disabled 1 GiB
 
Relocating to 3ff2e000, new gd at 3eaedee8, sp at 3eaedec0
 
NAND:  1024 MiB
 
MMC:  Card did not respond to voltage select!
 
Card did not respond to voltage select!
 
sdhci@e0100000 - probe failed: -95
 
Card did not respond to voltage select!
 
  
 +
<pre>
 +
Bora> setenv nandboot2 'run loadunand loadfdtnand nandargs2 addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}'
 +
Bora> savee
 +
Saving Environment to SPI Flash...
 
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
 
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
In:    serial@e0001000
+
Erasing SPI flash...Writing to SPI flash...done
Out:   serial@e0001000
+
Valid environment: 1
Err:  serial@e0001000
+
Bora> edit loadunand
Model: Bora
+
edit: Bora> nand help
Board: Xilinx Zynq
+
nand - NAND sub-system
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
 
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
 
SOM ConfigID#: 00000005
 
SOM UniqueID#: 3a11013a:40b52447
 
ds2431_readmem(): error in chip reset
 
ds2431_readmem(): error in reading buffer
 
ds2431_readmem(): error in chip reset
 
ds2431_readmem(): error in reading buffer
 
CB ConfigID CRC mismatch for 0x00000000 (was 0x00000000, expected 0x2144df1c) at block 3 (offset 96): using default
 
CB ConfigID#: ffffffff
 
CB UniqueID#: 00000000:00000000
 
Net:  ZYNQ GEM: e000b000, phyaddr 7, interface rgmii-id
 
eth0: ethernet@e000b000
 
Hit ENTER within 3 seconds to stop autoboot
 
  
NAND read: device 0 offset 0x3000000, size 0xf00000
+
Usage:
15728640 bytes read: OK
+
nand info - show available NAND devices
 
+
nand device [dev] - show or set current device
NAND read: device 0 offset 0x0, size 0x3000000
+
nand read - addr off|partition size
50331648 bytes read: OK
+
nand write - addr off|partition size
 
+
    read/write 'size' bytes starting at offset 'off'
NAND read: device 0 offset 0x3f00000, size 0x100000
+
    to/from memory address 'addr', skipping bad blocks.
1048576 bytes read: OK
+
nand read.raw - addr off|partition [count]
FDT: property som_configid FDT: override 'som_configid' with '00000005'
+
nand write.raw[.noverify] - addr off|partition [count]
FDT: override 'som_uniqueid' with '3a11013a:40b52447'
+
    Use read.raw/write.raw to avoid ECC and access the flash as-is.
FDT: override 'cb_uniqueid' with '00000000:00000000'
+
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
## Booting kernel from Legacy Image at 02080000 ...
+
     With '.spread', erase enough for given file size, otherwise,
  Image Name:  Linux-4.9.0-belk-4.0.0-xilinx
+
    'size' includes skipped bad blocks.
  Image Type:  ARM Linux Kernel Image (uncompressed)
+
nand erase.part [clean] partition - erase entire mtd partition'
  Data Size:    9904120 Bytes = 9.4 MiB
+
nand erase.chip [clean] - erase entire chip'
  Load Address: 00008000
+
nand bad - show bad blocks
  Entry Point:  00008000
+
nand dump[.oob] off - dump page
  Verifying Checksum ... OK
+
nand scrub [-y] off size | scrub.part partition | scrub.chip
## Flattened Device Tree blob at 01f00000
+
    really clean NAND erasing bad blocks (UNSAFE)
  Booting using the fdt blob at 0x1f00000
+
nand markbad off [...] - mark bad block(s) at offset (UNSAFE)
  Loading Kernel Image ... OK
+
nand biterr off - make a bit error at offset (UNSAFE)
  Loading Device Tree to 1effa000, end 1efff996 ... OK
+
nand lock [tight] [status]
Switching to NAND storage before starting Linux
+
    bring nand to lock state or display locked pages
 
+
nand unlock[.allexcept] [offset] [size] - unlock section
Starting kernel ...
+
Bora> edit loadunand
 
+
edit: nand read ${loadaddr} 0 3000000
Uncompressing Linux... done, booting the kernel.
+
Bora> edit loadfdtnand
[    0.000000] Booting Linux on physical CPU 0x0
+
edit: nand read ${fdtaddr} 3000000 f00000
[    0.000000] Linux version 4.9.0-belk-4.0.0-xilinx (dvdk@osboxes) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #4 SMP PREEMPT Tue Mar 5 10:27:41 CET 2019
+
Bora> edit loadfdtnand
[   0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
+
edit: nand read ${fdtaddr} 3f00000 100000
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
+
Bora> savee
[   0.000000] OF: fdt:Machine model: Bora
+
Saving Environment to SPI Flash...
[   0.000000] bootconsole [earlycon0] enabled
+
Erasing SPI flash...Writing to SPI flash...done
[    0.000000] cma: Reserved 16 MiB at 0x3f000000
+
Valid environment: 2
[    0.000000] Memory policy: Data cache writealloc
+
Bora> edit nandargs2
[    0.000000] On node 0 totalpages: 262144
+
edit: setenv bootargs ''
[    0.000000] free_area_init_node: node 0, pgdat c102d8c0, node_mem_map ef7f7000
 
[    0.000000]  Normal zone: 1536 pages used for memmap
 
[    0.000000]  Normal zone: 0 pages reserved
 
[    0.000000]  Normal zone: 196608 pages, LIFO batch:31
 
[    0.000000]  HighMem zone: 65536 pages, LIFO batch:15
 
[    0.000000] percpu: Embedded 14 pages/cpu @ef7d1000 s26124 r8192 d23028 u57344
 
[    0.000000] pcpu-alloc: s26124 r8192 d23028 u57344 alloc=14*4096
 
[    0.000000] pcpu-alloc: [0] 0 [0] 1
 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260608
 
[    0.000000] Kernel command line: root=/dev/nfs rw nfsroot=${serverip}:${rootpath},tcp ip=192.168.0.81:192.168.0.13:192.168.0.254:255.255.255.0:bora:eth0 console=ttyPS0,115200n8 debug earlyprintk cma=16M mtdparts=pl35x-nand:48M(data0),15M(data1),1M(data2),-(data3)
 
[   0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
 
[   0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
 
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
 
[    0.000000] Memory: 1007072K/1048576K available (6144K kernel code, 232K rwdata, 1576K rodata, 7168K init, 323K bss, 25120K reserved, 16384K cma-reserved, 245760K highmem)
 
[    0.000000] Virtual kernel memory layout:
 
[    0.000000]     vector  : 0xffff0000 - 0xffff1000  (  4 kB)
 
[    0.000000]    fixmap  : 0xffc00000 - 0xfff00000  (3072 kB)
 
[    0.000000]    vmalloc : 0xf0800000 - 0xff800000  ( 240 MB)
 
[    0.000000]    lowmem  : 0xc0000000 - 0xf0000000  ( 768 MB)
 
[    0.000000]    pkmap  : 0xbfe00000 - 0xc0000000  (  2 MB)
 
[    0.000000]    modules : 0xbf000000 - 0xbfe00000  (  14 MB)
 
[    0.000000]      .text : 0xc0008000 - 0xc0700000  (7136 kB)
 
[    0.000000]      .init : 0xc0900000 - 0xc1000000  (7168 kB)
 
[    0.000000]      .data : 0xc1000000 - 0xc103a2e0  ( 233 kB)
 
[    0.000000]        .bss : 0xc103a2e0 - 0xc108b0f4  ( 324 kB)
 
[    0.000000] Preemptible hierarchical RCU implementation.
 
[    0.000000]  Build-time adjustment of leaf fanout to 32.
 
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
 
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
 
[    0.000000] NR_IRQS:16 nr_irqs:16 16
 
[    0.000000] efuse mapped to f0802000
 
[    0.000000] slcr mapped to f0804000
 
[    0.000000] L2C: platform modifies aux control register: 0x02060000 -> 0x02460000
 
[    0.000000] L2C: DT/platform modifies aux control register: 0x02060000 -> 0x02460000
 
[    0.000000] L2C-310 erratum 769419 enabled
 
[    0.000000] L2C-310 enabling early BRESP for Cortex-A9
 
[    0.000000] L2C-310 full line of zeros enabled for Cortex-A9
 
[    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
 
[    0.000000] L2C-310 cache controller enabled, 8 ways, 512 kB
 
[    0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46460001
 
[    0.000000] zynq_clock_init: clkc starts at f0804100
 
[    0.000000] Zynq clock init
 
[    0.000000] ps_clk frequency not specified, using 33 MHz.
 
[    0.000011] sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
 
[    0.007866] clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
 
[    0.018884] Switching to timer-based delay loop, resolution 3ns
 
[    0.024886] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
 
[    0.033933] timer #0 at f080c000, irq=17
 
[    0.038249] Console: colour dummy device 80x30
 
[    0.042577] Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
 
[    0.053057] pid_max: default: 32768 minimum: 301
 
[   0.057838] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
 
[    0.064341] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
 
[    0.071972] CPU: Testing write buffer coherency: ok
 
[   0.076891] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
 
[    0.082480] Setting up static identity map for 0x100000 - 0x100058
 
[   0.238338] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
 
[    0.238441] Brought up 2 CPUs
 
[    0.246981] SMP: Total of 2 processors activated (1333.33 BogoMIPS).
 
[    0.253360] CPU: All CPU(s) started in SVC mode.
 
[    0.258930] devtmpfs: initialized
 
[    0.265358] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
 
[    0.273121] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
 
[    0.283743] pinctrl core: initialized pinctrl subsystem
 
[   0.290081] NET: Registered protocol family 16
 
[    0.296286] DMA: preallocated 256 KiB pool for atomic coherent allocations
 
[    0.338362] cpuidle: using governor ladder
 
[    0.378348] cpuidle: using governor menu
 
[    0.394845] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
 
[    0.402735] hw-breakpoint: maximum watchpoint size is 4 bytes.
 
[    0.408680] zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0xf0880000
 
[    0.415532] zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
 
[    0.435803] vgaarb: loaded
 
[    0.439188] SCSI subsystem initialized
 
[    0.443427] usbcore: registered new interface driver usbfs
 
[    0.448889] usbcore: registered new interface driver hub
 
[    0.454202] usbcore: registered new device driver usb
 
[    0.460236] pps_core: LinuxPPS API ver. 1 registered
 
[    0.465075] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
 
[    0.474261] PTP clock support registered
 
[    0.498445] clocksource: Switched to clocksource arm_global_timer
 
[    0.518806] NET: Registered protocol family 2
 
[    0.523753] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
 
[   0.530869] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
 
[    0.537296] TCP: Hash tables configured (established 8192 bind 8192)
 
[    0.543630] UDP hash table entries: 512 (order: 2, 16384 bytes)
 
[    0.549530] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
 
[    0.556004] NET: Registered protocol family 1
 
[    0.560678] RPC: Registered named UNIX socket transport module.
 
[    0.566459] RPC: Registered udp transport module.
 
[    0.571228] RPC: Registered tcp transport module.
 
[    0.575919] RPC: Registered tcp NFSv4.1 backchannel transport module.
 
[    0.582400] PCI: CLS 0 bytes, default 64
 
[    1.102945] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
 
[    1.112338] futex hash table entries: 512 (order: 3, 32768 bytes)
 
[    1.119158] workingset: timestamp_bits=30 max_order=18 bucket_order=0
 
[    1.126156] jffs2: version 2.2. (NAND) (SUMMARY)  c 2001-2006 Red Hat, Inc.
 
[    1.133986] bounce: pool size: 64 pages
 
[    1.137708] io scheduler noop registered
 
[    1.141742] io scheduler deadline registered
 
[    1.145977] io scheduler cfq registered (default)
 
[    1.153301] dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
 
[    1.159920] dma-pl330 f8003000.dmac:        DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
 
[    1.169000] e0000000.serial: ttyPS1 at MMIO 0xe0000000 (irq = 145, base_baud = 3125000) is a xuartps
 
[    1.178412] e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 146, base_baud = 3125000) is a xuartps
 
à[   1.187538] console [ttyPS0] enabled
 
[    1.187538] console [ttyPS0] enabled
 
[    1.194636] bootconsole [earlycon0] disabled
 
[    1.194636] bootconsole [earlycon0] disabled
 
[    1.203842] xdevcfg f8007000.devcfg: ioremap 0xf8007000 to f086f000
 
[   1.210771] [drm] Initialized
 
[   1.226747] brd: module loaded
 
[    1.237253] loop: module loaded
 
[    1.242684] libphy: Fixed MDIO Bus: probed
 
[    1.249767] CAN device driver interface
 
[    1.256030] libphy: MACB_mii_bus: probed
 
[    1.359199] macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 148 (00:50:c2:1e:af:b3)
 
[    1.369069] Micrel KSZ9031 Gigabit PHY e000b000.etherne:07: attached PHY driver [Micrel KSZ9031 Gigabit PHY] (mii_bus:phy_addr=e000b000.etherne:07, irq=-1)
 
[    1.383239] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
 
[    1.389008] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
 
[    1.395903] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
 
[    1.402401] ehci-pci: EHCI PCI platform driver
 
[    1.406934] usbcore: registered new interface driver usb-storage
 
[    1.413140] e0002000.usb supply vbus not found, using dummy regulator
 
[    1.419839] ULPI transceiver vendor/product ID 0x0424/0x0006
 
[    1.425414] Found SMSC USB331x ULPI transceiver.
 
[    1.430048] ULPI integrity check: passed.
 
[    1.435825] mousedev: PS/2 mouse device common for all mice
 
[    1.441733] i2c /dev entries driver
 
[    1.445407] cdns-i2c e0004000.i2c: 100 kHz mmio e0004000 irq 142
 
[    1.458675] rtc-ds3232 0-0068: rtc core: registered ds3232 as rtc0
 
[    1.466248] ina2xx 0-0041: power monitor ina226 (Rshunt = 10000 uOhm)
 
[    1.474606] Xilinx Zynq CpuIdle Driver started
 
[    1.479492] sdhci: Secure Digital Host Controller Interface driver
 
[    1.485582] sdhci: Copyright(c) Pierre Ossman
 
[    1.489994] sdhci-pltfm: SDHCI platform and OF driver helper
 
[    1.548509] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using DMA
 
[    1.556145] usbcore: registered new interface driver usbhid
 
[    1.562699] usbhid: USB HID core driver
 
[    1.569627] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xd3
 
[    1.575932] nand: Unknown W29N08GV
 
[    1.579320] nand: 1024 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
 
[    1.587634] Bad block table found at page 524224, version 0x01
 
[    1.594713] Bad block table found at page 524160, version 0x01
 
[    1.601301] 4 cmdlinepart partitions found on MTD device pl35x-nand
 
[    1.607504] Creating 4 MTD partitions on "pl35x-nand":
 
[    1.612653] 0x000000000000-0x000003000000 : "data0"
 
[    1.630900] 0x000003000000-0x000003f00000 : "data1"
 
[    1.636915] 0x000003f00000-0x000004000000 : "data2"
 
[    1.642873] 0x000004000000-0x000040000000 : "data3"
 
[    1.656664] NET: Registered protocol family 17
 
[    1.662102] can: controller area network core (rev 20120528 abi 9)
 
[    1.668256] NET: Registered protocol family 29
 
[    1.672658] can: raw protocol (rev 20120528)
 
[    1.676874] can: broadcast manager protocol (rev 20161123 t)
 
[    1.682548] can: netlink gateway (rev 20130117) max_hops=1
 
[    1.688386] Registering SWP/SWPB emulation handler
 
[    1.707302] rtc-ds3232 0-0068: setting system clock to 2019-03-05 11:36:06 UTC (1551785766)
 
[    4.838753] macb e000b000.ethernet eth0: link up (1000/Full)
 
[    4.898465] IP-Config: Complete:
 
[    4.901612]      device=eth0, hwaddr=00:50:c2:1e:af:b3, ipaddr=192.168.0.81, mask=255.255.255.0, gw=192.168.0.254
 
[    4.911871]      host=bora, domain=, nis-domain=(none)
 
[    4.916971]      bootserver=192.168.0.13, rootserver=192.168.0.13, rootpath=
 
[    4.924277] Warning: unable to open an initial console.
 
[    4.950584] Freeing unused kernel memory: 7168K (c0900000 - c1000000)
 
[    5.765125] udevd[688]: starting version 3.2
 
[    5.770394] random: udevd: uninitialized urandom read (16 bytes read)
 
[    5.776981] random: udevd: uninitialized urandom read (16 bytes read)
 
[    5.783499] random: udevd: uninitialized urandom read (16 bytes read)
 
[    5.799662] udevd[689]: starting eudev-3.2
 
[    5.833892] random: udevd: uninitialized urandom read (16 bytes read)
 
[    6.769401] random: dd: uninitialized urandom read (512 bytes read)
 
[  11.480222] random: fast init done
 
[  27.774344] NET: Registered protocol family 10
 
 
 
PetaLinux 2017.2 bora-ubi /dev/ttyPS0
 
 
 
bora-ubi login:
 
 
</pre>
 
</pre>
 
====Additional notes====
 
*<code>mtd0</code>, <code>mtd1</code>, and <code>mtd2</code> are significantly larger than the files they store used in this example. This allows having a spare room to store larger images. For the sake of simplicity, U-Boot was configured to read the whole partitions (see how the <code>loadunand</code>, <code>loadfdtnand</code>, and <code>loadfpga2</code> variables are defined). Obviously, this affect the overall boot time negatively. To optimize it, these variables have to be changed in order to read just the required amount of data according to the size of the actual stored files.
 
*As stated previously, the root filesystem is <code>initramfs</code> and thus not persistent. Consequently, every time the system boots, the directory <code>/mnt/data3</code> must be created before mounting the ''UBIFS'' file system stored in the NAND flash.
 
<section end=BELK/>
 

Revision as of 13:40, 1 March 2019

Info Box
Bora5-small.jpg Applies to Bora
BORA Xpress.png Applies to BORA Xpress

History[edit | edit source]

Version Date BXELK version Hardware Part Nr Notes
1.0.0 December 2016 BXELK 1.0.0 DBXF4110D2R
EVBBX0000C0R

Introduction[edit | edit source]

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 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 and program PL bitstream and then 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.

Use case #1[edit | edit source]

Program root file system in NAND flash[edit | edit source]

This is a common step for both booting options.

  • Boot the system via SD or NFS as described into the System boot and recovery via microSD card and Booting the system via NFS
  • By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for FSBL, U-boot and kernel images. Here we won't modify this default configuration. The MTD partitions can be dumped with /proc/mtd (the partition's name should be self-explanatory)


root@bora:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "nand-SPL"
mtd1: 00080000 00020000 "nand-uboot"
mtd2: 00040000 00020000 "nand-uboot-env1"
mtd3: 00040000 00020000 "nand-uboot-env2"
mtd4: 00440000 00020000 "nand-bitstream"
mtd5: 00040000 00020000 "nand-device-tree"
mtd6: 00400000 00020000 "nand-linux"
mtd7: 1f600000 00020000 "nand-rootfs"


200px-Emblem-important.svg.png

Please note that MTD partition index may change depending of flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside /proc/mtd to match your specific layout


  • Format and initialize nand-ubi partition, which in our case is mtd7, using UBI with:
ubiformat /dev/mtd7
ubiattach -m 7
ubimkvol /dev/ubi0 -N rootfs -m

E.g.

root@bora:~# ubiformat /dev/mtd7
ubiformat: mtd7 (nand), size 526385152 bytes (502.0 MiB), 4016 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 4015 -- 100 % complete
ubiformat: 4016 eraseblocks have valid erase counter, mean value is 2
ubiformat: formatting eraseblock 4015 -- 100 % complete
root@bora:~# ubiattach -m 7
[   95.732434] UBI: attaching mtd7 to ubi0
[  100.930047] UBI: scanning is finished
[  100.954932] UBI: attached mtd7 (name "nand-rootfs", size 502 MiB) to ubi0
[  100.961772] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  100.968534] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[  100.975248] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
[  100.982129] UBI: good PEBs: 4016, bad PEBs: 0, corrupted PEBs: 0
[  100.988100] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
[  100.995271] UBI: max/mean erase counter: 4/3, WL threshold: 4096, image sequence number: 1955579947
[  101.004308] UBI: available PEBs: 3852, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
[  101.013959] UBI: background thread "ubi_bgt0d" started, PID 913
UBI device number 0, total 4016 LEBs (509935616 bytes, 486.3 MiB), available 3852 LEBs (489111552 bytes, 466.5 MiB), LEB size 126976 bytes (124.0 KiB)
root@bora:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 489111552
Volume ID 0, size 3852 LEBs (489111552 bytes, 466.5 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
  • Now mount the UBI volume using UBIFS in a temporary directory
mkdir -p /mnt/nand
mount -t ubifs ubi0_0 /mnt/nand

E.g.:

root@bora:~# mkdir -p /mnt/nand
root@bora:~# mount -t ubifs ubi0_0 /mnt/nand
[  151.397013] UBIFS: default file-system created
[  151.402858] UBIFS: background thread "ubifs_bgt0_0" started, PID 918
[  151.529438] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  151.535395] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  151.544507] UBIFS: FS size: 487079936 bytes (464 MiB, 3836 LEBs), journal size 24379392 bytes (23 MiB, 192 LEBs)
[  151.554646] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
[  151.560452] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 447F1480-E173-4BE9-B5BE-A3EC1267F99E, small LPT model
  • you can now extract the root file system into that directory
tar zxvf belk-3.0.1_bora-image-devel-bora.tar.gz -C /mnt/nand
  • finally, you need to cleanly umount and detach the MTD partition
umount /mnt/nand/
ubidetach -m 7

E.g.

root@bora:~# umount /mnt/nand/
[  385.604146] UBIFS: un-mount UBI device 0, volume 0
[  385.608892] UBIFS: background thread "ubifs_bgt0_0" stops
root@bora:~# ubidetach -m 7
[  387.671411] UBI: detaching mtd7 from ubi0
[  387.677554] UBI: mtd7 is detached from ubi0
root@bora:~#

You can now safely reboot or turn off the system.

Program boot images[edit | edit source]

NOR flash[edit | edit source]

We assume that the following environment variables are present in u-boot:

fdt_base=0x00780000
fpga_base=0x00180000
kernel_base=0x00800000
loadk=tftpboot ${loadaddr} ${bootfile}
loadfdt=tftpboot ${fdtaddr} ${fdtfile}
loadfpga=tftpboot ${loadaddr} ${fpgafile}
updatek=sf probe 0 0 0;sf erase ${kernel_base} +${filesize};sf write ${loadaddr} ${kernel_base} ${filesize}
updatefdt=sf probe 0 0 0;sf erase ${fdt_base} +${filesize};sf write ${fdtaddr} ${fdt_base} ${filesize}
updatefpga=sf probe 0 0 0;sf erase ${fpga_base} +${filesize};sf write ${loadaddr} ${fpga_base} ${filesize}
spi_loadk=sf read ${loadaddr} ${kernel_base} 0x800000
spi_loadfdt=sf read ${fdtaddr} ${fdt_base} 0x80000
spi_loadfpga=sf read ${loadaddr} ${fpga_base} 0x600000
program_fpga=run spi_loadfpga;fpga load 0 ${loadaddr} 0x5b3f0c
  • Update the bootfile, fdtfile and fpgafile environment variables to fit the filename as found inside the TFTP server.
  • Program kernel and device tree on NOR flash with the following U-Boot command
zynq-uboot> sf probe; run loadfpga updatefpga loadk updatek loadfdt updatefdt

E.g.:

zynq-uboot> sf probe; run loadfpga updatefpga loadk updatek loadfdt updatefdt
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Using Gem.e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.209
Filename 'bora/borax-BELK-3.0.0-fpga.bin'.
Load address: 0x2080000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################################
         823.2 KiB/s
done
Bytes transferred = 5979916 (5b3f0c hex)
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
SF: 6029312 bytes @ 0x180000 Erased: OK
SF: 5979916 bytes @ 0x180000 Written: OK
Using Gem.e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.209
Filename 'bora/linux/belk-3.0.0_uImage'.
Load address: 0x2080000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##############################
         545.9 KiB/s
done
Bytes transferred = 3477184 (350ec0 hex)
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
SF: 3538944 bytes @ 0x800000 Erased: OK
SF: 3477184 bytes @ 0x800000 Written: OK
Using Gem.e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.209
Filename 'bora/linux/belk-3.0.0_bora.dtb'.
Load address: 0x2000000
Loading: T ##
         2 KiB/s
done
Bytes transferred = 10019 (2723 hex)
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
SF: 65536 bytes @ 0x780000 Erased: OK
SF: 10019 bytes @ 0x780000 Written: OK


In U-Boot environment please set the following variables in order to be able to boot from NOR + NAND

nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
spi_nand=sf probe; run program_fpga spi_loadk spi_loadfdt nandargs addcons addmisc; bootm ${loadaddr} - ${fdtaddr}


Reboot the system and configure U-Boot to apply the new configuration

=> setenv bootcmd run spi_nand
=> saveenv

Use case #2[edit | edit source]

llandre@linuxserver2:/tftpboot/borax/elt$ python /devel/dave/bora-DBRx/fpga/fpga-bit-to-bin.py -f bitstream.bit bitstream.bin
Design name: TOP_LEVEL;UserID=0XFFFFFFFF;Version=2017.4
Partname 7z030sbg485
Date 2019/02/01
Time 16:38:59
found binary data: 5979916


Bora> nand info

Device 0: nand0, sector size 128 KiB
  Page size       2048 b
  OOB size          64 b
  Erase size    131072 b
  subpagesize      512 b
  options     0x       0
  bbt options 0x   20000
Bora> nand erase 0 3000000

NAND erase: device 0 offset 0x0, size 0x3000000
Erasing at 0x2fe0000 -- 100% complete.
OK
Bora> nand write ${loadaddr} 0 <INTERRUPT>
Bora> print ${filesize}
## Error: "8fc790" not defined
Bora> print
DBXx_test_result=test_passed
addcons=setenv bootargs ${bootargs} console=${console},115200n8 debug earlyprintk
addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gateway}:${netmask}:${hostname}:${ethdev}
addmisc=setenv bootargs ${bootargs} cma=16M ${mtdparts}
baudrate=115200
bootaddr=0x101100
bootcmd=run net_nfs
bootdelay=3
bootfile=bora/linux/belk-4.0.0_uImage
bootscript=echo Running bootscript from ${recoverydev} ...; source ${loadaddr}
cb_configid#=ffffffff
cb_uniqueid#=00000000:00000000
configid_fixupfdt=if configid checkfdt ${fdtaddr} som_configid ${som_configid#}; then configid fdt_uniqueid ${fdtaddr}; fi
console=ttyPS0
ethact=ethernet@e000b000
ethaddr=00:50:C2:1E:AF:B3
ethdev=eth0
fdt_base=0x00780000
fdt_high=0x1F000000
fdtaddr=2000000
fdtcontroladdr=3ffa0a90
fdtfile=bora/linux/belk-4.0.0_bora.dtb
fileaddr=2080000
filesize=8fc790
fpga_base=0x00180000
fpgafile=bora/bora.bin
fsbl_base=0x40000
gateway=192.168.0.254
header_base=0
hostname=bora
ipaddr=192.168.0.81
jtag_vx=run vxargs; bootvx 0x200000
kernel_base=0x00800000
load=tftpboot ${loadaddr} bora/u-boot.bin
loadaddr=0x02080000
loadbootscript=fatload ${recoverydev} 0:1 ${loadaddr} ${script};
loadfdt=tftpboot ${fdtaddr} ${fdtfile}
loadfpga=tftpboot ${loadaddr} ${fpgafile}
loadfsbl=tftpboot ${loadaddr} bora/bora_fsbl.bin
loadhdr=tftpboot ${loadaddr} bora/boot_header
loadk=tftpboot ${loadaddr} ${bootfile}
loadvx=tftpboot ${loadaddr} ${vxfile}
mmcargs=setenv bootargs root=/dev/mmcblk0p${mmcpart} rootwait rw
mmcdev=0
mmcpart=2
mmcrecovery=mmc dev 0; mmc rescan; setenv recoverydev mmc; run recovery
modeboot=qspiboot
mtdids=nand0=pl353-nand
mtdparts=mtdparts=pl35x-nand:48M(data0),15M(data1),1M(data2),-(data3)
mtdparts1=mtdparts=pl353-nand:512K(spl),512K(uboot),256K(env1),256K(env2),4M(fpga),256K(fdt),4M(kernel),-(nand-ubi)
nand_erasesize=20000
nand_loadk=nand read ${loadaddr} kernel
nand_oobsize=40
nand_updatek=nand erase.part kernel; nand write ${loadaddr} nand-kernel ${filesize}
nand_writesize=800
nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
net_nfs=ping ${serverip};run loadk loadfdt nfsargs addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}
net_vx=run loadvx vxargs; bootvx ${loadaddr}
netmask=255.255.255.0
nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath},tcp
normalboot=net_nfs
program_fpga=run loadfpga;fpga load 0 ${loadaddr} 0x${filesize}
qspiboot=echo Booting from QSPI: use net_nfs && run net_nfs
ramdisk_size=0x200000
recovery=if run loadbootscript; then run bootscript; fi
rootpath=/opt/nfsroot/bora/belk-4.0.0
script=boot.scr
serial#_DBXx=00C5
serverip=192.168.0.13
som_configid#=00000005
som_uniqueid#=3a11013a:40b52447
stderr=serial@e0001000
stdin=serial@e0001000
stdout=serial@e0001000
u-boot_base=0x80000
update=sf probe 0 0 0;sf erase ${u-boot_base} +${filesize};sf write ${loadaddr} ${u-boot_base} ${filesize}
updatefdt=sf probe 0 0 0;sf erase ${fdt_base} +${filesize};sf write ${fdtaddr} ${fdt_base} ${filesize}
updatefpga=sf probe 0 0 0;sf erase ${fpga_base} +${filesize};sf write ${loadaddr} ${fpga_base} ${filesize}
updatefsbl=sf probe 0 0 0;sf erase ${fsbl_base} +${filesize};sf write ${loadaddr} ${fsbl_base} ${filesize}
updatehdr=sf probe 0 0 0;sf erase ${header_base} +${filesize};sf write ${loadaddr} ${header_base} ${filesize}
updatek=sf probe 0 0 0;sf erase ${kernel_base} +${filesize};sf write ${loadaddr} ${kernel_base} ${filesize}
usbrecovery=usb start; usb dev 0; setenv recoverydev usb; run recovery
vxargs=setenv bootargs gem(0,0)host:vxWorks.st h=${serverip} e=${ipaddr} g=${gatewayip} tn=${hostname} u=target pw=vxTarget f=0x0
vxfile=bora/vxWorks

Environment size: 3823/262139 bytes
Bora> nand write ${loadaddr} 0 ${filesize}

NAND write: device 0 offset 0x0, size 0x8fc790
 9422736 bytes written: OK
Bora> tftpboot ${loadaddr} borax/elt/bitstream.bit
Using ethernet@e000b000 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
Filename 'borax/elt/bitstream.bit'.
Load address: 0x2080000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################################
         2.6 MiB/s
done
Bytes transferred = 5980021 (5b3f75 hex)
Bora> nand erase 3000000 f00000

NAND erase: device 0 offset 0x3000000, size 0xf00000
Erasing at 0x3ee0000 -- 100% complete.
OK
Bora> nand write ${loadaddr} 3000000 ${filesize}

NAND write: device 0 offset 0x3000000, size 0x5b3f75
 5980021 bytes written: OK
Bora> nand erase 3f00000 100000

NAND erase: device 0 offset 0x3f00000, size 0x100000
Erasing at 0x3fe0000 -- 100% complete.
OK
Bora> tftpboot ${loadaddr} borax/elt/bora.dtb
Using ethernet@e000b000 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.81
Filename 'borax/elt/bora.dtb'.
Load address: 0x2080000
Loading: ###
         746.1 KiB/s
done
Bytes transferred = 15280 (3bb0 hex)
Bora> nand write ${loadaddr} 3f00000 ${filesize}

NAND write: device 0 offset 0x3f00000, size 0x3bb0
 15280 bytes written: OK
Bora>



root@bora:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 03000000 00020000 "data0"
mtd1: 00f00000 00020000 "data1"
mtd2: 00100000 00020000 "data2"
mtd3: 3c000000 00020000 "data3"
root@bora:~# ubiformat /dev/mtd3
ubiformat: mtd3 (nand), size 1006632960 bytes (960.0 MiB), 7680 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 7679 -- 100 % complete
ubiformat: 7676 eraseblocks are supposedly empty
ubiformat: 4 bad eraseblocks found, numbers: 7676, 7677, 7678, 7679
ubiformat: formatting eraseblock 7679 -- 100 % complete
root@bora:~# ubiattach -m 3
[ 1149.075187] ubi0: attaching mtd3
[ 1154.062660] ubi0: scanning is finished
[ 1154.093813] ubi0: attached mtd3 (name "data3", size 960 MiB)
[ 1154.099516] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[ 1154.106479] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[ 1154.113172] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[ 1154.120026] ubi0: good PEBs: 7676, bad PEBs: 4, corrupted PEBs: 0
[ 1154.126302] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 1154.133591] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 248135964
[ 1154.142667] ubi0: available PEBs: 7516, total reserved PEBs: 160, PEBs reserved for bad PEB handling: 156
[ 1154.152304] ubi0: background thread "ubi_bgt0d" started, PID 870
UBI device number 0, total 7676 LEBs (990388224 bytes, 944.5 MiB), available 7516 LEBs (969744384 bytes, 924.8 MiB), LEB size 129024 bytes (126.0 KiB)
root@bora:~# ubimkvol /dev/ubi0 -N data3 -m
Set volume size to 969744384
Volume ID 0, size 7516 LEBs (969744384 bytes, 924.8 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "data3", alignment 1
root@bora:~# ls -la /mnt/
total 16
drwxr-xr-x    4 root     root          4096 Mar 19  2018 .
drwxrwxr-x   16 541      502           4096 Jul  9 21:11 ..
drwxr-xr-x    2 root     root          4096 Mar 19  2018 tftpvideo
drwxr-xr-x    2 root     root          4096 Mar 19  2018 ubifs
root@bora:~# mkdir -p /mnt/data3
root@bora:~# mount -t ubifs ubi0_0 /mnt/data3
[ 1238.777228] UBIFS (ubi0:0): default file-system created
[ 1238.783887] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 878
[ 1238.913347] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "data3"
[ 1238.920577] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 1238.930509] UBIFS (ubi0:0): FS size: 967421952 bytes (922 MiB, 7498 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)
[ 1238.941440] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[ 1238.948006] UBIFS (ubi0:0): media format: w4/r0 (latest is w4/r0), UUID B4CA7F10-B2AE-4C89-B2E1-59B38879E564, small LPT model
root@bora:~# mount
192.168.0.13:/opt/nfsroot/bora/belk-4.0.0 on / type nfs (rw,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=1,mountproto=tcp,local_lock=all,addr=192.168.0.13)
devtmpfs on /dev type devtmpfs (rw,relatime,size=506608k,nr_inodes=126652,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
ubi0_0 on /mnt/data3 type ubifs (rw,relatime)
root@bora:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
192.168.0.13:/opt/nfsroot/bora/belk-4.0.0
                     103080204  95026920   2810460  97% /
devtmpfs                506608         0    506608   0% /dev
tmpfs                   515312        48    515264   0% /run
tmpfs                   515312        48    515264   0% /var/volatile
ubi0_0                  887868        16    883016   0% /mnt/data3
root@bora:~#


Bora> setenv nandboot2 'run loadunand loadfdtnand nandargs2 addip addcons addmisc; run configid_fixupfdt; bootm ${loadaddr} - ${fdtaddr}'
Bora> savee
Saving Environment to SPI Flash...
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
Erasing SPI flash...Writing to SPI flash...done
Valid environment: 1
Bora> edit loadunand
edit: Bora> nand help
nand - NAND sub-system

Usage:
nand info - show available NAND devices
nand device [dev] - show or set current device
nand read - addr off|partition size
nand write - addr off|partition size
    read/write 'size' bytes starting at offset 'off'
    to/from memory address 'addr', skipping bad blocks.
nand read.raw - addr off|partition [count]
nand write.raw[.noverify] - addr off|partition [count]
    Use read.raw/write.raw to avoid ECC and access the flash as-is.
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
    With '.spread', erase enough for given file size, otherwise,
    'size' includes skipped bad blocks.
nand erase.part [clean] partition - erase entire mtd partition'
nand erase.chip [clean] - erase entire chip'
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub [-y] off size | scrub.part partition | scrub.chip
    really clean NAND erasing bad blocks (UNSAFE)
nand markbad off [...] - mark bad block(s) at offset (UNSAFE)
nand biterr off - make a bit error at offset (UNSAFE)
nand lock [tight] [status]
    bring nand to lock state or display locked pages
nand unlock[.allexcept] [offset] [size] - unlock section
Bora> edit loadunand
edit: nand read ${loadaddr} 0 3000000
Bora> edit loadfdtnand
edit: nand read ${fdtaddr} 3000000 f00000
Bora> edit loadfdtnand
edit: nand read ${fdtaddr} 3f00000 100000
Bora> savee
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done
Valid environment: 2
Bora> edit nandargs2
edit: setenv bootargs ''