petalinux操作步骤
- 整体流程
- 安装
1)sudo dpkg-reconfigure dash 在界面中将shell改成bash
2)安装依赖库:
sudo apt-get install -y gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev
sudo apt-get install -y flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip
sudo apt-get install -y texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev zlib1g:i386 screen pax gzip
3)修改文件夹用户
只能非root安装。方法,可以chown -r 把某个文件夹所有者改成用户。然后安装。
mkdir -p /opt/pkg/petalinux/2018.2
chown chenjian -r /opt/pkg/petalinux/2018.2
4)安装
./petalinux-v2018.2-final-installer.run /opt/pkg/petalinux/2018.2
source /opt/pkg/petalinux/2018.2/settings.sh 设置环境变量,可以添加到Bashrc中
5)工程建立
petalinux-create --type project --template <PLATFORM> --name <PROJECT_NAME>
<PLATFORM>:zynq或者zynqMP (for UltraScale+ MPSoC)
<PROJECT_NAME>:项目名称
或者从一个参考BSP开始
petalinux-create -t project -s <path-to-bsp>
6)硬件信息导入
在新建项目的根目录下
petalinux-config --get-hw-description=<path-to-directory-containing-hardware> description-file>
<path-to-directory-containing-hardware description-file> :硬件hdf文件所在的目录
7)配置
petalinux-config
配置-*- Subsystem AUTO Hardware Settings ---> :硬件子系统
配置 boot启动项,SD卡分区、文件系统等
8)编译
项目根目录下:
petalinux-build
9)生成boot文件
petalinux-package --boot --format BIN --fsbl images/linux/zynq_fsbl.elf --u-boot images/linux/u-boot.elf --fpga images/linux/dpu_sys_wrapper.bit --force
10)发布映像文件
petalinux-package --prebuilt --fpga images/linux/dpu_sys_wrapper.bit --force
11)SD卡分区
Linux下使用gparted软件进行分区,注意虚拟机下SD卡需要采用读卡器才可以。
第1个区分为fat32,第2个区根据文件系统来决定,格式化成ext3或者ext4.
12)拷贝文件到SD卡启动
pre-built/linux/images/下的 BOOT.BIN和image.ub拷贝到SD卡的第一个分区启动。注意如果要文件系统,前面config时要配置文件系统在SD卡上,并进行编译,不配置时默认是RAMDISK
将文件系统安装到SD卡的第2个分区
sudo tar xvf rootfs.tar.gz -C /media/rootfs
若使用linaro linux
sudo tar --strip-components=3 -C /media/chenjian/rootfs -xzpf linaro-o-ubuntu-desktop-tar-20111219-0.tar.gz binary/boot/filesystem.dir
13)其他定制化配置
此外,petalinux工具还可以将个人开发的应用程序集成到系统中,待完成代码后再补充该部分内容。
//全局配置
petalinux-config
//kernel配置
petalinux-config -c kernel
//保存kernel.config文件
//u-boot配置
petalinux-config -c u-boot
//保存u-boot.config文件
//文件系统配置
petalinux-config -c rootfs