I’m trying to verify the built‑in AES demo on my ChipWhisperer CW310 board from Python, but no matter what I do all the register reads return 0x00
and the script always times out with RuntimeError: AES never finished!
. Here’s a minimal reproduction of the code I’m using:
import chipwhisperer as cw
import time
AES_CONTROL_ADDR = 0x05 # write=GO, read=BUSY
AES_KEY_ADDR = 0x06 # 16 bytes @ 0x06–0x15
AES_PLAINTEXT_ADDR = 0x0A # 16 bytes @ 0x0A–0x19
AES_CIPHERTEXT_ADDR = 0x16 # 16 bytes @ 0x16–0x25
test_key = list(bytes.fromhex(“000102030405060708090A0B0C0D0E0F”))
test_pt = list(bytes.fromhex(“00112233445566778899AABBCCDDEEFF”))
expected = list(bytes.fromhex(“69C4E0D86A7B0430D8CDB78070B4C55A”))
print(“Programming AES bitstream…”)
target = cw.target(None, cw.targets.CW310, bsfile=“cw310_aes.bit”, force=True)
target.fpga_write(AES_KEY_ADDR, test_key)
time.sleep(0.1)
print(“Key readback:”, target.fpga_read(AES_KEY_ADDR, 16))
target.fpga_write(AES_PLAINTEXT_ADDR, test_pt)
time.sleep(0.1)
print(“PT readback:”, target.fpga_read(AES_PLAINTEXT_ADDR, 16))
target.fpga_write(AES_CONTROL_ADDR, [1])
start = time.time()
while time.time() - start < 5:
busy = target.fpga_read(AES_CONTROL_ADDR, 1)[0]
print(“Busy =”, busy)
if busy == 0:
break
time.sleep(0.01)
else:
raise RuntimeError(“AES never finished!”)
ct = target.fpga_read(AES_CIPHERTEXT_ADDR, 16)
print(“Ciphertext:”, ct)
assert ct == expected, “Output mismatch!”
print(“ Success”)