Skip to content

Commit

Permalink
Add CH32V317 series boards
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Sep 16, 2024
1 parent 948133a commit cf94192
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 7 deletions.
45 changes: 45 additions & 0 deletions boards/genericCH32V317TCU6.json
Original file line number Diff line number Diff line change
@@ -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"
}
45 changes: 45 additions & 0 deletions boards/genericCH32V317VCT6.json
Original file line number Diff line number Diff line change
@@ -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"
}
45 changes: 45 additions & 0 deletions boards/genericCH32V317WCU6.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion examples/adc-cpu-temp-none-os/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#elif defined(CH32V30X) || defined(CH32V31X)
#include <ch32v30x.h>
#endif
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/blinky-cpp-none-os/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#elif defined(CH32V30X) || defined(CH32V31X)
#include <ch32v30x.h>
#elif defined(CH32L10X)
#include <ch32l103.h>
Expand Down
3 changes: 3 additions & 0 deletions examples/blinky-none-os/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/blinky-none-os/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#elif defined(CH32V30X) || defined(CH32V31X)
#include <ch32v30x.h>
#elif defined (CH32X035)
#include <ch32x035.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-world-harmony-liteos/src/target_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern "C" {
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#elif defined(CH32V30X) || defined(CH32V31X)
#include <ch32v30x.h>
#elif defined(CH32X035) || defined(CH32X033)
#include <ch32x035.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-world-rt-thread/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#elif defined(CH32V30X) || defined(CH32V31X)
#include <ch32v30x.h>
#elif defined(CH32X035) || defined(CH32X033)
#include <ch32x035.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/uart-printf-none-os/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ch32v10x.h>
#elif defined(CH32V20X)
#include <ch32v20x.h>
#elif defined(CH32V30X)
#elif defined(CH32V30X) || defined(CH32V31X)
#include <ch32v30x.h>
#elif defined(CH32X035) || defined(CH32X033)
#include <ch32x035.h>
Expand Down
10 changes: 9 additions & 1 deletion misc/scripts/gen_boarddefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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"):
Expand Down Expand Up @@ -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] = [
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit cf94192

Please sign in to comment.