From fc773c278433c1b400b5ac45eae7b21342538fe5 Mon Sep 17 00:00:00 2001
From: Jason Smith <jason.inet@gmail.com>
Date: Tue, 14 Jan 2020 13:36:47 -0800
Subject: [PATCH] Fix Fysetc S6 FLASH_PAGE_SIZE and test build (#16560)

---
 .github/workflows/test-builds.yml                 |  1 +
 .../share/PlatformIO/scripts/fysetc_STM32S6.py    |  2 +-
 .../share/PlatformIO/variants/FYSETC_S6/variant.h |  2 +-
 buildroot/share/git/mftest                        |  1 +
 buildroot/share/tests/FYSETC_S6-tests             | 15 +++++++++++++++
 platformio.ini                                    |  2 +-
 6 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 buildroot/share/tests/FYSETC_S6-tests

diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml
index db5c5ab701..301165fcd0 100644
--- a/.github/workflows/test-builds.yml
+++ b/.github/workflows/test-builds.yml
@@ -54,6 +54,7 @@ jobs:
         - BIGTREE_SKR_PRO
         - mks_robin
         - ARMED
+        - FYSETC_S6
 
         # Put lengthy tests last
 
diff --git a/buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py b/buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
index de1a5e787d..be010b10fe 100644
--- a/buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
+++ b/buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
@@ -1,5 +1,5 @@
 from os.path import join
-Import("env", "projenv")
+Import("env")
 
 import os,shutil
 from SCons.Script import DefaultEnvironment
diff --git a/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h b/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h
index a99109fdd7..be04ef6b86 100644
--- a/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h
+++ b/buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h
@@ -149,7 +149,7 @@ extern "C" {
 /* HAL configuration */
 #define HSE_VALUE               12000000U
 
-#define FLASH_PAGE_SIZE         uint32(4 * 1024)
+#define FLASH_PAGE_SIZE         (4U * 1024U)
 
 #ifdef __cplusplus
 } // extern "C"
diff --git a/buildroot/share/git/mftest b/buildroot/share/git/mftest
index a83a309bd9..d80b9ed810 100755
--- a/buildroot/share/git/mftest
+++ b/buildroot/share/git/mftest
@@ -34,6 +34,7 @@ case $TESTENV in
      f1)  TESTENV='STM32F103RE' ;;
      f4)  TESTENV='STM32F4' ;;
      f7)  TESTENV='STM32F7' ;;
+     s6)  TESTENV='FYSETC_S6' ;;
   teensy) TESTENV='teensy31' ;;
      t31) TESTENV='teensy31' ;;
      t32) TESTENV='teensy31' ;;
diff --git a/buildroot/share/tests/FYSETC_S6-tests b/buildroot/share/tests/FYSETC_S6-tests
new file mode 100644
index 0000000000..a9e0331acd
--- /dev/null
+++ b/buildroot/share/tests/FYSETC_S6-tests
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+#
+# Build tests for FYSETC_S6
+#
+
+# exit on first failure
+set -e
+
+# Build examples
+restore_configs
+use_example_configs FYSETC/S6
+exec_test $1 $2 "FYSETC S6 Example"
+
+# cleanup
+restore_configs
diff --git a/platformio.ini b/platformio.ini
index f3d24799a7..b0cf2be831 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -627,7 +627,7 @@ build_flags       = ${common.build_flags}
   -DVECT_TAB_OFFSET=0x10000
   -DUSBCON -DUSBD_USE_CDC -DHAL_PCD_MODULE_ENABLED -DUSBD_VID=0x0483 '-DUSB_PRODUCT="FYSETC_S6"'
 build_unflags     = -std=gnu++11
-extra_scripts     = buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
+extra_scripts     = pre:buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
 src_filter        = ${common.default_src_filter} +<src/HAL/HAL_STM32>
 lib_ignore        = Arduino-L6470
 debug_tool        = stlink
-- 
GitLab