-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CH32V203C8 and CH32V203C6 (#23)
* Update package.json * Fix multiple build warnings and errors * Fix multiple build warnings and errors * Add PlatformIO builder script * Fix build with mac toolchain, wtf? * Add support for CH32V203C6 and CH32V203C6 * fix some warnings --------- Co-authored-by: Maximilian Gerhardt <[email protected]>
- Loading branch information
1 parent
29c76ad
commit f187ac1
Showing
29 changed files
with
1,385 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"name": "framework-arduino-ch32v", | ||
"description": "Arduino Wiring-based Framework (CH32V Core)", | ||
"version": "0.0.0", | ||
"url": "https://github.com/openwch/arduino_core_ch32" | ||
} | ||
"description": "Core library for CH32duino", | ||
"name": "framework-arduino-openwch-ch32", | ||
"system": "all", | ||
"url": "https://github.com/openwch/arduino_core_ch32", | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# Copyright 2023-present Maximilian Gerhardt <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
Arduino | ||
Arduino Wiring-based Framework allows writing cross-platform software to | ||
control devices attached to a wide range of Arduino boards to create all | ||
kinds of creative coding, interactive objects, spaces or physical experiences. | ||
http://arduino.cc/en/Reference/HomePage | ||
""" | ||
|
||
from os.path import isdir, join | ||
import sys | ||
|
||
from SCons.Script import DefaultEnvironment | ||
|
||
IS_MAC = sys.platform.startswith("darwin") | ||
|
||
env = DefaultEnvironment() | ||
platform = env.PioPlatform() | ||
board = env.BoardConfig() | ||
mcu = env.BoardConfig().get("build.mcu") | ||
chip_series: str = board.get("build.series", "")[0:-1].upper() + "x" | ||
variant_h = board.get("build.arduino.openwch.variant_h") | ||
|
||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-openwch-ch32") | ||
assert isdir(FRAMEWORK_DIR) | ||
|
||
machine_flags = [ | ||
"-march=%s" % board.get("build.march"), | ||
"-mabi=%s" % board.get("build.mabi"), | ||
"-msmall-data-limit=8", | ||
"-msave-restore", | ||
] | ||
|
||
env.Append( | ||
ASFLAGS=machine_flags, | ||
ASPPFLAGS=[ | ||
"-x", "assembler-with-cpp" | ||
], | ||
|
||
CFLAGS=[ | ||
"-std=gnu99" | ||
], | ||
|
||
CCFLAGS=machine_flags + [ | ||
"-Os", | ||
"-Wall", | ||
"-fmessage-length=0", | ||
"-fsigned-char", | ||
"-ffunction-sections", | ||
"-fdata-sections", | ||
"-fno-common", | ||
#"-flto", | ||
], | ||
|
||
CXXFLAGS=[ | ||
"-fno-threadsafe-statics", | ||
"-fno-rtti", | ||
"-fno-exceptions", | ||
"-fno-use-cxa-atexit", | ||
"-fpermissive", | ||
"-std=gnu++14" | ||
], | ||
|
||
LINKFLAGS=machine_flags + [ | ||
"-Os", | ||
"-fmessage-length=0", | ||
"-fsigned-char", | ||
"-ffunction-sections", | ||
"-fdata-sections", | ||
"-fno-common", | ||
"-Wl,--gc-sections", | ||
#"-flto", | ||
"--specs=nosys.specs", | ||
"--specs=nano.specs", | ||
"-nostartfiles", | ||
'-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map") | ||
], | ||
|
||
CPPDEFINES= [ | ||
("ARDUINO", 10808), | ||
("VARIANT_H", env.StringifyMacro(variant_h)), | ||
chip_series | ||
], | ||
|
||
# LIBS is handled in _LIBFLAGS below | ||
|
||
LIBSOURCE_DIRS=[ | ||
join(FRAMEWORK_DIR, "libraries") | ||
], | ||
|
||
CPPPATH=[ | ||
join(FRAMEWORK_DIR, "cores", "arduino"), | ||
join(FRAMEWORK_DIR, "cores", "arduino", "avr"), | ||
join(FRAMEWORK_DIR, "cores", "arduino", "ch32"), | ||
join(FRAMEWORK_DIR, "cores", "arduino", "ch32", "lib"), | ||
join(FRAMEWORK_DIR, "system", chip_series, "USER"), | ||
join(FRAMEWORK_DIR, "system", chip_series, "SRC", "Core"), | ||
join(FRAMEWORK_DIR, "system", chip_series, "SRC", "Debug"), | ||
join(FRAMEWORK_DIR, "system", chip_series, "SRC", "Startup"), | ||
join(FRAMEWORK_DIR, "system", chip_series, "SRC", "Peripheral", "inc"), | ||
join(FRAMEWORK_DIR, "system", chip_series, "SRC", "Peripheral", "src"), | ||
], | ||
) | ||
# Use exact same size regexes as the real core | ||
env.Replace( | ||
SIZEPROGREGEX=r"^(?:\.text|\.data|\.rodata)\s+([0-9]+).*", | ||
# excludes stack | ||
SIZEDATAREGEXP=r"^(?:\.data|\.bss|\.noinit)\s+(\d+).*", | ||
) | ||
|
||
# | ||
# Target: Build Core Library | ||
# | ||
|
||
libs = [] | ||
|
||
if "build.variant" in board: | ||
variants_dir = join( | ||
"$PROJECT_DIR", board.get("build.variants_dir")) if board.get( | ||
"build.variants_dir", "") else join(FRAMEWORK_DIR, "variants") | ||
|
||
variant = board.get("build.arduino.openwch.variant", board.get("build.variant")) | ||
env.Append( | ||
CPPPATH=[ | ||
join(variants_dir, variant) | ||
], | ||
LDSCRIPT_PATH=join(FRAMEWORK_DIR, "system", chip_series, "SRC", "Ld", "Link.ld"), | ||
|
||
) | ||
env.BuildSources( | ||
join("$BUILD_DIR", "FrameworkArduinoVariant"), | ||
join(variants_dir, variant) | ||
) | ||
|
||
# Startup files and debug.c require this to be built using BuildSources or with -Wl,-whole-archive | ||
pre_libs = "-lprintf" if not IS_MAC else "" | ||
env.Prepend(_LIBFLAGS="%s -Wl,--whole-archive " % pre_libs) | ||
env.Append(_LIBFLAGS=" -Wl,--no-whole-archive -lc") | ||
|
||
libs.append(env.BuildLibrary( | ||
join("$BUILD_DIR", "FrameworkArduino"), | ||
join(FRAMEWORK_DIR, "cores", "arduino"), | ||
)) | ||
|
||
env.Prepend(LIBS=libs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.