The code
Embedded C for Cortex-M. It compiles. There are 3 real bugs in it: the kind that pass a bench test and fail in the field.
__attribute__((section(".noinit"))) static struct {
uint32_t boot_count;
uint32_t last_fault_pc;
} retained;
void boot_record(void)
{
retained.boot_count++;
if (RCC->CSR & RCC_CSR_IWDGRSTF) {
log_watchdog_reset(retained.last_fault_pc);
}
}
void HardFault_Handler(void)
{
retained.last_fault_pc = __get_PSP();
NVIC_SystemReset();
}What an interviewer expects
- Point to each line you'd stop in a code review.
- Say what actually breaks: the failure mode, not just the rule it violates.
- Fix it, then defend the fix when asked the follow-up.
The bugs, reference fixes and the follow-up question are in the practice app, after you've tried it.
Companies that test this
Matched on the skills each company's embedded roles emphasise.
BoschAutomotive supplier · India hiring: HighDensoAutomotive supplier · India hiring: MediumMedtronicMedical devices · India hiring: MediumABBIndustrial · India hiring: MediumAcsia TechnologiesEngineering services · India hiring: MediumAppleConsumer devices · India hiring: LowAptivAutomotive supplier · India hiring: MediumArmChipmaker · India hiring: Medium
Related challenges
Tick timeouts and delaysTiming · Warm-up · 3 bugs · ~4 minInteger promotion trapsMemory & C · Medium · 3 bugs · ~5 minBootloader jump to applicationBoot & OTA · Hard · 3 bugs · ~6 minSwitching OTA slotsBoot & OTA · Medium · 3 bugs · ~5 minSaving settings to internal flashBoot & OTA · Medium · 3 bugs · ~5 minBootloader image verificationBoot & OTA · Hard · 3 bugs · ~8 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs