LPC54608 and code in External RAM

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

LPC54608 and code in External RAM

5,262 Views
giannigrondona
Contributor III

Hi

I tried to allocate a simple routine written in C in the external memory RAM. The map File is corret and the address of routine is in esternal RAM (0xa0000000). The esternal RAM work in a correct way, I used the example in SDK to initialize external RAM component, Inside external memory at the adress 0xa0000000 I found the expected code.

The problem is when my main  call the routine placed in RAM  I get an exception (hard fault) for IACCViol.

In Im1 you can see the dissasembly code before calling the C routine ( MYFuncRAM4). In the memory window you can see the address of C routine placed in RAM (0xA0000000). In Im2 you can see in the memory window the RAM memory at address 0xA0000000 the C routine ( MYFuncRAM4). 

After a single step (F5 from MCUXpresso) I get the error you can see in Im3.

Any help?
Thank you

Best Regards

Giovanni

Labels (1)
0 Kudos
10 Replies

4,381 Views
giannigrondona
Contributor III

Thank you for your help. Could you tell me the document where I can find Optional Memory Protection Unit ?
Best Regards

Giovanni

0 Kudos

4,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Giovanni Grondona,

Thanks for your reply.

4.5 Optional Memory Protection Unit in the attachment.

Have a great day,

TIC

 

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

0 Kudos

4,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Giovanni Grondona,

The __RAMFUNC(RAM) macro can relocate the function into the internal RAM, however it doesn't suit for the external RAM, as startup code can't  then perform the necessary initialization (copy code/data from Flash to RAM) well by following the managed linker script mechanism.

So I'd like to suggest that you need to copy the specific function whose stored in the flash to the external RAM manually.

Hope it's clear.
Have a great day,
TIC

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

0 Kudos

4,381 Views
lpcxpresso_supp
NXP Employee
NXP Employee

This is not strictly true. You simply need to ensure that the code that carries out the setup of the external RAM is called from the startup code before the code that does the flash -> ram copying.

Regards,

MCUXpresso IDE Support

0 Kudos

4,381 Views
giannigrondona
Contributor III

Hi 

I have initialized Dynamic RAM BEFORE the copy From Flash To Ram.as you can seen from file startup_lpc54608.c I have enclosed in my project zip file. The RAM afer the copy contains the right code....doesn't work the jump

Regards

Giovanni Grondona

0 Kudos

4,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Giovanni Grondona,

Yes, I see.

I have a idea to confirm whether the data copied to RAM successful.

You can find that the which address the function store in the Flash in map file, and you can read the function from the external SDRAM to compare the function stored the Flash via the Memory window in the MCUXpressor.

I'm looking forward to your reply.

Have a great day,
TIC

 

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

0 Kudos

4,381 Views
giannigrondona
Contributor III

Yes the two memory area contain the same code...compared byte to byte.....when the Program counter jumps to SDRAM triggers an execption

Best Regards

Giovanni

0 Kudos

4,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Giovanni Grondona,

After discussing with the AE team, we analyzed that 0xA0000000-0xDFFFFFFF is none executable region by default (ARM Cortex M4 devices generic user guide chapter 2.2), All instruction fetch is prohibited. User should use MPU to override default setting.

2017-08-04_14-46-57.jpg

After testing, the "fault" in register windows called "iAccVoil" and its explanation is below.

Instruction access violation flag:
0 = no instruction access violation fault
1 = the processor attempted an instruction fetch from a location that does not permit execution.
This fault occurs on any access to an XN region, even when the MPU is disabled or not present.

So we think it's the root cause of the issue.
Have a great day,
TIC

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

4,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Giovanni Grondona,

After going over the statement of the thread, I was wondering if you can share the sample code, then I can replicate the issue on my site by running the code.

I'm looking forward to your reply.

Have a great day,
TIC

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

0 Kudos

4,381 Views
giannigrondona
Contributor III

Hi 

Re: LPC54608 and code in External RAM
jeremyzhou

jeremyzhou

I have attached a zip file contained all the project.

Best Regards

Giovanni

0 Kudos