Create own flash algorithm from binary

I have a STM32H730VBTx target with a custom board with some own SPI flash memory. The CMSIS database doesn't have the appropriate driver for my MCU / memory chip combination.
I have read how to make an own "external loader" with STMCubeIDE / STMCubeMX. I think, that term means the same as "flash algorithm" in the probe-rs world.

Now I want to use the convinient assistant of STMCubeMX for generating the external loader source with all nessecary pinout configurations, initializations etc. I see no use in (re)writing that stuff by hand in rust.
But, I want to write my main application in rust. So I'd like to use the generated external loader from STMCubeIDE with my rust toolchain (VSCode, rust-analyzer, probe-rs).

How Can I achieve this? I can compile the external loader inside STM32CubeIDE to an elf file. But then what? How to I get this ELF file into my probe-rs target definition yaml under "flash_algorithms -> instructions" ? I see some BASE64-enconding in the existing target-yamls. But when I use the probe-rs' flash-algorithm-template and compare the base64-decoded "instructions" of the resulting yaml with the resulting ELF, it's totally different. So, there must be some other magic involved?

Or any other way or tool to achieve this?

Ok, one possibility I see in integrating the STM32CubeProgrammer into my Rust Toolchain as a GDB server. Might work (didn't try yet), but anyway I'd like not to have 2 toolchains ready, after my flash algorithm is ready. Also, there are other developers of the main application in rust, and it would be tedious, if all of them also would need to install the STM tools too.

Any solution somebody, ELF file -> probe-rs target?

Ahh, it's that easy, I just found it accidently here:
target-gen elf -u some/flash-algo.elf TARGET.yaml

So, I failed in writing an external loader in STMCubeIDE, but Clive Turvey did that. Thanks to him, I have a working "external loader", tested with STMCubePorgrammer: stm32extldr/h7_is25lp128/CLIVEONE-IS25LP128_STM32H72X-PA3-PC11-PC9-PC10-PE2-PA6.stldr at main · cturvey/stm32extldr · GitHub
Now, when I try

target-gen elf -u CLIVEONE-IS25LP128_STM32H72X-PA3-PC11-PC9-PC10-PE2-PA6.stldr TARGET.yaml

I get

Error: Failed to extract flash information from ELF file 'CLIVEONE-IS25LP128_STM32H72X-PA3-PC11-PC9-PC10-PE2-PA6.stldr'.

Caused by:
    Failed to find 'FlashDevice' symbol in ELF file.

Can someone help me, how do I get the "FlashDevice" symbol into that elf?

This is the symbol table of the elf file:

$ objdump -t CLIVEONE-IS25LP128_STM32H72X-PA3-PC11-PC9-PC10-PE2-PA6.stldr

CLIVEONE-IS25LP128_STM32H72X-PA3-PC11-PC9-PC10-PE2-PA6.stldr:     Dateiformat elf32-little

SYMBOL TABLE:
00000000 g     O .info	000000c8 StorageInfo
240007c1 g     F .prog	000001e0 Init
240009a1 g     F .prog	00000004 DeInit
24000aa1 g     F .prog	000000a4 Write
24000a31 g     F .prog	00000070 Read
24000a21 g     F .prog	0000000e MassErase
240009a5 g     F .prog	0000007c SectorErase

Same error message Failed to find 'FlashDevice' symbol in ELF file I also get for any arbitrary external loader that is delivered with STM32CubeProgrammer inside the STM32CubeProgrammer/bin/ExternalLoader directory.

This is such a niche topic you are probably better off asking in the rust embedded matrix channel: https://matrix.to/#/#rust-embedded:matrix.org

That said, please report your findings here to build up the searchable knowledge base for future programmers going down the same path, let's avoid this:

image
(from xkcd: Wisdom of the Ancients)

Yes, I'll do that, that was the reason for post 3.
But here's a better space (room) for explaining the problem and a better findability for the solution, as You said. :+1:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.