- 整體流程
- 安裝
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