Uncategorized

KEYNOTE VIDEO: ELECIA WHITE discovers TREASURE IN THE MEMORY MAP

If you dig microcontrollers, as well as you like to dig into exactly how they work, Elecia White wishes to assist you navigate their innermost tricks with the assist of memory map files. In this refreshingly funny, however extremely deep keynote talk from the 2021 Hackaday Remoticon, Elecia guides us with one of the most intimidating artifacts of compilation — a data that listings where whatever is being put in the microcontroller’s memory — as well as explains landmarks that assist to make it more navigable.

And when you requirement to look into the map file, you most likely truly requirement to look into the map file. When your embedded widget mysteriously stops working, memory issues are a few of the usual suspects. perhaps you ran out of RAM or flash storage space, perhaps you have some strange difficult fault as well as you want to understand what part of the program is triggering the trouble, or perhaps you requirement to do some speed profiling to make everything run faster. In all of these cases, you get an absolute memory address. What lives there? look it up in the memory map!

Charting a Course

Elecia starts out with the map data from a “hello world” program, however it’s a hello world running on an RTOS, so already there’s sufficient meat to dig into. She starts out with the top-level overview: flash for the code as well as RAM for the program to use. In flash, the code lives in .text as well as .const, as well as RAM has sections that should be familiar to you like .heap as well as .stack, however likewise .data as well as .bss. The memory map data likewise complies with this structure: very first an overview, then the section markers, as well as then the details of what’s inside each section.

If you get a crash, for instance, as well as you understand where the numerical value of program counter when it went all pear-shaped, the .text section listings the function name where that happened. The section with worldwide variable definitions, listed alphabetically? You can most likely just scroll on by that — there’s a great deal of redundancy in the map file, sometimes sorted by memory address, sometimes sorted alphabetically. You don’t want to checked out a map file, you just want to dip in, get what you need, as well as get out. got a variable that you believe is getting overwritten? discover it in the section listed by address, as well as look at its neighbors — one of them may be overrunning.

But the genuine star of the show is the gorgeous map Elecia made in the style of a role-playing game. across the River of Initialization from the static Shores, you’ll discover RAMlandia, the high planes of the Stacks, the low boggy Heap Hallows, as well as the Port of (memory mapped) Peripheral Registers. There are really dragons in the ocean of Unused Address Space. By changing back as well as forth between this fun, however useful, map as well as the actual text memory map file, Elecia ties a unforgettable view of memory with the dense text of the map data as it lives in your job folder.

And no talk about memory in microcontrollers is total without noting the dangers of what occurs when the RAM’s heap, which grows downwards, kisses the RAM’s stack, which grows upwards. What occurs then? One more function phone call as well as the functions begin overwriting your data. “This is fine. like a dog sitting in a cafe on fire.” The issue is, this is the part of memory administration that’s dynamic, functions phone call other functions as well as memory is allocated as well as cleared. individual input modifications which parts of the program run, as well as therefore where data is stored. right here is the one location where the memory map won’t assist you, except to discover out what’s close-by where the accident happened. however the true response to “How much RAM do I have now?” truly is ineffably “I dunno.”

If you’re new to embedded design, perhaps the very first twenty minutes of the talk is for you, as well as even if you’re a hardened veteran, you’ll discover something from the later sections. I thoroughly enjoyed Elecia’s talk, as well as so will you. You can watch it embedded just below. Bring a copy of the slides along too.