Skip to content
Tech Interview Prep
Technical interview guide

Hardware-Software Co-Design & Peripheral Drivers

Writing drivers directly against a datasheet, using DMA to move data without the CPU, and the collaboration with hardware engineers that shapes firmware architecture.

Read
65 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: Current Zephyr device/driver/devicetree/DMA/PM documentation and CMSIS-Driver 6/SVD/Core guidance reviewed 2026-09-04.

Curated: · Written: · Reviewed:

25 questions

MCQ-8A driver on an ARM64 SoC brings up a DMA controller mapped at 0x4000_0000. The register map says the channel-enable register at offset 0x04 is 32 bits wide, is write-only, and the device ignores any access narrower than a full 32-bit write. The driver does: ```c volatile uint8_t *base = (volatile uint8_t *)0x40000000; base[0x00] = 0x03; /* control: source/dest width */ base[0x04] = 0x01; /* enable channel 0 */ ``` The channel never starts. A bus analyzer shows the control write at 0x00 arriving first, then a single byte write at 0x04, which the device ignores. The driver already waits 10 µs between the two stores, and the reset register at 0x08 reads back 0x00. What is the cause?
MCQ-9A UART driver's interrupt status register STATUS has four write-one-to-clear bits: bit 0 RX_OVERRUN, bit 1 TX_COMPLETE, bit 2 RX_TIMEOUT, bit 3 PARITY_ERROR. Writing 1 to a bit clears it; writing 0 leaves that bit unchanged. The ISR reads STATUS, gets 0x0000_000B, handles only the overrun, and runs: ```c uint32_t v = REG_READ(STATUS); /* returns 0x0000_000B */ v &= ~(1u << 0); /* drop the bit we handled */ REG_WRITE(STATUS, v); /* v == 0x0000_000A */ ``` Between the read and the write, a new RX_TIMEOUT event sets bit 2. What does STATUS read immediately after the write, and which events are lost?
MCQ-2A driver reads a 12-bit ADC over SPI. The register map documents only two things: 0x02 = result MSB, 0x03 = result LSB. The driver computes `raw = (b0 << 8) | b1` and `volts = raw * 3.3 / 4096`. Two field reports arrive. On one board, roughly 1 reading in 500 is exactly 3.300 V on a channel whose signal never exceeds 1.20 V. On another board, readings taken within 2 µs of the conversion-start write are consistently 40 mV low. Which addition to the interface contract removes the cause of both reports?
MCQ-5A board bring-up engineer is porting Linux to a new SoC. The bootloader hands the kernel a devicetree blob, and the kernel probes a UART whose `reg` property is `<0x0 0x1c090000 0x0 0x1000>` with `compatible = "snps,dw-apb-uart"`. The driver binds, but the console prints nothing and no interrupt is ever delivered. The engineer confirms the UART's clock gate is enabled and the pinmux is correct. Which single devicetree change is most likely to fix the silent console?
MCQ-6A driver configures an SPI controller entirely from a device tree node generated from the vendor's SVD: base address, register offsets, field widths and reset values. The peripheral bus clock is 40 MHz. With the divider field set to 2 the bus runs at 20 MHz and returns corrupted frames; with the divider set to 8 it runs at 5 MHz and every transfer is clean. The silicon errata for this revision states the SPI divider must be at least 4. What does this case show about the SVD's role?
MCQ-7A product's ADC driver registers SYS_INIT(adc_init, PRE_KERNEL_2, 0). Its PMIC regulator driver registers SYS_INIT(pmic_init, POST_KERNEL, 80). adc_init() calls device_is_ready() on the PMIC and returns -ENODEV when it is false, so the ADC never comes up. What is the cause?
MCQ-3A firmware team ships the same product on two boards. Board A's accelerometer is on I2C and returns raw counts at a fixed ±2 g range; Board B's is on SPI, has a selectable ±16 g range, and exposes a FIFO. The application layer currently calls `accel_read_xyz()` and gets counts, and the team wants one driver interface that both boards implement. Which interface design lets the application code stay unchanged across both boards?
MCQ-16A sensor driver exposes `read()` and `set_rate()`. `read()` is called from a task and from the DMA-completion ISR; `set_rate()` is called from a task and from a timer callback. The driver keeps a single `struct state` with no lock, and the ISR path calls `read()` directly. Under load, `read()` occasionally returns a half-updated sample and `set_rate()` sometimes leaves the rate register and the cached rate disagreeing. The team's fix is to add a mutex around `state` in both functions. What is the actual defect the mutex does not fix?
MCQ-25A UART driver's ISR pushes received bytes into a shared ring buffer, and four user-space threads dequeue from it concurrently on a 4-core ARM64 SoC. The ISR must never block. Which scheme keeps the buffer consistent?
MCQ-4A Zephyr driver serves two identical SPI NOR chips on one SPI controller: flash_a on chip select 0, flash_b on chip select 2. Each chip has its own device instance: - config, declared const: the SPI controller pointer, cs (0 or 2), max_hz = 8000000 - data: a k_mutex lock, a uint32_t sectors_written counter, a 256-byte page staging buffer - one file-scope object: static uint8_t cmd[8], the opcode-plus-address frame that every transfer fills and then hands to spi_write() A bench run has thread A programming 4 KB into flash_a in 256-byte pages while thread B sends 64 KB sector-erase commands to flash_b. Each instance is driven by exactly one thread. On about one frame in three, the analyser shows 0x20 (sector erase) on MOSI in the middle of flash_a's page program, and that sector reads back blank. Which change removes the fault?
MCQ-11A Cortex-M4 UART RX driver runs at 921600 baud, 8N1, with a single-byte receive register and no hardware FIFO. The RX ISR reads the data register, appends the byte to a 256-byte ring buffer, then writes a trace line through a blocking `printf` to a second UART. Measured ISR entry-to-exit time is 90 µs. Under sustained input the overrun error flag sets within milliseconds and bytes are lost. What change removes the loss?
MCQ-12A Zephyr driver on an STM32F4 uses the DMA API directly. It calls dma_config() on channel 4, then dma_start() for a 512-byte read into a buffer from k_malloc(). dma_start() returns immediately. The caller polls the first 64 bytes of the buffer, and once they look right it calls k_free() on the buffer. Under load, about 1 in 20 reads returns 64 correct bytes followed by 448 bytes of data written by a later allocation. What is the cause?
MCQ-13A driver receives a 1502-byte packet whose payload starts at address 0x1002, two bytes into a malloc'd page. The DMA controller on this hypothetical SoC requires the source address to be 4-byte aligned and the transfer length to be a multiple of 4. It does not reject a misaligned descriptor: it clears the low two address bits and rounds the length down to a multiple of 4. The driver submits the payload pointer directly. What does the controller DMA, and what should the driver do?
MCQ-14A Cortex-M7 board runs Zephyr with the data cache enabled and a 32-byte cache line. A driver starts a DMA receive of 64 bytes into `uint8_t rx_buf[64]`, which the linker places at 0x20000010. Immediately before starting the transfer the application calls `sys_cache_data_invd_range(rx_buf, 64)`. The transfer completes correctly, but a global `uint32_t tx_count` at 0x20000000, which the CPU incremented just before the DMA started, reads back its pre-increment value. What explains this?
MCQ-24A driver shares a 4 MB tensor buffer between the CPU and an on-chip accelerator across a non-coherent interconnect. Per job the CPU writes input tensors into the buffer and writes a doorbell register; the accelerator reads the inputs, writes outputs back into the same buffer, then raises an interrupt; the CPU reads the outputs. The CPU also reads the buffer between jobs, so its data cache can still hold lines from the previous job. Which sequence of driver operations guarantees the accelerator reads the CPU's inputs and the CPU reads the accelerator's outputs?
MCQ-15A NIC driver's `xmit()` programs the DMA engine with the address of the caller's 64-byte descriptor and returns 0 immediately. The transmit-complete interrupt fires about 2 ms later, and only then does the driver read the descriptor's `flags` byte to decide whether to re-arm the queue. A caller builds the descriptor in a local variable, calls `xmit()`, and returns. Under sustained load the driver reads `flags=0x00` roughly once per 10,000 packets; at idle it never happens. The driver's public API and all existing callers are frozen for this release. Which change fixes the fault?
MCQ-10A Linux driver on x86-64 writes 0x1 to a PCIe device's control register at MMIO address 0xFE000000 to start a DMA from a buffer, then immediately calls free(buffer). Intermittently, the device reads 0xDEADBEEF from the freed buffer. Adding a single read of 0xFE000000 after the write eliminates the bug. What does the read accomplish?
MCQ-19A driver's runtime-PM callback returns 0 from its `runtime_suspend` hook, but the device's parent bus clock is still enabled and the device has a pending DMA transfer queued by a work item that has not yet run. The driver calls `pm_runtime_put_sync()` from its work handler. What does the PM core do with the suspend request?
MCQ-17A storage driver waits for a device command by polling an MMIO status register in a loop of 50,000 iterations. On the target SoC the loop runs at 0.4 µs per iteration at nominal clock, but the CPU clock is scaled down 4× under thermal throttling. The device's worst-case completion time is 30 ms. When the loop expires the driver immediately reuses the request slot for the next command, and the device's late completion writes its status into that slot. Which change makes the timeout correct for this driver?
MCQ-20A storage driver returns a single `EIO` for every failure. In production, a node's NVMe device starts failing writes; the driver's caller retries each write five times with 50 ms backoff, then marks the volume read-only and the node is drained. The device is healthy: the writes failed because the host's PCIe link dropped to a degraded width and the controller returned a transport error. What is the primary failure in this design?
MCQ-18A PCIe device exposes two functions under one root port: function 0 is a NIC, function 1 is an NVMe controller. The NIC's completion timeout fires. The driver reads function 0's status register as 0xFFFFFFFF and its firmware heartbeat as frozen for 4 s, while function 1 is still completing I/O. The driver issues a function-level reset (FLR) to function 0, waits 100 ms, re-arms the TX/RX rings, and returns success. Within 30 s the same timeout recurs, and function 1 is now also off the bus. The driver then reads: root port AER Uncorrectable Error Status = 0x00000010 (Data Link Protocol Error), function 0 AER Uncorrectable Error Status = 0x00004000 (Completion Timeout), function 0 vendor ID = 0xFFFF, function 1 vendor ID = 0xFFFF. Which recovery sequence is correct?
MCQ-1A 200 MHz Cortex-M7 vision pipeline must run a Sobel edge filter at 30 fps on 640x480 frames, giving a 33 ms frame budget. In software the filter takes 45 ms per frame. Mapped to the on-chip accelerator it takes 10.5 ms of compute plus 4 ms of DMA setup per frame, and the accelerator block draws 3x the power of the software path. The product is battery-powered, and the accelerator is the only block on the die that can be clock-gated between frames; the CPU must stay awake to service the rest of the pipeline. Which partition decision is correct for this system?
MCQ-21A 12-bit pressure sensor is read as raw counts 0–4095. The nominal transfer is P_kPa = (counts - 200) * 0.5, valid 0–1000 kPa. The raw counts are logged and fed to a control loop. The dashboard currently computes P = (counts - 200) * 0.5 with constants compiled in. At 20°C readings match a reference gauge. At -10°C and 70°C they drift by up to 8 kPa. After a sensor swap, readings are off by 15 kPa until the EEPROM is reflashed. Where should the conversion happen, and what must accompany each sample?
MCQ-22A steer-by-wire ECU runs a control core and a safety monitor core on one SoC. Each core reads its own torque-sensing element, but both elements are sampled by a single 12-bit ADC whose two multiplexed channels share one external 2.5 V voltage reference, and both cores take their 1 kHz loop timing from one PLL. The monitor cuts assist when its torque estimate differs from the control core's by more than 15%; the sensor spans 0.5 V to 2.2 V, which reads as code 819 to 3603. Six of 12,000 vehicles have pulled hard to one side for about 5 ms while cranking. On all six, the ADC reference was found collapsed to about 0.4 V during the event. Bench replay at 0.4 V reproduces the pull, with both channels pinned at code 0xFFF and the two cores' torque estimates differing by 0 Nm. Which change removes the failure mode those six vehicles show?
MCQ-23A Linux PCIe network driver's `ndo_start_xmit` handler runs in softirq context. It copies the skb's payload into a pre-allocated coherent DMA ring buffer using `skb->len`, then programs the descriptor's length field and rings the doorbell. The skb was built by the network stack from a userspace `sendmsg` on an `AF_PACKET` socket. A security review flags the handler. Which input is the actual trust-boundary violation the review should focus on?