前回1、Zybo-Z7-20用にLinuxをビルドしたが、apt
等で楽をしたいのでUbuntu 20.04 LTSをZyboに載せた。
その作業ログである。
環境
項目 | 概要 |
---|---|
OS | Windows 10 Enterprise 1909 |
Vivado (on Windows) ※今回は使ってない | 2021.1 |
Virtual Box | 6.1.26 |
PetaLinux | 2021.1 |
Board | Zybo z7-20 |
SDカード作成
gpartedを使って起動用パーティションをfat32、rootfs用パーティションをext4に区切る。
image.ub作成
今回も前回同様、PetaLinuxを使ってやっていく。
ディレクトリ構造は下記構成で行った。
~ ━ build_ws ━ design_1_wrapper.xsa
cd ~/build_ws
petalinux-create -t project --template zynq -n linux_build_test # ビルドプロジェクト作成
cd linux_build_test
petalinux-config --get-hw-description=../design_1_wrapper.xsa # 設定
前回はデフォルトのまま[Exit]したが、今回はrootfsをUbuntuにするのでその辺りを変更する。
[Image Packaging Configuration]>[Root filesystem type]を[EXT4]に変更。
他記事でデバイスツリーに記述されるbootargsを変更してrootfsの読み出し場所を変えているものがあるが、この変更によりPetaLinuxがその辺りも変更してくれる。
これで作成されるimage.ubにはrootfsは含まれず、カーネルであるuImage(ダンプして見たらzImageでした)とデバイスツリーだけになる。
これをビルドし、起動に必要なファイルを第一パーティションにコピーする。起動部分は終わり。
petalinux-build
cd images/linux/
cp image.ub BOOT.bin boot.scr [path-to-first-partition]
rootfs作成
debootstrapを使用し、Ubuntu 20.04 LTSのrootfsを第2パーティションに書き込む
sudo apt install qemu-user-static debootstrap
lsblk
# 出力
sde 8:64 1 7.4G 0 disk
├─sde1 8:65 1 128M 0 part /media/[usr_name]/hoge
└─sde2 8:66 1 7.3G 0 part /media/[usr_name]/fuga
# 出力終わり。sde2がext4で確保した第2パーティションだと分かる。
sudo mount -o loop /dev/sde2 /mnt # 第2パーティションを/mntにマウント
sudo debootstrap --foreign --arch armhf focal /mnt http://ports.ubuntu.com/ # rootfs作成。focalの部分がUbuntu 20.04を示す。
sudo cp /usr/bin/qemu-arm-static /mnt/usr/bin/ # エミュレータをコピー
sudo chroot /mnt # SDカード内へ
# 以下、SDカード上
./debootstrap/debootstrap --second-stage
passwd # パスワード設定
su
adduser [name] # ユーザ追加
exit # root抜ける
exit # chroot抜ける
これでSDカードは完成。
起動
microSDをZyboに差し込み、JP5がSDブートの位置になっていることを確認して電源スイッチを入れる。
起動後、有線ネットワークが使えない等の問題があるが、DHCP等の設定をしてやると出来る2。
体感としてはPetaLinux環境が既にあり、ハードウェアも組んであるなら、FSBLをVitisで作ったりデバイスツリーをビルドするよりPetaLinux使う方が楽なのかもしれない。
最後に起動メッセージを載せてこの記事を終わる。
U-Boot 2021.01 (Jun 01 2021 - 11:54:06 +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
2595 bytes read in 17 ms (148.4 KiB/s)
## Executing script at 03000000
Trying to load boot images from mmc0
4609712 bytes read in 814 ms (5.4 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: 4589000 Bytes = 4.4 MiB
Architecture: ARM
OS: Linux
Load Address: 0x00200000
Entry Point: 0x00200000
Hash algo: sha256
Hash value: 219a17c8486701a0713405c927be2ecc9aa60c29effb1d4a82b879d187cc16e4
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: 0x104607cc
Data Size: 18815 Bytes = 18.4 KiB
Architecture: ARM
Hash algo: sha256
Hash value: c8b0a0e0a1afae1795e0e04398c1a1ec1b622d7888315c3c82347c496939d6a0
Verifying Hash Integrity ... sha256+ OK
Booting using the fdt blob at 0x104607cc
Loading Kernel Image
Loading Device Tree to 2fff8000, end 2ffff97e ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 5.10.0-xilinx-v2021.1 (oe-user@oe-host) (arm-xilinx-linux-gnueabi-gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Fri Jun 4 15:57:16 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
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 15 pages/cpu s32332 r8192 d20916 u61440
Built 1 zonelists, mobility grouping on. Total pages: 260416
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: 1009796K/1048576K available (7168K kernel code, 269K rwdata, 1868K rodata, 1024K init, 161K bss, 22396K 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+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)
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 32, 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 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) c 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 34 (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-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=47
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
mmc0: SDHCI controller on e0100000.mmc [e0100000.mmc] using ADMA
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 0007
mmcblk0: mmc0:0007 SD8GB 7.42 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
random: fast init done
systemd[1]: System time before build time, advancing clock.
systemd[1]: Failed to look up module alias 'autofs4': Function not implemented
systemd[1]: systemd 245.4-4ubuntu3 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid)
systemd[1]: Detected architecture arm.
Welcome to Ubuntu 20.04 LTS!
systemd[1]: Set hostname to <[myname]-VirtualBox>.
systemd[1]: /lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
random: systemd: uninitialized urandom read (16 bytes read)
systemd[1]: system-modprobe.slice: unit configures an IP firewall, but the local system does not support BPF/cgroup firewalling.
systemd[1]: (This warning is only shown for the first unit using IP firewalling.)
systemd[1]: Created slice system-modprobe.slice.
[ OK ] Created slice system-modprobe.slice.
random: systemd: uninitialized urandom read (16 bytes read)
systemd[1]: Created slice system-serial\x2dgetty.slice.
[ OK ] Created slice system-serial\x2dgetty.slice.
random: systemd: uninitialized urandom read (16 bytes read)
systemd[1]: Created slice User and Session Slice.
[ OK ] Created slice User and Session Slice.
systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[ OK ] Started Dispatch Password …ts to Console Directory Watch.
systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[ OK ] Started Forward Password R…uests to Wall Directory Watch.
systemd[1]: Condition check resulted in Arbitrary Executable File Formats File System Automount Point being skipped.
systemd[1]: Reached target Local Encrypted Volumes.
[ OK ] Reached target Local Encrypted Volumes.
systemd[1]: Reached target Paths.
[ OK ] Reached target Paths.
systemd[1]: Reached target Remote File Systems.
[ OK ] Reached target Remote File Systems.
systemd[1]: Reached target Slices.
[ OK ] Reached target Slices.
systemd[1]: Reached target Swap.
[ OK ] Reached target Swap.
systemd[1]: Listening on Syslog Socket.
[ OK ] Listening on Syslog Socket.
systemd[1]: Listening on initctl Compatibility Named Pipe.
[ OK ] Listening on initctl Compatibility Named Pipe.
systemd[1]: Condition check resulted in Journal Audit Socket being skipped.
systemd[1]: Listening on Journal Socket (/dev/log).
[ OK ] Listening on Journal Socket (/dev/log).
systemd[1]: Listening on Journal Socket.
[ OK ] Listening on Journal Socket.
systemd[1]: Listening on udev Control Socket.
[ OK ] Listening on udev Control Socket.
systemd[1]: Listening on udev Kernel Socket.
[ OK ] Listening on udev Kernel Socket.
systemd[1]: Condition check resulted in Huge Pages File System being skipped.
systemd[1]: Condition check resulted in POSIX Message Queue File System being skipped.
systemd[1]: Condition check resulted in Kernel Debug File System being skipped.
systemd[1]: Condition check resulted in Kernel Trace File System being skipped.
systemd[1]: Starting Journal Service...
Starting Journal Service...
systemd[1]: Starting Set the console keyboard layout...
Starting Set the console keyboard layout...
systemd[1]: Condition check resulted in Create list of static device nodes for the current kernel being skipped.
systemd[1]: Condition check resulted in Load Kernel Module drm being skipped.
systemd[1]: Condition check resulted in Set Up Additional Binary Formats being skipped.
systemd[1]: Starting Load Kernel Modules...
Starting Load Kernel Modules...
systemd[1]: Starting Remount Root and Kernel File Systems...
Starting Remount Root and Kernel File Systems...
systemd[1]: Starting udev Coldplug all Devices...
Starting udev Coldplug all Devices...
systemd[1]: Finished Load Kernel Modules.
[ OK ] Finished Load Kernel Modules.
systemd[1]: Finished Remount Root and Kernel File Systems.
[ OK ] Finished Remount Root and Kernel File Systems.
systemd[1]: Condition check resulted in FUSE Control File System being skipped.
systemd[1]: Mounting Kernel Configuration File System...
Mounting Kernel Configuration File System...
systemd[1]: Condition check resulted in Rebuild Hardware Database being skipped.
systemd[1]: Condition check resulted in Platform Persistent Storage Archival being skipped.
systemd[1]: Starting Load/Save Random Seed...
Starting Load/Save Random Seed...
systemd[1]: Starting Apply Kernel Variables...
Starting Apply Kernel Variables...
systemd[1]: Starting Create System Users...
Starting Create System Users...
systemd[1]: Mounted Kernel Configuration File System.
[ OK ] Mounted Kernel Configuration File System.
[ OK ] Finished Apply Kernel Variables.
[ OK ] Finished Create System Users.
[ OK ] Started Journal Service.
Starting Flush Journal to Persistent Storage...
Starting Create Static Device Nodes in /dev...
[ OK ] Finished Set the console keyboard layout.
[ OK ] Finished Create Static Device Nodes in /dev.
[ OK ] Finished udev Coldplug all Devices.
[ OK ] Reached target Local File Systems (Pre).
[ OK ] Reached target Local File Systems.
Starting Set console font and keymap...
Starting udev Kernel Device Manager...
[ OK ] Finished Set console font and keymap.
[ OK ] Finished Flush Journal to Persistent Storage.
Starting Create Volatile Files and Directories...
[ OK ] Started udev Kernel Device Manager.
Starting Network Service...
[ OK ] Finished Create Volatile Files and Directories.
Starting Network Time Synchronization...
Starting Update UTMP about System Boot/Shutdown...
[ OK ] Finished Update UTMP about System Boot/Shutdown.
[ OK ] Found device /dev/ttyPS0.
[ OK ] Started Network Service.
Starting Network Name Resolution...
[ OK ] Started Network Time Synchronization.
[ OK ] Reached target System Initialization.
[ OK ] Started Daily Cleanup of Temporary Directories.
[ OK ] Reached target System Time Set.
[ OK ] Reached target System Time Synchronized.
[ OK ] Started Daily apt download activities.
[ OK ] Started Daily apt upgrade and clean activities.
[ OK ] Started Periodic ext4 Onli…ata Check for All Filesystems.
[ OK ] Started Discard unused blocks once a week.
[ OK ] Started Daily rotation of log files.
[ OK ] Started Message of the Day.
[ OK ] Reached target Timers.
[ OK ] Listening on D-Bus System Message Bus Socket.
[ OK ] Reached target Sockets.
[ OK ] Reached target Basic System.
[ OK ] Started Regular background program processing daemon.
[ OK ] Started D-Bus System Message Bus.
[ OK ] Started Save initial kernel messages after boot.
Starting Remove Stale Onli…t4 Metadata Check Snapshots...
Starting Dispatcher daemon for systemd-networkd...
[ OK ] Started Set the CPU Frequency Scaling governor.
Starting System Logging Service...
Starting Login Service...
[ OK ] Finished Load/Save Random Seed.
[ OK ] Started System Logging Service.
[ OK ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[ OK ] Started Network Name Resolution.
[ OK ] Reached target Network.
[ OK ] Reached target Host and Network Name Lookups.
Starting Permit User Sessions...
[ OK ] Finished Permit User Sessions.
[ OK ] Started Serial Getty on ttyPS0.
Starting Set console scheme...
[ OK ] Finished Set console scheme.
[ OK ] Started Login Service.
[ OK ] Created slice system-getty.slice.
[ OK ] Started Getty on tty1.
[ OK ] Reached target Login Prompts.
[ OK ] Started Dispatcher daemon for systemd-networkd.
[ OK ] Reached target Multi-User System.
[ OK ] Reached target Graphical Interface.
Starting Update UTMP about System Runlevel Changes...
[ OK ] Finished Update UTMP about System Runlevel Changes.
Ubuntu 20.04 LTS [myname]-VirtualBox ttyPS0
[myname]-VirtualBox login: