Hi, i am using DISCO_L496AG, NUCLEO_F413ZH mbed board, as a start i would like to run a basic benchmark code.Agenda:Transferring the data within the same memory type i.e FLASH - FLASH and SRAM - SRAM and capture the time of the data transfer.Here is my code:
(Perform the test by storing the CODE area in FLASH region and CODE area in SRAM region).→ CODE in FLASH can be achieved with the default linker script (I.e CODE resides in FLASH region, DATA, bss, stack resides in SRAM )location of original linker script:mbed-os/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TOOLCHAIN_GCC_ARM/stm32l496xg.ld
Now the real problem starts:
To achieve the 2nd part (CODE area in SRAM region) i am facing lot of issues and i have come-up with the list which i have tried so far… (see below):
1st method: Added a new section to the original linker script and added my main.cpp file into that section and excluded the same file in the original text section but the output of .bin file is very large (in MB) here are my additions to the original linker script:FYI: i have tried placing NOLOAD also to avoid large .bin file but it didn’t worked..text_b :{. = ALIGN(4);__text_b_start = .;main.o(.text* .rodata*). = ALIGN(4);__text_b_end = .;} > RAM.text :{*(EXCLUDE_FILE(main.o) .text .rodata)} > FLASH
2nd Method:Instead of placing complete file into RAM memory i tried to place my private function into particular linker section but ended up with no luck still the code is executing from the FLASH memory only.FYI: I tried other experiment also i.e to keep the “ram” is the VMA & rom in the LMA.Here is my code:.text_b :{. = ALIGN(4);__text_b_start = .;(.text_b)__text_b_end = .;} > RAM AT > FLASH
3rd method(last sad try):The idea is to copy my private function code from the FLASH to the SRAM during the execution which will run from the SRAM execution, i am 100% sure that my function is copying into the SRAM correctly but its going into exception handler. When trying to print the PC address it is correctly printing the my_func() address but throwing an exception.
here is my code:
If anyone knows anything about the issue please help me thanks in advance.
Exception:Here i have tried to print the data located stored RAM address which is exactly matched with the .lst fileNote: here R3 register is the exact location of my_func() but the exception i am getting at location prior to the R3 register (0x20000F6C)
++ MbedOS Error Info ++Error Status: 0x80FF013D Code: 317 Module: 255Error Message: Fault exceptionLocation: 0x20000F6CError Value: 0x20004130Current Thread: main Id: 0x200017C0 Entry: 0x8001E71 StackSize: 0x1000 StackMem: 0x200030F0 SP: 0x200040B0For more info, visit: mbedos-error– MbedOS Error Info –¦m-timestamp-mode-performancem-lap-us-9484m-init-donem-readyData matched with the .lst file38b57946124c13482160fff7acff1248124dfff7a8ff12482f0dff81148fff7a2ff11480232a68d15c268d154133b3f504ff7d1a482f02f96a46b4b1a607b462360724694b1a6038bd0bfe8f020923a489a3a48b41020f0f020aa3a48b81020ecf020e4f020ram func = 20000f6d
++ MbedOS Fault Handler ++
FaultType: HardFault
Context:R 0: 00000014R 1: 0000000AR 2: 00000000R 3: 20000F6DR 4: 20000FE0R 5: 20000FE0R 6: 08043AE9R 7: 20000FECR 8: 08043B6DR 9: 20000FE4R 10: 08043B47R 11: 08043B21R 12: 00000000SP : 200040B0LR : 0800043BPC : 20000F6CxPSR : 01010000PSP : 20004048MSP : 2003FFC0CPUID: 410FC241HFSR : 40000000MMFSR: 00000001BFSR : 00000000UFSR : 00000000DFSR : 00000008AFSR : 00000000Mode : ThreadPriv : PrivilegedStack: PSP
– MbedOS Fault Handler –
++ MbedOS Error Info ++Error Status: 0x80FF013D Code: 317 Module: 255Error Message: Fault exceptionLocation: 0x20000F6CError Value: 0x20004130Current Thread: main Id: 0x200017C0 Entry: 0x8001E71 StackSize: 0x1000 StackMem: 0x200030F0 SP: 0x200040B0For more info, visit: mbedos-error– MbedOS Error Info –
.lst file data: