← RTL Design Interviews · SoC Architecture Interviews

Interview Question · Plan Boot, Reset, and Power Transitions

Where Is the First Value of a Variable?

L1 JuniorL2 Mid-Levelboot reset and power

The Question

The interviewer asks

A board retains its program across power loss. main updates an initialized variable in SRAM. Draw the two addresses startup needs before calling main.

Reveal the Model Answer

The load address holds the initial bytes in persistent program memory. The run address names writable storage. Startup copies from _data_load into [_data_start, _data_end). It clears [_bss_start, _bss_end). Each end symbol names the first byte beyond its section. Code may run from its stored address or from a separately loaded image.

Self-Check

Tick each key point you covered in your answer.

What Interviewers Want to Hear (Junior)

Trace one initial value from its stored image to its writable address.

Choose Your Follow-up

I’ve answered the opening question

Choose the route closest to your reasoning. Answer the follow-up aloud, then open the closing question.

I placed the variable in SRAM.

At PC 1c in S6.7, x28 gets 5 from 000000d0. At PC 20 it stores 5 to 80000000. Which address should later assignments use?

Reveal the Model Answer

Write 80000000. The later load confirms the destination: “0000008c | lw x10, 0(x8) | x10 = 00000005 from mem[80000000]”. The ROM location supplies the initial value again after restart. The next pass copies 3 from d4 to 80000004. Derive the bounds from the image symbols so a layout change moves the startup copy too.

Self-Check

Tick each key point you covered in your answer.

Pick the Code Location

On a chip with embedded flash, startup time and RAM are tight. The team wants all code in RAM to accelerate a loop. Which layout gets the first build?

Reveal the Model Answer

Start with execute in place from embedded flash. On ap_soc, execution in place from board flash is unavailable because the ROM loader copies the image into SRAM. S6.17’s comparison takes six copied words and 88 RAM bytes versus 126 words and 568 bytes for copy to RAM. Measure instruction fetch waits in the hot loop. Move code only if the runtime saving repays startup and fits beside the stack.

Self-Check

Tick each key point you covered in your answer.

I added section sizes.

In the separate S6.17 image, .data has size 18 hex and .bss size 40 hex. Why does startup copy six words but clear sixteen?

Reveal the Model Answer

The 24 initialized bytes occupy both ROM and RAM. The 64 zeroed bytes occupy RAM alone. Their 88 RAM bytes plus 1024 reserved for stack give the recorded 1112 bytes. Check that the stack cannot grow into the sections.

Self-Check

Tick each key point you covered in your answer.

Pick the Code Location

On a chip with embedded flash, startup time and RAM are tight. The team wants all code in RAM to accelerate a loop. Which layout gets the first build?

Reveal the Model Answer

Start with execute in place from embedded flash. On ap_soc, execution in place from board flash is unavailable because the ROM loader copies the image into SRAM. S6.17’s comparison takes six copied words and 88 RAM bytes versus 126 words and 568 bytes for copy to RAM. Measure instruction fetch waits in the hot loop. Move code only if the runtime saving repays startup and fits beside the stack.

Self-Check

Tick each key point you covered in your answer.

What People Get Wrong

Common wrong answers and why they fail.

Misconception

Zero-filled .bss needs a ROM copy.

Its size reserves RAM and startup clears it.

Source S6.17, .bss load=--------.

Half-Truth

The stack gets whatever capacity is left.

Reserve the worst required stack before accepting the image.

Source S6.17, linkOverlap: “the stack and the sections overlap by 8 bytes”.

Learn It, Then Prove It