Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/build-libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ jobs:
- name: "Rename and write sha256sum"
working-directory: build
run: |
ATOMVMLIB_FILE=atomvmlib-${{ github.ref_name }}.avm
mv libs/atomvmlib.avm "libs/${ATOMVMLIB_FILE}" &&
sha256sum "libs/${ATOMVMLIB_FILE}" > "libs/${ATOMVMLIB_FILE}.sha256"
for variant in atomvmlib atomvmlib-esp32 atomvmlib-rp2 atomvmlib-stm32 atomvmlib-emscripten; do
VARIANT_FILE="${variant}-${{ github.ref_name }}.avm"
mv "libs/${variant}.avm" "libs/${VARIANT_FILE}" &&
sha256sum "libs/${VARIANT_FILE}" > "libs/${VARIANT_FILE}.sha256"
done
HELLO_WORLD_FILE=hello_world-${{ github.ref_name }}.avm
mv examples/erlang/hello_world.avm "examples/erlang/${HELLO_WORLD_FILE}"
sha256sum "examples/erlang/${HELLO_WORLD_FILE}" > "examples/erlang/${HELLO_WORLD_FILE}.sha256"
Expand All @@ -129,5 +131,13 @@ jobs:
files: |
build/libs/atomvmlib-${{ github.ref_name }}.avm
build/libs/atomvmlib-${{ github.ref_name }}.avm.sha256
build/libs/atomvmlib-esp32-${{ github.ref_name }}.avm
build/libs/atomvmlib-esp32-${{ github.ref_name }}.avm.sha256
build/libs/atomvmlib-rp2-${{ github.ref_name }}.avm
build/libs/atomvmlib-rp2-${{ github.ref_name }}.avm.sha256
build/libs/atomvmlib-stm32-${{ github.ref_name }}.avm
build/libs/atomvmlib-stm32-${{ github.ref_name }}.avm.sha256
build/libs/atomvmlib-emscripten-${{ github.ref_name }}.avm
build/libs/atomvmlib-emscripten-${{ github.ref_name }}.avm.sha256
build/examples/erlang/hello_world-${{ github.ref_name }}.avm
build/examples/erlang/hello_world-${{ github.ref_name }}.avm.sha256
19 changes: 7 additions & 12 deletions .github/workflows/pico-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ jobs:
npm install
npx tsx run-tests.ts ../build.nosmp/tests/rp2_tests.uf2 ../build.nosmp/tests/test_erl_sources/rp2_test_modules.uf2

- name: Build atomvmlib.uf2
- name: Build atomvmlib-rp2.uf2
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w' && matrix.platform == '' && matrix.jit == ''
shell: bash
run: |
set -euo pipefail
mkdir build
cd build
cmake ..
make atomvmlib-${{ matrix.board }}.uf2
make atomvmlib-rp2-${{ matrix.board }}.uf2

- name: Rename AtomVM and write sha256sum
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == '' && matrix.jit == ''
Expand All @@ -157,19 +157,14 @@ jobs:
mv src/AtomVM.uf2 "src/${ATOMVM_UF2}"
sha256sum "src/${ATOMVM_UF2}" > "src/${ATOMVM_UF2}.sha256"
popd
pushd build/libs
ATOMVMLIB_FILE=atomvmlib-${{ matrix.board }}-${{ github.ref_name }}.uf2
mv atomvmlib.uf2 "${ATOMVMLIB_FILE}"
sha256sum "${ATOMVMLIB_FILE}" > "${ATOMVMLIB_FILE}.sha256"
popd

- name: Rename atomvmlib and write sha256sum
- name: Rename atomvmlib-rp2 and write sha256sum
if: startsWith(github.ref, 'refs/tags/') && matrix.board != 'pico_w' && matrix.platform == '' && matrix.jit == ''
shell: bash
run: |
pushd build/libs
ATOMVMLIB_FILE=atomvmlib-${{ matrix.board }}-${{ github.ref_name }}.uf2
mv atomvmlib-${{ matrix.board }}.uf2 "${ATOMVMLIB_FILE}"
ATOMVMLIB_FILE=atomvmlib-rp2-${{ matrix.board }}-${{ github.ref_name }}.uf2
mv atomvmlib-rp2-${{ matrix.board }}.uf2 "${ATOMVMLIB_FILE}"
sha256sum "${ATOMVMLIB_FILE}" > "${ATOMVMLIB_FILE}.sha256"
popd

Expand All @@ -182,8 +177,8 @@ jobs:
files: |
src/platforms/rp2/build/src/AtomVM-${{ matrix.board }}-${{ github.ref_name }}.uf2
src/platforms/rp2/build/src/AtomVM-${{ matrix.board }}-${{ github.ref_name }}.uf2.sha256
build/libs/atomvmlib-${{ matrix.board }}-${{ github.ref_name }}.uf2
build/libs/atomvmlib-${{ matrix.board }}-${{ github.ref_name }}.uf2.sha256
build/libs/atomvmlib-rp2-${{ matrix.board }}-${{ github.ref_name }}.uf2
build/libs/atomvmlib-rp2-${{ matrix.board }}-${{ github.ref_name }}.uf2.sha256

- name: Release (PicoW)
uses: softprops/action-gh-release@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests-with-beam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
working-directory: build
run: |
export PATH="${{ matrix.path_prefix }}$PATH"
erl -pa tests/libs/estdlib/ -pa tests/libs/estdlib/beams/ -pa libs/etest/src/beams -pa libs/eavmlib/src/beams -s tests -s init stop -noshell
erl -pa tests/libs/estdlib/ -pa tests/libs/estdlib/beams/ -pa libs/etest/src/beams -pa libs/eavmlib/src/beams -pa libs/avm_network/src/beams -s tests -s init stop -noshell

# Test
- name: "Run tests/libs/etest/test_eunit with OTP eunit"
Expand Down
201 changes: 167 additions & 34 deletions .github/workflows/stm32-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ on:
- 'CMakeModules/**'
- 'src/platforms/stm32/**'
- 'src/libAtomVM/**'
- 'libs/**'
pull_request:
paths:
- '.github/workflows/stm32-build.yaml'
- 'CMakeLists.txt'
- 'CMakeModules/**'
- 'src/platforms/stm32/**'
- 'src/libAtomVM/**'
- 'libs/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }}
Expand All @@ -34,17 +36,84 @@ jobs:
contents: read
security-events: write

steps:
- uses: actions/cache@v4
id: builddeps-cache
with:
path: |
/home/runner/libopencm3
key: ${{ runner.os }}-build-deps
strategy:
fail-fast: false
matrix:
device:
- stm32f407vgt6
- stm32f411ceu6
- stm32f429zit6
- stm32h743vit6
- stm32h743zit6
- stm32u585ait6q
- stm32wb55rg
- stm32h562rgt6
- stm32f746zgt6
- stm32g474ret6
- stm32l476rgt6
- stm32l562qei6
- stm32f207zgt6
- stm32u375rgt6
- stm32g0b1ret6
include:
- device: stm32f407vgt6
max_size: 524288
renode_platform: stm32f4.repl
avm_address: "0x08080000"
# Renode's STM32F4_I2C model has a bug: it never calls
# FinishTransmission() on the I2C slave when a STOP condition
# occurs, causing the BME280 sensor to get stuck in Reading
# state and ignore subsequent writes.
skip_i2c_test: true
- device: stm32f411ceu6
max_size: 393216
renode_platform: stm32f4.repl
avm_address: "0x08060000"
skip_i2c_test: true
- device: stm32f429zit6
max_size: 524288
- device: stm32h743vit6
max_size: 524288
renode_platform: stm32h743.repl
avm_address: "0x08080000"
- device: stm32h743zit6
max_size: 524288
- device: stm32u585ait6q
max_size: 524288
- device: stm32wb55rg
max_size: 524288
- device: stm32h562rgt6
max_size: 524288
- device: stm32f746zgt6
max_size: 524288
renode_platform: stm32f746.repl
avm_address: "0x08080000"
- device: stm32g474ret6
max_size: 393216
- device: stm32l476rgt6
max_size: 524288
- device: stm32l562qei6
max_size: 393216
renode_platform: stm32l562.repl
avm_address: "0x08060000"
# Renode's built-in stm32l552.repl uses STM32F4_I2C (legacy I2C
# register layout) but the L5 HAL uses the newer I2C registers
# (TIMINGR, ISR, etc.), causing a complete register mismatch.
skip_i2c_test: true
- device: stm32f207zgt6
max_size: 524288
- device: stm32u375rgt6
max_size: 524288
- device: stm32g0b1ret6
max_size: 393216
renode_platform: stm32g0b1.repl
avm_address: "0x08060000"

steps:
- uses: erlef/setup-beam@v1
with:
otp-version: "27"
otp-version: "28"
rebar3-version: "3.25.1"
hexpm-mirrors: |
https://builds.hex.pm
https://repo.hex.pm
Expand All @@ -54,42 +123,106 @@ jobs:
run: sudo apt update

- name: "Install deps"
run: sudo apt install -y cmake gperf gcc-arm-none-eabi
run: sudo apt install -y cmake ninja-build gperf python3-pip && pip3 install meson

- name: Checkout and build libopencm3
if: ${{ steps.builddeps-cache.outputs.cache-hit != 'true' }}
working-directory: /home/runner
- name: "Install ARM GNU Toolchain"
run: |
set -euo pipefail
cd /home/runner
test -d libopencm3 && rm -fr libopencm3
git clone https://github.com/libopencm3/libopencm3.git -b v0.8.0
cd libopencm3
make
wget -q https://developer.arm.com/-/media/Files/downloads/gnu/15.2.rel1/binrel/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi.tar.xz
tar xJf arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt
echo "/opt/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi/bin" >> $GITHUB_PATH

- name: Checkout repo
uses: actions/checkout@v4

- name: "Git config safe.directory for codeql"
run: git config --global --add safe.directory /__w/AtomVM/AtomVM

- name: "Initialize CodeQL"
uses: github/codeql-action/init@v4
with:
languages: 'cpp'
build-mode: manual
queries: +./code-queries/term-to-non-term-func.ql,./code-queries/non-term-to-term-func.ql,./code-queries/mismatched-atom-string-length.ql,./code-queries/mismatched-free-type.ql,./code-queries/term-use-after-gc.ql

- name: Build
- name: "Build for ${{ matrix.device }}"
shell: bash
working-directory: ./src/platforms/stm32/
run: |
set -euo pipefail
mkdir build
cd build
# -DAVM_WARNINGS_ARE_ERRORS=ON
cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/arm-toolchain.cmake -DLIBOPENCM3_DIR=/home/runner/libopencm3
make -j
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=cmake/arm-toolchain.cmake -DDEVICE=${{ matrix.device }}
cmake --build .

- name: "Check firmware size for ${{ matrix.device }}"
shell: bash
working-directory: ./src/platforms/stm32/build
run: |
set -euo pipefail
ELF="AtomVM-${{ matrix.device }}.elf"
SIZES=$(arm-none-eabi-size "$ELF" | tail -1)
TEXT=$(echo "$SIZES" | awk '{print $1}')
DATA=$(echo "$SIZES" | awk '{print $2}')
FLASH_USED=$((TEXT + DATA))
MAX=${{ matrix.max_size }}
echo "Firmware flash usage: ${FLASH_USED} bytes ($(( FLASH_USED / 1024 )) KB)"
echo "Flash limit: ${MAX} bytes ($(( MAX / 1024 )) KB)"
if [ "$FLASH_USED" -gt "$MAX" ]; then
echo "::error::Firmware too large: ${FLASH_USED} bytes exceeds ${MAX} byte limit for ${{ matrix.device }}"
exit 1
fi
echo "OK: ${FLASH_USED} / ${MAX} bytes ($(( FLASH_USED * 100 / MAX ))% used)"

- name: "Perform CodeQL Analysis"
uses: github/codeql-action/analyze@v4
- name: Build host AtomVM and test AVMs
if: matrix.renode_platform
run: |
set -euo pipefail
mkdir build-host
cd build-host
cmake .. -G Ninja
cmake --build . -t stm32_boot_test stm32_gpio_test stm32_i2c_test

- name: Install Renode
if: matrix.renode_platform
run: |
set -euo pipefail
mkdir -p renode-portable
wget -qO- https://builds.renode.io/renode-latest.linux-portable.tar.gz \
| tar -xzf - -C renode-portable --strip-components=1
echo "$PWD/renode-portable" >> $GITHUB_PATH
pip install -r renode-portable/tests/requirements.txt

- name: Run Renode boot test
if: matrix.renode_platform
run: |
LOCAL_REPL="src/platforms/stm32/tests/renode/${{ matrix.renode_platform }}"
if [ -f "$LOCAL_REPL" ]; then
PLATFORM="@$PWD/$LOCAL_REPL"
else
PLATFORM="@platforms/cpus/${{ matrix.renode_platform }}"
fi
renode-test src/platforms/stm32/tests/renode/stm32_boot_test.robot \
--variable ELF:@$PWD/src/platforms/stm32/build/AtomVM-${{ matrix.device }}.elf \
--variable AVM:@$PWD/build-host/src/platforms/stm32/tests/test_erl_sources/stm32_boot_test.avm \
--variable AVM_ADDRESS:${{ matrix.avm_address }} \
--variable PLATFORM:$PLATFORM

- name: Run Renode GPIO test
if: matrix.renode_platform
run: |
LOCAL_REPL="src/platforms/stm32/tests/renode/${{ matrix.renode_platform }}"
if [ -f "$LOCAL_REPL" ]; then
PLATFORM="@$PWD/$LOCAL_REPL"
else
PLATFORM="@platforms/cpus/${{ matrix.renode_platform }}"
fi
renode-test src/platforms/stm32/tests/renode/stm32_gpio_test.robot \
--variable ELF:@$PWD/src/platforms/stm32/build/AtomVM-${{ matrix.device }}.elf \
--variable AVM:@$PWD/build-host/src/platforms/stm32/tests/test_erl_sources/stm32_gpio_test.avm \
--variable AVM_ADDRESS:${{ matrix.avm_address }} \
--variable PLATFORM:$PLATFORM

- name: Run Renode I2C test
if: matrix.renode_platform && !matrix.skip_i2c_test
run: |
LOCAL_REPL="src/platforms/stm32/tests/renode/${{ matrix.renode_platform }}"
if [ -f "$LOCAL_REPL" ]; then
PLATFORM="@$PWD/$LOCAL_REPL"
else
PLATFORM="@platforms/cpus/${{ matrix.renode_platform }}"
fi
renode-test src/platforms/stm32/tests/renode/stm32_i2c_test.robot \
--variable ELF:@$PWD/src/platforms/stm32/build/AtomVM-${{ matrix.device }}.elf \
--variable AVM:@$PWD/build-host/src/platforms/stm32/tests/test_erl_sources/stm32_i2c_test.avm \
--variable AVM_ADDRESS:${{ matrix.avm_address }} \
--variable PLATFORM:$PLATFORM
2 changes: 1 addition & 1 deletion .github/workflows/wasm-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
cd build
cmake .. -G Ninja -DAVM_WARNINGS_ARE_ERRORS=ON
# test_eavmlib does not work with wasm due to http + ssl test
ninja AtomVM atomvmlib erlang_test_modules test_etest test_alisp test_estdlib hello_world run_script call_cast html5_events wasm_webserver
ninja AtomVM atomvmlib atomvmlib-emscripten erlang_test_modules test_etest test_alisp test_estdlib hello_world run_script call_cast html5_events wasm_webserver

- name: "Perform CodeQL Analysis"
uses: github/codeql-action/analyze@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added initial support for ESP32C5 and ESP32C61
- Added `Range:size/1`
- Added missing `ledc` functions for esp32 platform
- Added support for 10 new STM32 families by switching to STM32 official SDK

### Changed

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ add_subdirectory(tools/uf2tool)
if (NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
add_custom_target(dialyzer COMMENT "Run dialyzer")
add_subdirectory(libs)
add_subdirectory(src/platforms/stm32/tests/test_erl_sources)
if(NOT AVM_BUILD_RUNTIME_ONLY)
add_subdirectory(examples)
add_subdirectory(doc)
Expand Down
Loading
Loading