u-boot 生成和载入步骤
1. 创建工程
首先加载 Petalinux 工具链
# 设置 petalinux 工作环境
source <PLNX_INSTALL_DIR>/settings.sh
# 例如
source /opt/pkg/petalinux/2018.3/settings.sh
创建 Petalinux 工程
# 创建 Petalinux 工程
petalinux-create -t project --template zynq -n <PRJ_NAME>
# 进入到 Petalinux 工程目录下
cd ./<PRJ_NAME>
2. 导入 HDF 文件
将 HDF 文件放置到 <PRJ_NAME>
文件夹中。更新 SOC 时,替换 HDF 文件后重新导入即可。
# 导入 HDF 文件
petalinux-config --get-hw-description ./
3. 配置 uboot
在 petalinux 工程配置窗口设置:
- Subsystem AUTO Hardware Settings -- Ethernet Settings -- Obtain IP address automatically
- u-boot Configuration -- TFTP server IP address
- Image Packaging Configuration -- Root filesystem type / Copy final images to tftpboot
如果要使用本地的 uboot,还需要设置:
-
Linux Components Selection -- u-boot -- ext-local-src
-
Linux Components Selection -- External u-boot local source settings
${TOPDIR}/../components/ext_sources/u-boot-xlnx ( ${TOPDIR} 表示 build 文件夹路径 )
-
将 uboot 代码复制到
<PRJ_DIR>/components/ext_sources/
,修改文件名为 u-boot-xlnx -
修改工程文件夹的权限:
sudo chmod -R 777 <PRJ_DIR>
4. 编译 uboot
默认下 petalinux 使用的是 git 上的 uboot 代码,编译后会删除源码。如果要保留源码,可执行以下指令。使用本地的 uboot 代码则不会删除代码。
# 保留 linux 源码
echo 'RM_WORK_EXCLUDE += "linux-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf
# 保留 uboot 源码
echo 'RM_WORK_EXCLUDE += "u-boot-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf
echo ''>> project-spec/meta-user/conf/petalinuxbsp.conf
工程编译后,源码位于
<PRJ_DIR>/build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/
路径下。
编译 fsbl 和 u-boot
petalinux-build -c fsbl
petalinux-build -c u-boot
生成 BOOT.BIN 文件
petalinux-package --boot --fsbl --u-boot --force
5. 加载 uboot
方法一:通过 JATG 运行 uboot.elf。
petalinux-boot --jtag --u-boot --fpga --bitstream ./images/linux/system.bit
方法二:将 BOOT.BIN 和 system.bit 复制到 SD 卡,使用 SD 卡启动。
# 从 sd 卡烧录 BOOT.BIN 到 QSPI
load mmc 0 0x08000000 BOOT.BIN
sf probe 0
sf erase 0 A0000
sf write 0x08000000 0 ${filesize}
方法三:在 vivado SDK 上使用 HDF 文件搭建 FSBL 工程,烧录 BOOT.BIN 到 FLASH。
6. 清理过程文件
petalinux-build -x distclean
# Petalinux常用命令汇总
创建plnx工程
Create a new project from a reference BSP file.
用于从官方下载的BSP中抽取数据产生工程
petalinux-create -t project -s <FULLPATH-TO-BSP>
Create a new project based on the ZYNQ™ template.
用于让petalinux工具包,从系统中抽取模板,产生工程
petalinux-create -t project --template zynq -n <PROJECT_NAME>
Initialize a PetaLinux project within the project directory with an external HDF.
用于指定一个位于工程目录之外的包含.hdf的文件夹用于搜索
petalinux-config --get-hw-description=<PATH-TO-HDF-DIRECTORY>
Initialize a PetaLinux project from within the directory containing an HDF.
用于指定一个位于工程目录之外的包含.hdf的文件夹用于搜索
petalinux-config --get-hw-description -p <%PATH-TO-PETALINUX-PROJECT%>
Initialize a PetaLinux project from a neutral location.
用于指定一个petalinux工程目录,并指定一个单独的.hdf文件
petalinux-config --get-hw-description <%PATH-TO-HDF%> -p <%PATH-TO-PETALINUX-PROJECT%>
配置
Start the menuconfig for the system-level configuration:
系统级配置
petalinux-config
Parse the configuration onto Kconfig without opening the GUI(--oldconfig
), for the root filesystem(-c rootfs
):
无GUI配置组件
# 以根文件系统为例
petalinux-config -c rootfs --oldconfig
Load the Linux kernel configuration with a specific default configuration:
以指定的配置文件对组件进行配置
注意,这样的配置文件需要存在于kernel或者uboot的源码树中,不能额外指定外部文件。
否则会报错:ERROR: linux-xlnx-4.14-xilinx-v2018.3+gitAUTOINC+eeab73d120-r0 do_kernel_metadata: A KBUILD_DEFCONFIG 'xxx' was specified, but not present in the source tree
# 以内核为例
petalinux-config -c kernel --defconfig xilinx_zynq_base_trd_defconfig
# 以 uboot 为例
petalinux-config -c u-boot --defconfig xilinx_zynqmp_zcu102_defconfig
Generate the source code for fsbl/fs-boot:
生成源码(以fsbl/fs-boot为例)。
petalinux-config -c bootloader
构建
Build the entire PetaLinux project
构建整个工程
petalinux-build
Build the kernel forcefully
强制构建内核
petalinux-build -c kernel -f
Compile a kernel forcefully
强制编译内核
petalinux-build -c kernel -x compile -f
Clean all build collaterals from the U-Boot component of the PetaLinux project.
清理构建中间组件
petalinux-build -c u-boot -x cleansstate
Create an updated FIT image from the current contents of the deploy area.
从部署域的当前内容创建更新的FIT映像
petalinux-build -x package
清理
Clean all build collaterals. It removes build/, ${TMPDIR} and images. This will bring the project to its initial state
## 慎用
petalinux-build -x mrproper
Clear the build area of the PetaLinux project for archiving as a BSP or for revision control. This example retains the images directory of the project
petalinux-build -x distclean
烧录
Download and boot a pre-built bitstream (and FSBL for Zynq-7000 or Zynq UltraScale+ MPSoC) via JTAG to a physical board.
petalinux-boot --jtag --prebuilt 1
Download and boot a pre-built U-Boot elf via JTAG to a physical board.
petalinux-boot --jtag --prebuilt 2
For Zynq-7000, it downloads:
- bitstream pre-built/linux/implementation/download.bit
- fsbl pre-built/linux/images/zynq_fsbl.elf
- u-boot pre-built/linux/images/u-boot.elf
For Zynq UltraScale+ MPSoC, it downloads:
- bitstream pre-built/linux/implementation/download.bit
- fsbl pre-built/linux/images/zynqmp_fsbl.elf
- ATF pre-built/linux/images/bl31.elf
- u-boot pre-built/linux/images/u-boot.elf
- pmufw pre-built/linux/images/pmufw.elf
Download and boot a pre-built kernel image via JTAG to a physical board
petalinux-boot --jtag --prebuilt 3
For Zynq-7000, it downloads:
- bitstream pre-built/linux/implementation/download.bit
- fsbl pre-built/linux/images/zynq_fsbl.elf
- DTB pre-built/linux/images/system.dtb
- kernel pre-built/linux/images/zImage
For Zynq UltraScale+ MPSoC, it downloads:
- bitstream pre-built/linux/implementation/download.bit
- fsbl pre-built/linux/images/zynqmp_fsbl.elf
- kernel pre-built/linux/images/Image
- DTB pre-built/linux/images/system.dtb
- ATF pre-built/linux/images/bl31.elf
- pmufw pre-built/linux/images/pmufw.elf
Download and boot a built U-Boot image via JTAG to a physical board
petalinux-boot --jtag --u-boot
For Zynq-7000, it downloads:
- fsbl images/linux/zynq_fsbl.elf
- U-Boot images/linux/u-boot.elf.
For Zynq UltraScale+ MPSoC, it downloads:
- fsbl images/linux/zynqmp_fsbl.elf
- U-Boot images/linux/u-boot.elf
- ATF images/linux/bl31.elf
- pmufw images/linux/pmufw.elf
Download and boot a built kernel image via JTAG to a physical board.
petalinux-boot --jtag --kernel
(For Zynq-7000, it boots:
- fsbl images/linux/zynq_fsbl.elf
- DTB images/linux/system.dtb
- kernel images/linux/zImage
For Zynq UltraScale+ MPSoC, it boots:
- fsbl images/linux/zynqmp_fsbl.elf
- kernel images/linux/Image
- DTB images/linux/system.dtb
- ATF images/linux/bl31.elf
- pmufw images/linux/pmufw.elf
启动
Load and boot a pre-built U-Boot elf via QEMU.
$ petalinux-boot --qemu --prebuilt 2
Load and boot a pre-built U-Boot elf via QEMU in root mode.
$ petalinux-boot --qemu --root --prebuilt 2
打包
Create a BOOT.BIN file for a Zynq family device (including Zynq-7000 and Zynq UltraScale+ MPSoC).
petalinux-package --boot --format BIN --fsbl <%PATH-TO-FSBL%> --u-boot -o <%PATH-TO-OUTPUT-WITH-FILE-NAME%>
Create a BOOT.BIN file for a Zynq family device that includes a PL bitstream and FIT image.
petalinux-package --boot --format BIN --fsbl <%PATH-TO-FSBL%> --u-boot --fpga <%PATH-TO-BITSTREAM%> --kernel -o <%PATH-TO-OUTPUT%>
Create a BOOT.BIN file for a Zynq UltraScale+ MPSoC device that includes a PMU firmware.
petalinux-package --boot --u-boot --kernel --pmufw <%PATH_TO_PMUFW%>
Clean the project and then generate the BSP installation image (.BSP file)
petalinux-package --bsp --clean -o <%PATH-TO-BSP%> -p <%PATH-TO-PROJECT%>
Generate the BSP installation image that includes a reference hardware definition
petalinux-package --bsp --hwsource <%PATH-TO-HW-EXPORT%> -o <%PATH-TO-BSP%> -p <%PATH-TO-PROJECT%>
Generate the BSP installation image from a neutral location
$ petalinux-package --bsp -p <%PATH-TO-PROJECT%> -o <%PATH-TO-BSP%>
Generate uImage
petalinux-package --image -c kernel --format uImage
(The uImage is in <%plnx-proj-root%>/images/linux directory)
Include a specific bitstream in the pre-built area.
petalinux-package --prebuilt --fpga <%BITSTREAM%>
Include a specific data file in the pre-built area.
petalinux-package --prebuilt -a <%APP%>:images/<%APP%>
其他
Launch the GNU GDB debugger
petalinux-util --gdb
Launch a specific Linux kernel image.
petalinux-util --jtag-logbuf -i <%PATH-TO-IMAGE%>
Launch the JTAG logger from a neutral location. This workflow is for Zynq-7000 devices only
petalinux-util --jtag-logbuf -i <%PATH-TO-IMAGE%> -p <%PATH-TO-PROJECT%>
To find the default bitstream of a project:
petalinux-util --find-hdf-bitstream
To find the bitstream of a hdf:
petalinux-util --find-hdf-bitstream --hdf-file <%path to hdf file%>
Toggle the WebTalk feature off.
petalinux-util --webtalk off
标签:Petalinux,built,--,boot,linux,images,petalinux
From: https://www.cnblogs.com/liuzefeng/p/17286270.html