天天看点

ZYNQ petalinux系统启动文件固化到FLASH

首先明确:petalinux启动文件从FLASH启动系统,也就是将启动文件放入FLASH中。

1,vivado配置:

ZYNQ petalinux系统启动文件固化到FLASH

2,导入硬件后配置petalinux

  source /opt/Xilinx/Vivado/2017.4/settings64.sh  

  source /opt/pkg/petalinux/settings.sh

  petalinux-create --type project --template zynq --name ax_peta

  petalinux-config --get-hw-description ../linux_base.sdk  (存放  *.hdf文件的地方)  

这里我们仅需要修改两个启动方式选项即可。boot和kernel的存储位置,都选到QSPI Flash即可

Subsystem AUTO Hardware Settings --->

#    Advanced bootable images storage Settings --->

#        boot image settings --->

#            image storage media ---> <*> primary flash

ZYNQ petalinux系统启动文件固化到FLASH
ZYNQ petalinux系统启动文件固化到FLASH

#Subsystem AUTO Hardware Settings --->

#    Advanced bootable images storage Settings --->

#        kernel image settings --->

#            image storage media ---> <*> primary flash

ZYNQ petalinux系统启动文件固化到FLASH
ZYNQ petalinux系统启动文件固化到FLASH

附录:如果板子没有SD卡硬件,就不能通过简单的SD卡烧写boot.bin到flash,必须通过JTAG下载BOOT.bin。

          烧录完成BOOT.bin之后,可以通过JTAG或者串口或者网线tftp烧录image.ub文件到flash。

3,内核配置:    petalinux-config -c kernel     //设置驱动

      配置完成后,ESC并保存。

4,编译petalinux启动文件

       petalinux-build    时间很慢

       petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga --u-boot --force   生成启动文件

       fsbl.elf,download.bit,u-boot.elf  (三个文件用来在SDK中生成BOOT.mcs文件);

       image.ub(petalinux工具生成的image文件,包含kernel,devicetree和ramdisk)

5,将petalinux启动文件烧写到flash中:

方法一:先用SD卡在板子上启动petalinux系统,系统起来后使用指令烧写

(1)flash_eraseall /dev/mtd0    先擦除

         用于存放BOOT.bin  : flashcp BOOT.bin  /dev/mtd0

(2)flash_eraseall /dev/mtd2    先擦除

        用于存放image.ub:flashcp image.ub /dev/mtd2

(3)将拨码开关设置为flash启动,就能看到petalinux在putty启动起来;

方法二:使用 jtag 烧写BOOT.bin,使用SecureCRT 串口烧写image.ub

     (1)    Zynq> sf probe 0 0 0

      SF: Detected n25q128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB

     (2) Zynq> sf erase 0x520000 0xa00000                            //擦除

      SF: 10485760 bytes @ 0x520000 Erased: OK

     (3) Zynq> sf read 10000000 0x520000 0xa00000              //这是清空存放image.ub的flash地址段里面的内容

        device 0 offset 0x520000, size 0xa00000

        SF: 10485760 bytes @ 0x520000 Read: OK

       (4)Zynq> loadx 0x10000000              //xmodem下载image文件到DDR

       //等待ScureCRT传递数据;选择Transfer->SendXmodem->目录对话框中选择image.ub文件,串口波特率115200

ZYNQ petalinux系统启动文件固化到FLASH

     (5)Zynq>  sf write 0x10000000    0x520000   0x00906d5c          (image.ub大概16M,需要持续好几分钟)

     //将DDR中的image拷贝到QSPI flash中,0x10000000 RAM中暂存image起始地址,

     //0x520000 flash中存放image的偏移地址     offset,0x00906d5c   image文件大小(size)

ZYNQ petalinux系统启动文件固化到FLASH

      (6)将拨码开关设置为flash启动,就能看到petalinux在SecureCRT 8.1上启动起来;

方法三:从裸机SDK下载petalinux启动文件

(1)将拨码开关设置为FLASH启动模式,在Xilinx SDK中选择 Xilinx Tools->Program Flash。

Image File选择刚才生成的BOOT.bin文件,Flash Type选择qspi_single,Offset填写0,点击Program按钮。烧录完成后,我们的FSBL,bit,FSBL就下载到QSPI Flash中去了,已经可以实现u-boot的启动了,但是要烧录完uImage后才能引导kernel。

ZYNQ petalinux系统启动文件固化到FLASH

(2)将拨码开关设置为FLASH启动模式,烧录image.ub文件,因为Image file只能选择.bin或者.mcs文件,

       所以需要把image.ub重新命名为image.ub.bin,然后再烧录( Xilinx Tools->Program Flash)

Offset需要填写偏移地址,这个地址可以通过petalinux-config配置,或者可以通过system-config.dtsi文件查看。内容如下:

&qspi {

    #address-cells = <1>;

    #size-cells = <0>;

    flash0: [email protected] {

        compatible = "micron,n25q128";

        reg = <0x0>;

        #address-cells = <1>;

        #size-cells = <1>;

        spi-max-frequency = <50000000>;

        [email protected] {

            label = "boot";

            reg = <0x00000000 0x00500000>;

        };

        [email protected] {

            label = "bootenv";

            reg = <0x00500000 0x00020000>;

        };

        [email protected] {

            label = "kernel";

            reg = <0x00520000 0x00a80000>;

        };

        [email protected] {

            label = "spare";

            reg = <0x00fa0000 0x00000000>;

        };

    };

};

我们kernel的偏移地址是0x00520000,因此Offset就填写这个数值,点击烧录。

由于image.ub.bin总共16M,这个过程有点漫长;

ZYNQ petalinux系统启动文件固化到FLASH
ZYNQ petalinux系统启动文件固化到FLASH

 (3)将拨码开关设置为FLASH启动模式,先关闭再打开电源,可以看到有如下启动打印信息

Board: Xilinx Zynq

DRAM:  ECC disabled 1 GiB

MMC:   Card did not respond to voltage select!

[email protected] - probe failed: -95

sdhci_transfer_data: Error detected in status(0x208000)!

Card did not respond to voltage select!

SF: Detected n25q128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB

*** Warning - bad CRC, using default environment

In:    serial

Out:   serial

Err:   serial

Net:   ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id

Retry time exceeded

Hit any key to stop autoboot:  0

SF: Detected n25q128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB

device 0 offset 0x520000, size 0xa80000

SF: 11010048 bytes @ 0x520000 Read: OK

## Loading kernel from FIT Image at 10000000 ...

   Using '[email protected]' configuration

   Verifying Hash Integrity ... OK

   Trying '[email protected]' kernel subimage

     Description:  Linux Kernel

     Type:         Kernel Image

     Compression:  uncompressed

     Data Start:   0x100000d4

     Data Size:    3750752 Bytes = 3.6 MiB

     Architecture: ARM

     OS:           Linux

     Load Address: 0x00008000

     Entry Point:  0x00008000

     Hash algo:    sha1

     Hash value:   236f44568b2e728df5febdddb42e33470d433b03

   Verifying Hash Integrity ... sha1+ OK

## Loading ramdisk from FIT Image at 10000000 ...

   Using '[email protected]' configuration

   Trying '[email protected]' ramdisk subimage

     Description:  ramdisk

     Type:         RAMDisk Image

     Compression:  uncompressed

     Data Start:   0x103979d8

     Data Size:    5719461 Bytes = 5.5 MiB

     Architecture: ARM

     OS:           Linux

     Load Address: unavailable

     Entry Point:  unavailable

     Hash algo:    sha1

     Hash value:   b02c0cc32ace50d3465f5c9df5772defc10d61b5

   Verifying Hash Integrity ... sha1+ OK

## Loading fdt from FIT Image at 10000000 ...

   Using '[email protected]' configuration

   Trying '[email protected]' fdt subimage

     Description:  Flattened Device Tree blob

     Type:         Flat Device Tree

     Compression:  uncompressed

     Data Start:   0x10393d28

     Data Size:    15360 Bytes = 15 KiB

     Architecture: ARM

     Hash algo:    sha1

     Hash value:   6d55ad512906e1349d09df5bf6f396af7b00f262

   Verifying Hash Integrity ... sha1+ OK

   Booting using the fdt blob at 0x10393d28

   Loading Kernel Image ... OK

   Loading Ramdisk to 07a8b000, end 07fff5a5 ... OK

   Loading Device Tree to 07a84000, end 07a8abff ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

Booting Linux on physical CPU 0x0

Linux version 4.9.0-xilinx ([email protected]) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #1 SMP PREEMPT Tue Mar 24 11:31:00 PDT 2020

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

cma: Reserved 16 MiB at 0x3f000000

Memory policy: Data cache writealloc

percpu: Embedded 14 pages/cpu @ef7d1000 s25932 r8192 d23220 u57344

Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260608

Kernel command line: console=ttyPS0,115200 earlyprintk

PID hash table entries: 4096 (order: 2, 16384 bytes)

Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)

Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)

Memory: 1007268K/1048576K available (6144K kernel code, 200K rwdata, 1464K rodata, 1024K init, 233K bss, 24924K reserved, 16384K cma-reserved, 245760K highmem)

Virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)

    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)

    vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)

    lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)

    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)

    modules : 0xbf000000 - 0xbfe00000   (  14 MB)

      .text : 0xc0008000 - 0xc0700000   (7136 kB)

      .init : 0xc0900000 - 0xc0a00000   (1024 kB)

      .data : 0xc0a00000 - 0xc0a32100   ( 201 kB)

       .bss : 0xc0a32100 - 0xc0a6c8d8   ( 234 kB)

Preemptible hierarchical RCU implementation.

        Build-time adjustment of leaf fanout to 32.

        RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.

RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2

NR_IRQS:16 nr_irqs:16 16

efuse mapped to f0802000

slcr mapped to f0804000

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 f0804100

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 f080c000, 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: 2048 (order: 1, 8192 bytes)

Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)

CPU: Testing write buffer coherency: ok

CPU0: thread -1, cpu 0, socket 0, mpidr 80000000

Setting up static identity map for 0x100000 - 0x100058

CPU1: thread -1, cpu 1, socket 0, mpidr 80000001

Brought up 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

pinctrl core: initialized pinctrl subsystem

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 @ 0xf0880000

zynq-pinctrl 700.pinctrl: zynq pinctrl initialized

e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 25, base_baud = 6249999) is a xuartps

`ttyPS0] enabled

console [ttyPS0] enabled

bootconsole [earlycon0] disabled

bootconsole [earlycon0] disabled

GPIO IRQ not connected

XGpio: /amba_pl/[email protected]: registered, base is 1016

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 <[email protected]>

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: 8192 (order: 3, 32768 bytes)

TCP bind hash table entries: 8192 (order: 4, 65536 bytes)

TCP: Hash tables configured (established 8192 bind 8192)

UDP hash table entries: 512 (order: 2, 16384 bytes)

UDP-Lite hash table entries: 512 (order: 2, 16384 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: 5588K (c7a8b000 - c8000000)

hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available

futex hash table entries: 512 (order: 3, 32768 bytes)

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 noop registered

io scheduler deadline registered

io scheduler cfq registered (default)

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

42c00000.serial: ttyUL1 at MMIO 0x42c00000 (irq = 47, base_baud = 0) is a uartlite

42c10000.serial: ttyUL2 at MMIO 0x42c10000 (irq = 48, base_baud = 0) is a uartlite

xdevcfg f8007000.devcfg: ioremap 0xf8007000 to f0908000

[drm] Initialized

brd: module loaded

loop: module loaded

m25p80 spi0.0: found n25q128a13, expected n25q512a

m25p80 spi0.0: n25q128a13 (16384 Kbytes)

4 ofpart partitions found on MTD device spi0.0

Creating 4 MTD partitions on "spi0.0":

0x000000000000-0x000000500000 : "boot"

0x000000500000-0x000000520000 : "bootenv"

0x000000520000-0x000000fa0000 : "kernel"

0x000000fa0000-0x000001000000 : "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 27 (00:0a:35:00:1e:53)

RTL8211F Gigabit Ethernet e000b000.etherne:00: attached PHY driver [RTL8211F Gigabit Ethernet] (mii_bus:phy_addr=e000b000.etherne:00, irq=-1)

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

mousedev: PS/2 mouse device common for all mice

i2c /dev entries driver

cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at f099e000 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

mmc1: SDHCI controller on e0101000.sdhci [e0101000.sdhci] using ADMA

ledtrig-cpu: registered to indicate activity on CPUs

usbcore: registered new interface driver usbhid

usbhid: USB HID core driver

NET: Registered protocol family 10

sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver

NET: Registered protocol family 17

can: controller area network core (rev 20120528 abi 9)

NET: Registered protocol family 29

can: raw protocol (rev 20120528)

can: broadcast manager protocol (rev 20161123 t)

can: netlink gateway (rev 20130117) 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:

  No soundcards found.

mmc1: new high speed MMC card at address 0001

Freeing unused kernel memory: 1024K (c0900000 - c0a00000)

mmcblk1: mmc1:0001 Q2J55L 7.09 GiB

mmcblk1boot0: mmc1:0001 Q2J55L partition 1 16.0 MiB

INIT: mmcblk1boot1: mmc1:0001 Q2J55L partition 2 16.0 MiB

mmcblk1rpmb: mmc1:0001 Q2J55L partition 3 4.00 MiB

version 2.88 booting mmcblk1: p1

Starting udev

udevd[751]: starting version 3.2

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[752]: starting eudev-3.2

random: udevd: uninitialized urandom read (16 bytes read)

random: fast init done

FAT-fs (mmcblk1p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Populating dev cache

hwclock: can't open '/dev/misc/rtc': No such file or directory

Wed Mar 25 13:58:37 UTC 2020

hwclock: can't open '/dev/misc/rtc': No such file or directory

Starting internet superserver: inetd.

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...

macb e000b000.ethernet eth0: link up (100/Full)

IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

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 AAAAB3NzaC1yc2EAAAADAQABAAABAQCaf2BVkHKXM34bTzf8E837A+HgGdHjrpa6UTaW6tUiHfkeI93HNfqe2FutLUcO+ess8Z1P/LrXibAC4Rh1JyN9VNlw8GYBzuHb+wBTFzAcw6/TZni+L//sIgB6pLEjjtCpqTd+KtIDthdIgmmJ21a8UHdHfHX1/OZOqwy5nUU8/GxU4TadpGcs9fw8zGICg9QVi4GJBQFhZfgoUvyDL7JR895naaGT7/uE6WJnGvIxCNwHuAnitqNKKvKvfurfDOnMho6Ih9n/kb5H5ZyXAvWvyTd8vYpbKqwuXw+CTZU8LBbuuEL6/E5i4ioX8DxVl1LwTx9qRSllOm/Pau4+tPzj [email protected]_peta

Fingerprint: md5 a8:5e:57:97:62:e8:6b:83:8d:69:2c:1d:ac:40:fc:f9

dropbear.

hwclock: can't open '/dev/misc/rtc': No such file or directory

Starting syslogd/klogd: done

Starting tcf-agent: OK

PetaLinux 2017.4 ax_peta /dev/ttyPS0

ax_peta login: