From b6eb7a1db9e4265777e6935c73e08a026f95b2bc Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 14 Jun 2020 00:52:19 -0400 Subject: [PATCH 1/5] Add WIP chtool upload Add uploader to support CH55x MCS-51 USB chips --- builder/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/builder/main.py b/builder/main.py index da7f4a4..34be4ab 100644 --- a/builder/main.py +++ b/builder/main.py @@ -161,6 +161,19 @@ def _parseSdccFlags(flags): env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") ] +# CH55x upload tool +elif upload_protocol == "ch55x": + UPLOADER="ch55xtool.py" + UPLOADERFLAGS=[ + "-r","-f" + ]; + UPLOADCMD="python3 $UPLOADER $UPLOADERFLAGS $BUILD_DIR/${PROGNAME}.bin" + upload_actions = [ + env.VerboseAction(" ".join(["$OBJCOPY","-I","ihex","-O","binary", + "$SOURCE", "$BUILD_DIR/${PROGNAME}.bin"]), "Creating binary"), + env.VerboseAction("$UPLOADCMD", "Uploading ${PROGNAME}.bin") + ] + # custom upload tool elif upload_protocol == "custom": upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] From 2a26ffdc1db618732e15f26cb892fc4dffd937f0 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 14 Jun 2020 01:18:40 -0400 Subject: [PATCH 2/5] Add CH559 board definition --- boards/ch559.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 boards/ch559.json diff --git a/boards/ch559.json b/boards/ch559.json new file mode 100644 index 0000000..937743a --- /dev/null +++ b/boards/ch559.json @@ -0,0 +1,20 @@ +{ + "build": { + "f_cpu": "56000000L", + "size_iram": 256, + "size_xram": 6144, + "size_code": 65536, + "size_heap": 128, + "mcu": "ch559", + "cpu": "mcs51" + }, + "frameworks": [], + "upload": { + "maximum_ram_size": 6400, + "maximum_size": 65536, + "protocol": "ch55x" + }, + "name": "CH559", + "url": "http://www.wch-ic.com/products/CH559.html", + "vendor": "WCH" +} From 1c3964a2930811c9b756e5121e89d585615abafe Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 14 Jun 2020 02:09:38 -0400 Subject: [PATCH 3/5] Update ch559.json change f_cpu to match reset state, per data sheet: After reset, Fosc = 12MHz, Fpll = 288MHz, Fusb4x = 48MHz, Fsys = 12MHz. --- boards/ch559.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/ch559.json b/boards/ch559.json index 937743a..e55ffc1 100644 --- a/boards/ch559.json +++ b/boards/ch559.json @@ -1,6 +1,6 @@ { "build": { - "f_cpu": "56000000L", + "f_cpu": "12000000L", "size_iram": 256, "size_xram": 6144, "size_code": 65536, From 13b5c6032631689325e7ffd2d26b35944b44eb03 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 14 Jun 2020 10:02:30 -0400 Subject: [PATCH 4/5] fix the omission of "env.Replace" Now working with manual placement of ch55xtool.py in project folder --- builder/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/main.py b/builder/main.py index 34be4ab..8df5661 100644 --- a/builder/main.py +++ b/builder/main.py @@ -163,11 +163,13 @@ def _parseSdccFlags(flags): # CH55x upload tool elif upload_protocol == "ch55x": - UPLOADER="ch55xtool.py" - UPLOADERFLAGS=[ - "-r","-f" - ]; - UPLOADCMD="python3 $UPLOADER $UPLOADERFLAGS $BUILD_DIR/${PROGNAME}.bin" + env.Replace( + UPLOADER="ch55xtool.py", + UPLOADERFLAGS=[ + "-f" + ], + UPLOADCMD="python3 $UPLOADER $UPLOADERFLAGS $BUILD_DIR/${PROGNAME}.bin") + upload_actions = [ env.VerboseAction(" ".join(["$OBJCOPY","-I","ihex","-O","binary", "$SOURCE", "$BUILD_DIR/${PROGNAME}.bin"]), "Creating binary"), From ce8ab0a29db6e2816703a21643eeed517f14de89 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 10 Apr 2022 23:31:50 -0400 Subject: [PATCH 5/5] update python3 to $PYTHONEXE Per https://github.com/platformio/platform-intel_mcs51/pull/29#discussion_r846836842 --- builder/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/main.py b/builder/main.py index 8df5661..cd038c8 100644 --- a/builder/main.py +++ b/builder/main.py @@ -168,7 +168,7 @@ def _parseSdccFlags(flags): UPLOADERFLAGS=[ "-f" ], - UPLOADCMD="python3 $UPLOADER $UPLOADERFLAGS $BUILD_DIR/${PROGNAME}.bin") + UPLOADCMD="$PYTHONEXE $UPLOADER $UPLOADERFLAGS $BUILD_DIR/${PROGNAME}.bin") upload_actions = [ env.VerboseAction(" ".join(["$OBJCOPY","-I","ihex","-O","binary",