2021-10-22 03:13 PM
Hello every one,
I have being used STM32CubeIDE to develop a project, and then using STM32Programmer to program the code into internal flash. with more features added, specially more images added, the internal memory is not enough to store the code, so we decide to use QSPI external memory to store the images' code.
STM32Programmer is able to program the code into specific memory, either internal flash or external memory with external loader. If my understanding is correct, STM32CubeIDE generates only one executable file including the code stored in internal flash and the code stored in external memory. My question is how to get the separate files, one for internal flash one for external memory? Or is STM32Programmer able to program one file code into corresponding memory according to the code's address?
Thanks in advance!
2021-10-22 03:37 PM
I think the options for objcopy to split the content have been given in other threads around similar topics.
Keil's FromELF to can split sections also.
STM32 Cube Programmer can determine memory regions from .ELF, .DFU and .HEX files which describe the addresses of blocks/lines of data.
2021-10-22 03:44 PM
Hi Tesla,
thank you for your information. can you give the link where to discuss the similar topics?
you mean I can use STM32CubeProgrammer to program the one file, and the Programmer will automatically program the corresponding code into corresponding memory?
2021-10-23 02:14 AM
That's how it's supposed to work.
It can't typically do it from a single .BIN as the regions has a significant separation within the 4GB addressable space of the MCU
Quick forum search yielded
https://community.st.com/s/question/0D53W00000PpuUgSAJ/split-bin-in-multiple-regions
arm-none-eabi-objcopy.exe -O binary --only-section=ExtFlashSection "${BuildArtifactFileBaseName}.elf" ExtFlash.bin
2021-10-25 09:26 AM
Hi Tesla,
Thanks a lot. It works. using arm-none-eabi-objcopy.exe -O binary --only-section=ExtFlashSection "${BuildArtifactFileBaseName}.elf" ExtFlash.bin can generate ExtFlashSection code from the elf file.
2021-10-27 12:47 AM
Just to share an alternative option which may be useful sometimes less useful sometimes:
By default CubeIDE auto-generates makefiles. If you examine the auto-generated makefiles you will noticed that the very last line in this file is:
-include ../makefile.targets
This means, that you are able to manually add a file called makefile.targets In the root of your project. In makefile.targets you can add additional build targets that are not deleted / re-generated each time you click build (opposed to all the contend in the Debug and Release build output folders).
As an example, if I have a project where I use TouchGFX, then I may want to build an additional elf-file only containing graphics resources which are to be placed in external flash. Such build target can be defined in makefile.targets. Below is just some some quick and dirty example as inspiration:
# Tool invocations
graphics_stuff.elf: $(OBJS) $(USER_OBJS) C:\Users\norlandm\STM32CubeIDE\workspace_1.7.0\F7_TGFX\EXT_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS)
arm-none-eabi-gcc -o "$@" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m7 -T"C:\Users\norlandm\STM32CubeIDE\workspace_1.7.0\F7_TGFX\EXT_FLASH.ld" --specs=nosys.specs -Wl,-Map="F7_TGFX.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
@echo 'Finished building target: $@'
@echo ' '
main-build: graphics_stuff.elf