Wednesday, March 21, 2012

Firmware Interview Excercise

Recently I thought of a good job interview excercise for a potential firmware engineer. Here is the excercise for your use, plus guidlines of how to grade it:

Write on the whiteboard C/C++ code to read a memory mapped register, clear a bit, then write it back.

Things I don't care about:
  • If there are any simple syntax errors or missing semicolons.
  • The variables types used, as long as the candidate knows how many bits they are (int, versus uint32, versus DWORD).
Things I do care about:
  • Was the "volatile" keyword used when declaring the variable that would point to the register? (I would hope that the value we get from the register is a fresh, uncached value).
  • Did the candidate ask how big the data bus of the system is? (How else would I know how the pointer type?)
  • Was it second nature to use the "wordwithbittoflip &= ~MASK" convention.
  • Did the candidate ask whether a MMU is being used? (need to make sure you are accessing physical memory, not virtual)
  • Did the candidate ask what OS is being used, if any? (tracing back to the MMU question, if there is one being used, getting access to physical memory will vary from OS)
Bonus points:
  • The candidate uses bit banding for increased speed.
  • The candidate wonders if the system is big or little endian when setting up the mask.
Next chance I get to interview someone maybe I'll give it a shot. It is consistent with Joel On Software guidlines to have the interview candidate write simple, non "gotcha" code. The above should be simple for anyone with embedded experience.