如何配置petalinux使用本地kernel、u-boot、rootfs
文章目录1. 配置petalinux工程1.1 导入vivado的hdf文件1.2 配置源码来源1.3 配置根文件系统类型为SD CARD2.配置设备树3. 编译petalinux工程4. 制作SD卡4.1 设置SD卡分区为2个4.2 格式化SD卡4.3 分区挂载4.4 将目标文件拷贝至两个分区1. 配置petalinux工程1.1 导入vivado的hdf文件1.2 配置源码来源将特定源码拷贝至
·
文章目录
1. 配置petalinux工程
1.1 导入vivado的hdf文件
- 进入工程目录后:
petalinux-config --get-hw-description ../../hdf/Navigator_7020.sdk/
1.2 配置源码来源
- 将特定源码拷贝至Ubuntu中,借助petalinux的petalinux-config令打开图形化界面命配置u-boot来源
- 同理配置内核来源
1.3 配置根文件系统类型为SD CARD
- 借助petalinux的petalinux-config令打开图形化界面命配置根文件系统类型为SD CARD
2.配置设备树
- 下面目录下存储了设备树的配置信息,存储在system-user.dtsi文件中
~/petalinux/ALIENTEK-ZYNQ/project-spec/meta-user/recipes-bsp/device-tree/files
- 设备树文件实例:
/include/ "system-conf.dtsi"
#include <dt-bindings/gpio/gpio.h>
/ {
model = "Alientek Navigator Zynq Development Board";
compatible = "xlnx,zynq-zc702", "xlnx,zynq-7000";
aliases {
ethernet0 = &gem0;
ethernet1 = &gem1;
i2c0 = &i2c0;
i2c1 = &i2c1;
i2c2 = &i2c2;
serial0 = &uart0;
serial1 = &uart1;
spi0 = &qspi;
mmc0 = &sdhci0;
mmc1 = &sdhci1;
usb0 = &usb0;
gpio0 = &gpio0;
gpio1 = &gpio1;
};
leds {
compatible = "gpio-leds";
gpio-led1 {
label = "led1";
gpios = <&gpio0 54 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
};
gpio-led2 {
label = "pl_led0";
gpios = <&gpio0 55 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
gpio-led3 {
label = "pl_led1";
gpios = <&gpio0 56 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
gpio-led4 {
label = "ps_led0";
gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
gpio-led5 {
label = "ps_led1";
gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
gpio-led6 {
label = "led2";
gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
};
keys {
compatible = "gpio-keys";
autorepeat;
gpio-key1 {
label = "pl_key1";
gpios = <&gpio0 57 GPIO_ACTIVE_LOW>;
linux,code = <105>; // Right
debounce-interval = <20>; // 20ms
};
gpio-key2 {
label = "pl_key2";
gpios = <&gpio0 58 GPIO_ACTIVE_LOW>;
linux,code = <106>; // Left
debounce-interval = <20>;
};
gpio-key3 {
label = "ps_key1";
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
linux,code = <103>; // Up
debounce-interval = <20>;
};
gpio-key4 {
label = "ps_key2";
gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
linux,code = <108>; // Down
debounce-interval = <20>;
};
touch-key {
label = "touch_key";
gpios = <&gpio0 59 GPIO_ACTIVE_HIGH>;
linux,code = <28>; // ENTER
gpio-key,wakeup;
debounce-interval = <20>;
};
};
beep {
compatible = "gpio-beeper";
gpios = <&gpio0 60 GPIO_ACTIVE_HIGH>;
};
usb_phy0: phy0@e0002000 {
compatible = "ulpi-phy";
#phy-cells = <0>;
reg = <0xe0002000 0x1000>;
view-port = <0x0170>;
drv-vbus;
};
#if 0
backlight_lcd: backlight {
compatible = "pwm-backlight";
pwms = <&pwm_0 0 5000000>;
brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>;
default-brightness-level = <10>;
};
#endif
};
&qspi {
u-boot,dm-pre-reloc;
};
&flash0 {
compatible = "w25q256";
};
&watchdog0 {
reset-on-timeout; // Enable watchdog reset function
};
&pwm_0 {
compatible = "digilent,axi-pwm";
#pwm-cells = <2>;
clock-names = "pwm";
npwm = <1>;
};
&gem0 {
phy-handle = <ðernet_phy>;
local-mac-address = [00 0a 35 00 1e 53];
ethernet_phy: ethernet-phy@1 { /* rtl8211e */
reg = <0x1>;
device_type = "ethernet-phy";
};
};
&gem1 {
local-mac-address = [00 0a 35 00 11 55];
phy-reset-gpio = <&gpio0 66 GPIO_ACTIVE_LOW>;
phy-reset-active-low;
};
&phy0 {
reg = <0x19>; /* B50610 phy address */
};
&sdhci0 {
u-boot,dm-pre-reloc;
};
&uart0 {
u-boot,dm-pre-reloc;
};
&adc {
status = "okay";
xlnx,channels {
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
};
};
};
&i2c0 {
clock-frequency = <100000>;
eeprom@50 {
compatible = "24c64";
reg = <0x50>;
pagesize = <32>;
};
rtc@51 {
compatible = "nxp,pcf8563";
reg = <0x51>;
};
codec: wm8960@1a {
compatible = "wlf,wm8960";
reg = <0x1a>;
#sound-dai-cells = <0>;
wlf,shared-lrclk;
};
};
&i2c1 {
clock-frequency = <100000>;
edt-ft5x06@38 {
compatible = "edt,edt-ft5426";
reg = <0x38>;
interrupt-parent = <&gpio0>;
interrupts = <63 0x2>;
reset-gpio = <&gpio0 62 GPIO_ACTIVE_LOW>;
interrupt-gpio = <&gpio0 63 GPIO_ACTIVE_LOW>;
};
goodix_ts@5d {
compatible = "goodix,gt9xx";
status = "okay";
//reg = <0x5d>;
reg = <0x14>;
interrupt-parent = <&gpio0>;
interrupts = <63 0>;
reset-gpio = <&gpio0 62 GPIO_ACTIVE_LOW>;
interrupt-gpio = <&gpio0 63 GPIO_ACTIVE_LOW>;
};
};
&i2c2 {
clock-frequency = <100000>;
ov5640@3c {
compatible = "ovti,ov5640";
reg = <0x3c>;
pwn-gpios = <&gpio0 64 GPIO_ACTIVE_LOW>;
rst-gpios = <&gpio0 65 GPIO_ACTIVE_LOW>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
ov5640_ep: endpoint {
remote-endpoint = <&xlnx_vcap>;
};
};
};
};
&usb0 {
dr_mode = "otg";
usb-phy = <&usb_phy0>;
};
/* RGB LCD */
&lcd_vtc {
compatible = "xlnx,v-tc-5.01.a";
};
&lcd_vdma {
dma-ranges = <0x00000000 0x00000000 0x40000000>; // 1GB
};
/* HDMI */
&hdmi_vtc {
clocks = <&hdmi_dynclk>, <&clkc 15>;
compatible = "xlnx,v-tc-5.01.a";
};
&hdmi_dynclk {
compatible = "digilent,axi-dynclk";
#clock-cells = <0>;
};
&hdmi_vdma {
dma-ranges = <0x00000000 0x00000000 0x40000000>; // 1GB
};
&audio_formatter {
xlnx,tx = <&i2s_transmitter>;
xlnx,rx = <&i2s_receiver>;
audio-codec = <&codec>;
};
&i2s_receiver {
xlnx,snd-pcm = <&audio_formatter>;
};
&i2s_transmitter {
xlnx,snd-pcm = <&audio_formatter>;
};
&amba_pl {
xlnx_vdmafb_lcd {
compatible = "xilinx,vdmafb";
status = "okay";
vtc = <&lcd_vtc>;
clocks = <&clk_wiz_0 0>;
clock-names = "lcd_pclk";
dmas = <&lcd_vdma 0>;
dma-names = "lcd_vdma";
pwms = <&pwm_0 0 5000000>;
reset-gpio = <&gpio0 61 GPIO_ACTIVE_LOW>;
lcdID-gpio = <&gpio1 0 0 GPIO_ACTIVE_LOW &gpio1 1 0 GPIO_ACTIVE_LOW &gpio1 2 0 GPIO_ACTIVE_LOW>;
display-timings {
timing_4342: timing0 {
clock-frequency = <9000000>;
hactive = <480>;
vactive = <272>;
hback-porch = <40>;
hfront-porch = <5>;
hsync-len = <1>;
vback-porch = <8>;
vfront-porch = <8>;
vsync-len = <1>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
timing_4384: timing1 {
clock-frequency = <31000000>;
hactive = <800>;
vactive = <480>;
hback-porch = <88>;
hfront-porch = <40>;
hsync-len = <48>;
vback-porch = <32>;
vfront-porch = <13>;
vsync-len = <3>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
timing_7084: timing2 {
clock-frequency = <33300000>;
hactive = <800>;
vactive = <480>;
hback-porch = <46>;
hfront-porch = <210>;
hsync-len = <1>;
vback-porch = <23>;
vfront-porch = <22>;
vsync-len = <1>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
timing_7016: timing3 {
clock-frequency = <51200000>;
hactive = <1024>;
vactive = <600>;
hback-porch = <140>;
hfront-porch = <160>;
hsync-len = <20>;
vback-porch = <20>;
vfront-porch = <12>;
vsync-len = <3>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
timing_1018: timing4 {
clock-frequency = <71100000>;
hactive = <1280>;
vactive = <800>;
hback-porch = <80>;
hfront-porch = <70>;
hsync-len = <10>;
vback-porch = <10>;
vfront-porch = <10>;
vsync-len = <3>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
};
};
xlnx_vdmafb_hdmi {
compatible = "xilinx,vdmafb";
status = "okay";
vtc = <&hdmi_vtc>;
clocks = <&hdmi_dynclk>;
clock-names = "lcd_pclk";
dmas = <&hdmi_vdma 0>;
dma-names = "lcd_vdma";
hdmi;
display-timings {
timing_1080p: timing5 {
clock-frequency = <148500000>;
hactive = <1920>;
vactive = <1080>;
hback-porch = <148>;
hsync-len = <44>;
hfront-porch = <88>;
vback-porch = <36>;
vsync-len = <5>;
vfront-porch = <4>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <1>;
};
};
};
xlnx_vipp {
compatible = "xlnx,video";
dmas = <&lcd_vdma 1>;
dma-names = "port0";
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
direction = "input";
xlnx_vcap: endpoint {
remote-endpoint = <&ov5640_ep>;
};
};
};
};
};
3. 编译petalinux工程
- 返回工程的根目录,使用petalinux-build进行全编译
- 打包生成BOOT.BIN文件和image.ub文件
petalinux-package --boot --fsbl --fpga --u-boot --force
# 若后面不跟路径则自动在所在工程目录下寻找可用的文件,执行完毕后打印输出所用文件
4. 制作SD卡
4.1 设置SD卡分区为2个
#插入SD卡至PC
#由于之前制作的SD卡中没有包含文件系统,因此需要重新制作
ar@ar:~/petalinux/ALIENTEK-ZYNQ$ df -h #查看挂载的SD卡
文件系统 容量 已用 可用 已用% 挂载点
udev 4.2G 0 4.2G 0% /dev
tmpfs 853M 9.4M 844M 2% /run
/dev/sda1 39G 35G 1.5G 96% /
tmpfs 4.2G 236K 4.2G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 4.2G 0 4.2G 0% /sys/fs/cgroup
tmpfs 853M 60K 853M 1% /run/user/1000
vmhgfs-fuse 277G 207G 70G 75% /mnt/hgfs
/dev/sdb1 15G 9.6M 15G 1% /media/ar/boot
#卸载SD卡
ar@ar:~/petalinux/ALIENTEK-ZYNQ$ umount /media/ar/boot
#对SD卡进行配置
ar@ar:~/petalinux/ALIENTEK-ZYNQ$ sudo fdisk /dev/sdb
[sudo] ar 的密码:
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
#命令解释可以通过m获取
命令(输入 m 获取帮助): p
Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfcf79508
设备 启动 Start 末尾 扇区 Size Id 类型
/dev/sdb1 2048 31116287 31114240 14.9G c W95 FAT32 (LBA)
命令(输入 m 获取帮助): d
Selected partition 1
Partition 1 has been deleted.
命令(输入 m 获取帮助): p
Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfcf79508
命令(输入 m 获取帮助): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
#创建100M的分区1
Using default response p.
分区号 (1-4, default 1): 1
First sector (2048-31116287, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-31116287, default 31116287): +100M
Created a new partition 1 of type 'Linux' and of size 100 MiB.
#将剩余的内存作为分区2
命令(输入 m 获取帮助): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
分区号 (2-4, default 2):
First sector (206848-31116287, default 206848):
Last sector, +sectors or +size{K,M,G,T,P} (206848-31116287, default 31116287):
Created a new partition 2 of type 'Linux' and of size 14.8 GiB.
命令(输入 m 获取帮助): p
Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfcf79508
设备 启动 Start 末尾 扇区 Size Id 类型
/dev/sdb1 2048 206847 204800 100M 83 Linux
/dev/sdb2 206848 31116287 30909440 14.8G 83 Linux
#更改分区类型为FAT32
命令(输入 m 获取帮助): t
分区号 (1,2, default 2): 1
Partition type (type L to list all types): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
命令(输入 m 获取帮助): t
分区号 (1,2, default 2):
Partition type (type L to list all types): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
命令(输入 m 获取帮助): p
Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfcf79508
设备 启动 Start 末尾 扇区 Size Id 类型
/dev/sdb1 2048 206847 204800 100M c W95 FAT32 (LBA)
/dev/sdb2 206848 31116287 30909440 14.8G c W95 FAT32 (LBA)
# 保存
命令(输入 m 获取帮助): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
4.2 格式化SD卡
#格式化分区1
ar@ar:~/petalinux/ALIENTEK-ZYNQ$ sudo mkfs.vfat -F 32 -n boot /dev/sdb1
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
#格式化分区2
ar@ar:~/petalinux/ALIENTEK-ZYNQ$ sudo mkfs.ext4 -L rootfs /dev/sdb2
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 3863680 4k blocks and 966656 inodes
Filesystem UUID: 6af96941-3fc0-4431-89d1-61ef37ee6352
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
4.3 分区挂载
- 完成上述步骤后只需要点击左侧菜单的最下面两个USB图标即可完成挂载,一个USB图标对应一个分区。
ar@ar:~/petalinux/ALIENTEK-ZYNQ/images/linux$ df -h
文件系统 容量 已用 可用 已用% 挂载点
udev 4.2G 0 4.2G 0% /dev
tmpfs 853M 9.4M 844M 2% /run
/dev/sda1 39G 35G 1.5G 96% /
tmpfs 4.2G 236K 4.2G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 4.2G 0 4.2G 0% /sys/fs/cgroup
tmpfs 853M 68K 853M 1% /run/user/1000
vmhgfs-fuse 277G 207G 70G 75% /mnt/hgfs
/dev/sdb1 99M 512 99M 1% /media/ar/boot
/dev/sdb2 15G 37M 14G 1% /media/ar/rootfs
- 可见最后两行分别是SD卡的分区1/2,完成挂载。
4.4 将目标文件拷贝至两个分区
- 将BOOT.BIN和image.ub文件拷贝至分区1
ar@ar:~/petalinux/ALIENTEK-ZYNQ/images/linux$ cp -a BOOT.BIN image.ub /media/ar/boot/
ar@ar:~/petalinux/ALIENTEK-ZYNQ/images/linux$ sync
- 将根文件系统拷贝到共享文件夹后解压至分区2
cd /mnt/hgfs/share/
ar@ar:/mnt/hgfs/share$ ls
rootfs-qt5-atk.tar.gz
ar@ar:/mnt/hgfs/share$ df -h
文件系统 容量 已用 可用 已用% 挂载点
udev 4.2G 0 4.2G 0% /dev
tmpfs 853M 9.4M 844M 2% /run
/dev/sda1 39G 35G 1.5G 96% /
tmpfs 4.2G 236K 4.2G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 4.2G 0 4.2G 0% /sys/fs/cgroup
tmpfs 853M 68K 853M 1% /run/user/1000
vmhgfs-fuse 277G 208G 69G 76% /mnt/hgfs
/dev/sdb1 99M 8.7M 90M 9% /media/ar/boot
/dev/sdb2 15G 37M 14G 1% /media/ar/rootfs
#将文件系统解压至分区2
ar@ar:/mnt/hgfs/share$ sudo tar -xzf rootfs-qt5-atk.tar.gz -C /media/ar/rootfs
ar@ar:/mnt/hgfs/share$ sync
# 卸载两分区,拔掉SD卡
ar@ar:/mnt/hgfs/share$ umount /media/ar/boot
ar@ar:/mnt/hgfs/share$ umount /media/ar/rootfs
更多推荐
已为社区贡献1条内容
所有评论(0)