Xilinx / Vitis-AI

Vitis AI is Xilinx’s development stack for AI inference on Xilinx hardware platforms, including both edge devices and Alveo cards.
https://www.xilinx.com/ai
Apache License 2.0
1.45k stars 627 forks source link

unsuccessfully trying to significantly reduce boot time in ZYNQ MPSOC environment 2021.2 #1321

Open hudini87 opened 1 year ago

hudini87 commented 1 year ago

unsuccessfully trying to significantly reduce boot time in ZYNQ MPSOC environment 2021.2 .

it takes more than a minute to get the login as a root.

can you give some tips?

i am using petalinux 2021.2 to create linux boot image on Mercury XU8 SOM , zynq mpsoc xzcu7ev SOC assembled on it.

it takes more than a minute(!!!!) to complete boot and get into system as a root user, it doesn't matter if i do the boot from SD card (mmc1) or emmc (mmc0), it took the same time and more than a minute.

2 main blocks i have to fix:

it can be seen live during boot that i am waiting (emmc or sd card boot) 20 seconds when Trying to load boot images from mmc1 or mmc0:

sswitch to partitions #0, OK mmc0(part 0) is current device Scanning mmc 0:1... Found U-Boot script /boot.scr 2710 bytes read in 15 ms (175.8 KiB/s)

Executing script at 20000000

Trying to load boot images from mmc0 305488600 bytes read in 20165 ms (14.4 MiB/s)

it can be seen live during boot that i am waiting (emmc or sd card) 14 seconds when Trying to unpack rootfs:

[ 2.597160] RPC: Registered tcp transport module. [ 2.601832] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 2.608826] PCI: CLS 0 bytes, default 64 [ 2.612230] Trying to unpack rootfs image as initramfs... [ 16.407064] Freeing initrd memory: 289108K [ 16.468780] Initialise system trusted keyrings [ 16.468925] workingset: timestamp_bits=46 max_order=20 bucket_order=0

please advice.

thanks and best regards.

quentonh commented 1 year ago

@hudini87 There are potentially many paths that you can explore to reduce the size of initramfs, but this is very much outside the scope of Vitis AI.

You should first seek to understand precisely what is included in your initramfs and also, determine precisely what is needed for the initial boot. There is nothing saying that everything that is included in the initramfs in a default PetaLinux build is required for this initial boot, and as a user you can choose to slim this down to the point where the system will still boot and mount an additional filesystem that contains other required packages. You can also explore the possibility of different compression schemes which may have an impact on unpacking performance, but here again, this is outside the scope of Vitis AI. These are really Linux development related issues, not specific to Vitis AI.

https://wiki.debian.org/initramfs https://wiki.ubuntu.com/Initramfs https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842473/Build+and+Modify+a+Rootfs

The best path for you to explore this is not via filing Vitis AI Github issues (there is no bug here), but rather through the use of the Xilinx PetaLinux and Embedded forums, Xilinx technical support, or your local FAE.

quentonh commented 1 year ago

Also, perhaps see https://xilinx.github.io/Vitis-Tutorials/2021-1/build/html/docs/Vitis_Platform_Creation/Introduction/02-Edge-AI-ZCU104/step2.html#add-ext4-rootfs-support-optional-but-recommended

hudini87 commented 1 year ago

hi, thanks alot @quentonh , but i still need help and assistance. i reduce image.ub sizefrom 350MByte to 286MByte (initramfs FS ) but image.ub read by u-boot still takes a long time :(

switch to partitions #0, OK mmc0(part 0) is current device Scanning mmc 0:1... Found U-Boot script /boot.scr 2710 bytes read in 16 ms (165 KiB/s)

Executing script at 20000000

Trying to load boot images from mmc0 286172648 bytes read in 18889 ms (14.4 MiB/s)

Loading kernel from FIT Image at 10000000 ...

I GET while stop at u-boot stage:

ZynqMP> version U-Boot 2021.01 (Oct 12 2021 - 09:28:42 +0000)

ZynqMP> mmc list mmc@ff160000: 0 (eMMC) mmc@ff170000: 1

ZynqMP> mmc dev 0 switch to partitions #0, OK mmc0(part 0) is current device ZynqMP> mmcinfo Device: mmc@ff160000 Manufacturer ID: 70 OEM: 100 Name: W5251 Bus Speed: 199999998 Mode: HS200 (200MHz) Rd Block Len: 512 MMC version 5.0 High Capacity: Yes Capacity: 14.3 GiB Bus Width: 8-bit Erase Group Size: 512 KiB HC WP Group Size: 16 MiB User Capacity: 14.3 GiB Boot Capacity: 4 MiB ENH RPMB Capacity: 4 MiB ENH Boot area 0 is not write protected Boot area 1 is not write protected

as expected.

the big problem is: ZynqMP> fatload mmc 0 0x1000000 image.ub 305175408 bytes read in 19943 ms (14.6 MiB/s)

it takes 20 seconds to u-boot to read image.ub. why read transfer rate is so slow, 14.6MiB/s??????

we have 200MHz reference clock from PS subsystem, 8 bus width, means 200MByte/s capacity..so according my calculation : 305175408/200000000 = 1.5 SECONDS. am i wrong?

in addition kernel debug is also fine: root@petalinux:~# cat /sys/kernel/debug/mmc0/ios clock: 200000000 Hz actual clock: 200000000 Hz vdd: 21 (3.3 ~ 3.4 V) bus mode: 2 (push-pull) chip select: 0 (don't care) power mode: 2 (on) bus width: 3 (8 bits) timing spec: 9 (mmc HS200) signal voltage: 1 (1.80 V) driver type: 0 (driver type B)

can you help?

quentonh commented 1 year ago

@hudini87 My recommendation is that you post Linux optimization related questions here and potentially also that you consult with a local Field Applications Engineer.