Detect if running inside QEMU
I’m working on some bare metal Cortex-M4 code. It usually runs on a dev board, but to run unit tests I emulate it under QEMU. However, some hardware configurations are done differently depending on whether it’s running on the board or QEMU — for instance, stdout
is redirected to SWO if running on the board, and to USART if running under QEMU.