[U-Boot-Users] A problem with stack pointer on 8541
Michael
michaelzwrk at gmail.com
Sun Jan 14 20:27:54 CET 2007
Hi.
I am at early stages of board bring-up.
The board uses Freescale 8541 platform.
On function call of one of the first functions, the stack pointer
(stored in r1) gets corrupted.
I tried a couple of things, but I still don't get what is going on there.
Advise will be very much appreciated (what can be the problem and what
should I check).
See some details below:
I use L1 data cache RAM for global data and stack, with the
configuration described below.
I use ELDK 4.0, U-boot 1.1.6.
The problem I face is as following:
When running board_init_f code, seems like the stack pointer (stored
in r1) gets corrupted.
When going through the for (init_fnc_ptr = init_sequence;
*init_fnc_ptr; ++init_fnc_ptr), after returning from
board_early_init_f, the return address is some random value.
I tried following:
1. change CFG_INIT_SP_OFFSET to CFG_INIT_SP_OFFSET - X for various X-s.
Result: I get through the first (few) function(s), but eventually get
the stack pointer corrupted again.
2. put the memset under comment.
Result: I get through the first function, but don't get back from the next one.
Board configuration:
************************************************
#define CONFIG_L1_INIT_RAM
#define CFG_INIT_RAM_LOCK 1
#define CFG_INIT_RAM_ADDR 0xe4010000 /* Initial RAM address */
#define CFG_INIT_RAM_END 0x4000 /* End of used area in RAM */
#define CFG_L2_SRAM_BASE 0xDF000000
#define CFG_GBL_DATA_SIZE 128 /* num bytes initial data */
#define CFG_GBL_DATA_OFFSET (CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE)
#define CFG_INIT_SP_OFFSET CFG_GBL_DATA_OFFSET
***************************************************
Below is the relevant piece of code:
*************************************************************
void board_init_f (ulong bootflag)
{
bd_t *bd;
ulong len, addr, addr_sp;
ulong *s;
gd_t *id;
init_fnc_t **init_fnc_ptr;
#ifdef CONFIG_PRAM
#endif
/* Pointer is writable since we allocated a register for it */
gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
/* compiler optimization barrier needed for GCC >= 3.4 */
__asm__ __volatile__("": : :"memory");
#if !defined(CONFIG_CPM2)
/* Clear initial global data */
memset ((void *) gd, 0, sizeof (gd_t));
#endif
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr) () != 0) {
hang ();
}
}
*************************************************************
Thanks for your help
More information about the U-Boot
mailing list