|
|
2 年 前 | |
|---|---|---|
| .. | ||
| .github | 2 年 前 | |
| helpers | 2 年 前 | |
| images | 2 年 前 | |
| scenes | 2 年 前 | |
| screenshots | 2 年 前 | |
| views | 2 年 前 | |
| .gitignore | 2 年 前 | |
| LICENSE | 2 年 前 | |
| Readme.md | 2 年 前 | |
| application.fam | 2 年 前 | |
| ch32v_flipper_flasher.c | 2 年 前 | |
| ch32v_flipper_flasher.h | 2 年 前 | |
| config.h | 2 年 前 | |
| error_list.h | 2 年 前 | |
| errors.c | 2 年 前 | |
| errors.h | 2 年 前 | |
| minichlink_debugger.c | 2 年 前 | |
| minichlink_debugger.h | 2 年 前 | |
| nhc_link042_emulator.c | 2 年 前 | |
| nhc_link042_emulator.h | 2 年 前 | |
| utils.h | 2 年 前 | |
| wch_swio_flasher.c | 2 年 前 | |
| wch_swio_flasher.h | 2 年 前 | |
| wch_swio_flasher.png | 2 年 前 | |
WCH SWIO debugger and flasher emulated on Flipper Zero tool - tool for flashing and debugging CH32V003 chip.
tested only on CH32V003
Flash CH32Vxx in menu) without connection to computer. Supported is:
In emulation mode, Flipper Zero act just as NCH Link042 programmer HW. All commands towards chip are driven from your computer via USB, even reset and debug session init.
In programmer mode, Flipper Zero act as all-in-one device and initiate debug session with chip at his own. This allows some usable hacks with chip. Most important one is hard reset before any operation towards CH32Vxx chip. It is helpful when you using sleepmodes or low clock mode (in sleep mode or low clock freqcency is not possible to establish debug session so, you can't simply program chip).
Be care, SWIO is driven as open-drain bus with pull-up with high clock freqency (around 8MHz). It means, SWIO pin is sensitive to wire/pcb line capacity. In case of bad designs, Flipper Zero can not be available 'catch' all bits from chip and communication will fail. But it is not that bad, with 1k - 5k resistor as external pull-up it work well even with dupont wires. Just be aware about that.
Main SWIO magic. Mostly written in ARM Assembler, not relay nice code and definitely is not portable to other platform without huge rework.
See: RISC-V QingKeV2 Microprocessor Debug Manual and RISC-V Debug Specification
- src/helpers/swio.c
- src/helpers/swio_pin_magic.c
code based on aappleby/PicoRVD
Used for for 'Erase and write program code' feature. Code allows to control debug interface directly from Flipper Zero.
- src/helpers/wch_flasher.c
- src/helpers/riscv_debug.c
Utility programs used to run in target RiscV chip. Mostly originated from aappleby/PicoRVD.
Code responsible for emulation USB bulk communication with minichlink.
- src/nhc_link042_emulator.c
- src/minichlink_debugger.c
Read chip info
user@awesomemachine minichlink % ./minichlink -i
Found NHC-Link042 Programmer
Interface Setup
USER/RDPR : e817/5aa5
DATA1/DATA0: ff00/ff00
WRPR1/WRPR0: 00ff/00ff
WRPR3/WRPR2: 00ff/00ff
Flash Size: 16 kB
R32_ESIG_UNIID1: xxxxxxxx
R32_ESIG_UNIID2: xxxxxxxx
R32_ESIG_UNIID3: ffffffff
Erase chip
user@awesomemachine minichlink % ./minichlink -E
Found NHC-Link042 Programmer
Interface Setup
Whole-chip erase
minichlink patch (file minichlink/nhc-link042.c, function TryInit_NHCLink042)
// After line:
libusb_claim_interface(hdev, 0);
// Paste this:
int readed;
do{
status = libusb_bulk_transfer(hdev, 0x81, buff, 64, &readed, 10);
} while(readed > 0 && status == 0);