1 Development Mode
- When writing Linux drivers, there are some elements that are often changed
Device tree file, Linux kernel, root file system
Of course, if you change the PL, you also need to change the bit file. So we separate these elements out to make it easier to change.That is, we separate the bit file from the original boot. BIN file and split the image.ub file into the kernel zImage and the device tree DTB. Also put the root file system on the SD card
2 Boot. BIN Strips out the bitStream file
- Select an appropriate path in the Ubuntu host terminal to create the Petalinux project for the factory image, and then enter the following command in the terminal:
Source/opt/PKG/petalinux / 2018.3 / Settings. Sh / / set petalinux petalinux work environment - the create - t project - the template zynq - n Alientek-zynq // Create a Petalinux project CD alientek-Zynq // Go to the Petalinux project directory petalinux-config --get-hw-description.. Navigator_7010.sdk/ // Import HDF fileCopy the code
- Enter the “Advanced Bootable ImagesStorage Settings” menu under “Subsystem AUTO Hardware Settings”, Move to the “DTB Image Settings” option and set image Storage Media to Primary SD
- The Root Filesystem Type (INITRAMFS) sub-menu is displayed under Image Packaging Configuration
- After the configuration, compile the uboot and generate the boot. BIN file
petalinux-build -c u-boot
petalinux-package --boot --fsbl --u-boot --force
Copy the code
3 Image. ub Removes the ZImage, device tree, or root file
- Generate device tree files. After compiling uboot in the Petalinux process, the device tree files will be generated in the components/plnx_workspace/device-tree/device-tree/ directory. The red box is the device tree file that we need to use, the skeleton.dtsi file that we don’t usually use.
The kernel source
, with the new Xilinx official 2018.3 version (this version is xilinx set version, its X Linux version is 4.14.0) kernel source code
3.1 Modifying the Device Tree File
- Dtsi, pl.dtsi, and system-top.dts are generated in the previously generated device tree file (the generated device tree file is stored in the Petalinux Project Components /plnx_workspace/device-tree/device-tree/ directory) And zynq-7000.dtsi four files directly copied to
The kernel source
In the arch/ ARM /boot/ DTS directory.
3.2 Compiling the Kernel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage -j10
Copy the code
- After compiling, a kernel image file named zImage will be generated in arch/ ARM /boot/
3.3 Compiling the Device Tree
- DTB file: arch/arm/boot/ DTS file: arch/arm/boot/ DTS
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- system-top.dtb -j10
Copy the code
- The system-top. DTB file is generated in arch/ ARM /boot/ DTS
- For convenience, the author renamed the system-top. DTB file
3.4 compile rootfs
petalinux-config -c rootfs
Copy the code
- Go to the “Image Features –>” menu and enable “Debug-tweaks”, as shown in the following figure
- Wait for the compilation to complete, and the resulting root file system zip is in the images/ Linux directory
4 Create an SD boot card
4.1 Copying an Image to a FAT Partition
- Copy the various image files generated in the previous procedure to the FAT partition of the SD boot card, including
zImage
(arch/ ARM /boot/zImage),system-top.dtb
(arch/ ARM /boot/ DTS /system-top.dtb),systemt.bit
Bitstream file on the PL side, images/ Linux /system.bit in the Petalinux project directory. - will
BOOT.BIN
Copy files to FAT partition
4.2 Decompressing the root file System to EXT4
sudo tar -xzf rootfs.tar.gz -C /media/linux/rootfs
Copy the code
5 Start the development board
- Before the 2-second countdown of the U-boot startup, press Enter or the space bar to stop the startup and go to the U-boot command line
In the u-boot command line, execute the following commands to set the environment variables.
env default -a
setenv bitstream_load_address 0x100000
setenv bitstream_image system.bit
setenv bitstream_size 0x300000
setenv kernel_img zImage
setenv dtbnetstart 0x2000000
setenv netstart 0x2080000
setenv default_bootcmd 'if mmcinfo; then run uenvboot; echo Copying Linux from SD to RAM... && load mmc
0 ${bitstream_load_address} ${bitstream_image} && fpga loadb 0 ${bitstream_load_address} ${bitstream_size}
&& run cp_kernel2ram && run cp_dtb2ram && bootz ${netstart} - ${dtbnetstart}; fi'
Copy the code
- Run the boot command to start the kernel or run the reset command to restart the development board.