newaetech / naeusb

USB library for ChipWhisperer devices
Apache License 2.0
14 stars 3 forks source link

Add NuMicro 8051 ICP programmer #12

Open nikitalita opened 5 months ago

nikitalita commented 5 months ago

This PR adds support for ICP programming Nuvoton NuMicro 8051 chips. It is adapted from my work here.

The reason for ICP programming being used here is that, while Nuvoton chips do have an ISP protocol, it requires an LDROM to be loaded onto the chips first. The chips do not come pre-programmed with that and have to be loaded using an ICP tool, and if we have an ICP tool, we can just program the APROM directly. The LDROM also induces substantial latency when booting, which is not really suitable for our purposes, where the chips may be resetting thousands of times during glitch attempts.

The USB wire protocol implementation here is largely derived from the XPROG one; I've tried to conform to the expectations there (putting all responses in the rambuf, putting all transmitted bulk data into the rambuf before programming, etc.)

Since this requires toggling nRST, this requires that AVR ISP be set first.

This should work for all the chips that are supported for the NuMicro CW308 target board, but I have only tested this with the N76E003, the MS51FB9AE, and the MS51FC0AE.

I have the chipwhisperer userland programmer implementation up here, but I'm going to wait until this gets into naeusb before PRing it.

The reason this is a draft is because there are a couple of points that are marked as TODO:

nikitalita commented 5 months ago

BTW, this is currently based on 0dfd148 rather than current main. Current main does not build with the chipwhisperer lite firmware in the chipwhisperer repo, as it requires missing functions that are no longer implemented in naeusb. Is there a more up to date version of the cwlite firmware somewhere?

alex-dewar commented 5 months ago

We've currently got a private repo that we're planning on moving the capture firmware to. I've had other projects on the go, so I haven't been able to get that finished/tested, but it should hopefully be soon.