@@ -22,14 +22,69 @@ rustup target add riscv32imac-unknown-none-elf
2222
2323- RISC-V toolchain ([ e.g. from SiFive] ( https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz ) )
2424
25+ One of:
26+
27+ - [ dfu-util] ( http://dfu-util.sourceforge.net/ )
2528- [ openocd for GD32VF103] ( https://github.com/riscv-mcu/riscv-openocd )
29+ - [ RV-LINK] ( https://gitee.com/zoomdy/RV-LINK )
2630
27- ### Running the examples
31+ ### Building
2832
2933If you have a GD32VF103C** B** chip on your board, edit ` .cargo/config ` and replace
3034` memory-c8.x ` with ` memory-cb.x ` .
3135
32- Start openocd:
36+ To build all the provided examples run
37+ ```
38+ cargo build --examples --release --features=lcd
39+ ```
40+
41+ ### Using dfu-util for Flashing
42+
43+ The GD32VF103 contains a [ DFU] ( https://www.usb.org/sites/default/files/DFU_1.1.pdf )
44+ compatible bootloader which allows to program the firmware of your longan-nano without
45+ additional hardware like a JTAG adapter; instead just using an ordenary USB-C cable.
46+ You can use [ dfu-util] ( http://dfu-util.sourceforge.net/ ) or the vendor supplied tool to
47+ flash the firmware.
48+
49+ Unfortunately, some versions of this chip shipped with a buggy bootloader and it won't report
50+ the correct parameters to flash it sucessfully. As of May 2020, the most recent version of
51+ [ dfu-util] ( http://dfu-util.sourceforge.net/ ) from the git repository contains a workaround.
52+ Make sure you use an up-to-date version.
53+
54+
55+ Steps to flash an example via DFU:
56+
57+ 1 ) Extract the binary
58+
59+ ``` sh
60+ riscv-nuclei-elf-objcopy -O binary target/riscv32imac-unknown-none-elf/release/blinky firmware.bin
61+ ```
62+
63+ 2 ) Flash using ` dfu-util ` :
64+
65+ Keep the BOOT0 button pressed while power-up or while pressing and releaseing the reset button. Then
66+ run
67+
68+ ``` sh
69+ dfu-util -a 0 -s 0x08000000:leave -D firmware.bin
70+ ```
71+
72+ Ensure that dfu-util uses a page size of 1024; either because your GD32VF103 has
73+ a bootloader without the the aforementioned bug, or because the output reads
74+
75+ ```
76+ [...]
77+ Device returned transfer size 2048
78+ DfuSe interface name: "Internal Flash "
79+ Found GD32VF103, which reports a bad page size and count for its internal memory.
80+ Fixed layout based on part number: page size 1024, count 128.
81+ Downloading to address = 0x08000000, size = 23784
82+ [...]
83+ ```
84+
85+ ### Using OpenOCD for Flashing and Debugging
86+
87+ Start openocd assuming you have Sipeed JTAG adapter:
3388``` sh
3489/path/to/openocd -f sipeed-jtag.cfg -f openocd.cfg
3590```
0 commit comments