2016-10-03 03:39 AM
Hello,
I am using the STM32F746 Discovery Board with STM32 System Workbench IDE. I know SDRAM is a volatile memory but I want copy a picture to the external SDRAM at startup because it's too big for the internal Flash. What I did fist is to initialize the SystemClock and the SDRAM in the SystemInit(). I checked it an it's working fine because I can use it without any more initialisation in the main(). My next step was to define an additional memory block in the LinkerScript. MEMORY { FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K SDRAM (xrw) : ORIGIN = 0xC0000000, LENGTH = 8M } after this I added a section as followed. I copied that idea from the .data section which is copied from the Flash in the internal RAM. SECTIONS { ... /* used by the startup to initialize data */ _sidata_sdram = LOADADDR(.sdram_data); /* Initialized data sections goes into RAM, load LMA copy after code */ .sdram_data : { . = ALIGN(4); _sdata_sdram = .; /* create a global symbol at data start */ *(.sdram_data) /* .sdram_data sections */ *(.sdram_data*) /* .sdram_data* sections */ . = ALIGN(4); _edata_sdram = .; /* define a global symbol at data end */ } >SDRAM AT> FLASH ... } In the assembly written startup file I added .words for the defined addresses in the LinkerScript and a copy routine like for the .data. The routine I added after the SystemInit() that the SysClk and SDRAM are already initialized. /* Call the clock system initialization function.*/ bl SystemInit /* Copy the data segment initializers from flash to SRAM */ movs r1, #0 b LoopCopyDataSdram CopyDataSdram: ldr r3, =_sidata_sdram ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 LoopCopyDataSdram: ldr r0, =_sdata_sdram ldr r3, =_edata_sdram adds r2, r0, r1 cmp r2, r3 bcc CopyDataSdram If I now define a global variable as followed I can't see that it's working. __attribute__((__section__(''.sdram_data''))) uint8_t picture1[] = { ... 0x00, 0xFF, 0xFF, ... }; Does anybody know what I am making wrong? I try to find a solution since a week but nothing is working. :( Or does anyboy have a small programm wich is doing that correctly?2016-10-07 12:05 AM
I understand the differences in hardware but what are the differences in software? Why is it possible to store data in qspi flash at startup without using the internal flash (home_alarm example from st firmware) and not with the sdram?
2016-10-08 02:32 AM
I don't think the qspi content are copied on startup, but rather at programming time. The ST-Link utility has an external loader (as Clive said) that can access this external non-volatile memory and load it with data. It is done just after programming the uC flash, and only once.
2016-10-08 05:37 AM
I understand the differences in hardware...
Ok, so what part of this aren't you getting? The memory that doesn't retain content must be refreshed each time the part starts, this content must be copied from a memory that does retains its content, and that will take up space. ie a Load Region describes and area that can be unpacked into other areas. The FLASH and QSPI can be write ONCE by the downloader. Stuff the needs to be in (SD)RAM either needs to be downloaded each time the part starts up (impracticable outside a debugger), or it must be copied there using a mechanism defined by the linker/loader