Thang Le
Thang Le

Reputation: 1449

The using of address ZTEXTADDR in Linux booting for ARM

What is the role of ZTEXTADDR in Linux kernel ?

From lxr.linux.no, it's an address in RAM that holds address of zImage as sequence below?

A.

uImage (DataFlash/NAND) ---load_to_RAM---> 
 uImage (@ boot_addr) ---decompress_uImage--> 
  zImage (@ ZTEXTADDR) --- decompress_zImage---> 
   uncompressed image (@ ZRELADDR).

or just:

B.

uImage (DataFlash/NAND) ---load_to_RAM---> 
 uImage (@ boot_addr) ---decompress_uImage--> 
  uncompressed image (@ ZRELADDR)

no using ZTEXTADDR in new kernel version for booting process ?

Upvotes: 2

Views: 1479

Answers (1)

artless-noise-bye-due2AI
artless-noise-bye-due2AI

Reputation: 22395

The Linux ARM decompression boot loader is capable of relocating itself when running from RAM. The relocation portion is PC-relative and so it can be loaded at any address. However, if your main image starts from FLASH/ROM, the code can not be relocated; while moving an image in RAM is a simple memmove(), it is much more involved for NOR flash and can be impossible for ROM.

In this case, a compressed boot linker script is used with the ZTEXTADDR as the location of the decompression code. In your diagram, you have a u-boot, which will load the uImage. There is no reason to execute this directly from Flash/ROM. u-boot can copy the image to RAM and there is no need for the ZTEXTADDR value and it should be left as zero.

If your image boots directly from Flash/ROM, without a boot loader then ZTEXTADDR is useful,

 zImage (in flash) --> decompress vmlinux.bin to RAM --> run kernel

The zImage may need to be annotated with some chip setup for this to work and would need ATAGS or device trees linked. For this reason, there are many machine variants in boot/compressed; This is not maintainable and these type of files are discouraged. Typically another bootloader loads the image to RAM and the zImage can move itself to whatever destination it needs; I think that is your situation and you should set ZTEXTADDR to zero and forget about it.

Upvotes: 2

Related Questions