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.
bool frame_valid(const uint8_t *p, uint8_t len, uint8_t expected)
{
uint8_t sum = 0;
for (uint8_t i = 0; i < len; i++) {
sum += p[i];
}
return ~sum == expected;
}
void irq_enable(volatile uint32_t *iser, int irqn)
{
*iser = (1 << irqn);
}
void send_reversed(const uint8_t *buf, uint8_t len)
{
for (uint8_t i = len - 1; i >= 0; i--) {
uart_putc(buf[i]);
}
}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 minCasting a byte stream to a structMemory & C · Medium · 4 bugs · ~6 minStrings on the stackMemory & C · Warm-up · 3 bugs · ~4 minArray helpers with memcpyMemory & C · Warm-up · 3 bugs · ~4 minHeap use in a message handlerMemory & C · Medium · 3 bugs · ~5 minData retained across resetsBoot & OTA · Hard · 3 bugs · ~6 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs