From cf9419280a25a29de91a562b74dcab487daff071 Mon Sep 17 00:00:00 2001 From: Maximilian Gerhardt Date: Mon, 16 Sep 2024 17:03:54 +0200 Subject: [PATCH] Add CH32V317 series boards --- boards/genericCH32V317TCU6.json | 45 +++++++++++++++++++ boards/genericCH32V317VCT6.json | 45 +++++++++++++++++++ boards/genericCH32V317WCU6.json | 45 +++++++++++++++++++ examples/adc-cpu-temp-none-os/src/main.c | 2 +- examples/blinky-cpp-none-os/src/main.cpp | 2 +- examples/blinky-none-os/platformio.ini | 3 ++ examples/blinky-none-os/src/main.c | 2 +- .../src/target_config.h | 2 +- examples/hello-world-rt-thread/src/main.c | 2 +- examples/uart-printf-none-os/src/main.c | 2 +- misc/scripts/gen_boarddefs.py | 10 ++++- 11 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 boards/genericCH32V317TCU6.json create mode 100644 boards/genericCH32V317VCT6.json create mode 100644 boards/genericCH32V317WCU6.json diff --git a/boards/genericCH32V317TCU6.json b/boards/genericCH32V317TCU6.json new file mode 100644 index 0000000..229cd9d --- /dev/null +++ b/boards/genericCH32V317TCU6.json @@ -0,0 +1,45 @@ +{ + "build": { + "extra_flags": "-DCH32V317TC -DCH32V31X -DCH32V31x -DCH32V317 -DCH32V30x_D8C", + "f_cpu": "144000000L", + "hwids": [ + [ + "0x1A86", + "0x8010" + ] + ], + "mabi": "ilp32", + "march": "rv32imacxw", + "mcu": "ch32v317tcu6", + "series": "ch32v307" + }, + "debug": { + "onboard_tools": [ + "wch-link" + ], + "openocd_config": "wch-riscv.cfg", + "svd_path": "CH32V307xx.svd" + }, + "frameworks": [ + "noneos-sdk", + "freertos", + "harmony-liteos", + "rt-thread", + "tencent-os", + "ch32v003fun" + ], + "name": "Generic CH32V317TCU6", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "wch-link", + "protocols": [ + "wch-link", + "minichlink", + "isp", + "wlink" + ] + }, + "url": "http://www.wch-ic.com/products/CH32V307.html", + "vendor": "W.CH" +} \ No newline at end of file diff --git a/boards/genericCH32V317VCT6.json b/boards/genericCH32V317VCT6.json new file mode 100644 index 0000000..7b7d594 --- /dev/null +++ b/boards/genericCH32V317VCT6.json @@ -0,0 +1,45 @@ +{ + "build": { + "extra_flags": "-DCH32V317VC -DCH32V31X -DCH32V31x -DCH32V317 -DCH32V30x_D8C", + "f_cpu": "144000000L", + "hwids": [ + [ + "0x1A86", + "0x8010" + ] + ], + "mabi": "ilp32", + "march": "rv32imacxw", + "mcu": "ch32v317vct6", + "series": "ch32v307" + }, + "debug": { + "onboard_tools": [ + "wch-link" + ], + "openocd_config": "wch-riscv.cfg", + "svd_path": "CH32V307xx.svd" + }, + "frameworks": [ + "noneos-sdk", + "freertos", + "harmony-liteos", + "rt-thread", + "tencent-os", + "ch32v003fun" + ], + "name": "Generic CH32V317VCT6", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "wch-link", + "protocols": [ + "wch-link", + "minichlink", + "isp", + "wlink" + ] + }, + "url": "http://www.wch-ic.com/products/CH32V307.html", + "vendor": "W.CH" +} \ No newline at end of file diff --git a/boards/genericCH32V317WCU6.json b/boards/genericCH32V317WCU6.json new file mode 100644 index 0000000..f4a773c --- /dev/null +++ b/boards/genericCH32V317WCU6.json @@ -0,0 +1,45 @@ +{ + "build": { + "extra_flags": "-DCH32V317WC -DCH32V31X -DCH32V31x -DCH32V317 -DCH32V30x_D8C", + "f_cpu": "144000000L", + "hwids": [ + [ + "0x1A86", + "0x8010" + ] + ], + "mabi": "ilp32", + "march": "rv32imacxw", + "mcu": "ch32v317wcu6", + "series": "ch32v307" + }, + "debug": { + "onboard_tools": [ + "wch-link" + ], + "openocd_config": "wch-riscv.cfg", + "svd_path": "CH32V307xx.svd" + }, + "frameworks": [ + "noneos-sdk", + "freertos", + "harmony-liteos", + "rt-thread", + "tencent-os", + "ch32v003fun" + ], + "name": "Generic CH32V317WCU6", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "wch-link", + "protocols": [ + "wch-link", + "minichlink", + "isp", + "wlink" + ] + }, + "url": "http://www.wch-ic.com/products/CH32V307.html", + "vendor": "W.CH" +} \ No newline at end of file diff --git a/examples/adc-cpu-temp-none-os/src/main.c b/examples/adc-cpu-temp-none-os/src/main.c index b8ee571..7d7ee09 100644 --- a/examples/adc-cpu-temp-none-os/src/main.c +++ b/examples/adc-cpu-temp-none-os/src/main.c @@ -4,7 +4,7 @@ #include #elif defined(CH32V20X) #include -#elif defined(CH32V30X) +#elif defined(CH32V30X) || defined(CH32V31X) #include #endif #include diff --git a/examples/blinky-cpp-none-os/src/main.cpp b/examples/blinky-cpp-none-os/src/main.cpp index 52611aa..2f87167 100644 --- a/examples/blinky-cpp-none-os/src/main.cpp +++ b/examples/blinky-cpp-none-os/src/main.cpp @@ -4,7 +4,7 @@ #include #elif defined(CH32V20X) #include -#elif defined(CH32V30X) +#elif defined(CH32V30X) || defined(CH32V31X) #include #elif defined(CH32L10X) #include diff --git a/examples/blinky-none-os/platformio.ini b/examples/blinky-none-os/platformio.ini index 5f3d9eb..f9c4947 100644 --- a/examples/blinky-none-os/platformio.ini +++ b/examples/blinky-none-os/platformio.ini @@ -57,6 +57,9 @@ board = genericCH32V305FBP6 [env:genericCH32V307WCU6] board = genericCH32V307WCU6 +[env:genericCH32V317VCT6] +board = genericCH32V317VCT6 + [env:genericCH32X035G8U6] board = genericCH32X035G8U6 ; to build with clock = 96MHz from ext. crystal: diff --git a/examples/blinky-none-os/src/main.c b/examples/blinky-none-os/src/main.c index d0cc9dd..5a9b86e 100644 --- a/examples/blinky-none-os/src/main.c +++ b/examples/blinky-none-os/src/main.c @@ -4,7 +4,7 @@ #include #elif defined(CH32V20X) #include -#elif defined(CH32V30X) +#elif defined(CH32V30X) || defined(CH32V31X) #include #elif defined (CH32X035) #include diff --git a/examples/hello-world-harmony-liteos/src/target_config.h b/examples/hello-world-harmony-liteos/src/target_config.h index 80ab64a..e1682bb 100644 --- a/examples/hello-world-harmony-liteos/src/target_config.h +++ b/examples/hello-world-harmony-liteos/src/target_config.h @@ -47,7 +47,7 @@ extern "C" { #include #elif defined(CH32V20X) #include -#elif defined(CH32V30X) +#elif defined(CH32V30X) || defined(CH32V31X) #include #elif defined(CH32X035) || defined(CH32X033) #include diff --git a/examples/hello-world-rt-thread/src/main.c b/examples/hello-world-rt-thread/src/main.c index 577cd41..74b784d 100644 --- a/examples/hello-world-rt-thread/src/main.c +++ b/examples/hello-world-rt-thread/src/main.c @@ -13,7 +13,7 @@ #include #elif defined(CH32V20X) #include -#elif defined(CH32V30X) +#elif defined(CH32V30X) || defined(CH32V31X) #include #elif defined(CH32X035) || defined(CH32X033) #include diff --git a/examples/uart-printf-none-os/src/main.c b/examples/uart-printf-none-os/src/main.c index 8fb77b3..4f0b1ff 100644 --- a/examples/uart-printf-none-os/src/main.c +++ b/examples/uart-printf-none-os/src/main.c @@ -4,7 +4,7 @@ #include #elif defined(CH32V20X) #include -#elif defined(CH32V30X) +#elif defined(CH32V30X) || defined(CH32V31X) #include #elif defined(CH32X035) || defined(CH32X033) #include diff --git a/misc/scripts/gen_boarddefs.py b/misc/scripts/gen_boarddefs.py index 760485a..5b9f55f 100644 --- a/misc/scripts/gen_boarddefs.py +++ b/misc/scripts/gen_boarddefs.py @@ -25,7 +25,7 @@ def get_classification_macro(self) -> Optional[str]: "CH32V20x_D8": ["CH32V203RB"], "CH32V20x_D8W": ["CH32V208GB", "CH32V208CB", "CH32V208RB", "CH32V208WB"], "CH32V30x_D8": ["CH32V303CB", "CH32V303RB", "CH32V303RC", "CH32V303VC"], - "CH32V30x_D8C": ["CH32V305FB", "CH32V305RB", "CH32V307RC", "CH32V307WC", "CH32V307VC"] + "CH32V30x_D8C": ["CH32V305FB", "CH32V305RB", "CH32V307RC", "CH32V307WC", "CH32V307VC", "CH32V317"] } for dev_class, devs in dev_classes.items(): if any([self.name.upper().startswith(chip) for chip in devs]): @@ -54,6 +54,7 @@ def get_riscv_arch_and_abi(self) -> Tuple[str, str]: # ch32v10x only rv32imac (RISC-V3A) # ch32v00x only rv32ecxw (RISC-V2A) name_lower = self.name.lower() + # applies to ch32v307 and ch32v317 if name_lower.startswith("ch32v3"): return ("rv32imacxw", "ilp32") elif name_lower.startswith("ch32v2"): @@ -85,6 +86,9 @@ def exact_series(self) -> str: # FreeRTOS. if self.name.lower().startswith("ch32x03"): return "ch32x035" + # Hack: A ch32v317 uses the same SDK as the ch32v307. + if self.name.lower().startswith("ch32v317"): + return "ch32v307" return self.name[0:len("ch32vxxx")] chip_db: List[ChipInfo] = [ @@ -147,6 +151,10 @@ def exact_series(self) -> str: ChipInfo("CH32V307RCT6", 256, 64, 144, "LQFP64M"), ChipInfo("CH32V307WCU6", 256, 64, 144, "QFN64X8"), ChipInfo("CH32V307VCT6", 256, 64, 144, "LQFP100"), + # CH32V317 + ChipInfo("CH32V317TCU6", 256, 64, 144, "QFN36C4"), + ChipInfo("CH32V317WCU6", 256, 64, 144, "QFN68"), + ChipInfo("CH32V317VCT6", 256, 64, 144, "LQFP100"), # CH32X035/3 ChipInfo("CH32X035R8T6", 62, 20, 48, "LQFP64M"), ChipInfo("CH32X035C8T6", 62, 20, 48, "LQFP48"),