Embedded interview questions
The questions embedded interviewers ask out loud, from volatile to priority inversion, each with a model answer.
Fundamentals
- What is embedded C?
- What is an embedded system?
- What is the difference between a microprocessor and a microcontroller?
- What are the basic differences between C and embedded C?
- What does portability mean in embedded C, and how do you achieve it?
- How do you handle errors in embedded C?
- How do you perform input and output in embedded C?
- How do you debug embedded C code?
- How do you optimise embedded C code?
- How do you handle floating-point arithmetic in embedded C?
- How do you perform fixed-point arithmetic in embedded C?
- How do you create a delay in embedded C?
- What is hardware-software co-design?
- What is hardware/software partitioning?
- What are real-time constraints?
- How do you meet real-time constraints in firmware?
- What is the difference between hard, firm and soft real-time systems?
- What are the stages of building a C program for a microcontroller?
- What is MISRA C and why is it used?
- What is the difference between undefined, unspecified and implementation-defined behaviour?
Keywords, types and qualifiers
- What data types are used in C for embedded systems?
- How do you declare a constant in embedded C?
- What is the volatile keyword used for?
- Can a variable be both const and volatile?
- What does the const keyword do?
- What are the three uses of the static keyword?
- What is the significance of the extern keyword?
- What is the purpose of the inline keyword?
- What is the difference between a macro and an inline function?
- What is the significance of the restrict keyword?
- What is the role of the typedef keyword?
- What is the difference between typedef and #define for naming a type?
- What are the storage classes in C?
- What is the difference between a declaration and a definition?
- What is integer promotion, and why does it cause bugs?
- Why should you not assume the size of int?
- How large is an enum, and why does it matter?
- What are header guards and why are they needed?
- Does volatile make a variable safe to share with an interrupt?
- How do #define, const and enum compare for defining constants?
Pointers, memory and data layout
- How do you declare and use a pointer?
- What is a pointer to a function, and where is it used?
- What is a structure and how is it used?
- What are bit fields?
- What is a union and how is it used?
- What is memory alignment, and how do you control it?
- What is structure padding, and when should you pack a struct?
- What is the difference between little-endian and big-endian byte order?
- How do you handle endianness issues?
- What is the difference between static and dynamic memory allocation?
- How do you perform dynamic memory allocation, and what are the risks?
- What is a memory pool, and how do you implement one?
- How do you perform fixed-size memory allocation?
- How do you implement a memory management scheme?
- What makes a memory management scheme suitable for real-time use?
- What types of memory are found in embedded systems?
- Where are variables stored in a C program?
- What is the difference between the stack and the heap, and how do you detect a stack overflow?
- What are null, dangling and wild pointers?
- How do you implement a software stack?
Bits, registers and memory-mapped I/O
- How do you perform bitwise operations?
- What are the advantages of bit manipulation?
- How do you perform memory-mapped I/O?
- What are memory-mapped peripherals?
- What is direct addressing of a memory-mapped register?
- What is indirect addressing of a memory-mapped register?
- What is bank switching?
- How do you access memory-mapped registers safely?
- How do you access memory-mapped ports?
- How do you access memory-mapped devices in a generic way?
- How do you work with memory-mapped buffers?
- How do memory-mapped files relate to embedded systems?
- How do you use memory-mapped files to reach hardware on embedded Linux?
- What is the risk in a read-modify-write of a register?
Interrupts, timers and concurrency
- What is an interrupt and how is it handled?
- What is the difference between polling and interrupt-driven I/O?
- What is the role of an interrupt service routine?
- What rules should an ISR follow?
- What is interrupt latency?
- What is the interrupt vector table?
- What is the role of the interrupt controller?
- How does exception handling work in embedded C?
- What is nested interrupt handling and interrupt priority?
- How do you program a timer?
- What is the role of the system timer?
- What is the role of a watchdog timer?
- How do you implement a watchdog properly?
- How do you handle concurrency issues?
- How do you handle synchronisation issues?
- How do you handle resource contention?
- What is a re-entrant function?
- What is a critical section, and how do you make an operation atomic?
Data structures and firmware patterns
- How do you implement a circular buffer?
- How do you implement a finite state machine?
- How do you implement a state transition table?
- How do you implement a circular linked list?
- How do you implement a priority queue?
- How do you implement message passing?
- How do you debounce a mechanical switch in software?
- What is the super-loop architecture, and when is it not enough?
Processor, memory hardware and boot
- What is the role of the stack pointer?
- What is the role of the program counter?
- What is the role of the status register?
- What is the role of the system control register?
- What is the role of the reset vector?
- What is the role of startup code?
- What is the role of a bootloader?
- What is the role of the linker?
- What is a linker script?
- What is cache memory, and how does it affect embedded systems?
- What is the role of the memory management unit?
- What is the role of the memory protection unit?
- What is the role of a memory controller?
- What is direct memory access (DMA)?
- What is the role of the DMA controller?
- What is multi-core processing in embedded systems?
- What is the role of the power management unit?
- How do you handle power management in firmware?
- How do you design a power management scheme?
- What is the role of a peripheral controller?
Peripherals and drivers
- How do you write a hardware driver?
- What is a device driver, and how is one structured?
- How do you design a device driver framework?
- How do you control GPIO pins through memory-mapped registers?
- How do you use a memory-mapped UART?
- How do you use a memory-mapped SPI controller?
- How do you use a memory-mapped I2C controller?
- How do UART, SPI and I2C compare?
- How do you use a memory-mapped ADC?
- How do you use a memory-mapped DAC?
- How do you generate PWM with a memory-mapped timer?
- How do you access memory-mapped timers?
- How do you drive a memory-mapped display?
- How do you read memory-mapped sensors?
RTOS and scheduling
- What is a real-time operating system (RTOS)?
- How do you handle multi-threading in embedded C?
- How do you handle multi-tasking in embedded C?
- What is real-time scheduling?
- How do you implement a priority-based scheduler?
- How do you implement a round-robin scheduler?
- How do you implement a task scheduler?
- How do you implement a real-time scheduler?
- How do you implement a real-time operating system kernel?
- How do you handle inter-process communication in embedded C?
Task synchronisation
- What is real-time task synchronisation?
- How do semaphores synchronise tasks?
- How do mutexes synchronise tasks?
- How do message queues synchronise tasks?
- How do event flags synchronise tasks?
- How do condition variables synchronise tasks?
- What is priority inversion?
- What is priority inheritance?
- What is the priority ceiling protocol?
- What are spinlocks, and when are they used?
- What are reader-writer locks?
- What is a rendezvous in message passing?
- How do priority-based spinlocks work?
- How do priority-based semaphores work?
- How do priority-based condition variables work?
- How do priority-based mutexes work?
- How do priority-based reader-writer locks work?
- How does a priority-based rendezvous work?
Protocols, networking and storage
- How do you implement a communication protocol?
- How do you implement a communication protocol stack?
- How do you implement a real-time communication protocol?
- How do you implement a real-time communication protocol stack?
- How do you implement a fault-tolerant communication protocol?
- How do you implement a secure communication protocol stack?
- How do you implement a distributed communication protocol stack?
- How do you implement a real-time network stack?
- How do you implement an embedded web server?
- How do you implement a real-time distributed system?
- How do you implement an embedded database?
- How do you implement a file system?
- What makes a file system suitable for real-time use?
- What is a file system journal, and how is it implemented?
- What is a virtual file system?
- How do you implement a secure file system?
System design, verification and reliability
- What is hardware acceleration?
- How is an FPGA used for hardware acceleration?
- How is a GPU used for acceleration in embedded systems?
- What is hardware verification?
- What is hardware validation?
- How are formal methods used in hardware validation?
- What is hardware-in-the-loop testing?
- What is hardware-in-the-loop testing with virtual prototypes?
- What is hardware debugging?
- What is JTAG, and how is it used for debugging?
- What is hardware emulation?
- What is hardware emulation using virtual platforms?
- What is hardware simulation?
- What is hardware co-simulation?
- How is SystemC used for co-simulation?
- What is hardware modelling?
- How are hardware description languages used for modelling?
- What is hardware synthesis?
- What is high-level synthesis, and how is it used in co-design?
- How are IP cores used in hardware co-design?
- How do you implement a fault-tolerant system?
- How do you implement a real-time fault-tolerant system?
ISO-TP transport
- What problem does ISO-TP solve, and where does it sit between CAN and UDS?
- What are the four ISO-TP frame types, and how is each recognised?
- How does a first frame encode the message length, and what changes above 4095 bytes?
- What are the three flow status values in a flow control frame, and what must the sender do on each?
- How is the STmin byte encoded, and what should a sender do with a reserved value?
- How does the consecutive-frame sequence number work, and what does a receiver do on a wrong one?
- What is the difference between normal, extended and mixed addressing in ISO-TP?
- What is the difference between physical and functional addressing, and why can a functional request not be multi-frame?
- What happens when a new first frame or single frame arrives in the middle of a reception?
- How does ISO-TP change on CAN FD?
UDS diagnostic services
- What do a UDS request, its positive response and its negative response look like on the wire?
- What are the default, extended and programming sessions for, and what is lost on a session change?
- What is the S3 timer, and how does TesterPresent keep a session alive?
- What does the suppressPositiveResponse bit do, and which services have it?
- What is the difference between NRC 0x11, 0x12, 0x7E and 0x7F?
- When does a server answer 0x22 conditionsNotCorrect, 0x31 requestOutOfRange and 0x33 securityAccessDenied?
- How does ReadDataByIdentifier handle several DIDs in one request, and what if one is not supported?
- What does ClearDiagnosticInformation clear, and when may the positive response be sent?
- What is the difference between the ECUReset types, and when is the response sent?
- Why must a SecurityAccess seed be unpredictable, and what does a server answer to a seed request when it is already unlocked?
- How do the three RoutineControl sub-functions work, and how does a long routine report its result?
- Walk through the services a tester uses to reprogram an ECU.
AUTOSAR, fault memory and MISRA C
- What is the difference between sender-receiver and client-server ports in AUTOSAR?
- What is a PDU, and what does the PduR do with one?
- How do OS tasks, runnables and the main functions of the basic software modules relate?
- What protects an NvM block against corruption?
- What does a three-byte UDS DTC consist of, and what is the failure type byte?
- What is an operation cycle, and which status bits change when one starts?
- What are enable conditions and storage conditions for a diagnostic monitor?
- How does a confirmed DTC heal and age out?
- What is the MISRA essential type model, and which conversions does it forbid?
- What is the difference between a MISRA directive and a rule?
- Why does MISRA ask for a single point of exit, and how do you write error handling under it?
- What goes into a MISRA deviation record, and who approves it?
Faults and recovery
- How does firmware find out why the MCU reset, and what are the pitfalls?
- What survives a reset, and how do you keep data across one safely?
- How do you make writes to flash or EEPROM safe against a power failure part way through?
- What is a single event upset, and how is firmware made robust to one?
- Why must a stuck I2C bus be handled by the master's firmware, and how?
- What is fault injection testing for firmware, and how is it done?
Power engineering
- How do you calculate the average current of a duty-cycled device?
- Which figures in a datasheet do you need for a power budget, and what do they leave out?
- What is the difference between Sleep, Stop and Standby on an STM32?
- Why can a debugger make a low-power design look broken?
- How do you measure a device's current when it ranges from microamps asleep to tens of milliamps transmitting?
- What does "race to sleep" mean, and when is it wrong?
Product security
- What does secure boot guarantee, and what does it not?
- Where should cryptographic keys live in an embedded device?
- How do you design an over-the-air update that cannot brick the device?
- What makes a comparison constant time, and why does it matter?
- What is a glitch attack, and how do you design against one?
- What do security standards for connected products require of the firmware?