提示:文章完成后,目录可以自动生成,如何生成可以参考右边的帮助文档
ZynqLinux最小系统系列—— 4、Petalinux工程创建、编译、烧写FLASH(二)
- 写在前面
- 接上一篇
- 烧写FLASH
写在前面
ZynqLinux最小系统系列是我现在写的一系列帖子。写这个系列的帖子并不意味着我精通这方面。Linux在驱动方面,我应该还是菜鸟。如果你是一名专家,你可以给我一些建议,或者直接不看。如果你也是一名新手,你不妨看看你在学习过程中是否遇到过同样的问题,这是可以借鉴的。总之,FPGA在专业之外扩展学习总是不会错的,也许有一天会有意想不到的效果。 虽然我以前在工作中做过一点ZynqLinux,但是时间越长,越容易忘记。Petalinux和原生的Linux两个系统的构建将分别描述和记录
接上一篇
这个错误发生在前一篇文章中。我搜索帖子,看看为什么。 并以此为介绍,完成下一步工作,对其配置过程有更深入的了解。
首先,通过一段时间的学习,我了解到配置FLASH启动时,需要对各分区的镜像进行相关配置
输入指令:
petalinux-config --get-hw-description=.
选择以下红色方框的选项
然后弹出以下界面: (1) boot image boot image 就包括了zynq_fsbl.elf、system.bit、u-boot.elf把这些文件的内容放在里面FLASH以前会转化为二进制bin文件,名字叫BOOT.BIN 这个分区的名字叫boot。 这里要设置为保存flash中间,如上图红框。 在这里,我们将大致估计这三个文件转换为二进制文件后的大小,因为空间分配仍然需要分区
- System.bit 本身就是二进制文件,5,980,160 字节(5840KB)
- u-boot.elf为3845KB,但还有一个u_boot.bin,一定是u-boot.elf只有458,752 字节(448KB)
- 还有一个zynq_fsbl.elf为421KB,没有生成对应的bin文件,但通过u-boot.elf推断二进制文件,zynq_fsbl.elf成为二进制文件后,大约50个KB大约50、972字节。
- 5,980,160 458,752 50,972 = 6,489,884字节 = 63071C。这个数字非常接近错误提示的字节数 (2) bootenv 看起来没用,但看别人的帖子说不能删除,总之就是这样设置的 (3) kernel
kernel image就是image.ub把它命名为kernel在分区内。
(4) jffs2 rootfs 这是文件系统,文件系统image名称和分区名称如下 kernel image就是image.ub把它命名为kernel在分区内。
(5) dtb image 暂时按默认设置,设备树没有专门设置分区,但随着以后的学习,我认为以后可能会独立放在一个分区,方便以后更新设备树的操作(暂时认为是这样) 【https://zhuanlan.zhihu.com/p设备树扫盲
2、 接下来具体进行FLASH分区的配置
下一步: 这个是FLASH分区默认情况:
基本和刚才Bootable images storage setting分区的设置能够对应的上。在默认情况下: 第一个0分区的名字是boot,大小是0x500000(字节)
第一分区的名字是bootenv,大小为0x20000(字节) 第二分区的名字是kernel,大小为0xA80000(字节) 默认情况下,这里只有三个分区。根据自身实际情况增加分区,修改大小。 第一分区的大小保持不变 第2分区大小0xA80000(字节) = 11、010、048字节,我们image.ub9,973,760 字节,浪费不多,也不改。
最终设置如下图所示:
Petalinux-build 之后,检查设备树 然后按照上一篇的方法生成BOOT.bin 这里需要改变 好了 ,这次没有报错,正常生成BOOT.bin
烧写FLASH
烧写FLASH需要制定时间fsbl文件。查阅文章最方便的方法是SDK再建一个FSBL并把BootModeRegister 强制改成JTAG_MODE。优点是起动模式的跳线帽可以固定在QSPI FLASH启动方式不需要插入JTAG启动。因为它直接屏蔽了启动模式管脚的检测。
//BootModeRegister = Xil_In32(BOOT_MODE_REG); //BootModeRegister &= BOOT_MODES_MASK; BootModeRegister = JTAG_MODE;
烧写成功了 断电重启后,终端终于打印出预期内容
U-Boot 2020.01 (May 27 2022 - 16:41:23 0000) CPU: Zynq 7z030 Silicon: v3.1 DRAM: ECC disabled 512 MiB Flash: 0 Bytes NAND: 0 MiB MMC: mmc@e0100000: 0 Loading Environment from SPI Flash... SF: Detected n25q256a with page size 256 Bytes, erase size 4 KiB, total 32 MiB *** 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 Warning: ethernet@e000b000 using MAC address from DT eth0: ethernet@e000b00
Hit any key to stop autoboot: 0
SF: Detected n25q256a with page size 256 Bytes, erase size 4 KiB, total 32 MiB
device 0 offset 0xfc0000, size 0x40000
SF: 262144 bytes @ 0xfc0000 Read: OK
QSPI: Trying to boot script at 0x3000000
## Executing script at 03000000
Wrong image format for "source" command
QSPI: SCRIPT FAILED: continuing...
JTAG: Trying to boot script at 0x3000000
## Executing script at 03000000
Wrong image format for "source" command
JTAG: SCRIPT FAILED: continuing...
Card did not respond to voltage select!
MMC Device 1 not found
no mmc device at slot 1
SF: Detected n25q256a with page size 256 Bytes, erase size 4 KiB, total 32 MiB
device 0 offset 0xfc0000, size 0x40000
SF: 262144 bytes @ 0xfc0000 Read: OK
QSPI: Trying to boot script at 0x3000000
## Executing script at 03000000
Wrong image format for "source" command
QSPI: SCRIPT FAILED: continuing...
no devices available
NAND: SCRIPT FAILED: continuing...
NOR: Trying to boot script at 0x3000000
## Executing script at 03000000
Wrong image format for "source" command
NOR: SCRIPT FAILED: continuing...
starting USB...
No working controllers found
USB is stopped. Please issue 'usb start' first.
starting USB...
No working controllers found
USB is stopped. Please issue 'usb start' first.
starting USB...
No working controllers found
ethernet@e000b000 Waiting for PHY auto negotiation to complete.........................................................................................................................ÿ
U-Boot 2018.01 (May 21 2022 - 19:53:10 -0700) Xilinx Zynq ZC702
Board: Xilinx Zynq
Silicon: v3.1
DRAM: ECC disabled 512 MiB
MMC: Card did not respond to voltage select!
mmc_init: -95, time 23
sdhci@e0100000 - probe failed: -95
Card did not respond to voltage select!
mmc_init: -95, time 24
SF: Detected n25q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
*** Warning - bad CRC, using default environment
In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Board: Xilinx Zynq
Silicon: v3.1
Net: ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
eth0: ethernet@e000b000
U-BOOT for petalinux_boot_from_flash
ethernet@e000b000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Hit any key to stop autoboot: 0
Card did not respond to voltage select!
mmc_init: -95, time 23
** Bad device mmc 0 **
no mmc device at slot 0
Zynq> ÿÿ¥
U-Boot 2018.01 (May 28 2022 - 01:41:44 -0700) Xilinx Zynq ZC702
Board: Xilinx Zynq
Silicon: v3.1
DRAM: ECC disabled 512 MiB
MMC: Card did not respond to voltage select!
mmc_init: -95, time 22
sdhci@e0100000 - probe failed: -95
Card did not respond to voltage select!
mmc_init: -95, time 24
SF: Detected n25q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
*** Warning - bad CRC, using default environment
In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Board: Xilinx Zynq
Silicon: v3.1
Net: ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
eth0: ethernet@e000b000
U-BOOT for petalinux_boot_from_flash3
ethernet@e000b000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Hit any key to stop autoboot: 0
SF: Detected n25q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
device 0 offset 0x720000, size 0xa80000
SF: 11010048 bytes @ 0x720000 Read: OK
## 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: gzip compressed
Data Start: 0x10000104
Data Size: 3937945 Bytes = 3.8 MiB
Architecture: ARM
OS: Linux
Load Address: 0x00008000
Entry Point: 0x00008000
Hash algo: sha1
Hash value: fcefa6cc321632d6962cbc3ce957e36185bb1906
Verifying Hash Integrity ... sha1+ OK
## Loading ramdisk from FIT Image at 10000000 ...
Using 'conf@system-top.dtb' configuration
Trying 'ramdisk@1' ramdisk subimage
Description: petalinux-user-image
Type: RAMDisk Image
Compression: gzip compressed
Data Start: 0x103c5258
Data Size: 6016354 Bytes = 5.7 MiB
Architecture: ARM
OS: Linux
Load Address: unavailable
Entry Point: unavailable
Hash algo: sha1
Hash value: 1212ec277a230917f6b1b5e98174f045bb3261e0
Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 10000000 ...
Using 'conf@system-top.dtb' configuration
Trying 'fdt@system-top.dtb' fdt subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x103c18a0
Data Size: 14581 Bytes = 14.2 KiB
Architecture: ARM
Hash algo: sha1
Hash value: b2818abc6461aff7a10b9a2d42288575f40259fe
Verifying Hash Integrity ... sha1+ OK
Booting using the fdt blob at 0x103c18a0
Uncompressing Kernel Image ... OK
Loading Ramdisk to 07a43000, end 07fffd62 ... OK
Loading Device Tree to 07a3c000, end 07a428f4 ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 4.14.0-xilinx-v2018.2 (oe-user@oe-host) (gcc version 7.2.0 (GCC)) #1 SMP PREEMPT Sat May 28 01:37:00 PDT 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
bootconsole [earlycon0] enabled
Memory policy: Data cache writealloc
cma: Reserved 16 MiB at 0x1f000000
percpu: Embedded 16 pages/cpu @debc6000 s34764 r8192 d22580 u65536
Built 1 zonelists, mobility grouping on. Total pages: 130048
Kernel command line: console=ttyPS0,115200 earlyprintk
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 487180K/524288K available (6144K kernel code, 238K rwdata, 1560K rodata, 1024K init, 153K bss, 20724K reserved, 16384K cma-reserved, 0K highmem)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xe0800000 - 0xff800000 ( 496 MB)
lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
.text : 0xc0008000 - 0xc0700000 (7136 kB)
.init : 0xc0900000 - 0xc0a00000 (1024 kB)
.data : 0xc0a00000 - 0xc0a3b900 ( 239 kB)
.bss : 0xc0a3b900 - 0xc0a61e44 ( 154 kB)
Preemptible hierarchical RCU implementation.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
Tasks RCU enabled.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
efuse mapped to e0800000
slcr mapped to e0802000
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
zynq_clock_init: clkc starts at e0802100
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
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
timer #0 at e080a000, irq=17
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: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x100000 - 0x100060
Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
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
random: get_random_u32 called from bucket_table_alloc+0x1c4/0x204 with crng_init=0
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)
pinctrl core: initialized pinctrl subsystem
random: fast init done
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
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 @ 0xe0840000
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
e0000000.serial: ttyPS1 at MMIO 0xe0000000 (irq = 25, base_baud = 6249999) is a xuartps
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 26, base_baud = 6249999) is a xuartps
`¬ʫ½±[ttyPS0] enabled
console [ttyPS0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
ERROR: could not get clock /amba_pl/gpio@41200000:s_axi_aclk(0)
xilinx-gpio 41200000.gpio: Input clock not found
xilinx-gpio: probe of 41200000.gpio failed with error -2
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
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
fpga-region fpga-full: FPGA Region probed
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm_global_timer
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
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.
Trying to unpack rootfs image as initramfs...
Freeing initrd memory: 5876K
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=30 max_order=17 bucket_order=0
jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
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
m25p80 spi0.0: found n25q256a13, expected n25q512a
m25p80 spi0.0: n25q256a13 (32768 Kbytes)
4 ofpart partitions found on MTD device spi0.0
Creating 4 MTD partitions on "spi0.0":
0x000000000000-0x000000700000 : "boot"
0x000000700000-0x000000720000 : "bootenv"
0x000000720000-0x0000011a0000 : "kernel"
0x0000011a0000-0x000002000000 : "spare"
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 28 (00:0a:35:00:1e:53)
Marvell 88E1510 e000b000.ethernet-ffffffff:00: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=POLL)
e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
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
IR NEC protocol handler initialized
IR RC5(x/sz) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR SANYO protocol handler initialized
IR Sharp protocol handler initialized
IR MCE Keyboard/mouse protocol handler initialized
IR XMP protocol handler initialized
cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at e0942000 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
mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
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 (rev 20170425 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20170425)
can: broadcast manager protocol (rev 20170425 t)
can: netlink gateway (rev 20170425) max_hops=1
Registering SWP/SWPB emulation handler
hctosys: unable to open rtc device (rtc0)
of_cfs_init
of_cfs_init: OK
ALSA device list:
Freeing unused kernel memory: 1024K
INIT: version 2.88 booting
Starting udev
udevd[725]: starting version 3.2.2
udevd[726]: starting eudev-3.2.2
hwclock: can't open '/dev/misc/rtc': No such file or directory Sat May 28 08:41:22 UTC 2022 hwclock: can't open '/dev/misc/rtc': No such file or directory
Starting internet superserver: inetd.
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... IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
udhcpc (v1.24.1) started
Sending discover...
Sending discover...
Sending discover...
No lease, forking to background
done.
Starting Dropbear SSH server: Generating key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDpzaCxW43dWhRNBIw9aup9IYE46Xff94w8C3NB/MkIaWUf1ZK6GCGUpX9O/pXLWEI0zJP4rQbtUl5HSOojeekstycBQPHRbi1Q9rIG1GeWMXCpvb5/lF5vFRWvuHid9TCCc+HwGW4laLATg9wWyaZzicIrIHaFPz4Yydgzt7MlDttm7jTITasCAAEu/oenUMeM+Cx8vBZFYNcNiMH8Za/3CNC6zq64GdM/3IccCDYoGvbvV/XYfIKTmMR/2Yv4KgkJLZsyvgcXvhclSsJQZRc7vWbdmahZAiB3D4QYAed/uoc7pRg9TseU+6BM7bJsmV73Q+C9678wL4GCPIsRGciD root@petalinux_boot_from_flash3
Fingerprint: md5 60:a2:0c:dd:7f:14:09:9d:36:18:f9:67:8b:15:16:64
dropbear.
hwclock: can't open '/dev/misc/rtc': No such file or directory
Starting syslogd/klogd: done
Starting tcf-agent: OK
PetaLinux 2018.2 petalinux_boot_from_flash3 /dev/ttyPS0
petalinux_boot_from_flash3 login: root
Password:
root@petalinux_boot_from_flash3:~#
到达这一步,其实我已经折腾了好一段时间了,中间总是Kernel加载不起来,在不断的摸索下发现QSPI FLASH的内存分区,以及分区的设置是关键步骤。
但 这并不是最小系统就完成了,目前还没有一个保存在FLASH的文件系统,也就是说任何操作只要掉电后就不会保存在开发板中了,这肯定是不行的。下一篇准备写下我尝试把文件系统烧写到FLASH中,并遇到瓶颈的过程