How to Emulate Firmware Compiled with ChipWhisperer Before Uploading to Microcontroller?

I am currently working on a project using ChipWhisperer and I am compiling my firmware using the following command:

%%bash -s "$PLATFORM" "$CRYPTO_TARGET" "$SS_VER"
cd ../../hardware/victims/firmware/simpleserial-base-SPA_ISRS
make PLATFORM=$1 CRYPTO_TARGET=$2 SS_VER=$3 -j

This generates a binary (simpleserial-base-CW308_SAM4S.elf) for the ATSAM4S2A microcontroller (Cortex-M4). Before uploading the firmware to the microcontroller, I want to emulate or simulate its behavior to verify correctness.

I tried using QEMU for emulation with the following command:

qemu-system-arm -M lm3s6965evb -nographic -kernel simpleserial-base-CW308_SAM4S.elf

However, this results in a lockup with the error:

Timer with period zero, disabling
qemu: fatal: Lockup: can't escalate 3 to HardFault (current priority -1)

I also checked the list of supported machines in QEMU, but there doesn’t seem to be direct support for ATSAM4S2A. I tried other machine models, such as mps2-an386 and netduinoplus2, but none of them seem to work properly.

Questions:

  1. Is it possible to emulate the ATSAM4S2A microcontroller (Cortex-M4) using QEMU or any other tool? If so, what is the correct setup?
  2. Are there any alternative emulation or simulation tools that would allow me to test this firmware on a virtualized environment before flashing it to the microcontroller?
  3. Could debugging tools like GDB or custom configurations in QEMU help resolve this issue?

Any guidance on how I can emulate this firmware to avoid uploading it to real hardware for every test would be greatly appreciated!

Thanks in advance!

Here is my device details:

SCOPETYPE = ‘OPENADC’
PLATFORM = ‘CW308_SAM4S’
CRYPTO_TARGET=‘TINYAES128C’
SS_VER=‘SS_VER_1_1’

@NewDwarf @jpthibault can you guys look into it?

No, that’s not something we support; I can’t help you with that. Try on QEMU forums.

1 Like