2013-11-02 02:08 AM
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-fmc2013-11-02 04:28 AM
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¤tviews=426]this thread2013-11-02 08:15 AM
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 regards2013-11-02 11:12 AM
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.2013-11-03 02:34 AM
2014-05-22 07:33 PM
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! ning2014-05-22 09:26 PM
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
}