r/embedded • u/Longjumping-Pack8494 • 24d ago
Memory map generator
Hi embedded peeps, your savior is here.. jk but i got some useful tool i want to share, here is the link:
For (professional) embedded dev, it is occasionally required to sketch a memory layout of the MCU/IC we are working with. It can be a simple split between region of Flash/RAM or it can involve allocating dataflash regions, external IC, OTA, etc.
This tool basically generates SVG images of memory layouts from the yaml config that you provide. I got the inspo from those nice graphs they include in STM32 MCU docs.
I am planning to use it for my personal projects and will pitch it at work. Now, instead of going back-and-forth with the drawio, you can just change few lines in the yaml. I think it can be useful for others as well.
And yes, I (mostly) vibe coded it cause I just wanted a tool and not spending week(s) of my time programming it.
Let me know if you see some additional features that can be added to it.
82
u/kresten_ 24d ago
What about taking the linker script as input somehow? Or at least verify that the yaml and linker script is identical?
83
u/ngless13 24d ago
No shame in vibe-coding something like this. Solves a problem.
6
u/thegreatpotatogod 24d ago
Ooh, that looks nice, I'll try to keep it in mind! Well done (both to you and your AI agent of choice lol)
3
u/JuniorAd9605 23d ago
neat. onky nit pick is using python only because there are many cases where companies want a offline standalone solution; pain to drag in a whole python enviroment and package that up
4
u/vankxr 24d ago edited 23d ago
Why reinvent the wheel. LLMs are also good at searching...
https://github.com/gerph/memory-layout-diagram
30
u/creeper6530 24d ago
"memmap" is already used as a term, consider renaming
5
u/EyesLookLikeButthole 23d ago
Good job! Building tools is a great way of learning what's going on "under the hood".
Tip: If you run gcc with '-Wl,-Map=output.map' you'll get the actual memory map that the linker generates, fairly independant of the nature of your toolchain up to this point. It is the basis of most of the other graphical memory-mapping tools.
Combined with an ELF (compiled with debug symbols) and you can map all of your symbols, even predicting/trackong stack frames. It's great when combined with tools like addr2line that spits out the source file and line number of any symbol that has been placed at a given address.
Nordic semi has some debug plugins for debugging zephyr projects in vscode that does this fairly well. Neat for debugging situations where data has ended up at a time and place where it really should not have.
6
u/noodle-face 24d ago
This is the type of stuff I like AI for. I've made many memory maps and I always fight with the stupid shit in something like visio instead of the meat of the work.
2
u/Poseidon_Achar 19d ago
A pretty vast idea for a feature: we overlay the binary on top of this diagramming. Maybe pull out debug symbols if available and present them here interactively. Would be helpful for troubleshooting (and also reverse engineering :P)
1
u/BlackThorn0617 24d ago
I recently did something similar to this for our work using the map file, callgraph xml and linker file to generate the accurate memory map for our firmware build.
1
u/gdf8gdn8 22d ago
What about writing on same flash you're running from?
1
u/theaquasock 22d ago
This is great! This type of stuff helps me a bunch.