Hello,
after facing problem with ULINK2 with using Memory layout from Target Register of uVision, I have switched to Scatterfile with followed content:
; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00100000 { ; load region size_region ER_IROM1 0x08000000 0x00100000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) } RW_SDRAM1 0xC0000000 0x00100000 { ; RW data stored in SDRAM (1M) .ANY (+RW +ZI) } RW_IRAM1 0x20000000 0x00040000 { .ANY (+RW +ZI) } RW_IRAM2 0x20040000 UNINIT 0x00010000 { EventRecorder.o (+ZI) } }
But now I can not start my Debugger, because I'm redirect to HardFault_Handler. If I stop the debugger and show Callee Code, it points to MemManage_Handler.
I'm trying to access in Compiler v5 (C99 mode) external SDRAM from CubeMX and self defined Viriable as followed:
__attribute__ ((at(0xC0050000))) uint32_t framebuffer[2];
Who knows the solution? Maybe the Scatter file is wrong for that situation?
It is very difficult to decipher the solution from just the above information. 0xC0050000 should be located within RW_SDRAM1 region. Has the memory been initialized when the code attempts to write to it?
I suspect you will need to debug the initialization code. In the Project Options, go to the Debug tab, and deselect "Run to main()" so that the code loads and stops at the initial Reset handler. You can step through from there to determine when exactly in the code this HardFault is triggered. Trace is also a very useful tool if this is available to you.
Is your SDRAM controller configured correctly?
Does your MPU configuration allow access to those addresses?
MPU is not used but with SDRAM I'm not sure, I'm using the CubeMX configuration.
Activating of MPU takes no improvements:
my FMC Confiiguration is as followed:
Thanks for the answer, the crash is happening in followed routine (line 9)
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP
Breakpoint is at the beginning of main is activated and til that breakpoint cames the execution not
MPU activation regarding that tutorial takes no improvment - it stays the same.
Thanks for the hint. Now it is working. I have applied followed ST Tutorial. After Correktur to Rigion Size to 0x00040000 (because it is in int32) and disable RW_IRAM2 it working with Debugger Variables and it doesn't crashing. I will maybe open new Request for not possible access from Code to SDRAM.