DESK-XZ7-L/Deployment/Standalone boot

From DAVE Developer's Wiki
< DESK-XZ7-L
Revision as of 08:01, 22 November 2022 by U0007 (talk | contribs) (Program root file system into NAND flash)

Jump to: navigation, search
History
ID# Issue Date Notes

17xxx

Q1 2023 DESK-XZ7-L 1.0.0 release


Standalone boot[edit | edit source]

Introduction[edit | edit source]

This document was written and tested with the software/hardware combination described in the history table above. However, it contains general concepts that can be adapted to any DAVE Embedded Systems' Linux platform.


200px-Emblem-important.svg.png

The following programming examples are intended for laboratory usage or for preliminary deployment strategy.

A complete deployment strategy has to be carefully identifiyed taking into account the overall arguments like: boot speed, safe boot, recovery mechanisms, watchdog supervisor, etc.


We'll explain how to program and configure a <SOM> to boot in standalone mode, without the need for a system microSD card or an NFS server, with three options:

  • booting with SD only
    • in this configuration the whole system will boot without the need for a NOR/NAND flashes storage, all images and the root file system will be fetched from the SD card
  • booting with NOR and NAND internal storage
    • in this configuration the primary boot images will be fetched from NOR flash storage, while the root file system will be fetched from NAND flash

Program boot images into SD card[edit | edit source]

The SD card should have at least 2 partition:

  • the first must be an FAT32 partition (type b) with size of at least 64MB
  • the second is a normal linux partition (type 83) of at least 512M with ext3/ext4 filesystem

Create the SD card partitions[edit | edit source]

  • SD device has to be partitioned and properly formatted choosing the file system for each partition
  • an example of SD partitioning script is the following one (running on a DAVE Embedded Systems' DVDK VM):
#!/bin/sh

node=$1

# partition size in MB
RESERVED=8
BOOT_ROM_SIZE=128
RFS_SIZE=2048

# create the SDCARD partition
part=""
echo ${node} | grep mmcblk > /dev/null
if [ "$?" -eq "0" ]; then
        part="p"
fi

# print the SD total capacity
total_size=`sfdisk -s ${node}`
total_size=`expr ${total_size} / 1024`
echo SD total size: ${total_size}KB

# calculate partition sizes
boot_start=`expr ${RESERVED} \\* 1024 \\* 1024 / 512`
boot_size=`expr ${BOOT_ROM_SIZE} \\* 1024 \\* 1024 / 512`
rfs_start=`expr ${boot_size} + ${boot_start}`
rfs_size=`expr ${RFS_SIZE} \\* 1024 \\* 1024 / 512`

umount ${node}${part}1 > /dev/null 2>&1
umount ${node}${part}2 > /dev/null 2>&1

# call sfdisk to create partition table
{ echo ${boot_start},${boot_size},0c,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}

# format the SDCARD partition
echo "formatting boot"
mkfs.vfat -F 32 -n BOOT  ${node}${part}1
echo "formatting rfs"
mkfs.ext4 -F ${node}${part}2 -Lrfs

E.g.

vdk@vagrant:~/desk-xz-l$ sudo ./sdcard-partition.sh /dev/sdc
SD total size: 7580KB
Checking that no-one is using this disk right now ... OK

Disk /dev/sdc: 7.41 GiB, 7948206080 bytes, 15523840 sectors
Disk model: STORAGE DEVICE  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd775a452

Old situation:

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1        8192 15523839 15515648  7.4G  b W95 FAT32

>>> Created a new DOS disklabel with disk identifier 0x3f242b9b.
/dev/sdc1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB.
/dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 GiB.
Partition #2 contains a ext4 signature.
/dev/sdc3: Done.

New situation:
Disklabel type: dos
Disk identifier: 0x3f242b9b

Device     Boot  Start     End Sectors  Size Id Type
/dev/sdc1        16384  278527  262144  128M  c W95 FAT32 (LBA)
/dev/sdc2       278528 4472831 4194304    2G 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
formatting boot
mkfs.fat 4.1 (2017-01-24)
formatting rfs
mke2fs 1.45.5 (07-Jan-2020)
/dev/sdc2 contains a ext4 file system labelled 'rfs'
        created on Mon Nov 21 13:14:20 2022
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: cc691ca0-1eb4-4ff9-87cc-da74f9e91685
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

dvdk@vagrant:~/desk-xz-l$ 

Then, insert the SD card in the target and boot the system via NFS as described in the e Booting from nfs guide

  • create a mount point and mount the first partition
root@bora:~# mkdir -p /mnt/sd
root@bora:~# mount /dev/mmcblk0p1 /mnt/sd
  • copy boot image files
root@bora:~# cp BOOT.BIN /mnt/sd
root@bora:~# cp image.ub /mnt/sd
root@bora:~# cp boot.scr /mnt/sd

Program root file system into SD card[edit | edit source]

  • mount the ext3/ext4 volume in the temporary directory
root@bora:~# mount /dev/mmcblk0p2 /mnt/ext
  • now, you can extract the root file system in the target directory
root@bora:~# tar zxpf images/linux/rootfs.tar.gz -C /mnt/ext
  • finally, you need to cleanly umount and safely reboot or turn off the system.
root@bora:~# umount /mnt/sd
root@bora:~# umount /mnt/ext
root@bora:~# reboot

Once restarted, the complete boot log can be like this one:

U-Boot 2021.01 (Oct 12 2021 - 09:28:42 +0000)

CPU:   Zynq 7z020
Silicon: v3.1
DRAM:  ECC disabled 1 GiB
Flash: 0 Bytes
NAND:  0 MiB
MMC:   mmc@e0100000: 0
Loading Environment from FAT... *** Warning - bad CRC, using default environment

In:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Net:
ZYNQ GEM: e000b000, mdio bus e000b000, phyaddr -1, interface rgmii-id
eth0: ethernet@e000b000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
ERROR: reserving fdt memory region failed (addr=3e000000 size=1000000)
2710 bytes read in 22 ms (120.1 KiB/s)
## Executing script at 03000000
Trying to load boot images from mmc0
ERROR: reserving fdt memory region failed (addr=3e000000 size=1000000)
4847892 bytes read in 398 ms (11.6 MiB/s)
## Loading kernel from FIT Image at 10000000 ...
   Using 'conf-system-top.dtb' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel-1' kernel subimage
     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x100000f8
     Data Size:    4826176 Bytes = 4.6 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00200000
     Entry Point:  0x00200000
     Hash algo:    sha256
     Hash value:   e92c329ce6440944a9b8d2c581f9e2f668870af9b90648b321f5b2c996bfb47f
   Verifying Hash Integrity ... sha256+ OK
## Loading fdt from FIT Image at 10000000 ...
   Using 'conf-system-top.dtb' configuration
   Verifying Hash Integrity ... OK
   Trying 'fdt-system-top.dtb' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x1049a644
     Data Size:    19819 Bytes = 19.4 KiB
     Architecture: ARM
     Hash algo:    sha256
     Hash value:   021ac7fe236180abcd9d663112aeadec8c6a8c1be2e31e729504ea585d99ca42
   Verifying Hash Integrity ... sha256+ OK
   Booting using the fdt blob at 0x1049a644
   Loading Kernel Image
ERROR: reserving fdt memory region failed (addr=3e000000 size=1000000)
   Loading Device Tree to 2fff8000, end 2ffffd6a ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 5.10.0-xilinx-v2021.2 (oe-user@oe-host) (arm-xilinx-linux-gnueabi-gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Tue Oct 12 09:30:57 UTC 2021
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: xlnx,zynq-7000
earlycon: cdns0 at MMIO 0xe0001000 (options '115200n8')
printk: bootconsole [cdns0] enabled
Memory policy: Data cache writealloc
OF: reserved mem: OVERLAP DETECTED!
rproc@3e000000 (0x3e000000--0x3f000000) overlaps with vdev0vring0@3e800000 (0x3e800000--0x3e804000)
Reserved memory: created DMA memory pool at 0x3e000000, size 16 MiB
OF: reserved mem: initialized node rproc@3e000000, compatible id shared-dma-pool
Reserved memory: created DMA memory pool at 0x3e800000, size 0 MiB
OF: reserved mem: initialized node vdev0vring0@3e800000, compatible id shared-dma-pool
Reserved memory: created DMA memory pool at 0x3e804000, size 0 MiB
OF: reserved mem: initialized node vdev0vring1@3e804000, compatible id shared-dma-pool
Reserved memory: created DMA memory pool at 0x3e808000, size 1 MiB
OF: reserved mem: initialized node vdev0buffer@3e808000, compatible id shared-dma-pool
cma: Reserved 16 MiB at 0x3f000000
Zone ranges:
  Normal   [mem 0x0000000000000000-0x000000002fffffff]
  HighMem  [mem 0x0000000030000000-0x000000003fffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000000000000-0x000000003dffffff]
  node   0: [mem 0x000000003f000000-0x000000003fffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000000003fffffff]
percpu: Embedded 15 pages/cpu s32396 r8192 d20852 u61440
Built 1 zonelists, mobility grouping on.  Total pages: 256320
Kernel command line: console=ttyPS0,115200 earlycon root=/dev/mmcblk0p2 rw rootwait
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
mem auto-init: stack:off, heap alloc:off, heap free:off
Memory: 993544K/1032192K available (7168K kernel code, 275K rwdata, 1940K rodata, 1024K init, 162K bss, 22264K reserved, 16384K cma-reserved, 229376K highmem)
rcu: Preemptible hierarchical RCU implementation.
rcu:    RCU event tracing is enabled.
rcu:    RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
        Trampoline variant of Tasks RCU enabled.
rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
efuse mapped to (ptrval)
slcr mapped to (ptrval)
GIC physical location is 0xf8f01000
L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 ID prefetch enabled, offset 1 lines
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76760001
random: get_random_bytes called from start_kernel+0x2c0/0x4a0 with crng_init=0
zynq_clock_init: clkc starts at (ptrval)
Zynq clock init
sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
Switching to timer-based delay loop, resolution 3ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: using BPIALL workaround
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x100000 - 0x100060
rcu: Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
CPU1: Spectre v2: using BPIALL workaround
smp: Brought up 1 node, 2 CPUs
SMP: Total of 2 processors activated (1333.33 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 512 (order: 3, 32768 bytes, linear)
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
thermal_sys: Registered thermal governor 'step_wise'
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0x(ptrval)
e0000000.serial: ttyPS1 at MMIO 0xe0000000 (irq = 34, base_baud = 3125000) is a xuartps
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 35, base_baud = 3125000) is a xuartps
printk: console [ttyPS0] enabled
printk: console [ttyPS0] enabled
printk: bootconsole [cdns0] disabled
printk: bootconsole [cdns0] disabled
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
mc: Linux media interface: v0.10
videodev: Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
FPGA manager framework
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm_global_timer
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
hw perfevents: no interrupt-affinity property for /pmu@f8891000, guessing.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
workingset: timestamp_bits=14 max_order=18 bucket_order=4
jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
bounce: pool size: 64 pages
io scheduler mq-deadline registered
io scheduler kyber registered
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac:        DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
brd: module loaded
loop: module loaded
spi_master spi0: cannot find modalias for /axi/spi@e000d000/flash@0
spi_master spi0: Failed to create SPI device for /axi/spi@e000d000/flash@0
libphy: Fixed MDIO Bus: probed
CAN device driver interface
libphy: MACB_mii_bus: probed
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 37 (00:0a:35:00:1e:53)
e1000e: Intel(R) PRO/1000 Network Driver
e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
usbcore: registered new interface driver usb-storage
i2c /dev entries driver
cdns-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 31
cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer with timeout 10s
EDAC MC: ECC not enabled
Xilinx Zynq CpuIdle Driver started
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
ledtrig-cpu: registered to indicate activity on CPUs
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
timer #0 at (ptrval), irq=50
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
mmc0: SDHCI controller on e0100000.mmc [e0100000.mmc] using ADMA
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered protocol family 10
Segment Routing with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
can: controller area network core
NET: Registered protocol family 29
can: raw protocol
can: broadcast manager protocol
can: netlink gateway - max_hops=1
Registering SWP/SWPB emulation handler
of-fpga-region fpga-full: FPGA Region probed
of_cfs_init
of_cfs_init: OK
ALSA device list:
  No soundcards found.
Waiting for root device /dev/mmcblk0p2...
mmc0: new high speed SDHC card at address e624
mmcblk0: mmc0:e624 SU08G 7.40 GiB
 mmcblk0: p1 p2
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel memory: 1024K
Run /sbin/init as init process
INIT: version 2.97 booting
random: fast init done
Starting udev
udevd[79]: starting version 3.2.9
random: udevd: uninitialized urandom read (16 bytes read)
random: udevd: uninitialized urandom read (16 bytes read)
random: udevd: uninitialized urandom read (16 bytes read)
udevd[80]: starting eudev-3.2.9
remoteproc remoteproc0: remoteproc@0 is available
EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
bootlogd: /dev/ttyPS0hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method.
Fri Mar  9 12:34:56 UTC 2018
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method.
Configuring packages on first boot....
 (This may take several minutes. Please do not power off the machine.)
Running postinst /etc/rpm-postinsts/100-sysvinit-inittab...
Running postinst /etc/rpm-postinsts/101-postfix-cfg...
newaliases: fatal: could not find any active network interfaces
update-rc.d: /etc/init.d/run-postinsts exists during rc.d purge (continuing)
 Removing any system startup links for run-postinsts ...
  /etc/rcS.d/S99run-postinsts
INIT: Entering runlevel: 5
Configuring network interfaces... udhcpc: started, v1.32.0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
udhcpc: no lease, forking to background
done.
Starting system message bus: dbus.
Starting haveged: haveged: command socket is listening at fd 3
haveged: haveged starting up


Starting Dropbear SSH server: Waiting for kernel randomness to be initialised...
haveged: haveged: ver: 1.9.13; arch: generic; vend: ; build: (gcc 10.2.0 CTV); collect: 128K

haveged: haveged: cpu: (VC); data: 16K (D); inst: 16K (D); idx: 12/40; sz: 15006/57790

haveged: haveged: tot tests(BA8): A:1/1 B:1/1 continuous tests(B):  last entropy estimate 8.00147

haveged: haveged: fills: 0, generated: 0

Generating 2048 bit rsa key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUVSSH5GBRYKSqp/IabWPY1YjhUafEjPgQ3z5jeMumYluG9SVENoI2GzLZrfCFJyA0WRDCk+oTjBnrEHEKGChX/srqIvlM9P36/qOlP9/kY6gvpPWeawFQ1srgLX12rtqnE0oxy/eDo8a+IjUIyBz4zrTdtpZ88mT32e0Egiy1XuSUCWdfVy+cEjFLEVWojAUPW/AcxiyNZrjmPR2YGNSH9/Y8LgH6WZj5/2g68tOH6hrW+qpdO8T8jTCoG/5OBuYWUzGlOPk058CABHmcFmDoiH0wKInoVMyNiPZCotNF9+QpArSosTHAUlUwHZ4fzxbV57K3gBt8co6FKLAfO/mP root@bora
Fingerprint: sha1!! 62:38:60:ea:fb:84:ea:71:b1:3f:a5:e4:14:96:eb:26:e3:35:ef:fd
dropbear.
Starting rpcbind daemon...done.
starting statd: done
Starting atd: OK
starting DNS forwarder and DHCP server: dnsmasq... done.
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method.
Starting internet superserver: inetd.
NFS daemon support not enabled in kernel
Starting ntpd: done
Starting system log daemon...0
Mar  9 12:35:16 bora kernel: OF: reserved mem: OVERLAP DETECTED!
Mar  9 12:35:16 bora kernel: rproc@3e000000 (0x3e000000--0x3f000000) overlaps with vdev0vring0@3e800000 (0x3e800000--0x3e804000)
Mar  9 12:35:16 bora kernel: L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
Mar  9 12:35:16 bora kernel: L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
Mar  9 12:35:16 bora kernel: hw perfevents: no interrupt-affinity property for /pmu@f8891000, guessing.
Mar  9 12:35:16 bora kernel: spi_master spi0: cannot find modalias for /axi/spi@e000d000/flash@0
Mar  9 12:35:16 bora kernel: spi_master spi0: Failed to create SPI device for /axi/spi@e000d000/flash@0
Mar  9 12:35:16 bora kernel: urandom_read: 2 callbacks suppressed
Starting internet superserver: xinetd.
Starting Postfix...Creating aliases database ...
postfix/postfix-script: starting the Postfix mail system
 Successful
Starting Lighttpd Web Server: lighttpd.
* starting FTP Server: vsftpd... done.
Starting crond: OK
Starting tcf-agent: OK

PetaLinux 2021.2 bora ttyPS0


root@bora:~#

Program boot images into internal storage[edit | edit source]

Program the NOR flash[edit | edit source]

BOOT.BIN[edit | edit source]

Update to the latest BOOT.BIN version: in the following example, the binary file is loaded from the tftp server:

Zynq> setenv boot_addr_r 0x1000000
Zynq> tftpboot ${boot_addr_r} desk-xz7/BOOT.BIN
Using ethernet@e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.90
Filename 'desk-xz7/BOOT.BIN'.
Load address: 0x1000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #####################################
         1.9 MiB/s
done
Bytes transferred = 22149396 (151f914 hex)

then erase and program the BOOT.BIN binary image:

Zynq> sf probe; sf erase 0 2000000
SF: Detected s25fl256s1 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 33554432 bytes @ 0x0 Erased: OK
Zynq> sf write ${boot_addr_r} 0 ${filesize}
device 0 offset 0x0, size 0x151f914
SF: 22149396 bytes @ 0x0 Written: OK
Zynq>
fit image[edit | edit source]
  • program the FIT image on NOR flash with the following U-Boot commands:
Zynq> tftpboot ${kernel_addr_r} ${serverip}:desk-xz7/image.ub
Using ethernet@e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.90
Filename 'desk-xz7/image.ub'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #####################################
         670.9 KiB/s
done
Bytes transferred = 4847892 (49f914 hex)
Zynq>
  • then erase and program the image-ub FIT image in NOR:
Zynq> sf probe; sf erase 1800000 800000; sf write ${kernel_addr_r} 1800000  ${filesize}
SF: Detected s25fl256s1 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
device 0 offset 0x1000000, size 0x49f914
SF: 4847892 bytes @ 0x1000000 Written: OK
Zynq>
  • configure U-Boot to apply the new configuration:
Zynq> setenv spi_nand 'sf probe; sf read ${kernel_addr_r} 1800000 800000; bootm ${kernel_addr_r}'
Zynq> setenv bootcmd 'run spi_nand'
Zynq> saveenv

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

  • boot the system via NFS as described in the e Booting from nfs guide
  • the NAND is partitioned following the /proc/mtd scheme (the partition's name should be self-explanatory). See the MTD for more information on MTD layer.


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 mtd0, using UBI with:
ubiformat /dev/mtd0
ubiattach -m 0
ubimkvol /dev/ubi0 -N rootfs -m

E.g.

root@bora:~# ubiformat /dev/mtd0
  • mount the UBI volume using UBIFS in a temporary directory
mkdir -p /mnt/nand
mount -t ubifs ubi0_0 /mnt/nand
  • you can now extract the root file system into that directory
tar zxpf images/linux/rootfs.tar.gz -C /mnt/nand
  • finally, you need to cleanly umount and detach the MTD partition
umount /mnt/nand/
ubidetach -m 

You can now safely reboot or turn off the system.

In U-Boot environment check the following variable, which must contain the same MTD partition number used above

nand_args=setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw ubi.mtd=0