pine64 / ArduinoCore-bouffalo

BL602 Arduino Core for Arduino IDE
GNU Lesser General Public License v2.1
68 stars 13 forks source link

Add initial PlatformIO support #6

Closed maxgerhardt closed 2 years ago

maxgerhardt commented 2 years ago

This adds a PlatformIO builder script (platformio-build.py) and a package.json to the project, which enables PlatformIO to compile the project.

PlatformIO is a SCons-based build system tool and VSCode extension that makes developing embedded fimwares much easier since it integrates nicely with a lot of IDEs, automates all toolchain and SDK download and unifies configuration files. Practically all Arduino cores have a PlatformIO integration, e.g., Arduino/esp8266, Arduino-ESP32, STM32Duino, etc.

These changes go along with custom extensions of the SiFive PlatformIO integration where the board definition for the pinecone board lives.

A full example project is at https://github.com/maxgerhardt/pio-bl602-boufallo-arduino-test.

Note: I do not yet have a BL602 based board for testing (shipping is in progress), but the current state is that it already builds the firmware like the Arduino IDE would and attempts uploading via the same serial flasher tool used in this core. So it should all work. I'm opening this PR preliminary so that I hopefully can just confirm it to be working on hardware after it arrives (or / and someone else tests it along with me) and then it can be merged. Thus this is marked as a darft PR.

People have been requesting PlatformIO support for a BL602 Arduino core in e.g. in https://github.com/esphome/feature-requests/issues/1049#issuecomment-893240169 and https://github.com/platformio/platformio-core/issues/4046.

(The URL in the package.json should be changed after merge)

gamelaster commented 2 years ago

Hello and thank you for your work!

It looks amazing. My timeframe for BL602 is quite limited, but I will try to find some time to test this. If in meantime you receive your BL602 and confirm it works just fine, please let me know, so we can merge this.

Thanks :)

maxgerhardt commented 2 years ago

Haha, it works! Thanks to a fix PR for the uploader someone did in the meantime (https://github.com/maxgerhardt/pio-bl60x-flash/pull/1), I was just able to compile & upload & open serial monitor for my "DT-BL-10" BL602-based dev board and see

RAM:   [===       ]  27.2% (used 89224 bytes from 327680 bytes)
Flash: [          ]   3.3% (used 42786 bytes from 1310720 bytes)
Configuring upload protocol...
AVAILABLE: bl60x-flash, ftdi, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = bl60x-flash
Looking for upload port...
Auto-detected: COM15
Uploading .pio\build\pinecone_bl602\firmware.bin
Loading helper binary
21872 bytes @ 0x22010000

  0%|          | 0.00/21.9k [00:00<?, ?byte/s]
 37%|███▋      | 8.16k/21.9k [00:00<00:00, 48.5kbyte/s]
 75%|███████▍  | 16.3k/21.9k [00:00<00:00, 48.2kbyte/s]
100%|██████████| 21.9k/21.9k [00:00<00:00, 48.3kbyte/s]
100%|██████████| 21.9k/21.9k [00:00<00:00, 48.2kbyte/s]

Erased 47100 bytes @ 0x10000

Programming 47100 bytes @ 0x10000
  0%|          | 0.00/47.1k [00:00<?, ?byte/s]
 30%|███       | 14.3k/47.1k [00:00<00:00, 135kbyte/s]
 61%|██████    | 28.7k/47.1k [00:00<00:00, 135kbyte/s]
 91%|█████████▏| 43.0k/47.1k [00:00<00:00, 135kbyte/s]
100%|██████████| 47.1k/47.1k [00:00<00:00, 135kbyte/s]
Verified by XIP SHA256 hash
=============================================================================== [SUCCESS] Took 11.55 seconds ===============================================================================
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on COM15  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Hello from BL602!
Hello from BL602!

So, this builder script is good to merge :)