Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NuMicro 8051 ICP programmer #12

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nikitalita
Copy link

@nikitalita nikitalita commented Apr 3, 2024

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:

  • in int N51PGM_init(void)(), I want to be able to check to see if we are in AVRISP mode and fail if we aren't, but I do not know how to do that from the firmware.
  • I have an ICP function called NuvoICP_Reentry_glitch(). What this does is cause the configuration bytes to be loaded at consistent times when entering ICP mode, the idea being that we can potentially glitch a locked chip to boot into ICP mode in an unlocked state. It activates a trigger right before entry (vs. after, because the delay between entry and config load is like two microseconds) so that the config load process can be captured and glitched. However, I don't know how to toggle any of the TIO lines from the firmware, and I don't know if there's a way to manually trigger a glitch from the firmware. Any advice here?

@nikitalita nikitalita marked this pull request as draft April 3, 2024 15:28
@nikitalita
Copy link
Author

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
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants