Skip to content

Commit

Permalink
Add initial support for CH559 (WIP/RFC) (#29)
Browse files Browse the repository at this point in the history
* Add WIP chtool upload

Add uploader to support CH55x MCS-51 USB chips

* Add CH559 board definition

* Update ch559.json

change f_cpu to match reset state, per data sheet:

After reset, Fosc = 12MHz, Fpll = 288MHz, Fusb4x = 48MHz, Fsys = 12MHz.

* fix the omission of "env.Replace"

Now working with manual placement of ch55xtool.py in project folder

* update python3 to $PYTHONEXE

Per #29 (comment)
  • Loading branch information
Tonymac32 committed Apr 11, 2022
1 parent e867d65 commit 81bf8cc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions boards/ch559.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"build": {
"f_cpu": "12000000L",
"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"
}
15 changes: 15 additions & 0 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ def _parseSdccFlags(flags):
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
]

# CH55x upload tool
elif upload_protocol == "ch55x":
env.Replace(
UPLOADER="ch55xtool.py",
UPLOADERFLAGS=[
"-f"
],
UPLOADCMD="$PYTHONEXE $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")]
Expand Down

0 comments on commit 81bf8cc

Please sign in to comment.