Skip to content

Latest commit

 

History

History
157 lines (79 loc) · 8.13 KB

imagefromsource.md

File metadata and controls

157 lines (79 loc) · 8.13 KB

Prepare boot image from source

install packages for cross-compiling:

sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential autoconf libtool cmake cmake-curses-gui pkg-config git python-dev swig3.0 libpcre3-dev nodejs-dev

1. Build u-boot

a. Set up enviroment

alt text

b. Initiate u-boot configuration

alt text

c. Build u-boot

alt text

(PS: before build the u-boot, modify the device tree "u-boot-xlnx/arch/arm/dts/zynqmp-zcu106-revA.dts")

alt text

(PS: if met yylloc error, please refer to (this). Then skip the next step d. and install dtc by "sudo apt install device-tree-compiler".)

d. Set up the mkimag tool path

alt text

2. Build Linux kernel

a. Set up enviroment

alt text

b. Initiate kernel configuration

alt text

c. Edit kernel configuration

alt text

i. Disable "General setup -> Initial RAM filesystem and RAM disk"

alt text

ii. Enable CPU govenors at "CPU Power Management -> CPU Frequency scaling"

alt text

iii. Enable DVFS at "Device Drivers -> Adaptive Voltage Scaling class support" and "Device Drivers -> Generic Dynamic Voltage and Frequency Scaling (DVFS) support"

alt text

alt text

iv. Save configuration

alt text

v. Enable physical memory access from userspace through /dev/mem (optional)

The default kernel setting filters the accessing physical memory through /dev/mem in userspace. This limitation can be released by modify the configuration of kenrel by editting .config file,

alt text

and make sure the option CONFIG_STRICT_DEVMEM is not set.

alt text

d. Build kernel

alt text

alt text

(PS: before build the kernel, modify the device tree "linux-xlnx/arch/arm64/boot/dts/xilinx/zynqmp-zcu106-revA.dts" )

alt text

(PS: again, if met yylloc error, please refer to (this). )

e. Build u-boot kernel image with command "mkimage -n 'Kernel Image' -A arm64 -O linux -C none -T kernel -a 0x8000 -e 0x8000 -d Image uImage"

3. Build device tree

a. Open a Vivado project by entering "source demo.tcl" in the vivado Tcl console. The block design diagram as shown:

alt text

This is a simple design without any function on PL. Synthesis, implement the project and generate the bit stream. Export the hardware throught "File -> Export -> Export Hardware ..".

b. Generate device tree using SDK

i. Open the SDK by "File > Launch SDK".
ii. Add device tree soure to BSP repository by "Xilinx Tools > Repositories > New... (select the device tree folder) > OK"

alt text

iii. Create new board support package project for device tree by "File > New > Board Support Package > Board Support Package OS: device-tree > Finish".

alt text

iv. Modify the device tree settings by click the "system.mss" then go to "Modify this BSP's Setting". In the "value" field of "device tree -> bootargs", enter "earlycon clk_ignore_unused consoleblank=0 cma=1700M uio_pdrv_genirq.of_id=generic-uio root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait".

alt text

v. Compile the device tree by going to the device tree BSP project folder in terminal and typing in "dtc -I dts -O dtb -o system.dtb system-top.dts".
(PS: Actually, when building both linus kernel and u-boot, the device tree is generated at "linux-xlnx/arch/arm64/boot/dts/xilinx/zynqmp-zcu106-revA.dtb" or "u-boot-xlnx/arch/arm/dts/zynqmp-zcu106-revA.dtb")

4. Build ARM Trasted Firmware

a. Set up eniroment as previous build kernel step

b. build the firmware

alt text

The new binary is at "/build/zynqmp/release/bl31/bl31.elf"

5. Generate First Stage Boot Loader (FSBL)

a. Launch Xilinx SDK as previous mentioned through Vivado.

b. Create a new project called "fsbl" by "File -> New ... Application Project (standalone) ". Click "Next" and choosing the "Zynq MP FSBL" template and click "Finish" to build the project. The fsbl.elf will be created under the compiled folder.

alt text

alt text

alt text

6. Generate Platform Management Unit Firmware (PMUFW)

a. Launch Xilinx SDK as previous mentioned through Vivado.

b. Create a new project called "pmufw" by "File -> New ... Application Project (standalone)". Choose "Target Hardware - Processor - psu_pmu_0" in the tab. Click the "Next", choose the "ZynqMP PMU Firmware" template and click "Finish" to build the project. The "pmufw.elf" will be created under the compiled folder.

alt text

alt text

alt text

7. Generate boot binary

a. Create "Boot.bin"

alt text

b. Create "Image.ub"

alt text