petalinux 初上手

422次阅读
没有评论

环境

vivado 与 petalinux 的环境都要 source 下
source /opt/pkg/petalinux/settings.sh
source /opt/Xilinx/Vivado/2017.4/settings64.sh

创建工程

获取硬件信息

  • petalinux-create --type project --template zynq --name helloworld
  • 进入 helloworld 目录, 新建 hardwareInfo 目录并把 vivado 生成的硬件相关文件拷贝到这个目录中(目录名可以随便取)
  • petalinux-config --get-hw-description ./hardwareInfo 获取硬件信息, 实际是解析了那个目录中的 hdf 文件, 会弹出配置信息

配置

使用 petalinux-config 来进行项目配置, 在运行完get-hw-description 也会自动进入配置
petalinux 初上手
主要配置以下内容
– linux components selection 内核 /uboot 来源, 默认从 git 中取, 网络不好的环境可指定路径
Subsystem AUTO Hardware Settings->Serial Settings 中设置默认打印串口
Subsystem AUTO Hardware Settings->Ethernet Settings IP MAC 配置
– 如果要从 SPI FLASH 启动, 配置Subsystem AUTO Hardware Settings->flsah settings->advanced flash auto configuration
– 如果从 SD 卡启动, 检查 SD/SDIO Settings 中有没有 SD 选项, 没有的话检查 vivado 的工程中是否配了 SD 卡
Advanced bootable images storage Settings中配置 uboot kernel 等文件存放的位置
petalinux 初上手

其他

  • u-boot Configuration 里的选项可以看到当前 uboot 的一些参数, 也看得到当前用的是哪个 uboot 配置文件, 如果不使用 petalinux, 可以使用那个文件来配置 uboot
  • petalinux-config -c kernel 进行内核配置, 去打开关闭内核的一些功能与驱动, 当前使用的 Micrel 的 PHY, 默认没有, 需要勾一下
  • petalinux-config -c rootfs 配置文件系统.
  • petalinux-build 编译内核

通常配置

在 kernel 中需要打开对应 PHY 驱动, ALINX 板子用的 Mircrel 的 PHY, 默认内核没打开
默认 Rootfs 中, 没有 libstdc++,qt 会报 libstdc++.so.6 找不到. 要么在运行时去找到编译器路径拷贝到 Lib 目录, 也可以在编译 rootfs 时集成进去. 选项路径如下
petalinux 初上手

打包镜像

编译完成后, 会在 images 目录生成一堆文件. 其中 image.ub 是针对 sd 卡的一个文件, 其中包含了 dtb uiamge rootfs
不过 fsbl 需要自已打包一下
petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/system.bit --u-boot --force
petalinux 初上手
可以看到生成了 boot.bin 然后将 image.ub boot.bin 拷贝到 SD 卡, 启动, 默认用户名及密码均为 root. 收工

正文完
 0
评论(没有评论)