cancel
Showing results for 
Search instead for 
Did you mean: 

32F429IDISCOVERY SDRAM Code execution error!

tmkaran
Associate II
Posted on November 02, 2013 at 10:08

Hi guys,

I have a strange problem about STM32F429-DISCO. I have used this board in a couple of weeks. I have run every hardware blocks successfully including SDRAM. Everything look fine to the right now! I want to execute code from the external SDRAM. But it always fails and throw the ''Hardware Fault'' exception. Why? I try some SDRAM initialization combinitation different from the orginal that is suggested by STMicro. Unfortunately I didn't achieve it. Do you have any idea or suggestions.

accomplish

accomplish

accomplish

#stm32f427-stm32f429-sdram-fmc
6 REPLIES 6
Posted on November 02, 2013 at 12:28

The key problem is that you can't get it to an address within the executable realm.

I discussed my observation at the latter end of [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/STM32F429I-DISCO%20Coming%20Soon&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx?Paged%3DTRUE%26p_StickyPost%3D%26p_DiscussionLastUpdated%3D20131021%252017%253a52%253a40%26p_ID%3D7952%26View%3D%257b78213E56%252dBE73%252d4DDC%252d9047%252dFDE1289499EB%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41&currentviews=426]this thread

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tmkaran
Associate II
Posted on November 02, 2013 at 16:15

Thanks my friend,

It was very usefull information for me. Actually I don't need to execute code from SDRAM at startup. I want to prepare the executable code that will loaded to the SDRAM and jump it. So I remapped the SDRAM Bank2 on STM32F429-DISCO to the Bank4-PC Card with SYSCFG->MEMRMP = 0x00000400. Then I-code cache is activated for Bank4. And my prepared code executed in SDRAM as you say.

Best regards

Posted on November 02, 2013 at 19:12

Initializing the SDRAM at start up was the last thing discussed, and not technically linked to the execution of code, but rather the ability to initialize and fill structures and variables via linker scripts or scatter files.

The code execution tests were done earlier by copying code fragments into RAM prior to execution.

The Cortex-M4 does not permit code execution in 0xC0000000 or 0xD0000000 regions, and to the best of my knowledge doesn't cache instruction spaces either.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tmkaran
Associate II
Posted on November 03, 2013 at 11:34

The Cortex-M4 does not permit code execution in 0xC0000000 or 0xD0000000 regions

I couldn't understand. Actually Code execution is permitted in SDRAM via bank swapping. After the bank swapping, SDRAM Bank1 will reside @ 0x80000000 and SDRAM Bank2 @ 0x90000000. So after this operation,  the code that will be executed can be copied to the new aliased address (0x90000000 for SDRAM Bank2 in STM32-DISCO). And jump the code. It can be executed without any problems. Unfortunately it is very slow than FLASH execution. About it is slower than 6x from FLASH. 

zeus_zhn
Associate II
Posted on May 23, 2014 at 04:33

I met exactly the same problem. Could anyone help? I stuck here for  weeks. Suffering.

I try to this simple test.

1. Swap SDRAM bank 1 to 0x8000 0000 using:

    SYSCFG->MEMRMP = 0x400; 

2. Wrote a simple empty function, and copy to 0x8000 0000.

3. In my main function, I do the sdram and other board initialization. and using:

        jmpusr(0x80000000) which the fucntion is

    jmpusr             PROC

                         BX      R0

     ENDP

But I found it can point pc to 0x8000 0000, and run a few steps, and then hardfault.

Any helpful suggestions?

Thank you!

ning

Posted on May 23, 2014 at 06:26

It would need to be an ODD address for 16-bit Thumb code

#define SDRAM_ADDR 0xC0000000
#define SDRAM_ADDR_SWP 0x80000000
typedef int (*pFunction)(void);
int RamCode(void)
{
static const uint16_t Code[] = { 0xF04F, 0x007B, 0x4770 }; // payload
uint8_t *Buffer = (uint8_t *)SDRAM_ADDR_SWP;
pFunction RunCode;
memcpy(Buffer, Code, sizeof(Code)); // Copy code
RunCode = (pFunction)&Buffer[1]; // +1 for Thumb code
return(RunCode()); // sourcer32@gmail.com
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..