Ok, update:
- I can now build the CH32V003 IAP bootloader example and upload it via wlink to system flash
- adding the below 2 lines to
platformio.ini
allows to build for address 0x00 but upload to system flash
upload_protocol = custom
upload_command = wlink flash $SOURCE --address 0x1FFFF000
- after optimizing the example a bit I could add a mode indication by LED (fast blinking). The APP example blinks the same pin slowly. That way I always know which code is actually running
- then I seemingly bricked the device:
- while playing around with the IAP example I commented the USART code and the mode switching. I figured I can always flash via debug interface
- switching to IAP mode worked as expected (LED blinks fast), but now WCH-LinkE can no longer connect (
Error: WCH-Link underlying protocol error: 55 [01]
). Power off/on also has no effect, device remains in IAP mode. And since mode switching is commented, I cannot exit IAP mode
To my understanding that means:
- boot mode information is indeed stored in flash (see initial post). Else information would be lost after power off
- debug not possibly in IAP mode indicates that on µC side debug seems to be via code included in normal applications, which is omitted in IAP example. Is this why a special linker file is required? Or is there another information why the debugger can connect in APP mode, but not in IAP mode?
PS: any idea if/how I can recover my device? I don’t mind the 10ct, but replacing the µC is a pain