03-30-2020 01:26 PM
I've been able to boot my Linux on the zcu106 as well as the QEMUs.
I'm using the Legacy U-Boot approach of fatload'ing the uImage, initramfs.ub and dtd and then use mboot.
Our userspace is read-only and so we never switchroot to any mounted fs.
However, I had to use memory addresses from existing on-line examples without understanding why those addresses are chosen. I reviewed the User Guide but I couldn't find anything that showed why a starting address for the kernel of 0x80000 works but 0x0 does not. I'm assuming that there is reserved space in the lower addresses for I/O space or something. I ended up using the Start addresses below. Can someone point me at a table which explains why most examples use 0x80000?
Size (dec) Size (hex) Start End
uImage 17,941,056 0x0111C240 0x00080000 0x0111C240
initramfs.ub 279,628,288 0x10AACA00 0x02000000 0x12AACA00
zynqmp-zcu106-revA.dtb 35,905 0x00008C41 0x20000000 0x20008C41
03-30-2020 04:20 PM
The bottom of the address space is typically where exception vectors and page tables are located, so this is why 0x0 does not work.
The historically recommended location for zImage is 0x8000 (32kiB) from start of RAM. There is also an upper limit of 128 MiB; if the kernel be loaded higher than this, them the zImage decompression code will mis-calculate the start of RAM, which in turn will cause the total RAM as reported by Linux to be less than you actually have.
The uImage has a small header (64 bytes) in front of the zImage. So it needs a few extra bytes, but basically can be treated just like a zImage.
Keep in mind that you need RAM for both the compressed kernel, and the uncompressed version. If the compressed image starts at 0x80000 and is 4MiB large, then it will end at 0x00408000. Next we need to know the size of the uncompressed image. This exact value can be obtained from the zImage, but we can also just approximate it as 2 to 3 times the size of the compressed image. So let perhaps as much as 12MiB for the uncompressed kernel. Adding this on, we are now up to offset 0x01008000.
You need a bit of extra space for various reasons, so always round up a bit. For example we might start at 0x01100000. The device tree and the ramdisk can be loaded at addresses above this value. U-boot will move the DTB to the near the top of RAM before starting the kernel.
In summary, they key is to have enough space to hold both compressed and uncompressed zImage, plus a bit of extra padding. Place your DTB and ramdisk beyond that point.
For maximum efficiency, eg. to avoid the kernel having to relocated itself before decompression, the historic rule of offset 0x8000 should be modified. You instead want to leave room for the uncompressed kernel to start at 0x8000. That is, skip ahead by the uncompressed size, and place the compressed image there. A typical value might be anywhere from 10 to 32 MiB from the start of RAM.
03-30-2020 06:05 PM - edited 03-30-2020 07:02 PM
Hi @BigAl ,
In addition to what @rfs613 said. For ARM64 devices kernel image load offset(text_offset) is set to 0x80000 for more details refer kernel docs https://github.com/Xilinx/linux-xlnx/blob/xlnx_rebase_v4.19_2019.2/Documentation/arm64/booting.txt#L77
For example if you have a PL DDR and want to boot linux from PL DDR instead of PS DDR, Assuming PL DDR address start address 0x400000000 and Kernel Image Load Offset is 0x80000 hence we load kernel at 0x400080000 in PL DDR.
Once linux is booted you can run below commands and check for kernel code in DDR to make sure kernel code is executing from right address.
root@zcu104-pl-ddr:~# cat /proc/meminfo MemTotal: 6108068 kB MemFree: 6040436 kB MemAvailable: 5960756 kB Buffers: 20 kB Cached: 24380 kB SwapCached: 0 kB Active: 3992 kB Inactive: 128 kB Active(anon): 3976 kB Inactive(anon): 124 kB Active(file): 16 kB Inactive(file): 4 kB Unevictable: 24188 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 3984 kB Mapped: 5188 kB Shmem: 192 kB Slab: 25556 kB SReclaimable: 7532 kB SUnreclaim: 18024 kB KernelStack: 1392 kB PageTables: 348 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3054032 kB Committed_AS: 36176 kB VmallocTotal: 263061440 kB VmallocUsed: 0 kB VmallocChunk: 0 kB Percpu: 720 kB AnonHugePages: 0 kB ShmemHugePages: 0 kB ShmemPmdMapped: 0 kB CmaTotal: 262144 kB CmaFree: 261464 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 0 kB root@zcu104-pl-ddr:~# cat /proc/iomem 00000000-7fefffff : System RAM 6bc00000-7fbfffff : reserved 7fef7000-7fefefff : reserved 7feff000-7fefffff : reserved fd0b0000-fd0bffff : perf-monitor@fd0b0000 fd0c0000-fd0c1fff : ahci@fd0c0000 fd3d0000-fd3d0fff : siou fd400000-fd43ffff : serdes fd490000-fd49ffff : perf-monitor@fd490000 fd4a0000-fd4a0fff : dp fd4aa000-fd4aafff : blend fd4ab000-fd4abfff : av_buf fd4ac000-fd4acfff : aud fd4c0000-fd4c0fff : dma@fd4c0000 fd4d0000-fd4d0fff : watchdog@fd4d0000 fd500000-fd500fff : dma@fd500000 fd510000-fd510fff : dma@fd510000 fd520000-fd520fff : dma@fd520000 fd530000-fd530fff : dma@fd530000 fd540000-fd540fff : dma@fd540000 fd550000-fd550fff : dma@fd550000 fd560000-fd560fff : dma@fd560000 fd570000-fd570fff : dma@fd570000 fe200000-fe207fff : dwc3@fe200000 fe200000-fe207fff : dwc3@fe200000 fe20c100-fe23ffff : dwc3@fe200000 ff000000-ff000fff : xuartps ff010000-ff010fff : xuartps ff030000-ff030fff : i2c@ff030000 ff070000-ff070fff : can@ff070000 ff0a0000-ff0a0fff : gpio@ff0a0000 ff0e0000-ff0e0fff : ethernet@ff0e0000 ff0f0000-ff0f0fff : spi@ff0f0000 ff150000-ff150fff : watchdog@ff150000 ff170000-ff170fff : mmc@ff170000 ff960000-ff960fff : memory-controller@ff960000 ff9d0000-ff9d00ff : usb0@ff9d0000 ffa00000-ffa0ffff : perf-monitor@ffa00000 ffa10000-ffa1ffff : perf-monitor@ffa10000 ffa50000-ffa507ff : ams-base ffa60000-ffa600ff : rtc@ffa60000 ffa80000-ffa80fff : dma@ffa80000 ffa90000-ffa90fff : dma@ffa90000 ffaa0000-ffaa0fff : dma@ffaa0000 ffab0000-ffab0fff : dma@ffab0000 ffac0000-ffac0fff : dma@ffac0000 ffad0000-ffad0fff : dma@ffad0000 ffae0000-ffae0fff : dma@ffae0000 ffaf0000-ffaf0fff : dma@ffaf0000 400000000-4ffffffff : System RAM 400080000-40105ffff : Kernel code 401060000-40112ffff : reserved 401130000-401224fff : Kernel data 404000000-404009fff : reserved 406000000-40680afff : reserved 4f9c00000-4fa9fffff : reserved 4fabc7000-4ffdfffff : reserved 4fff09000-4fff68fff : reserved 4fff69000-4fff69fff : reserved 4fff6a000-4fffc5fff : reserved 4fffc8000-4fffcbfff : reserved 4fffcc000-4ffff4fff : reserved 4ffff5000-4ffffefff : reserved 4fffff000-4ffffffff : reserved root@zcu104-pl-ddr:~#