Thanks for the probability that I decided to go to TH-cam 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.
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
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!
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.
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.
I mention it in this video "th-cam.com/video/HCfq44NNBaU/w-d-xo.html" and also add a make rule for it. The specific command/tool will vary depending on the microcontroller and debugger.
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!
Nice tutorial. But why is this int a[5] = { 0xAAAA, 0xBBBB, 0xCCCC }; placed in .const and .data instead of only in .data? Is this not a variable which can be modified at runtime? As far as I know arrays are not constants like strings? Also why is the global int c[5] 'only part of the ram'? Isn't it both in .bss in flash and then in .bss in RAM after the startup code initializes the RAM?
RAM contains garbage after power reset. So before we get to main(), the RAM variables (variables that can be modified at runtime) must be initialized. But to do this we must know what the the initialization values should be, and that information we are store in flash. In other words, a[5] first contains garbage, but is then overwritten with the initialization values from flash (.const). c[5] is also stored in RAM, but it's zero-initialized, and for space-efficiency (bss sometimes called "better save space") we don't store that information in flash. Instead the zero-initialized RAM variables are simply initialized to 0.
Yes this is something I could see myself doing a video about in the future. Until then, I can recommend this blog post series interrupt.memfault.com/tag/zero-to-main/. No they are not equivalent.
@@cihan1995 The IDE is CCSTUDIO from TI with MSP430 microcontroller. Though you could repeat this with other IDEs and MCUs as well. At the end I just use the bare-bone toolchain, GCC in this case, and Make.
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 ?
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.
ELF and linker scripts are not what you flash/upload, they are just intermediate files used during the compilation process that outputs the final machine code (typically a hex file). It's the final machine code (hex file) that is flashed/uploaded to the MCU with a dedicated programmer (e.g. segger-jlink, stlink). A bootloader is a small program that provides a convenient alternative interface (e.g. usb, uart, i2c , wifi, bt...) for uploading your normal application code (typically hex) without the need for a dedicated programmer. The bootloader has the same compilation process as described above and must be flashed with a dedicated programmer (technically not always true, e.g. multi-stage/self-updating bootloader).
why "int d[5]" which is the first thing in main () is not the first address of .text section ? why it is exists in the first address in . const section?
int d[5] is not constant, it's a variable allocated on the stack. The data it's initialized with is constant, and because of that it's stored in the .const section. The .text section holds the program code so it will have the instructions that copies the const data from .const section to the stack.
Although the values you are using for initialization are constants, they are not stored in a separate constant section when used in this context. Instead, they are part of the initialization process and directly copied into the memory allocated for the array on the stack.
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? :)
embeddedartistry.com is a good resource for embedded programming. I like Robert Feranec and Phil's lab for TH-cam tutorials on electronics/PCB design. Best way to learn in my opinion is to work on a project, start with a simple one, and let that guide your learning.
Flash and RAM are separate, but both are ntegrated into the microcontroller for benefits of space, cost, latency, design simplicity, and so on. Memory mapping allows us to programmatically access them in a similar manner, but they are still physically separated and behaves differently (e.g. Flash retains data on reset while RAM does not).
This is brilliant content. Жаль что embedded вообще не популярный и умирает. Не подскажете, вы работаете и как обстоит рынок в сфере embedded? Я бы очень хотел в эту сферу, но в связи низким спросом я сейчас учу backend чтобы выжить и прокормить себя.
I'm not Russian, but I translated. The embedded field is indeed less popular and harder to break into than other fields of programming, but it is by no means a dying field. It's not like we are getting fewer embedded systems around us :) But it is an evolving field, and we are slowly moving up the stack (e.g. less bare-metal, more OS-based systems). Yes, I work as an embedded systems engineer, and the market for embedded programming is good. If you know your way around C/C++ there is no shortage of jobs. Of course, the situation may vary depending on where you are located.
Thanks for the probability that I decided to go to TH-cam 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.
I find the first 15 minutes to have 80% of the value of this whole video. Thanks a lot!
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
Turn back, you are going the wrong way 😉😉
Please TH-cam recommend me again, i will watch it in the future, very tired right now
One of the best videos detailing the memory work, job well done - thank you.
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!
Commenting as a bookmark to watch this a few times lol
Best video ever in this topic, it gather more than what I've expected together. Thank you very much bruuuuuh
One of the best explanations I have ever heard before. Thanks a Lot ..👏
simply wow
Thank you for this great content. This explains very well how the memory is allocated !
How can I learn the details of all of this information? Do you recommend a book or set of books/lectures?
Amazing Video. Thank you for creating this.
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.
I won't be doing it for this video series since I'm not writing any unit tests in this project, but it is a topic I would like to cover in the future.
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.
I mention it in this video "th-cam.com/video/HCfq44NNBaU/w-d-xo.html" and also add a make rule for it. The specific command/tool will vary depending on the microcontroller and debugger.
@@artfulbytes Do u understand that u brilliant?
@@isakneuman9995 😇
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!
That would be "Iosevka Nerd Font Mono".
Memory layout so well explained. What is the IDE you use?
I got interviews coming up and this video is super helpful, thx.
Good luck on your interviews!
Incredible video❤️ very helpful! Thanks : )
Nice tutorial. But why is this int a[5] = { 0xAAAA, 0xBBBB, 0xCCCC }; placed in .const and .data instead of only in .data? Is this not a variable which can be modified at runtime? As far as I know arrays are not constants like strings?
Also why is the global int c[5] 'only part of the ram'? Isn't it both in .bss in flash and then in .bss in RAM after the startup code initializes the RAM?
RAM contains garbage after power reset. So before we get to main(), the RAM variables (variables that can be modified at runtime) must be initialized. But to do this we must know what the the initialization values should be, and that information we are store in flash. In other words, a[5] first contains garbage, but is then overwritten with the initialization values from flash (.const).
c[5] is also stored in RAM, but it's zero-initialized, and for space-efficiency (bss sometimes called "better save space") we don't store that information in flash. Instead the zero-initialized RAM variables are simply initialized to 0.
Thanks a lot. Could you please explain boot process ?
I also wonder, is start up code is the equivalent of boot manager and flash loader?
Yes this is something I could see myself doing a video about in the future. Until then, I can recommend this blog post series interrupt.memfault.com/tag/zero-to-main/. No they are not equivalent.
thank you, can you please also let me know the tools you used in this video ? I would like to repeat steps learned here on my own@@artfulbytes
@@cihan1995 The IDE is CCSTUDIO from TI with MSP430 microcontroller. Though you could repeat this with other IDEs and MCUs as well. At the end I just use the bare-bone toolchain, GCC in this case, and Make.
beautifully explained, thank you!
Best..all in one video🙏
This video is awesome ! Thanks for the information
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 ?
VERY useful, thank you for your videos!
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.
ELF and linker scripts are not what you flash/upload, they are just intermediate files used during the compilation process that outputs the final machine code (typically a hex file). It's the final machine code (hex file) that is flashed/uploaded to the MCU with a dedicated programmer (e.g. segger-jlink, stlink). A bootloader is a small program that provides a convenient alternative interface (e.g. usb, uart, i2c , wifi, bt...) for uploading your normal application code (typically hex) without the need for a dedicated programmer. The bootloader has the same compilation process as described above and must be flashed with a dedicated programmer (technically not always true, e.g. multi-stage/self-updating bootloader).
nice videos and good explanation.
why "int d[5]" which is the first thing in main () is not the first address of .text section ? why it is exists in the first address in . const section?
int d[5] is not constant, it's a variable allocated on the stack. The data it's initialized with is constant, and because of that it's stored in the .const section. The .text section holds the program code so it will have the instructions that copies the const data from .const section to the stack.
Although the values you are using for initialization are constants, they are not stored in a separate constant section when used in this context. Instead, they are part of the initialization process and directly copied into the memory allocated for the array on the stack.
Great stuff.
awesome explanation 👏
The variable 'i' cannot be stored in flash because flash memory does not have the ability to write values during runtime.
Yes you are right, I should have been more clear there. The loop code is in flash, but the variable is in ram.
Stack or heap
On some microcontrollers it can, but it's not used for those situations
educative and informative 👍
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? :)
embeddedartistry.com is a good resource for embedded programming. I like Robert Feranec and Phil's lab for TH-cam tutorials on electronics/PCB design. Best way to learn in my opinion is to work on a project, start with a simple one, and let that guide your learning.
@@artfulbytes thanks for the recommendation!
CFBR @@artfulbytes
Nice 👍
noob quation : where can i find that page you are working on
how about struct union and pointers?
In terms of where they are allocated is the same as other data variables, but yes could have been good to include them as examples too.
Awesome explanation which IDE are you using bro?
CCStudio
what kind IDE u use in this video?
Code Composer Studio (CCSTUDIO IDE) from TI
Do you use visual studio code as IDE ?
Sometimes, but not in this video series.
why are flash and RAM on the same media?
Flash and RAM are separate, but both are ntegrated into the microcontroller for benefits of space, cost, latency, design simplicity, and so on. Memory mapping allows us to programmatically access them in a similar manner, but they are still physically separated and behaves differently (e.g. Flash retains data on reset while RAM does not).
Thanks a lot 🎉
great. thx🤗
nice job!
This is brilliant content.
Жаль что embedded вообще не популярный и умирает. Не подскажете, вы работаете и как обстоит рынок в сфере embedded? Я бы очень хотел в эту сферу, но в связи низким спросом я сейчас учу backend чтобы выжить и прокормить себя.
I'm not Russian, but I translated. The embedded field is indeed less popular and harder to break into than other fields of programming, but it is by no means a dying field. It's not like we are getting fewer embedded systems around us :) But it is an evolving field, and we are slowly moving up the stack (e.g. less bare-metal, more OS-based systems). Yes, I work as an embedded systems engineer, and the market for embedded programming is good. If you know your way around C/C++ there is no shortage of jobs. Of course, the situation may vary depending on where you are located.
damn you so good at it
Good
Pls make video in slow motion
subscribed to the shrug
man that is a lot of talking about screenshots