diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000000000000000000000000000000000..c59c3c548a87f6401c442116d6ed011cbe6de23e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: PlatformIO CI + +on: [push, pull_request] + +jobs: + # Build using native Makefile buildsystem + makefile-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Dependencies + run: sudo apt-get update && sudo apt-get install -y build-essential make libnewlib-dev gcc-riscv64-unknown-elf libusb-1.0-0-dev + - name: Build Blink Example + run: cd examples/blink && make V=1 -j3 blink.elf && riscv64-unknown-elf-size blink.elf && cd ../.. + - name: Build debugprintfdemo Example + run: cd examples/debugprintfdemo && make V=1 -j3 debugprintfdemo.elf && riscv64-unknown-elf-size debugprintfdemo.elf && cd ../.. + # currently not compiling: __get_dscratch0() not defined. + #- name: Build sandbox Example + # run: cd examples/sandbox && make V=1 -j3 sandbox.elf && riscv64-unknown-elf-size sandbox.elf && cd ../.. + - name: Build uartdemo Example + run: cd examples/uartdemo && make V=1 -j3 uartdemo.elf && riscv64-unknown-elf-size uartdemo.elf && cd ../.. + - name: Build ws2812 Example + run: cd examples/ws2812demo && make V=1 -j3 ws2812bdemo.elf && riscv64-unknown-elf-size ws2812bdemo.elf && cd ../.. + # Build using PlatformIO + pio-build: + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Cache PlatformIO + uses: actions/cache@v3 + with: + path: ~/.platformio + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + - name: Run PlatformIO + run: pio run diff --git a/.gitignore b/.gitignore index 0820cf0ac21962dd838441fef36beabdea6c7866..449fc15f746d0797925a51a746d8f7fa0a2b4227 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ +.pio +.vscode *.elf *.hex *.lst *.bin *.map - diff --git a/README.md b/README.md index 2973109bbf293182430a7b7f7e055bea7b8f786a..13f422fdb7cac9995d8fe4eb3f48da26f9b0d79b 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ Currently, it ignores all the respone codes, except when querying the chip. But Anyone who wants to write a good/nice utility should probably look at the code in this folder. +## VSCode + PlatformIO + +This project can also be built, uploaded and debugged with VSCode and the PlatformIO extension. Simply clone and open this project in VSCode and have the PlatformIO extension installed. + +See [here](https://github.com/Community-PIO-CH32V/platform-ch32v) for further details. + ## Quick Reference * Needed for programming/debugging: `SWIO` is on `PD1` * Optional (not needed, can be configured as output if fuse set): `NRST` is on `PD7` diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..a23fc60a0f32ac959d20635c2aa647b51964e02a --- /dev/null +++ b/platformio.ini @@ -0,0 +1,44 @@ +; see https://docs.platformio.org/en/latest/projectconf/index.html +[platformio] +src_dir = . +include_dir = . + +[env] +platform = https://github.com/Community-PIO-CH32V/platform-ch32v.git +; or genericCH32V003A4M6 or whatever, see platform link +board = ch32v003f4p6_evt_r0 +monitor_speed = 115200 +; use a source filter to only build certain folders / files + +; for examples that use ch32v003evt as their base +[evt_base] +board_build.ldscript = ch32v003evt/ch32v003.ld +build_flags = -flto -Ich32v003evt -lgcc +build_src_filter = +<ch32v003evt> + +; for examples that use ch32v003fun as their base +[fun_base] +board_build.ldscript = ch32v003fun/ch32v003fun.ld +build_flags = -flto -Ich32v003fun -I/usr/include/newlib -DTINYVECTOR -lgcc +build_src_filter = +<ch32v003fun> + +[env:blink] +extends = fun_base +build_src_filter = ${fun_base.build_src_filter} +<examples/blink> + +[env:debugprintfdemo] +extends = fun_base +build_src_filter = ${fun_base.build_src_filter} +<examples/debugprintfdemo> + +; sandbox demo does currently not compile (undefined reference to `__get_dscratch0') +;[env:sandbox] +;extends = fun_base +;build_src_filter = ${fun_base.build_src_filter} +<examples/sandbox> + +[env:uartdemo] +extends = fun_base +build_src_filter = ${fun_base.build_src_filter} +<examples/uartdemo> + +[env:ws2812demo] +extends = fun_base +build_src_filter = ${evt_base.build_src_filter} +<examples/ws2812demo>