From 98df86243e140f948f0e1fb719667474b955bbb4 Mon Sep 17 00:00:00 2001 From: AlbertoPimpo Date: Tue, 17 Mar 2020 10:51:38 +0000 Subject: [PATCH] Add initial support for briki core (#294) --- boards/briki_abc_esp32.json | 39 ++++++++++++++++++++++++ boards/briki_mbc-wb_esp32.json | 39 ++++++++++++++++++++++++ builder/frameworks/arduino.py | 9 +++++- builder/main.py | 28 +++++++++++++++++ examples/arduino-blink/platformio.ini | 10 ++++++ examples/arduino-wifiscan/platformio.ini | 10 ++++++ platform.json | 12 +++++++- platform.py | 7 +++++ 8 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 boards/briki_abc_esp32.json create mode 100644 boards/briki_mbc-wb_esp32.json diff --git a/boards/briki_abc_esp32.json b/boards/briki_abc_esp32.json new file mode 100644 index 0000000..8cb8f62 --- /dev/null +++ b/boards/briki_abc_esp32.json @@ -0,0 +1,39 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "mbcwb", + "extra_flags": "-DBRIKI_MBC_WB_ESP -DBRIKI_ABC -w", + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "briki_mbcwb_esp32", + "partitions": "8MB_ffat.csv" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino" + ], + "name": "Briki ABC (MBC-WB) - ESP32", + "upload": { + "protocol": "mbctool", + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 3407872, + "require_upload_port": true, + "speed": 1500000 + + }, + "url": "https://briki.org", + "vendor": "meteca" +} diff --git a/boards/briki_mbc-wb_esp32.json b/boards/briki_mbc-wb_esp32.json new file mode 100644 index 0000000..75d9cfa --- /dev/null +++ b/boards/briki_mbc-wb_esp32.json @@ -0,0 +1,39 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "mbcwb", + "extra_flags": "-DBRIKI_MBC_WB_ESP -DBRIKI_MBC_WB -w", + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "briki_mbcwb_esp32", + "partitions": "8MB_ffat.csv" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino" + ], + "name": "Briki MBC-WB - ESP32", + "upload": { + "protocol": "mbctool", + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 3407872, + "require_upload_port": true, + "speed": 1500000 + + }, + "url": "https://briki.org", + "vendor": "meteca" +} diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 0f58a9d..161ad70 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -27,10 +27,17 @@ from os.path import join from SCons.Script import DefaultEnvironment, SConscript env = DefaultEnvironment() +board = env.BoardConfig() +build_core = board.get("build.core", "").lower() SConscript("_embed_files.py", exports="env") -if "espidf" not in env.subst("$PIOFRAMEWORK"): +if build_core == "mbcwb": + SConscript( + join(DefaultEnvironment().PioPlatform().get_package_dir( + "framework-arduino-mbcwb"), "tools", "platformio-esp-build.py")) + +elif "espidf" not in env.subst("$PIOFRAMEWORK"): SConscript( join(DefaultEnvironment().PioPlatform().get_package_dir( "framework-arduinoespressif32"), "tools", "platformio-build.py")) diff --git a/builder/main.py b/builder/main.py index 0dae46a..c1ffa13 100644 --- a/builder/main.py +++ b/builder/main.py @@ -341,6 +341,34 @@ elif upload_protocol == "esptool": env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") ] + +elif upload_protocol == "mbctool": + env.Replace( + UPLOADER=join( + platform.get_package_dir("tool-mbctool") or "", "bin", "mbctool"), + UPLOADERFLAGS=[ + "--device", "esp", + "--speed", "1500000", + "--port", "$UPLOAD_PORT", + "--upload", + "0x1000", join( + platform.get_package_dir("framework-arduino-mbcwb"), + "tools", "sdk", "bin", "bootloader_qio_80m.bin"), + "0x8000", join("$BUILD_DIR", "partitions.bin"), + "0xe000", join( + platform.get_package_dir("framework-arduino-mbcwb"), + "tools", "partitions", "boot_app0.bin"), + "0x10000", join("$BUILD_DIR", "${PROGNAME}.bin"), + ], + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' + ) + upload_actions = [ + env.VerboseAction(env.AutodetectUploadPort, + "Looking for upload port..."), + env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") + ] + + elif upload_protocol in debug_tools: openocd_args = ["-d%d" % (2 if int(ARGUMENTS.get("PIOVERBOSE", 0)) else 1)] openocd_args.extend( diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index ad383a4..4d012a2 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -7,6 +7,16 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/page/projectconf.html +[env:briki_abc_esp32] +platform = espressif32 +board = briki_abc_esp32 +framework = arduino + +[env:briki_mbc-wb_esp32] +platform = espressif32 +board = briki_mbc-wb_esp32 +framework = arduino + [env:esp wrover kit] platform = espressif32 framework = arduino diff --git a/examples/arduino-wifiscan/platformio.ini b/examples/arduino-wifiscan/platformio.ini index 32cbdd8..07a2d56 100644 --- a/examples/arduino-wifiscan/platformio.ini +++ b/examples/arduino-wifiscan/platformio.ini @@ -7,6 +7,16 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/page/projectconf.html +[env:briki_abc_esp32] +platform = espressif32 +board = briki_abc_esp32 +framework = arduino + +[env:briki_mbc-wb_esp32] +platform = espressif32 +board = briki_mbc-wb_esp32 +framework = arduino + [env:esp32dev] platform = espressif32 framework = arduino diff --git a/platform.json b/platform.json index 44062d7..c035866 100644 --- a/platform.json +++ b/platform.json @@ -17,7 +17,8 @@ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http://dl.platformio.org/packages/manifest.json", "https://raw.githubusercontent.com/eerimoq/simba/master/make/platformio/manifest.json", - "https://raw.githubusercontent.com/eerimoq/pumbaa/master/make/platformio/manifest.json" + "https://raw.githubusercontent.com/eerimoq/pumbaa/master/make/platformio/manifest.json", + "https://briki.org/download/resources/manifest.json" ], "frameworks": { "arduino": { @@ -52,6 +53,11 @@ "optional": true, "version": "~3.10004.191002" }, + "framework-arduino-mbcwb": { + "type": "framework", + "optional": true, + "version": ">=2.1.1" + }, "framework-espidf": { "type": "framework", "optional": true, @@ -70,6 +76,10 @@ "tool-esptoolpy": { "type": "uploader", "version": "~1.20600.0" + }, + "tool-mbctool": { + "type": "uploader", + "version": ">=2.0.0" }, "tool-openocd-esp32": { "type": "debugger", diff --git a/platform.py b/platform.py index 36a7109..e07764c 100644 --- a/platform.py +++ b/platform.py @@ -35,6 +35,13 @@ class Espressif32Platform(PlatformBase): self.packages[p]['optional'] = False self.packages['toolchain-xtensa32']['version'] = "~2.80200.0" + build_core = variables.get( + "board_build.core", self.board_config(variables.get("board")).get( + "build.core", "arduino")).lower() + if build_core == 'mbcwb': + self.packages["framework-arduinoespressif32"]["optional"] = True + self.packages["framework-arduino-mbcwb"]["optional"] = False + return PlatformBase.configure_default_packages(self, variables, targets)