Description
I should preface this with.. I'm not totally sure what I'm doing here.. so maybe I'm missing some obvious step,
But, I'm having issues flashing a nanoCH32V203
https://github.com/wuxx/nanoCH32V203
The board ticks off all my requirements:
- cheap
- has an RTOS
- has an SD card slot
- good voltage tolerances (I think?) so I can run it off a battery safely
However the official documentation is sparse.. and mostly Windows-centric
I've tried to flash the ch32fun
examples and am having trouble getting it work
I installed the prerequisite packages from the Ubuntu repo
I cloned this repo and built everything. This part seems to work just fine
git clone https://github.com/cnlohr/ch32fun.git
cd build_scripts/
make
I then go in to examples_v20x/blink
and run make
, but the flashing step seems to fail
riscv64-unknown-elf-gcc -E -P -x c -DTARGET_MCU=CH32V203G6U6 -DMCU_PACKAGE=2 -DTARGET_MCU_LD=2 -DTARGET_MCU_MEMORY_SPLIT= ../../ch32fun//ch32fun.ld > ../../ch32fun//generated_CH32V203G6U6_.ld
riscv64-unknown-elf-gcc -o blink.elf ../../ch32fun//ch32fun.c blink.c -g -Os -flto -ffunction-sections -fdata-sections -fmessage-length=0 -msmall-data-limit=8 -march=rv32imac -mabi=ilp32 -DCH32V20x=1 -static-libgcc -I/usr/include/newlib -I../../ch32fun//../extralibs -I../../ch32fun/ -nostdlib -I. -Wall -Wl,--print-memory-usage -Wl,-Map=blink.map -lgcc -T ../../ch32fun//generated_CH32V203G6U6_.ld -Wl,--gc-sections
Memory region Used Size Region Size %age Used
FLASH: 880 B 32 KB 2.69%
RAM: 0 B 10 KB 0.00%
riscv64-unknown-elf-objdump -S blink.elf > blink.lst
riscv64-unknown-elf-objcopy -O binary blink.elf blink.bin
riscv64-unknown-elf-objcopy -O ihex blink.elf blink.hex
make -C ../../ch32fun//../minichlink all
make[1]: Entering directory '/home/kxygk/Projects/extern/ch32fun/minichlink'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/kxygk/Projects/extern/ch32fun/minichlink'
../../ch32fun//../minichlink/minichlink -w blink.bin flash -b
Found programmer in IAP mode. Attempting to eject it out of IAP.
Eject command sent (1)
make: *** [../../ch32fun/ch32fun.mk:351: cv_flash] Error 253
The board should be able to program the micro (as far as I understand their documentation). If you plug it in over USB without doing anything and run make then the last lines will read
../../ch32fun//../minichlink/minichlink -w blink.bin flash -b
VID:0x1209, PID:0xb003
Error: Could not initialize any supported programmers
If you follow the flashing instruction https://github.com/wuxx/nanoCH32V203
Keep pressing the BOOT button on the development board, then press and release the RST button, and finally release the BOOT button to make the chip enter the bootloader.
Then you get the previous error
../../ch32fun//../minichlink/minichlink -w blink.bin flash -b
Found programmer in IAP mode. Attempting to eject it out of IAP.
Eject command sent (1)
make: *** [../../ch32fun/ch32fun.mk:351: cv_flash] Error 253
I've tried both ports on the board with no luck.
I'm guessing it's having some issue "Attempting to eject it out of IAP". But I can't find where this is documented
Before the example I've also tried going in to the minichlink
directory and running minichlink
(after running make
) - but I was giving me similar errors
I'm running Ubuntu 24.04 noble
I've tested with two boards - same errors
If anyone has any thoughts or suggestions, please let me know :))
PS: I originally wanted to port some Arduino code.. but I couldn't get Arduino to see the board in the "Port" menu (and no idea how to debug further). Obviously getting Arduino running would be preferable, but it's very difficult to deal with when things break