Jump to kernel from bootloader

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Jump to kernel from bootloader

893 Views
jaimepena
Contributor II

Hello all, I write due to a big question I have. I am using a custom board of imx6 with a custom bootloader and I am trying to copy the zimage from pnor to ram. There is no problem copy the information and then I want to jump to the memory address of the kernel to start its execution but it doesn work.

I found this same process in the u-boot file like the following: 

int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong (*zboot_entry)(int, char * const []) = NULL;
char *s0, *s1;
unsigned char *param = NULL;
char *cmdline;
char *bootargs;

disable_interrupts();

if (argc >= 3) {
/* argv[1] holds the address of the zImage */
s0 = argv[1];
/* argv[2] holds the address of zero page */
s1 = argv[2];
} else {
goto exit;
}

if (s0)
zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);

/* empty_zero_page */
if (s1)
param = (unsigned char*)simple_strtoul(s1, NULL, 16);

/* Linux kernel command line */
cmdline = (char *)param + COMMAND_LINE;
bootargs = getenv("bootargs");

/* Clear zero page */
/* cppcheck-suppress nullPointer */
memset(param, 0, 0x1000);

/* Set commandline */
strcpy(cmdline, bootargs);

/* Boot */
zboot_entry(0, NULL);

exit:
return -1;
}

So if the address of my kernel is 0x4000000 how should I jump to that address? Can someone explain me how this is working to do the jump? 

zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);

In internet i found this to jump to a memory address:

unsigned long address=0x80;
void (*func_ptr)(void) = (void (*)(void))address;
func_ptr();
but how exactly does it work?
Thanks for the help.
Labels (2)
0 Kudos
1 Reply

633 Views
igorpadykov
NXP Employee
NXP Employee

Hi Jaime

in general this may be debugged using AN4553 Using Open Source Debugging Tools for

Linux on i.MX Processors
http://www.nxp.com/assets/documents/data/en/application-notes/AN4553.pdf
and may be recommended to post this to uboot mail list

U-Boot Info Page 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos