From 96bf2796c53e5d96cfb964e8f389d3af8dc3aba6 Mon Sep 17 00:00:00 2001 From: zackees Date: Tue, 21 Jul 2026 16:51:54 -0700 Subject: [PATCH] fix(ch32v): validate framework selection Closes #1108 --- .../src/ch32v/orchestrator.rs | 27 +++++++++++++++++++ .../boards/json/genericCH32V208WBU6.json | 2 +- .../boards/json/genericCH32V303VCT6.json | 2 +- tests/platform/ch32v103/platformio.ini | 2 +- tests/platform/ch32v208/platformio.ini | 2 +- tests/platform/ch32v303/platformio.ini | 2 +- tests/platform/ch32x035/platformio.ini | 2 +- 7 files changed, 33 insertions(+), 6 deletions(-) diff --git a/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs b/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs index c5a5d97ef..63983baa3 100644 --- a/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs +++ b/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs @@ -38,6 +38,13 @@ impl BuildOrchestrator for Ch32vOrchestrator { // 1-2. Parse config, load board, setup build dirs, resolve src dir, collect flags let mut ctx = pipeline::BuildContext::new(params).await?; + let framework_name = ctx + .config + .get_env_config(¶ms.env_name) + .ok() + .and_then(|env| env.get("framework")) + .map(String::as_str); + validate_ch32v_framework(framework_name)?; // 3. Ensure RISC-V GCC toolchain let toolchain = fbuild_packages::toolchain::RiscvToolchain::new(¶ms.project_dir); @@ -243,6 +250,17 @@ pub fn create() -> Box { Box::new(Ch32vOrchestrator) } +/// Only the Arduino framework is implemented for CH32V. +fn validate_ch32v_framework(framework: Option<&str>) -> fbuild_core::Result<()> { + match framework.map(str::trim) { + None | Some("") | Some("arduino") => Ok(()), + Some(other) => Err(fbuild_core::FbuildError::ConfigError(format!( + "ch32v: framework = {other} is not supported yet; only `framework = arduino` " + "builds today (FastLED/fbuild#1108)" + ))), + } +} + /// Recursively add subdirectories that contain .h files as include paths. fn discover_header_subdirs(dir: &Path, include_dirs: &mut Vec) { if let Ok(entries) = std::fs::read_dir(dir) { @@ -409,6 +427,15 @@ mod tests { assert!(!is_ch32v_project(tmp.path(), "uno")); } + #[test] + fn test_validate_ch32v_framework() { + assert!(validate_ch32v_framework(None).is_ok()); + assert!(validate_ch32v_framework(Some("arduino")).is_ok()); + assert!(validate_ch32v_framework(Some(" arduino ")).is_ok()); + let error = validate_ch32v_framework(Some("noneos-sdk")).unwrap_err(); + assert!(error.to_string().contains("1108")); + } + #[test] fn test_series_to_system_dir() { // CH32V series: last digit replaced with 'x' diff --git a/crates/fbuild-config/assets/boards/json/genericCH32V208WBU6.json b/crates/fbuild-config/assets/boards/json/genericCH32V208WBU6.json index 74d7d592b..edafa6cf0 100644 --- a/crates/fbuild-config/assets/boards/json/genericCH32V208WBU6.json +++ b/crates/fbuild-config/assets/boards/json/genericCH32V208WBU6.json @@ -21,7 +21,7 @@ } }, "fcpu": 144000000, - "frameworks": ["noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"], + "frameworks": ["arduino", "noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"], "id": "genericCH32V208WBU6", "mcu": "CH32V208WBU6", "name": "Generic CH32V208WBU6", diff --git a/crates/fbuild-config/assets/boards/json/genericCH32V303VCT6.json b/crates/fbuild-config/assets/boards/json/genericCH32V303VCT6.json index 3f928f6ea..cb8225ae7 100644 --- a/crates/fbuild-config/assets/boards/json/genericCH32V303VCT6.json +++ b/crates/fbuild-config/assets/boards/json/genericCH32V303VCT6.json @@ -21,7 +21,7 @@ } }, "fcpu": 144000000, - "frameworks": ["noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"], + "frameworks": ["arduino", "noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"], "id": "genericCH32V303VCT6", "mcu": "CH32V303VCT6", "name": "Generic CH32V303VCT6", diff --git a/tests/platform/ch32v103/platformio.ini b/tests/platform/ch32v103/platformio.ini index e8cf96b78..c70e59cfc 100644 --- a/tests/platform/ch32v103/platformio.ini +++ b/tests/platform/ch32v103/platformio.ini @@ -11,4 +11,4 @@ [env:ch32v103] platform = ch32v board = genericCH32V103C8T6 -framework = noneos-sdk +framework = arduino diff --git a/tests/platform/ch32v208/platformio.ini b/tests/platform/ch32v208/platformio.ini index 59b778d69..b9fb36b52 100644 --- a/tests/platform/ch32v208/platformio.ini +++ b/tests/platform/ch32v208/platformio.ini @@ -11,4 +11,4 @@ [env:ch32v208] platform = ch32v board = genericCH32V208WBU6 -framework = noneos-sdk +framework = arduino diff --git a/tests/platform/ch32v303/platformio.ini b/tests/platform/ch32v303/platformio.ini index 241cd4488..175f03430 100644 --- a/tests/platform/ch32v303/platformio.ini +++ b/tests/platform/ch32v303/platformio.ini @@ -11,4 +11,4 @@ [env:ch32v303] platform = ch32v board = genericCH32V303VCT6 -framework = noneos-sdk +framework = arduino diff --git a/tests/platform/ch32x035/platformio.ini b/tests/platform/ch32x035/platformio.ini index 262f88f7d..0447eb218 100644 --- a/tests/platform/ch32x035/platformio.ini +++ b/tests/platform/ch32x035/platformio.ini @@ -11,4 +11,4 @@ [env:ch32x035] platform = ch32v board = genericCH32X035C8T6 -framework = noneos-sdk +framework = arduino