ã¯ããã«
ch32v003funã®ç°å¢ãWindowsã«æ§ç¯ããã¡ã¢ã§ãã
Wikiã®éãï¼ä»¥ä¸âï¼ã«ããã°è¯ãã®ã§ãããèªåã®ã¾ã¨ãããã¾ããã
ç°å¢
- Windows10
- CH32V003F4P6 Development board
- WCH-LinkE version 2.15
Development boardã®è©³ç´°ã¯ä»¥ä¸â
æ§ç¯
githubããch32v003funã好ããªãã©ã«ãã«ãã¦ã³ãã¼ããã¾ãã
ç§ã¯ãC:\Users\USERNAME\Downloads\ch32v003fun
ã«git cloneãã¾ããã
gccã¤ã³ã¹ãã¼ã«
以ä¸ãããrisc-v-gcc10.1.0.exe (22 MB) ããã¦ã³ãã¼ããã¤ã³ãã¼ã«ãã¾ãã
ã¤ã³ã¹ãã¼ã«å
ï¼C:\SysGCC
The minichlink.exe file is already ready to go in the minichlink folder.
ã¨ããããã«ãminichlink.exe
ã¯makeããªãã¦ããã§ã«å
¥ã£ã¦ãã¾ãã
Zading
以ä¸ãããZadingããã¦ã³ãã¼ããã¾ãã
zadig-2.9.exe
ããã¦ã³ãã¼ããã¾ããã
Zadingã§ãã©ã¤ããã¤ã³ã¹ãã¼ã«ããåã¯WCH-LinkEã¯Interfaceã§èªèãã¦ãã¾ãã
Zadingã§WinUSB(?)ãã¤ã³ã¹ãã¼ã«ãã¾ãã
ã¤ã³ã¹ãã¼ã«å¾ã¯USBããã¤ã¹ã¨ãã¦èªèããããã«ãªãã¾ãã
Lãã«
ãµã³ãã«ããã°ã©ã ãä½ã£ã¦ã¿ã¾ãã
以ä¸ãåèã«ããã¦ããã ãã¾ããã
C:\Users\USERNAME\Downloads\ch32v003fun\examples\template
ãã³ãã¼ãã
C:\Users\USERNAME\Downloads\ch32v003fun\examples\blinktest20241221
ãä½ãã¾ããã
template.cãtemplate.h ã®ãã¡ã¤ã«åãä½ãããããã°ã©ã åï¼ä¾ãã° usb_rebooter.cï¼ã«å¤æ´ãã¾ãã
ã¨ããã¾ãããtemplate.hã¯ç¡ããfunconfig.hã ã£ãã®ã§ãååå¤æ´ã¯template.cã®æ¹ã ãã«ãã¾ããã
blinktest20241221.c ã«å¤æ´ãã¦ãã¾ãã
CH32V003F4P6 Development Boardã®D1ãç¹æ» ããããã°ã©ã ã§ãã
ãµã³ãã«ããã°ã©ã ï¼C:\Users\USERNAME\Downloads\ch32v003fun\examples\blink\blink.c
ï¼ãã³ãããã¦ä¸è¦é¨åãã³ã¡ã³ãã¢ã¦ãããã®ã§ãä¸è¦è¡ãå¤ãã§ãã
/* blinktest20241221 D1ã®blink */ #include "ch32v003fun.h" #include <stdio.h> // use defines to make more meaningful names for our GPIO pins //#define PIN_1 PD0 #define PIN_K PD4 //#define PIN_BOB PD6 //#define PIN_KEVIN PC0 int main() { SystemInit(); // Enable GPIOs funGpioInitAll(); //funPinMode( PIN_1, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP ); funPinMode( PIN_K, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP ); //funPinMode( PIN_BOB, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP ); //funPinMode( PIN_KEVIN, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP ); while(1) { //funDigitalWrite( PIN_1, FUN_HIGH ); funDigitalWrite( PIN_K, FUN_HIGH ); //funDigitalWrite( PIN_BOB, FUN_HIGH ); //funDigitalWrite( PIN_KEVIN, FUN_HIGH ); Delay_Ms( 100 ); //funDigitalWrite( PIN_1, FUN_LOW ); funDigitalWrite( PIN_K, FUN_LOW ); //funDigitalWrite( PIN_BOB, FUN_LOW ); //funDigitalWrite( PIN_KEVIN, FUN_LOW ); Delay_Ms( 250 ); } }
ãªããã³ã¼ãã®ä½æã ch32v003fun ã® examples ãã£ã¬ã¯ããªå ã«æ°ãããã£ã¬ã¯ããªãä½ã£ã¦è¡ã£ãå ´åãTARGET ã ããæ¸ãæããã°è¯ãã§ãã
ã¨ã®ãã¨ã§ãã®ã§ãMakefileã¯
TARGET:=blinktest20241221
ã¨ã ãã«ãã¾ããã
æ¥ç¶
3.3V, GND, SWIO(pin18, PD1)ã®3æ¬ãæ¥ç¶ããã ãã§ãã
PD1ã¯J2 7pin
ãããã¯ãU4 2pin ã§ãã
ã©ã¡ãã§ãè¯ãã§ãã
makeãæ¸ãè¾¼ã¿
ãã®ãã£ã¬ã¯ããªã«powershellã§ç§»åãã¦make
ãã¾ãã
make
ãå
¥ã£ã¦ããªãå ´åã¯å
¥ããå¿
è¦ãããã¾ãã
ç§ã¯makeã¯å ã å ¥ãã¦ããã¾ããã
PS C:\Users\USERNAME> make -v GNU Make 3.82 Built for i686-pc-mingw32 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
makeãéããWCH-LinkEãèªèãCH32V003F4P6ãæ¤åºãã¦æ¸ãè¾¼ã¿ã¾ã§å®äºãã¦ãã¾ãã
PS C:\Users\USERNAME\Downloads\ch32v003fun\examples\blinktest20241221> make riscv64-unknown-elf-gcc -E -P -x c -DTARGET_MCU=CH32V003 -DMCU_PACKAGE= -DTARGET_MCU_LD=0 -DTARGET_MCU_MEMORY_SPLIT= ../../ch32v003fun/ch32v003fun.ld > ../../ch32v003fun/generated_ch32v003.ld riscv64-unknown-elf-gcc -o blinktest20241221.elf ../../ch32v003fun/ch32v003fun.c blinktest20241221.c -g -Os -flto -ffunction-sections -fdata-sections -fmessage-length=0 -msmall-data-limit=8 -march=rv32ec -mabi=ilp32e -DCH32V003=1 -static-libgcc -I/usr/include/newlib -I../../ch32v003fun/../extralibs -I../../ch32v003fun -nostdlib -I. -Wall -Wl,--print-memory-usage -Wl,-Map=blinktest20241221.map -L../../ch32v003fun/../misc -lgcc -T ../../ch32v003fun/generated_ch32v003.ld -Wl,--gc-sections Memory region Used Size Region Size %age Used FLASH: 1844 B 16 KB 11.25% RAM: 0 GB 2 KB 0.00% riscv64-unknown-elf-objdump -S blinktest20241221.elf > blinktest20241221.lst riscv64-unknown-elf-objcopy -O binary blinktest20241221.elf blinktest20241221.bin riscv64-unknown-elf-objcopy -O ihex blinktest20241221.elf blinktest20241221.hex make -C ../../ch32v003fun/../minichlink all make[1]: Entering directory `C:/Users/USERNAME/Downloads/ch32v003fun/minichlink' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `C:/Users/USERNAME/Downloads/ch32v003fun/minichlink' ../../ch32v003fun/../minichlink/minichlink -w blinktest20241221.bin flash -b Found WCH Link WCH Programmer is CH32V307 version 2.15 Full Chip Type Reply: [8] 82-0d-05-09-00-30-05-00-03 Detected: CH32V003 Setup success Flash Storage: 16 kB Part UUID : f7-36-ab-cd-5f-54-bc-51 PFlags : ff-ff-ff-ff Part Type (B): 00-30-05-00 Read protection: disabled Interface Setup Writing image Image written.
ã¾ã¨ã
æ¸ãè¾¼ã¿æé ãã¾ã¨ããã¨ã
- powershellã§ããã°ã©ã ããããã©ã«ãã«ç§»å
- WCH-LinkEã¨ãã¤ã³ã³ãæ¥ç¶ãã¦éé»
- powershellã§makeã¨æã¡ãenter
ããã§æ¸ãè¾¼ã¾ãã¾ããç°¡åï½
ãã®ä»
Zadingã§WinUSBãã¤ã³ã¹ãã¼ã«ããå¾ã¯ãArduinoã§æ¸ãè¾¼ã¿ãã§ããªããªãã¾ãã
å度Zadingã§æ»ãã°æ»ãããããã¾ããï¼æªç¢ºèªã§ãï¼
WCH-LinkEã¯å®ãã®ã§ãæ»ããã«è¤æ°æ¬æã£ã¦ãã¦ãè¯ãããããã¾ããã
以ä¸:)