How Microcontroller Memory Works | Embedded System Project Series #16

preview_player
Показать описание
I explain how microcontroller memory works with a code example. I use my IDE's memory browser to see where different variables end up in memory, and I demonstrate two command line tools to track how much flash memory my code occupies. Overall, knowing how memory works is important because microcontrollers have a limited amount of it, and if we are not mindful of how we write our code, we may run out of it.

0:00 Overview
1:30 Flash and RAM
3:22 From source code to memory
7:12 Code example
8:07 Different variables
12:20 Program code
13:13 Linker script
14:55 Memory browser and Map file
24:22 Surprising flash usage
27:30 Tool 1: Total flash usage
31:38 Tool 2: readelf
33:53 git commit
33:15 Last advice

#embeddedsystems #cprogramming #microcontroller

Code:

🌍 Links related to this video

🌍 Find me here

👨‍💻 About me
Hi and welcome. I'm Niklas, an embedded systems engineer from Sweden. On this channel, I make practical videos about embedded systems or, in general terms, about building and programming hardware.
Рекомендации по теме
Комментарии
Автор

Thanks for the probability that I decided to go to YouTube at 2 o'clock in the morning. You have such a storehouse on the channel. I will definitely watch every video and I am 10, 000% sure that every video will be super useful.

isakneuman
Автор

I find the first 15 minutes to have 80% of the value of this whole video. Thanks a lot!

SurvivalSquirrel
Автор

I like this kind of detailed low-level explanation. I port a ton of code from c/c++ into forth and basically have to know this stuff at a deep level. Thank you

codeth
Автор

Thanks, you put all the information I wanted into one video. The way a program is stored into the physical memory of a computer which runs a OS and has a MMU is very different to how a program is allocated to the microcontrollers memory. It was confusing to read and make sense of on my own! Thanks for uploading!

sqlbkby
Автор

Commenting as a bookmark to watch this a few times lol

L.Lagrange
Автор

One of the best videos detailing the memory work, job well done - thank you.

fifaham
Автор

Best video ever in this topic, it gather more than what I've expected together. Thank you very much

abdelrahmanyasser
Автор

One of the best explanations I have ever heard before. Thanks a Lot ..👏

Illayarajamuruga
Автор

Thank you for this great content. This explains very well how the memory is allocated !

Jindraxx
Автор

Hi, thank you for your contributions your videos are really helpful. Would you consider to make a video or video series maybe on how to use unit testing on embedded systems? Thanks in advance.

ArdaX
Автор

I got interviews coming up and this video is super helpful, thx.

alexgillespie
Автор

VERY useful, thank you for your videos!

pieterboning
Автор

This video is awesome ! Thanks for the information

juanrodrigoguerrerozarate
Автор

Memory layout so well explained. What is the IDE you use?

prasenjit
Автор

Please record a video explaining how to flash a microcontroller without any IDE. No one pays attention to this topic, but I think this will allow you to understand more deeply how the linker and the compiler in general work. That is, it will open up opportunities to flash not only microcontrollers of the same type, but almost all possible ones. After all, the base is that one.

isakneuman
Автор

Great stuff mate! Just got myself an MSP430 to follow along with some courses and learn about all this stuff, super excited. Just a side question, what font are you using in your terminal, when you were editing your make file? Looks great! Thanks!

xbitbybit
Автор

Thanks for such detailed video, it's nice how you explaining things on such low level.
I'm working as embedded linux engineer but I'd like to learn more low level "embedded" and want to have a good base.

Can you recommend your favourite resources for learning?

Also do you have any recommendation on learning electronics/circuit therory/pcb? :)

kirillyatsenko
Автор

Great video! but I have a question, in arduino when you want to burn a bootlader into a custom board (not uploading the code, just programming it) what you are doing in reality is uploading the ELF and linker script files to the MCU? I am not sure if I am misunderstanding the concepts of bootlader and those files.

rafassm
Автор

i have a question, normally, text section will lowest in flash memory, follow it is another section like data, bss, ... why in your video. text section have higher address than data and bss section ?

tannguyentrong
Автор

Awesome explanation which IDE are you using bro?

walidoulondon