2022/12/15

z-turnをpetalinuxで動かす

XILINX   

Spike SummersによるPixabayからの画像

ひでみさんから頂いたZ-turnを使用しております。ひでみさん、ありがとうございます。

z-turn(ZYNQ-7020)を使って、petalinuxを動かす。

ハードウェア情報

別の記事で作成したVivadoで作成したファイルを使用する

以下のファイルを使用する

project_2.runs/impl_1/design_1_wrapper.bit
design_1_wrapper.xsa

プロジェクトの作成

petalinux-create -t project --template zynq --name zturn
cd ztrun

ハードウェア情報のインポート

design_1_wrapper.xsaを使用して、ハードウェア情報をインポートする。–get-hw-description=の引数は、design_1_wrapper.xsaのディレクトリを指定する

petalinux-config --get-hw-description=../../project_2/

menuconfigの画面になるので、

Image Packaging Configration –> Rot filesystem type —> INITRDをEXT4に変更する

ビルド

petalinux-build

ブート用ファイルの作成

petalinux-package --boot --u-boot
 petalinux-package --prebuilt --fpga ../../project_2/project_2.runs/impl_1/design_1_wrapper.bit

SDカードの準備

z-turnの起動用のSDカードを準備する。Linuxのフォーマットする。SDカードは、/dev/sdaとする

fdiskをして、fat領域とext4領域に分ける

fdisk /dev/sda

コマンド (m でヘルプ): d
パーティション番号 (1,2, 既定値 2)

パーティション 2 を削除しました。

コマンド (m でヘルプ): d
パーティション 1 を選択
パーティション 1 を削除しました。

コマンド (m でヘルプ): n
パーティションタイプ
   p   基本パーティション (0 primary, 0 extended, 4 free)
   e   拡張領域 (論理パーティションが入ります)
選択 (既定値 p): p
パーティション番号 (1-4, 既定値 1): 1
最初のセクタ (2048-7829503, 既定値 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7829503, 既定値 7829503): +1G

新しいパーティション 1 をタイプ Linux、サイズ 1 GiB で作成しました。
パーティション #1 には vfat 署名が書き込まれています。

署名を削除しますか? [Y]es/[N]o: Y

署名は write (書き込み)コマンドを実行すると消えてしまいます。

コマンド (m でヘルプ): 

コマンド (m でヘルプ): n
パーティションタイプ
   p   基本パーティション (1 primary, 0 extended, 3 free)
   e   拡張領域 (論理パーティションが入ります)
選択 (既定値 p): p
パーティション番号 (2-4, 既定値 2): 
最初のセクタ (2099200-7829503, 既定値 2099200): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-7829503, 既定値 7829503): 

新しいパーティション 2 をタイプ Linux、サイズ 2.7 GiB で作成しました。
パーティション #2 には ext4 署名が書き込まれています。

署名を削除しますか? [Y]es/[N]o: Y

署名は write (書き込み)コマンドを実行すると消えてしまいます。

コマンド (m でヘルプ): w
パーティション情報が変更されました。
ioctl() を呼び出してパーティション情報を再読み込みします。
ディスクを同期しています。


fat領域をフォーマットする

umount /dev/sda1
umount /dev/sda2
mkfs.vfat /dev/sda1

ext4領域をフォーマットする

mkfs.ext4 /dev/sda2

fat領域にBOOT用のファイルをコピーする

mkdir tt
mount /dev/sda1 ./tt
cp pre-built/linux/images/BOOT.bin ./tt
cp pre-built/linux/images/boot.scr ./tt
cp pre-built/linux/images/image.ub ./tt
umount /dev/sda1

ext4領域にルートファイルシステムを作成する

mount /dev/sda2 ./tt
cp pre-built/linux/images/rootfs.tar.gz ./tt
cd tt
tar xfz rootfs.tar.gz
cd ..
umount /dev/sda2

起動

Z-trunにSDカードをさして、電源をいれて、RESETボタンを押すとLinuxが起動するはずだ。

ログ

起動ログをメモしておく


U-Boot 2022.01 (Apr 04 2022 - 07:53:54 +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... *** Error - No Valid Environment Area found
*** Warning - bad env area, 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
2776 bytes read in 13 ms (208 KiB/s)
## Executing script at 03000000
Trying to load boot images from mmc0
4554816 bytes read in 304 ms (14.3 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:   0x100000fc
     Data Size:    4533856 Bytes = 4.3 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00200000
     Entry Point:  0x00200000
     Hash algo:    sha256
     Hash value:   de7af236bfd033bdb9dc941130990742ed7285187a2243bc351cc1bc2d2118d1
   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:   0x10453068
     Data Size:    19058 Bytes = 18.6 KiB
     Architecture: ARM
     Hash algo:    sha256
     Hash value:   cf0a96b48fad21355d8e041e2875a03e47b6538cb0b910fabf5371a5df352303
   Verifying Hash Integrity ... sha256+ OK
   Booting using the fdt blob at 0x10453068
   Loading Kernel Image
   Loading Device Tree to 2fff8000, end 2ffffa71 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 5.15.19-xilinx-v2022.1 (oe-user@oe-host) (arm-xilinx-linux-gnueabi-gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37.20210721) #1 SMP PREEMPT Mon Apr 11 17:52:14 UTC 2022
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
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-0x000000003fffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000000003fffffff]
percpu: Embedded 12 pages/cpu s16588 r8192 d24372 u49152
Built 1 zonelists, mobility grouping on.  Total pages: 260608
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: 1010904K/1048576K available (7168K kernel code, 246K rwdata, 1892K rodata, 1024K init, 119K bss, 21288K reserved, 16384K cma-reserved, 245760K 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+0x364/0x5d4 with crng_init=0
zynq_clock_init: clkc starts at (ptrval)
Zynq clock init
sched_clock: 64 bits at 124MHz, resolution 8ns, wraps every 4398046511100ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x39a85c341c, max_idle_ns: 881590408241 ns
Switching to timer-based delay loop, resolution 8ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 249.99 BogoMIPS (lpj=1249999)
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 (499.99 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 PF_NETLINK/PF_ROUTE protocol family
DMA: preallocated 256 KiB pool for atomic coherent allocations
thermal_sys: Registered thermal governor 'step_wise'
cpuidle: using governor menu
amba f8801000.etb: Fixing up cyclic dependency with replicator
amba f8803000.tpiu: Fixing up cyclic dependency with replicator
amba f8804000.funnel: Fixing up cyclic dependency with replicator
amba f889c000.ptm: Fixing up cyclic dependency with f8804000.funnel
amba f889d000.ptm: Fixing up cyclic dependency with f8804000.funnel
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 = 35, base_baud = 6249999) is a xuartps
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 36, base_baud = 6249999) 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 PF_INET protocol family
IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
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 PF_UNIX/PF_LOCAL protocol family
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
armv7-pmu f8891000.pmu: hw perfevents: no interrupt-affinity property, guessing.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
workingset: timestamp_bits=30 max_order=18 bucket_order=0
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
CAN device driver interface
xilinx_can e0008000.can can0: TDC Offset value not in range 
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 38 (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: i2c /dev entries driver
cdns-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 31
cdns-i2c e0005000.i2c: 400 kHz mmio e0005000 irq 32
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: 716713566 ns
timer #0 at (ptrval), irq=51
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 PF_INET6 protocol family
Segment Routing with IPv6
In-situ OAM (IOAM) with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered PF_PACKET protocol family
can: controller area network core
NET: Registered PF_CAN protocol family
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 b368
mmcblk0: mmc0:b368 NCard 3.73 GiB 
 mmcblk0: p1 p2
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel image (initmem) memory: 1024K
Run /sbin/init as init process
INIT: version 2.99 booting
random: fast init done
Starting udev
Starting version 249.7+
EXT4-fs (mmcblk0p2): re-mounted. Opts: (null). Quota mode: disabled.
bootlogd: /dev/ttyPS0hwclock: can't open '/dev/misc/rtc': No such file or directory
Fri Mar  9 12:34:56 UTC 2018
hwclock: can't open '/dev/misc/rtc': No such file or directory
random: dd: uninitialized urandom read (512 bytes read)
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...
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... macb e000b000.ethernet eth0: PHY [e000b000.ethernet-ffffffff:03] driver [Generic PHY] (irq=POLL)
macb e000b000.ethernet eth0: configuring for phy/rgmii-id link mode
udhcpc: started, v1.34.1
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: no lease, forking to background
done.
Starting haveged: haveged: command socket is listening at fd 3
haveged: haveged starting up
[  OK  ]
Starting Dropbear SSH server: Waiting for kernel randomness to be initialised...
haveged: haveged: ver: 1.9.14; arch: generic; vend: ; build: (gcc 11.2.0 CTV); collect: 128K

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

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

haveged: haveged: fills: 0, generated: 0 

random: crng init done
Generating 2048 bit rsa key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0809kTFUGytsME7+xyNGZb6VLpRKS3uGUJ5qcL8Ho0gN1aKEt+3xuH6ZhoTkdLBoCjincF8/Fu0cwGxnd/zw7PpqS3ehmUGOIr6rlek/8tWMJd4EyncAFaKQxzcIJvbWGSK7SWlu2INKtH6ARhp+Q7fI0GgHPjP1j8AFfHHvljEhKDHES7zdbt1o8wIyana+4WkSv3EW0IIT/sZhcN5mewvPNZE8T/K/GjBVmlttZervzvDSni1pjac7f3cQkTECpizrdRK7C6u8XPLI/VLXNKcW+EG/MIl1S30sJDb9A8S9PatHRvIE6fqtZrG9h+v/fZKHF5fDjhuClhFXATrfd root@zturn
Fingerprint: sha1!! ec:ae:6c:7d:e0:dc:cd:8f:15:0b:ac:c7:f3:2b:12:1e:28:79:2c:94
dropbear.
Starting rpcbind daemon...done.
starting statd: done
hwclock: can't open '/dev/misc/rtc': No such file or directory
Starting internet superserver: inetd.
NFS daemon support not enabled in kernel
Starting syslogd/klogd: done
Starting tcf-agent: OK

PetaLinux 2022.1_release_S04190222 zturn /dev/ttyPS0

zturn login: petalinux
You are required to change your password immediately (administrator enforced).
New password: 
Retype new password: 
zturn:~$ ls
zturn:~$ mount
/dev/root on / type ext4 (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=505452k,nr_inodes=126363,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
/dev/mmcblk0p1 on /run/media/mmcblk0p1 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
zturn:~$ 
Prev:«

Next: »