Keynote Video: Elecia White Finds Treasure in the Memory Map

If you dig microcontrollers, and you like to dig into how they work, Elecia White wants to help you navigate their innermost secrets with the help of memory map files. In this refreshingly funny, but very deep keynote talk from the 2021 Hackaday Remoticon, Elecia guides us through one of the most intimidating artifacts of compilation -- a file that lists where everything is being put in the microcontroller's memory -- and points out landmarks that help to make it more navigable.

And when you need to look into the map file, you probably really need to look into the map file. When your embedded widget mysteriously stops working, memory problems are some of the usual suspects. Maybe you ran out of RAM or flash storage space, maybe you have some odd hard fault and you want to know what part of the program is causing the trouble, or maybe you need to do some speed profiling to make it all 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 file from a "hello world" program, but it's a hello world running on an RTOS, so already there's enough meat to dig into. She starts out with the top-level overview: flash for the code and RAM for the program to use. In flash, the code lives in .text and .const, and RAM has sections that should be familiar to you like .heap and .stack, but also .data and .bss. The memory map file also follows this structure: first an overview, then the section markers, and then the details of what's inside each section.

If you get a crash, for instance, and you know where the numerical value of program counter when it went all pear-shaped, the .text section lists the function name where that happened. The section with global variable definitions, listed alphabetically? You can probably just scroll on by that -- there's a lot of redundancy in the map file, sometimes sorted by memory address, sometimes sorted alphabetically. You don't want to read a map file, you just want to dip in, get what you need, and get out. Got a variable that you think is getting overwritten? Find it in the section listed by address, and look at its neighbors -- one of them might be overrunning.

But the real star of the show is the beautiful map Elecia made in the style of a role-playing game. Across the River of Initialization from the Static Shores, you'll find RAMlandia, the high planes of the Stacks, the low boggy Heap Hallows, and the Port of (memory mapped) Peripheral Registers. There are actually dragons in the Ocean of Unused Address Space. By switching back and forth between this fun, but useful, map and the actual text memory map file, Elecia ties a memorable view of memory with the dense text of the map file as it lives in your project folder.

And no talk about memory in microcontrollers is complete without noting the dangers of what happens when the RAM's heap, which grows downwards, kisses the RAM's stack, which grows upwards. What happens then? One more function call and the functions start overwriting your data. "This is fine. Like a dog sitting in a cafe on fire." The problem is, this is the part of memory management that's dynamic, functions call other functions and memory is allocated and cleared. User input changes which parts of the program run, and thus where data is stored. Here is the one place where the memory map won 't help you, except to find out what's nearby where the crash happened. But the true answer to "How much RAM do I have now?" truly is ineffably "I dunno."

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

#cons #hackadaycolumns #microcontrollers #2021hackadayremoticon #eleciawhite #memory

Keynote Video: Elecia White Finds Treasure In The Memory Map

If you dig microcontrollers, and you like to dig into how they work, Elecia White wants to help you navigate their innermost secrets with the help of memory map files. In this refreshingly funny, b…

Hackaday

Mastering Memory for Microcontrollers: Elecia White to Deliver Remoticon Keynote

I'm excited to share the news that Elecia White will deliver a keynote talk at the Hackaday Remoticon in just a few short weeks. Get your free ticket now!

Elecia is well-known throughout the embedded engineering world. She literally wrote the book on it -- or at least a book on it, one I have had in my bedside table for reference for years: O'Reilly's Making Embedded Systems: Design Patterns for Great Software. She hosts the weekly Embedded podcast which has published 390 episodes thus far. And of course Elecia is a principal embedded software engineer at Logical Elegance, Inc working on large autonomous off-road vehicles and deep sea science platforms.

Map metaphor used to help visualize microcontroller memory. [Source: embedded.fm]For her keynote, Elecia plans to unwrap the secrets often overlooked in the memory map file generated when compiling a program for a microcontroller. Anyone who has written code for these mighty little chips has seen the .map files, but how many of us have dared to really dive in?

Elecia will use a nifty metaphor for turning the wall of text and numbers into a true map of the code. That metaphor makes the topic approachable for everyone with at least a rudimentary knowledge of how embedded systems work, and even the grizzliest veteran will walk away with tips that help when optimizing for RAM usage and/or code space, updating firmware (with or without a bootloader), and debugging difficult crash bugs.

This autumn is a busy time for Elecia. She's been hard at work turning her book into a ten-part massive open online course (MOOC). Over the years she's been a strong supporter of Hackaday, more than once as a judge for the Hackaday prize (here's her tell-all following the final round judging of the 2014 Prize). She even took Hackaday on a tour of Xerox Parc.

Final Talk Announcements This Week and Next!

The Call for Proposals closed a few days ago. So far we've made two announcements about the accepted talks and we'll make two more, this Thursday and next. But there's no reason to wait. With Elecia White, Jeremy Fielding, and Keith Thorne presenting keynotes, and some superb social activities soon to be unveiled, this is an event not to be missed!

Remoticon is free to all, just head over and grab a ticket! If you want something tangible to remember the weekend by you can grab one of the $25 tickets that scores you a shirt, but either option gets you all the info you need to be at every virtual minute of the conference.

#cons #featured #2021hackadayremoticon #eleciawhite #embeddedengineering #keynote #memory #memorymap #ram

Mastering Memory For Microcontrollers: Elecia White To Deliver Remoticon Keynote

I’m excited to share the news that Elecia White will deliver a keynote talk at the Hackaday Remoticon in just a few short weeks. Get your free ticket now! Elecia is well-known throughout the …

Hackaday