[U-Boot] Kernel loading and memory layout

Greetings,
I am new to using uboot but have gone through the code to a certain degree but still have some questions.
1. Where does uboot transfer control to the linux kernel. By this I mean which file in the source code would I look for this.
Would it for example be in : arch/powerpc/boot and in one of the assembly language files?
2. I went through and did a lot of reading on how grub loads a linux kernel.
Is the memory layout of uboot similar to that of grub. If not, how and where do I find more information on how does uboot layout the memory and where is the real-mode portion of the kernel loaded and where is the protected mode portion of the kernel loaded etc.
Any pointers to the source code would greatly help.
Any other information to get me started along these lines would be of great help.
Thank you. Vinay

Hello
2009/1/21 Vinay Venkataraghavan raghavanvinay@yahoo.com:
I am new to using uboot but have gone through the code to a certain degree but still have some questions.
Where does uboot transfer control to the linux kernel. By this I mean which file in the source code would I look for this.
Would it for example be in : arch/powerpc/boot and in one of the assembly language files?
Look at $(uboot)/common/cmd_bootm.c, cmd_boot.c. On ARM the process also involves $(uboot)/lib_arm/bootm.c, I guess should be something similar on PPC.

Vinay Venkataraghavan wrote:
Greetings,
I am new to using uboot but have gone through the code to a certain degree but still have some questions.
- Where does uboot transfer control to the linux kernel. By this I
mean which file in the source code would I look for this.
Would it for example be in : arch/powerpc/boot and in one of the assembly language files?
You could start with the "bootm" command in common/cmd_bootm.c and read its logic and comments (just skim the code and comments till you get to the end where it does the transfer to the loaded program).
- I went through and did a lot of reading on how grub loads a linux kernel.
Is the memory layout of uboot similar to that of grub. If not, how and where do I find more information on how does uboot layout the memory and where is the real-mode portion of the kernel loaded and where is the protected mode portion of the kernel loaded etc.
It is totally different from grub. Grub is a second++ stage bootloader that runs after the PC-BIOS does the first stage initialization and loads grub.
U-Boot is generally the first and only bootloader (booting from NAND flash requires a very compact, simple first stage bootloader, which makes u-boot a second stage bootloader).
U-Boot loads the linux kernel in RAM where ever you tell it to and then jumps to the linux kernel entry point. The linux kernel, on start up, relocates itself to where *it* wants to live and then proceeds.
Any pointers to the source code would greatly help.
Any other information to get me started along these lines would be of great help.
Thank you. Vinay
Best regards, gvb

Dear Jerry Van Baren,
In message 49771642.1050705@ge.com you wrote:
U-Boot loads the linux kernel in RAM where ever you tell it to and then jumps to the linux kernel entry point. The linux kernel, on start up, relocates itself to where *it* wants to live and then proceeds.
This is not correct. You load the kernel to some memory address (in RAM or flash or SRAM etc.). U-Boot will then copy (or "load") it to the address givenm in the "load address" parameter of the image file, and then jumpt to the entry point address given in the "entry point address" parameter of the image file. Normally (at leats on PowerPC), Linux will NOT relocate itself (it may set up the MMU later, but the initial execution starts exactly at the "entry point address").
Best regards,
Wolfgang Denk

Thank you all for your responses. Has definitely got me going. Another really quick question. I notice that there are a lot of debug switches in the uboot code.
How do I turn on debugs in uboot. Is there a compile time flag or is there and #define that needs to be turned on. I looked in the code and could not find how all the debugs are related and can be switched on?
Thank you. Regards, Vinay
----- Original Message ---- From: Wolfgang Denk wd@denx.de To: Jerry Van Baren gerald.vanbaren@ge.com Cc: Vinay Venkataraghavan raghavanvinay@yahoo.com; u-boot@lists.denx.de Sent: Wednesday, January 21, 2009 11:03:39 AM Subject: Re: [U-Boot] Kernel loading and memory layout
Dear Jerry Van Baren,
In message 49771642.1050705@ge.com you wrote:
U-Boot loads the linux kernel in RAM where ever you tell it to and then jumps to the linux kernel entry point. The linux kernel, on start up, relocates itself to where *it* wants to live and then proceeds.
This is not correct. You load the kernel to some memory address (in RAM or flash or SRAM etc.). U-Boot will then copy (or "load") it to the address givenm in the "load address" parameter of the image file, and then jumpt to the entry point address given in the "entry point address" parameter of the image file. Normally (at leats on PowerPC), Linux will NOT relocate itself (it may set up the MMU later, but the initial execution starts exactly at the "entry point address").
Best regards,
Wolfgang Denk

Hello
2009/1/22 Vinay Venkataraghavan raghavanvinay@yahoo.com:
How do I turn on debugs in uboot. Is there a compile time flag or is there and #define that needs to be turned on. I looked in the code and could not find how all the debugs are related and can be switched on?
You may define DEBUG right in your board's configuration file. Will provide you with lots of useful debug messages.
participants (4)
-
Jerry Van Baren
-
Roman Mashak
-
Vinay Venkataraghavan
-
Wolfgang Denk