Understanding of several address parameters involved in uBoot and Linux kernel

  
 

Understanding the several address parameters involved in uBoot and Linux kernel



*************** **********************************

arch/arm/Makefile

//The kernel runs the virtual address TEXTADDR = 0xC0008000

********************************** ***************

arch/arm/boot/Makefile

//The kernel load address ZRELADDR = 0x20008000

** ***********************************************

arch/arm/boot/compressed/Makefile

//Self-extracting program address ZTEXTADDR = 0x00000000

(linux-2.4.19-rmk7 kernel self-extracting function gunzip is located in

/lib/inflate.c, which is the gzip-1.0.3 version, and the files compressed by the gzip

function on the PC cannot be recognized by the gzip-1.0.3 version of gunzip, so Linux-2.4.19-rmk7

The kernel self-extracting function can not be used. The default value ZTEXTADDR= 0x00000000

means not used. (Can only be loaded by uBoot's gunzip decompression)

)

**************************************** *******

//uImage storage address = 0x21000000

********* **************************************

mkimage -A arm -O Linux -C gzip -a 0x20008000 -e 0x20008000 -d linux.bin.gz uImage

-A:CPU type

-O:OS

-C: compression method used

-a: kernel load address

-e: kernel entry address

*********** ************************************

uBoot's do_bootm(cmd_tbl_t *cmdtp, Int flag, int argc, char *argv[]);

The function will check the header of the mkimage formatted uImage data stored at address 0x21000000

typedef struct image_header {

uint32_t ih_magic; /* Image Header Magic Number */

uint32_t ih_hcrc; /* Image Header CRC Checksum */

uint32_t ih_time; /* Image Creation Timestamp */

uint32_t ih_size; /* Image Data Size */

uint32_t ih_load; /* Data Load Address */

uint32_t ih_ep; /* Entry Point Address */

uint32_t ih_dcrc; /* Image Data CRC Checksum */

uint8_t ih_os; /* Operating System */

uint8_t ih_arch; /* CPU architecture */

uint8_t Ih_t Ype; /* Image Type */

uint8_t ih_comp; /* Compression Type */

uint8_t ih_name[IH_NMLEN]; /* Image Name */

}image_header_t;

(ih_ep value is 0x20008000, ih_load value is 0x20008000)

If the header fields and crc are legal, then do_bootm will call the following gunzip decompression function pair

0x21000000 + The compressed kernel at the addressof(image_header_t) address is decompressed:

gunzip((void*)ntohl(hdr->ih_load),0x400000,data,(int*)&len);

1. Hdr->ih_load is the output data address 0x20008000

2.0x400000 for the gunzip decompressed output data upper limit -4M

3. Data is the input data address data=0x21000000 +sizeof(image_header_t);

4. Len is the input data length len = ntohl(hdr->ih_size);

The actual size of the decompressed data will be stored after decompression is completed

The compressed Linux kernel file uImage is decompressed via gunzip After the function, pass

do_bootm_linux (cmdtp, flag, argc, argv, addr, len_ptr, verify);

function to pass the five parameters required for kernel operation to the Linux kernel

kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep ;

1. Hdr->ih_ep is 0x20008000

/*

* Linux Kernel Parameters:

* r3: ptr to board info data

* r4: initrd_start Or 0 if no initrd

* r5: initrd_end - unused if r4 is 0

* r6: Start of command line string

* r7: End of command line string< Br>

*/

(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);

This completes the transfer of 5 parameters required for Linux system startup. The work of uBoot is over, and Linux will be officially running at address 0x20008000.

Copyright © Windows knowledge All Rights Reserved