lpc54607 Running Application on external ram

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

lpc54607 Running Application on external ram

ソリューションへジャンプ
924件の閲覧回数
omeraygor
Contributor I

Hi,

i ama tring to run application on external ram. wrote a bootloader application that copies bin file from flash to externam sdram. then calling this function.

 

/* execute the firmware exists in sramx. */
typedef void(*func_0_t)(void);
void app_execute_ram_firmware(void * addr)
{
PRINTF("Function Starts...\n");

uint32_t * vector_table = (uint32_t *)addr;
uint32_t sp_base = vector_table[0];
func_0_t pc_func = (func_0_t)(vector_table[1]);
// func_0_t pc_func = (func_0_t)(addr + 4);

PRINTF("Function Starts... vector_table:%x\n",vector_table);
PRINTF("Function Starts... sp_base:%x\n",sp_base);
PRINTF("Function Starts... pc_func:%x\n",pc_func);
/* set new msp and psp. */
__set_MSP(sp_base);
__set_PSP(sp_base);
#if __VTOR_PRESENT == 1
SCB->VTOR = addr;
#endif
/* jump to application. */

pc_func();
/* the code should never reach here. */
while (1)
{}
}

my program output like this:

EEPROM init is OK.
File size is 16872.
BOOTLOADER file is OK.
Function Starts...
Function Starts... vector_table:a0000000
Function Starts... sp_base:20018000
Function Starts... pc_func:a0000415

 

but main code can not start.

 

when i put bootloader code and main code into lpc's internal flash memory. after bootloader , main code is works. 

Then i tested second things.

wrote some dummy data to external sd ram into bootloader. then i can read it again into main code.

is there any missing to work code form external sdram?

 

 

 

0 件の賞賛
1 解決策
905件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you run an api function in SRAMX, it is okay.

But if you want to run an api function in external SDRAM, you have to initialize MPU module as Mr Carsten Groen said.
I attach an application note which tell you how to run code in SDRAM.

Hope it can help you

BR

XiangJun Rong

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
867件の閲覧回数
omeraygor
Contributor I

Hi again, soory late return. coz i moved my office.

and happy endings..

SPIFI flash dma started
Usart functional API interrupt example
Board receives characters then sends them out
Now please input:
EEPROM init is OK.
File size is 16872.
BOOTLOADER file is OK.
Function Starts...
Function Starts... vector_table:a0000000
Function Starts... sp_base:20018000
Function Starts... pc_func:a0000415
Main Bootloader Data:.
MAIN CODE WORKS

thanks. for yor help.

what i done;

MPU->RNR = 0; //Region number 0
MPU->RBAR = 0xA0000000;//Region base address
/* Full Access | TEX: 000 | S: 0 | C: 0 | B:0 (No cacheable, no shareable)| 1M SIZE | ENABLE */
MPU->RASR = (0 << 28) | (0x3 << 24) | (0x0 << 19) | (0 << 18) | (0 << 17) | (0 << 16) | (0xFF < | (0x13 << 1) | (1 << 0); //Region
//size and enable
MPU->CTRL = MPU_CTRL_ENABLE_Msk | MPU_CTRL_PRIVDEFENA_Msk;

 

i added this lines as you said to my code before start main code into bootloader.

 

my bootloader sct file is:

 

 

 

#define m_interrupts_start             0x00000000
#define m_interrupts_size              0x00000400

#define m_text_start                   0x00000400
#define m_text_size                    0x0001A000

#define m_data_start                   0x20000000
#define m_data_size                    0x00018000

#define m_usb_sram_start               0x40100000
#define m_usb_sram_size                0x00002000

 

 

 

 

and my main code sct file is:

 

 

 

#define m_interrupts_start             0xA0000000
#define m_interrupts_size              0x00000400 

#define m_text_start                   0xA0000400
#define m_text_size                    0x0007FC00

#define m_data_start                   0x20000000
#define m_data_size                    0x00018000

#define m_usb_sram_start               0x40100000
#define m_usb_sram_size                0x00002000

 

 

 

 

 

0 件の賞賛
906件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you run an api function in SRAMX, it is okay.

But if you want to run an api function in external SDRAM, you have to initialize MPU module as Mr Carsten Groen said.
I attach an application note which tell you how to run code in SDRAM.

Hope it can help you

BR

XiangJun Rong

0 件の賞賛
919件の閲覧回数
carstengroen
Senior Contributor II

You need to allow "instruction fetch" in the MMU for the external SDRAM:

(Note, in my case below I use area 0xA0200000 and forward, you need to adjust that to fit your application)

  // Set up MPU:
  //  - Region 0: 0xA0200000 - 0xA0300000 --- SDRAM memory
  //              + Size: 1MB
  //              + XN=0: enable instruction fetch
  //              + AP=b011: full access
  //              + TEX=0, S=1, C=1, B=1
  //
  MPU->RNR = 0;//indicate MPU region 0
  MPU->RBAR = 0xA0200000; // update the base address for region 0
  MPU->RASR = 0x03070026 | 0x00000001;
  MPU->CTRL =(1<<0) | (1<<2) ; // Enable the MPU and enable default memory map
0 件の賞賛