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.
void save_setpoint(int16_t sp)
{
HAL_FLASH_Unlock();
FLASH_EraseInitTypeDef e = { .TypeErase = FLASH_TYPEERASE_PAGES,
.Page = CFG_PAGE, .NbPages = 1 };
uint32_t err;
HAL_FLASHEx_Erase(&e, &err);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, CFG_ADDR, sp);
HAL_FLASH_Lock();
}
int16_t load_setpoint(void)
{
return *(int16_t *)CFG_ADDR;
}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.
ABBIndustrial · India hiring: MediumEatonIndustrial · India hiring: HighInfineonChipmaker · India hiring: MediumNXP SemiconductorsChipmaker · India hiring: HighQuest GlobalEngineering services · India hiring: HighRenesasChipmaker · India hiring: MediumTata ElxsiEngineering services · India hiring: HighWipro EngineeringEngineering services · India hiring: High
Related challenges
Independent watchdog usageDrivers & ISRs · Medium · 3 bugs · ~5 minBootloader jump to applicationBoot & OTA · Hard · 3 bugs · ~6 minSwitching OTA slotsBoot & OTA · Medium · 3 bugs · ~5 minData retained across resetsBoot & OTA · Hard · 3 bugs · ~6 minBootloader image verificationBoot & OTA · Hard · 3 bugs · ~8 minSettings and calibration in one pageBoot & OTA · Medium · 4 bugs · ~7 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs