Petalinux制作linux系统

版本

PETALINUX_VER=2017.4

这里引用的u-boot,kernel,busybox版本分别是:

u-boot  : U-Boot 2017.01
kernel  : 4.9.0-xilinx-v2017.4
busybox : BusyBox v1.24.1

 

安装

1.安装必要的库

sudo apt-get install tofrodos gawk xvfb git libncurses5-dev tftpd zlib1g-dev zlib1g-dev:i386 \
libssl-dev flex bison chrpath socat autoconf libtool texinfo gcc-multilib \
libsdl1.2-dev libglib2.0-dev screen pax

 

2.安装 Petalinux

sudo -s
mkdir -p /opt/pkg/petalinux
chown flinn /opt/pkg/
chgrp flinn /opt/pkg/
chgrp flinn /opt/pkg/petalinux/
chown flinn /opt/pkg/petalinux/
exit

给安装文件添加运行权限

sudo chmod +x petalinux-v2017.4-final-installer.run
​
./petalinux-v2017.4-final-installer.run /opt/pkg/petalinux/

 

使用 Petalinux 定制 Linux 系统

依赖文件xx.hdf文件

设置 petalinux 环境变量

运行下面命令

source /opt/pkg/petalinux/settings.sh

这个脚本主要工作如下:

#
# Add toolchains to user's search path
#
PATH="${PETALINUX}/tools/linux-i386/aarch64-none-elf/bin:${PETALINUX}/tools/linux-i386/aarch64-linux-gnu/bin:${PATH}"
PATH="${PETALINUX}/tools/linux-i386/gcc-arm-none-eabi/bin:${PETALINUX}/tools/linux-i386/gcc-arm-linux-gnueabi/bin:${PATH}"
PATH="${PETALINUX}/tools/linux-i386/microblaze-xilinx-elf/bin:${PETALINUX}/tools/linux-i386/microblazeel-xilinx-linux-gnu/bin:${PATH}"
PATH="${PETALINUX}/tools/linux-i386/gcc-arm-none-eabi-r5/bin:${PATH}"
#
# Add required binary tools to the user's search path
#
PATH="${PETALINUX}/tools/linux-i386/petalinux/bin:${PETALINUX}/tools/common/petalinux/bin:${PATH}"

即指定gcc,并添加到环境变量里面

运行下面命令设置 vivado 环境变量

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

在这个脚本全部内容如下:

source /opt/Xilinx/Vivado/2017.4/.settings64-Vivado.sh
source /opt/Xilinx/SDK/2017.4/.settings64-SDK_Core_Tools.sh
source /opt/Xilinx/DocNav/.settings64-DocNav.sh

 

创建工程

petalinux-create --type project --template zynq --name peta_top
cd peta_top

 

配置 Petalinux 工程的硬件信息

petalinux-config --get-hw-description ../xx.sdk

 

配置 petalinux 工程

如果配置过后想再次配置,可以运行命令“petalinux-config”来配置。

配置 uboot 和 Linux 内核的来源

默认是 github

配置启动方式

在 Advanced bootable images storage Settings 选项中

默认从 sd 卡启动,为 了调试这里保持默认从 sd 卡启动,如果需要制作一个从 QSPI flash 启动的嵌入式 Linux, 可以在这里配置

以上配置主要针对u-boot的,详细可以参考最后章节‘附录’

配置 Linux 内核

petalinux-config -c kernel

 

配置根文件系统

petalinux-config -c rootfs

 

编译

使用下面命令配置编译 uboot、内核、根文件系统、设备树等

petalinux-build

 

生成 BOOT 文件

petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga --u-boot --force

 

烧写

images/linux 目录中的 BOOT.BIN 和 image.ub 复制到 sd 卡 ,从sd卡启动

使用 root 登录,默认密码 root,插上网线后(路由器支持自动获取 IP),使用 ifconfig 命 令可以看到网络状态

日志

最后启动日志:

U-Boot 2017.01 (Apr 30 2019 - 21:07:27 +0800)
​
Board: Xilinx Zynq
I2C:   ready
DRAM:  ECC disabled 512 MiB
MMC:   sdhci@e0100000: 0 (SD)
SF: Detected w25q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
*** Warning - bad CRC, using default environment
​
In:    serial
Out:   serial
Err:   serial
Net:   ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
eth0: ethernet@e000b000
U-BOOT for ax_peta
​
ethernet@e000b000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Hit any key to stop autoboot:  0 
Device: sdhci@e0100000
Manufacturer ID: 41
OEM: 3432
Name: SD16G 
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.6 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading image.ub
9491516 bytes read in 547 ms (16.5 MiB/s)
## Loading kernel from FIT Image at 10000000 ...
   Using 'conf@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@0' kernel subimage
     Description:  Linux Kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x100000d4
     Data Size:    3747280 Bytes = 3.6 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00008000
     Entry Point:  0x00008000
     Hash algo:    sha1
     Hash value:   a82d79b6213239ca724e394a992c8e19a298c5dc
   Verifying Hash Integrity ... sha1+ OK
## Loading ramdisk from FIT Image at 10000000 ...
   Using 'conf@1' configuration
   Trying 'ramdisk@0' ramdisk subimage
     Description:  ramdisk
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0x1039799c
     Data Size:    5723824 Bytes = 5.5 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: unavailable
     Entry Point:  unavailable
     Hash algo:    sha1
     Hash value:   c209b90efb5039d9c37d2e8501490190895cb54b
   Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 10000000 ...
   Using 'conf@1' configuration
   Trying 'fdt@0' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x10392f98
     Data Size:    18769 Bytes = 18.3 KiB
     Architecture: ARM
     Hash algo:    sha1
     Hash value:   d06aaa8ecccde42cc6ea78eae5decb442e290ad0
   Verifying Hash Integrity ... sha1+ OK
   Booting using the fdt blob at 0x10392f98
   Loading Kernel Image ... OK
   Loading Ramdisk to 07a8a000, end 07fff6b0 ... OK
   Loading Device Tree to 07a82000, end 07a89950 ... OK
​
Starting kernel ...
​
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 4.9.0-xilinx-v2017.4 (flinn@flinn) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #1 SMP PREEMPT Tue Apr 30 21:12:48 CST 2019
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 0x1f000000
Memory policy: Data cache writealloc
percpu: Embedded 14 pages/cpu @debc8000 s25932 r8192 d23220 u57344
Built 1 zonelists in Zone order, 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: 487428K/524288K available (6144K kernel code, 200K rwdata, 1460K rodata, 1024K init, 229K bss, 20476K 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 - 0xc0a32000   ( 200 kB)
       .bss : 0xc0a32000 - 0xc0a6b698   ( 230 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 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 - 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 @ 0xe0840000
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 27, base_baud = 6249999) is a xuartps
`¬ʫ½±[ttyPS0] enabled
console [ttyPS0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
GPIO IRQ not connected
XGpio: /amba_pl/gpio@41200000: registered, base is 1020
GPIO IRQ not connected
XGpio: /amba_pl/gpio@41210000: 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 <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: 5592K (c7a8a000 - 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=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)
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
xilinx-vdma 43000000.dma: Xilinx AXI VDMA Engine Driver Probed!!
xdevcfg f8007000.devcfg: ioremap 0xf8007000 to e081c000
[drm] Initialized
brd: module loaded
loop: module loaded
m25p80 spi0.0: found w25q256, expected n25q512a
m25p80 spi0.0: failed to read ear reg
m25p80 spi0.0: w25q256 (32768 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-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 29 (00:0a:35:00:1e:53)
RTL8211E Gigabit Ethernet e000b000.etherne:00: attached PHY driver [RTL8211E 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-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 23
cdns-i2c e0005000.i2c: 400 kHz mmio e0005000 irq 24
xilinx-vtc: probe of 43c10000.v_tc failed with error -2
cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at e088e000 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
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:
Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
INIT: mmc0: Problem switching card into high-speed mode!
mmc0: new SDHC card at address 0001
mmcblk0: mmc0:0001 SD16G 14.6 GiB 
 mmcblk0: p1 p2
version 2.88 booting
Starting udev
udevd[742]: 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[743]: starting eudev-3.2
random: udevd: uninitialized urandom read (16 bytes read)
random: fast init done
EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
FAT-fs (mmcblk0p1): 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
Tue Apr 30 13:14:19 UTC 2019
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...
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 AAAAB3NzaC1yc2EAAAADAQABAAABAQCFTEshGp/SIVuB0s6bIkurt1WmmLq+Uc1vIIa3hTnMctklQnR5xWs9XV/+vpzKSmgt7qyvxA6l2T1WiqpMy/ZnLtL8UBQtmMcckhfSshQuPZH3VGJKPhk7wySzg6FDFC672h8Y30ULvosbqIHXpQjsBUmNGAFa0+0FO2D2k/Na+LkQDKTqWzGJrrHi8vuXayDKAK1lF9IkqyLmRdfy37l9HtHZaUQevz3L/M3xaYEBwKs/UyCP5fPNrWRFLIrUhKzRIsrHndrA5261Vlns/kHo+0G9F5s8QKY9+SqbNXoMvz9N9WlmpM2q+m6ucTFl2w9CMT5ohvupx4M9p4Rd66bx root@ax_peta
Fingerprint: md5 f7:e8:df:05:5b:e9:7e:eb:1d:d9:24:58:49:b9:50:ca
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: root
Password: 
root@ax_peta:~# 
​

附录

--- Subsystem AUTO Hardware Settings      
    System Processor (ps7_cortexa9_0)  --->  
        (X) ps7_cortexa9_0  
    Memory Settings  ---> 
        Primary Memory (ps7_ddr_0)  --->
        (0x0) System memory base address 
        (0x20000000) System memory size (NEW)
        (0x0) kernel base address            
        (0x400000) u-boot text base address offset to memory base address
    Serial Settings  --->                  
        Primary stdin/stdout (ps7_uart_1)  --->
        System stdin/stdout baudrate (115200)  --->
    Ethernet Settings  --->                      
        Primary Ethernet (ps7_ethernet_0)  --->    
        [ ] Randomise MAC address                  
        (00:0a:35:00:1e:53) Ethernet MAC address   
        [*] Obtain IP address automatically
    Flash Settings  --->                 
        Primary Flash (ps7_qspi_0)  --->   
        [ ] Advanced Flash Auto Configuration
        *** partition 0 ***              
            (boot) name                          
            (0x500000) size                      
        *** partition 1 ***              
            (bootenv) name                       
            (0x20000) size                       
        *** partition 2 ***              
            (kernel) name                        
            (0xA80000) size              
        *** partition 3 ***          
            (spare) name                     
            (0x0) size                       
        *** partition 4 ***          
        ()  name  
    SD/SDIO Settings  --->             
        Primary SD/SDIO (ps7_sd_0)  ---> 
    RTC Settings  --->                 
    Advanced bootable images storage Settings  --->
        boot image settings  --->         
        image storage media (primary sd)  --->   
            BOOT.BIN) image name             
        u-boot env partition settings  --->       
            image storage media (primary flash)  --->       
            (bootenv) flash partition name      
        kernel image settings  --->     
            image storage media (primary sd)  --->               
            (image.ub) image name               
        jffs2 rootfs image settings  --->   
            image storage media (primary flash)  ---> 
            (jffs2) flash partition name              
            (rootfs.jffs2) image name           
        dtb image settings  --->
            image storage media (from boot image)  ---> 
            (system.dtb) image name 

其他

bootargs

[*] generate boot args automatically                                           
    [*] enable kernel earlyprintk                                              
        (console=ttyPS0,115200 earlyprintk) Auto generated bootargs (NO EDIT!) 

(template) MACHINE_NAME

u-boot configure

    U-boot config (PetaLinux u-boot config)  --->       
        (zynq_zc702_config) u-boot config target           
            (0x10000000) netboot offset                                                           
            (AUTO) TFTP Server IP address

Image Packaging Configuration

   Root filesystem type (INITRAMFS)  --->                                      
    (image.ub) name for bootable kernel image                                          
    (0x1000) DTB padding size                                                          
    [*] Copy final images to tftpboot                                                    
    (/tftpboot) tftpboot directory 

Firmware Version Configuration --->

(peta_top) Host name                                                           
    (peta_top) Product name                                                    
    (1.00) Firmware Version

Yocto Settings --->

    TMPDIR Location  --->                                                          
    Parallel thread execution  --->                                                
    Add pre-mirror url   --->                                                   
    Local sstate feeds settings  --->                                           
    [ ] Enable Debug Tweaks (NEW)                                                  
    [*] Enable Network sstate feeds (NEW)                                             
         Network sstate feeds URL  --->                                        
        [ ] Enable BB NO NETWORK (NEW)                           
        User Layers  ---> 
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页