boot.c code runs with debugger but wont run without it!?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

boot.c code runs with debugger but wont run without it!?

跳至解决方案
2,149 次查看
CarlFST60L
Senior Contributor II

Hi,

 

I am using the Cyclone MAX, CW7.1.2, MQX3.5 and 52259evb.

 

I have some code running in boot.c to illustrate the issue. The code is like this:

 

 

 

// Inside boot.c

asm void __boot(void) {
// MQX boot code as normal
// Modified last line only
         jsr bootloader_init  
}

typedef void(*pt2Func1)(void);
extern volatile pt2Func1 fp_mcf5225_init_image2;
extern volatile pt2Func1 fp_start_image2;

void bootloader_init(void)
{
 pt2Func1 _MQX_BOOT1;
 pt2Func1 _MQX_BOOT2;
        _MQX_BOOT1 = fp_mcf5225_init_image2; //From MRAM
        _MQX_BOOT2 = fp_start_image2; //From MRAM
 _MQX_BOOT1();      
 _MQX_BOOT2();      
 BootLoaderFail();
}     

 

 

The above code is in MRAM by way of this lcf entry:

 

    .MBL_Page:
    {
        Boot.c (.data)
        Boot.c (.rodata)
        Boot.c (.text)
    } > MBL   //(RX): ORIGIN = 0x1005E000, LENGTH = 0x00001FD0

 

The two MQX boot variables are in MRAM something like this:

 

 

// MBR_2.c
typedef void(*pt2Func1)(void);
extern void mcf5225_init(void);       
extern void _start(void);

volatile pt2Func1 fp_mcf5225_init_image2 = mcf5225_init;        //Boot location image 2
volatile pt2Func1 fp_start_image2 = _start;                        //Boot location image 2

 

 

And the above variables are put in MRAM by this

 

 

        .Bt_Img_Info_Page:
    {
        MBR_2.c (.data)
        MBR_2.c (.rodata)
        MBR_2.c (.text)
    } > Bt_Img_Info //(RX): ORIGIN = 0x1005FFD0, LENGTH = 0x0000002F

 

The S19 and elf read OK, when stepping through the code the code all works as expected, it runs from MRAM, loads the two MRAM variables and boots as expected. The assembly code loads the correct address...

 

Why would the code work 100% through the debugger and not without it? Its a little hard to debug because it works with the debugger! IS there something about the MRAM? Or is it something to do with how I have declared my variables?

 

In the project settings I have "initial launch" setup to download Exe, Const, Init (so it will program MRAM) and "Successive Runs" all unchecked. I figure if you have them all unchecked this will stop it sending any initialises data and simulate a hard boot?

 

 

0 项奖励
回复
1 解答
986 次查看
CarlFST60L
Senior Contributor II

There are two problems with what I was doing:

1. Even though I turned off the "Program Download Options", you still need to uncheck 'Use Target Init File' and 'Use Mem Config File' to stop anything from downloading.

2. You cannot run boot code from MRAM as Flexbus wont work without being configured , you must boot from flash.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
986 次查看
CarlFST60L
Senior Contributor II

I have done some more research and realized, quite obviously, that the FlexBUS must be configured to read MRAM.


Is there anything else I need to initialize to get the processor up and running so it will run my basic C code from MRAM? Is there some example initialization code somewhere?

 

I am going to start looking at the example for 52259evb startup code...

 

0 项奖励
回复
987 次查看
CarlFST60L
Senior Contributor II

There are two problems with what I was doing:

1. Even though I turned off the "Program Download Options", you still need to uncheck 'Use Target Init File' and 'Use Mem Config File' to stop anything from downloading.

2. You cannot run boot code from MRAM as Flexbus wont work without being configured , you must boot from flash.

0 项奖励
回复