5.5.16 · D3 · HinglishEmbedded Systems & Real-Time Software

Worked examplesStartup code — vector table, reset handler, stack initialization

2,941 words13 min read↑ Read in English

5.5.16 · D3 · Coding › Embedded Systems & Real-Time Software › Startup code — vector table, reset handler, stack initializa

Yahan sab kuch the parent topic pe build karta hai. Jab hum touch karte hain ki linker humein addresses kaise deta hai, woh hai Linker scripts and memory sections (.text .data .bss); jab hum touch karte hain ki CPU registers kaise stack karta hai, woh hai ARM Cortex-M exception and interrupt model.


Shuru karne se pehle: teen symbols jo har example use karta hai

Hum teen families of names se baar baar milte hain. Chalein inhe ek picture se pin kar dete hain taaki koi bhi symbol kabhi mystery na rahe.

Figure — Startup code — vector table, reset handler, stack initialization

Scenario matrix

Har case class jo yeh topic tumpe throw kar sakta hai, aur kaun sa worked example use cover karta hai:

# Case class Concrete stimulus Example
A Normal load — dono sections non-empty .data mein 2 words, .bss mein 1 word Ex 1
B Empty .data (degenerate copy) koi initialized globals nahi → _sdata == _edata Ex 2
C Empty .bss (degenerate zero) har global initialized hai → _sbss == _ebss Ex 2
D Stack boundary / first push entry ke baad aur first push ke baad MSP trace karo Ex 3
E Sign / direction of growth full-descending SP, kya yeh upar overflow hota hai ya neeche? Ex 3
F Collision limit — stack vs heap stack kitna grow kar sakta hai .bss se pehle? Ex 4
G Relocated table (VTOR ≠ 0) — bootloader case app ka table 0x0800_4000 pe, hardware kya read karta hai? Ex 5
H Real-world word problem ek sensor buffer as a global — uska data kahan se aata hai? Ex 6
I Exam twist.bss-not-cleared heisenbug bug ka symptom predict karo Ex 7
J Exam twist — misaligned _estack _estack odd/not word-aligned, kya fault hoga? Ex 8

Ab hum har cell ko hit karte hain.










Recall Kya har matrix cell hit hua?

Normal load (A) ::: Ex 1 Empty .data / empty .bss (B, C) ::: Ex 2 First push & growth direction (D, E) ::: Ex 3 Stack↔heap collision limit (F) ::: Ex 4 Relocated table via VTOR (G) ::: Ex 5 Real-world const-vs-bss (H) ::: Ex 6 .bss heisenbug symptom (I) ::: Ex 7 Misaligned _estack fault (J) ::: Ex 8


Yahan use ki gayi connections

  • Linker scripts and memory sections (.text .data .bss) — har _s…/_e… symbol ka source.
  • ARM Cortex-M exception and interrupt model — Ex 3 & Ex 8 mein auto-stacking aur alignment rules.
  • Stack vs Heap memory layout — Ex 4 mein collision geometry.
  • Bootloaders and VTOR relocation — Ex 5 mein relocated table.
  • Volatile, memory-mapped registers and hardware initVTOR khud kaise write hota hai.
  • The C runtime and crt0 — woh bigger picture jisme reset handler fit hota hai.