Bare metal embedded lecture-4: Writing linker scripts and section placement

Поделиться
HTML-код
  • Опубликовано: 6 янв 2025
  • НаукаНаука

Комментарии • 84

  • @ahbarahad3203
    @ahbarahad3203 Год назад +12

    I have been searching for something exactly like this for months on end, tried a dozen books, searched countless tutorials on the internet but i think this is hands down the best resource for arm bare metal programming, only wish i had discovered it earlier

    • @jundo374
      @jundo374 5 месяцев назад

      Yeah, same issue, but for me, it's only been about one week. One week ago, I didn't even know what an MCU was.

  • @pitankar
    @pitankar 4 года назад +51

    This is pure gold! Thanks for doing this. When you put this course up for sale, do let me know. I'll buy it :)
    I've bought all your courses already.

    • @MA-td2ic
      @MA-td2ic 4 года назад +4

      me too :) they deserve every penny spent :D
      I am hoping that they also make a series for advanced communication interface stacks topics (i.e. LWIP, TLS, ethernet, wifi, etc...)

    • @vb9950
      @vb9950 3 года назад

      Check Udemy

    • @FastbitEmbeddedBrainAcademy
      @FastbitEmbeddedBrainAcademy  2 года назад +3

      Thank you Piyush for your support

    • @bobweiram6321
      @bobweiram6321 2 года назад +4

      LOL! I was about to make the same exact statement, so I will take it a step further. These videos are exceptionally good and pure Iridium. Iridium is more rare and more expensive than gold. I believe it also has the highest melting point.

  • @pranit2112
    @pranit2112 4 года назад +18

    Can you suggest books referred here, which covers all these things?

  • @ulysses_grant
    @ulysses_grant 2 года назад +10

    Hi Kiran,
    Why do you use - 4 in SRAM2 origin calculation? (Timestamp: 10:56)
    Thanks so much for the video!

  • @padmaraghunathan4849
    @padmaraghunathan4849 3 года назад +3

    The best ever course on linker scripts, thanks a lot Sir !!!

  • @prometheus05developer68
    @prometheus05developer68 4 года назад +1

    I love you for this precise and on-point explanation of Linker scripts!

  • @24deepakjoy
    @24deepakjoy 4 года назад +2

    What a stuff. So encouraging.. pls continue this series, there’s lot more to learn. 👍

  • @anasskhaldi7840
    @anasskhaldi7840 Год назад

    Think you for your patience and your explanation

  • @AndresFH7233
    @AndresFH7233 Год назад +1

    This class was great, I've already purchased the full course on udemy.

  • @sirajtayyabkhan6820
    @sirajtayyabkhan6820 2 года назад

    True value addition on RUclips! ✔

  • @DimaS-nq4rq
    @DimaS-nq4rq 4 года назад +2

    Thank you, will buy the course at a full price when it will be released!!

  • @jimkokko5
    @jimkokko5 4 года назад +4

    Thank you so much for these videos!
    Just wanted to add the following: I'm following along with an STM32L452RE, and in the .map file I could see that my .isr_vector table as well as any Handlers I had defined in my startup file were discarded (basically mapped to address 0x0). It turns out that instead of `*(.isr_vector)` I needed to write `KEEP(*(.isr_vector))`; the symbols are otherwise thrown away because they are not referenced somewhere else in the .o files. Just thought I'd put that out there for anyone who got stuck like me.

  • @HimanshuSharma-du9nz
    @HimanshuSharma-du9nz 4 года назад +2

    First of all thank you sir for this series its really helpful at this time.
    I been working on QEMU emulator, it will be really helpful if you could make a educational video on this topic.

  • @vevasam
    @vevasam Год назад

    @12:00 We mentioed SRAM1 and SRAM2 memories as just SRAM as they both occupy contiguous memory locations on the processor memory map. Shouldn't this be the case, we would define them explicitly in the MEMORY layout. Isn't it? Please corect me if I am wrong.

  • @linkc598
    @linkc598 6 месяцев назад

    video of the week! thank you.

  • @MohamedMohamed-zg5hg
    @MohamedMohamed-zg5hg 3 года назад +1

    Thank you so much for this .
    I have a question is what happened if linker script is not provided to the linker ?

  • @jankeshchakravarthy9389
    @jankeshchakravarthy9389 Год назад +1

    hi kiran - why do you subtract 4 while calculating SRAM2 ORIGIN ?

  • @omercaylan6623
    @omercaylan6623 4 года назад +2

    Hi Kiran, thanks for everything, will you explain the "GROUP"section? How to set stack and heap and where is the stack pointer stored after set in startup?

  • @pitankar
    @pitankar 4 года назад +3

    I am thinking on this for quite some time now. The FLASH starts at 0x08000000 and because the isr_vector is put first, the stack pointer value is stored at 0x08000000. Is that correct?
    If so, then when the microcontroller powers up the PC would be pointing at 0x00 (please correct me if I am wrong). My understanding is that for the cortex controllers the stack pointer value needs to be stored at 0x00. But in our case it is at 0x08000000. I am a bit confused as to how the controller will pickup the stackpointer value if FLASH doesn't start at 0x0. Can you please help me understand? Am I missing something?

    • @FastbitEmbeddedBrainAcademy
      @FastbitEmbeddedBrainAcademy  4 года назад +7

      Thats a good question . The processor produces 0x00000000 but the STM32 internal design maps it to 0x08000000 based on the settings of boot pins. so by default 0x00000000 mapped to 0x08000000 in stm32.

    • @pitankar
      @pitankar 4 года назад +1

      Fastbit Embedded Brain Academy thanks. Now the story is complete :)

    • @Eren-yl2qi
      @Eren-yl2qi 4 года назад

      Hi, When power up MCU and reset mechanism release the reset condition,it means reset interrupt occured and than cpu internally read(not by code just fetch it internally) 0x08000004 address and branch to actual reset handler function to execute.In the reset handler first thing to do read 0x08000000 by our code and set it to process stack pointer or main stack pointer to set up c function call environment.PC counter never points 0x08000000 address because it is initial stack address pointer it is not a opcode.This is architecture specific mechanism.

    • @khoahuynh6884
      @khoahuynh6884 4 года назад

      to people who confuse, you may want to check this video, ruclips.net/video/3brOzLJmeek/видео.html

    • @ixnisarg
      @ixnisarg 4 года назад

      @@FastbitEmbeddedBrainAcademy is that written in any sort of document? for other controllers where to find?

  • @amitdhiman420
    @amitdhiman420 4 года назад +5

    why is 4 subtracted from SRAM 2 Origin??

  • @jdwlsn
    @jdwlsn 7 месяцев назад

    Great Stuff, Curious why you made SRAM attribute RWX did you plan to store instructions in the same place as data?

  • @sevenfernns
    @sevenfernns 10 месяцев назад

    Hi, thanks for the tutorial. One question, I checked the reference manual for stm32f407xx and it says that SRAM1 has a size of 112KB, how come we write it as 116KB in this linker script? thanks!
    EDIT: I checked other comments and it seems it was a mistake, SRAM1 indeed has a size of 112KB.

  • @DevendraGuptaProfile
    @DevendraGuptaProfile 2 года назад

    Sir on the slide linker script symbol: I guess the address are allocated after linking before that every object file maintain relocatable address against the symbols, please correct me if I m wrong.

  • @fawad9407
    @fawad9407 4 года назад +2

    Thank you so much for this, this is exactly what I needed and you explained it so well

  • @Monk-wv4ub
    @Monk-wv4ub 4 года назад +1

    Which book should we refer for this course .

  • @bennguyen1313
    @bennguyen1313 2 года назад

    The fpga/board designers suddenly said 'here is another 4k memory block at address 0x40000000. How can I
    1) add it to the existing memory pool so that the linker uses it as it pleases.. and/or
    2) add it as a separate section, so that is not available for linker's general use but rather is used only for specific variables
    For example in the case of #2 above, I added in the linker's MEMORY section :
    memblock (rw) : ORIGIN = 0x40000000, LENGTH = 4k
    And at the bottom of the SECTION portion, I added:
    .NEWBLOCK (NOLOAD):
    {
    . = ALIGN(8);
    * (NEWBLOCK);
    } > memblock
    But when I declare a variable attempting to place it in that section,
    char initialized_array[100] __attribute__ ((section ("NEWBLOCK"))) = { 0 };
    int non_init_data __attribute__ ((section ("NEWBLOCK")));
    It links fine (optimazation set to 0/none), yet these variables are located in in the same space any other variable (i.e. not 0x40000000)!
    I've tried with and without the NOLOAD, adding KEEP.. adding bss to the var declaration like section(".bss.NEWBLOCK") but nothing seems to map it correctly!

  • @gauravpuri8716
    @gauravpuri8716 2 года назад

    Very Nice set of videos!!! thanks a lot

  • @emiemi295
    @emiemi295 Год назад

    Hey, i bought your course and it s amazing, but i would like to know how to write the linker script for an arduino(ex: atmega328p chip) and i don t know how to set the memory command because the arduino doesn t have a memory map from what i found or any other explanation on how to load the global variables into sram, any tips would be very helpful, thanks!!

  • @Monk-wv4ub
    @Monk-wv4ub 4 года назад +1

    Wonderful lecture .

  • @AlifSayAwais
    @AlifSayAwais 2 года назад

    what if we remove attributes like xrw and rw ?

  • @danielwarzecha2007
    @danielwarzecha2007 3 года назад +1

    at 11:09 why do you -4??

    • @kirtikumarbaba
      @kirtikumarbaba Год назад

      I also had same question. maybe a mistake?

  • @codeplug
    @codeplug 3 года назад

    Doubt: Why do we load .data to Flash first and then to SRAM? Why not we directly load it into SRAM like we do for .bss section?

    • @ghislainmj
      @ghislainmj 3 года назад +1

      I am also wandering.
      Somebody commented before that ".data needs to be initialized somewhere". i am wandering what that means ?

    • @codeplug
      @codeplug 3 года назад +1

      @@ghislainmj I guess I figured it out - it means you have to store that data somewhere on flash. This is needed because SRAM will lose data on restart. If we store the data directly on SRAM it will be gone after first reset/restart.

    • @ghislainmj
      @ghislainmj 3 года назад +1

      @@codeplug that makes sense. very nice

    • @codeplug
      @codeplug 3 года назад

      @Martin LibTec yes I meant power off. Thanks for correcting

  • @selvalooks
    @selvalooks 2 года назад

    perfect , clean and clear !!!

  • @benjwill3828
    @benjwill3828 3 года назад +1

    thank you, very helpful!

  • @miguelduran900
    @miguelduran900 4 года назад

    Which one of the courses in fastbitlab page cover these topics?

  • @2605mac
    @2605mac 4 года назад

    What IDE should I use to comfortably programming the stm32 husarion board? Are there any ide's that have libraries for it built in?

    • @vladimirtatarchevskiy5886
      @vladimirtatarchevskiy5886 4 года назад

      Use Atollic True Studio. It's free and accessible to download from the st.com website.

  • @mohamedessam2760
    @mohamedessam2760 4 года назад

    at the end of the lecture, you make _sbss = . ; and you've said location counter is tracking VMA, so the location counter is equal to SRAM , due to that it will overwite the .data section .. am i wrong ??

  • @Ibrahimkhan-qo5vw
    @Ibrahimkhan-qo5vw Год назад

    Hi ..are these knowledge available on udemy ...I have taken some advanced course...but can any one provide link for these video where this topics are covered want to buy

    • @FastbitEmbeddedBrainAcademy
      @FastbitEmbeddedBrainAcademy  Год назад

      Hi, these videos are part of this course www.udemy.com/course/embedded-system-programming-on-arm-cortex-m3m4/

  • @sad_old_git
    @sad_old_git 3 года назад

    Does anyone have experience converting scatter files (Keil toolchain equivalent) to linker scripts?

  • @abhijeetraghuwanshi527
    @abhijeetraghuwanshi527 2 года назад

    can you share the ppt please

  • @yasirarafat9946
    @yasirarafat9946 3 года назад

    Wish I could press like button 1000 times. :)

  • @ravitejaj473
    @ravitejaj473 Год назад

    Thank you very much.....✨💫🌟

  • @rahulkumar-bf4cq
    @rahulkumar-bf4cq 3 года назад

    can you make tutorial on FOTA

  • @thineshwarv993
    @thineshwarv993 4 года назад

    hi sir, you have not told anything about stack pointer initialization(plzz.. correct me if i am wrong).

    • @brianthompson876
      @brianthompson876 11 месяцев назад

      He also didn't cover how to create the Interrupt Vector Table (a.k.a .isr_vector section) in the C or assembly code. This comment may be old, but for anyone else who is curious: The Stack Pointer Register is always initialized with the very first long word in the vector table. The default linker script for cortex-m4 processors for CMSIS has a __StackTop symbol that is calculated as at the top of the SRAM (as long as it is an 8 byte aligned address) which can be used at the top of the vector table which initializes the Stack Pointer Register on startup.
      In assembly use: `.long __StackTop` at the top of the vector table.
      In C use: `extern uint_32_t __StackTop;` then put `(void (*)(void))(&__StackTop)` at the top of the vector table.
      If you'd rather not define the symbol in the linker script:
      `#define __StackTop `
      ... In vector table ...
      `(void (*)(void))__StackTop`

  • @jagadeeshgottapu6115
    @jagadeeshgottapu6115 4 года назад

    GNU compiler is there in website for 32 bit system which is mentioned in first lecture. My system is 64 bit. Will it work on my system or not. Please confirm.

  • @mislavkulas4422
    @mislavkulas4422 4 года назад +3

    you have write SRAM1 = 116k and SRAM2 = 16k. Why you didnt then write SRAM 132k but you write it 128k?

    • @FastbitEmbeddedBrainAcademy
      @FastbitEmbeddedBrainAcademy  4 года назад +4

      Hi. Thats a mistake. SRAM1 is 112K not 116K

    • @ulysses_grant
      @ulysses_grant 10 месяцев назад +2

      @@FastbitEmbeddedBrainAcademyThank you. I'm still wondering why you put "-4" there in the calculation anyway.

  • @Danielmelvin7
    @Danielmelvin7 4 года назад

    Awesome stuff!!

  • @hownottobeanengineer3927
    @hownottobeanengineer3927 2 года назад

    very nice lecture

  • @karthiknmurthy
    @karthiknmurthy 4 года назад

    Very good Tutorial...

  • @TSS_CLIPS
    @TSS_CLIPS 7 месяцев назад

    Super lecture.

  • @hgl9590
    @hgl9590 4 года назад

    Hi,
    Can we just load the .data section to SRAM, i.e. set LMA to SRAM, so that we do not need to copy the the .data in the Reset_Handler().

    • @stana.281
      @stana.281 3 года назад

      You have to initialize the data in SRAM from somewhere

  • @raghul1208
    @raghul1208 3 года назад

    thank you for the content

  • @ashutoshtiwari2611
    @ashutoshtiwari2611 Год назад

    10 crore bahut sahi

  • @mogasatigopikrishna2025
    @mogasatigopikrishna2025 4 года назад

    Please upload lec5 .

  • @mohamedessam4704
    @mohamedessam4704 4 года назад +1

    at the end of the lecture, you make _sbss = . ; and you've said location counter is tracking VMA, so the location counter is equal to SRAM , due to that it will overwite the .data section .. am i wrong ??