Skip to content
Merged
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
14 changes: 7 additions & 7 deletions .github/workflows/esp32-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
fail-fast: false

matrix:
esp-idf-target: ["esp32", "esp32c3", "esp32p4"]
language: ['cpp']
esp-idf-target: ["esp32", "esp32c3"]
idf-version:
- 'v5.1.6'
- 'v5.2.6'
Expand All @@ -57,10 +56,11 @@ jobs:
exclude:
- esp-idf-target: "esp32c3"
idf-version: 'v5.1.6'
include:
- esp-idf-target: "esp32p4"
idf-version: 'v5.1.6'
idf-version: 'release-v5.4'
- esp-idf-target: "esp32p4"
idf-version: 'v5.2.6'
idf-version: 'v5.5.2'

steps:
- name: Checkout repo
Expand All @@ -70,9 +70,9 @@ jobs:
run: git config --global --add safe.directory /__w/AtomVM/AtomVM

- name: "Initialize CodeQL"
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{matrix.language}}
languages: "cpp"
build-mode: manual
queries: +./code-queries/term-to-non-term-func.ql,./code-queries/non-term-to-term-func.ql

Expand All @@ -94,7 +94,7 @@ jobs:
idf.py size-components

- name: "Perform CodeQL Analysis"
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4

- name: Install dependencies to build host AtomVM and run qemu
run: |
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/esp32-mkimage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
elixir_version: ["1.17"]
rebar3_version: ["3.24.0"]
compiler_pkgs: ["clang-14"]
soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c5", "esp32c6", "esp32c61", "esp32h2", "esp32p4"]
soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c5", "esp32c6", "esp32c61", "esp32h2", "esp32p4", "esp32p4_pre", "esp32p4_c6", "esp32p4_pre_c6"]
flavor: ["", "-elixir"]

env:
Expand Down Expand Up @@ -120,13 +120,30 @@ jobs:
run: |
make

- name: "Set SOC target"
run: echo "SOC_TARGET=${{ startsWith(matrix.soc, 'esp32p4') && 'esp32p4' || matrix.soc }}" >> $GITHUB_ENV

- name: "Use release defaults"
if: startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: ./src/platforms/esp32/
run: |
cp sdkconfig.release-defaults sdkconfig.defaults

- name: "Handle esp32p4 variants sdkconfig"
if: startsWith(matrix.soc, 'esp32p4') && matrix.soc != 'esp32p4'
shell: bash
working-directory: ./src/platforms/esp32/
run: |
cp sdkconfig.defaults.${{ matrix.soc }} sdkconfig.defaults.esp32p4

- name: "Handle esp32p4 c6 variants - add wifi_remote component"
if: matrix.soc == 'esp32p4_c6' || matrix.soc == 'esp32p4_pre_c6'
shell: bash
working-directory: ./src/platforms/esp32/components/avm_builtins
run: |
cp idf_component.yml.esp32p4_wifi_remote idf_component.yml

- name: "Build ${{ matrix.soc }}${{ matrix.flavor }} with idf.py"
shell: bash
working-directory: ./src/platforms/esp32/
Expand All @@ -137,7 +154,7 @@ jobs:
then
mv partitions${{ matrix.flavor }}.csv partitions.csv
fi
idf.py set-target ${{ matrix.soc }}
idf.py set-target ${{ env.SOC_TARGET }}
idf.py reconfigure
idf.py build

Expand All @@ -147,11 +164,14 @@ jobs:
if [ -z "${{ matrix.flavor }}" ]
then
./mkimage.sh
if [ "${{ matrix.soc }}" != "${{ env.SOC_TARGET }}" ]; then
mv atomvm-${{ env.SOC_TARGET }}.img atomvm-${{ matrix.soc }}.img
fi
else
FLAVOR_SUFFIX=$(echo "${{ matrix.flavor }}" | sed 's/-//g')
BOOT_FILE="../../../../build/libs/esp32boot/${FLAVOR_SUFFIX}_esp32boot.avm"
./mkimage.sh --boot "$BOOT_FILE"
mv atomvm-${{ matrix.soc }}.img atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img
mv atomvm-${{ env.SOC_TARGET }}.img atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img
fi
ls -l *.img

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/esp32-simtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ jobs:
idf-version: "v5.2.6"
- esp-idf-target: "esp32c5"
idf-version: "v5.3.4"
# CI now uses chip revision 3 that is currently only available in release-v5.5 branch
# CI now uses chip revision 3 that is currently only available in 5.5.2
include:
- esp-idf-target: "esp32p4"
idf-version: "release-v5.5"
idf-version: "v5.5.2"

steps:
- name: Checkout repo
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Removed `externalterm_to_term_copy` added in [0.6.5] and introduced flags to `externalterm_to_term` to perform copy.
- Release images for ESP32 chips are built with ESP-IDF v5.4
- Release images for ESP32 chips are built with ESP-IDF v5.5
- Only support ESP32P4 on ESP-IDF v5.5.2, v5.4.4 and later.
- ESP32: SPI peripheral defaults to `"spi2"` instead of deprecated `hspi`
- Added `zlib:compress/1`
- Entry point now is `init:boot/1` if it exists. It starts the kernel application and calls `start/0` from the
Expand Down
6 changes: 3 additions & 3 deletions src/platforms/esp32/components/avm_builtins/gpio_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static term nif_gpio_hold_dis(Context *ctx, int argc, term argv[])
return hold_dis(argv[0]);
}

#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 2) && SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 2) && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP)
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
static term nif_gpio_deep_sleep_hold_en(Context *ctx, int argc, term argv[])
{
UNUSED(ctx);
Expand Down Expand Up @@ -785,7 +785,7 @@ static const struct Nif gpio_hold_dis_nif =
.nif_ptr = nif_gpio_hold_dis
};

#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 2) && SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 2) && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP)
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
static const struct Nif gpio_deep_sleep_hold_en_nif = {
.base.type = NIFFunctionType,
.nif_ptr = nif_gpio_deep_sleep_hold_en
Expand Down Expand Up @@ -844,7 +844,7 @@ const struct Nif *gpio_nif_get_nif(const char *nifname)
return &gpio_hold_dis_nif;
}

#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 2) && SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 2) && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP)
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
if (strcmp("gpio:deep_sleep_hold_en/0", nifname) == 0 || strcmp("Elixir.GPIO:deep_sleep_hold_en/0", nifname) == 0) {
TRACE("Resolved platform nif %s ...\n", nifname);
return &gpio_deep_sleep_hold_en_nif;
Expand Down
8 changes: 1 addition & 7 deletions src/platforms/esp32/sdkconfig.defaults.esp32p4
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@ CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y

# esp-wifi-external config for ESP32-C6 esp_wifi_hosted via SDIO
# (default options for esp32-p4-function-ev-board)
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y
CONFIG_LWIP_IPV6=y
CONFIG_WIFI_RMT_EXTRA_IRAM_OPT=n
CONFIG_WIFI_RMT_SLP_IRAM_OPT=n
# no external chip/wifi
16 changes: 16 additions & 0 deletions src/platforms/esp32/sdkconfig.defaults.esp32p4_c6
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: AtomVM Contributors
#
# ESP32-P4 Flash and PSRAM
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y

# esp-wifi-external config for ESP32-C6 esp_wifi_hosted via SDIO
# (default options for esp32-p4-function-ev-board)
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y
CONFIG_LWIP_IPV6=y
CONFIG_WIFI_RMT_EXTRA_IRAM_OPT=n
CONFIG_WIFI_RMT_SLP_IRAM_OPT=n
13 changes: 13 additions & 0 deletions src/platforms/esp32/sdkconfig.defaults.esp32p4_pre
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: AtomVM Contributors
#
# ESP32-P4 Flash and PSRAM
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y

# no esp-wifi-external

# Support esp32p4 pre-release
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
19 changes: 19 additions & 0 deletions src/platforms/esp32/sdkconfig.defaults.esp32p4_pre_c6
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: AtomVM Contributors
#
# ESP32-P4 Flash and PSRAM
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y

# esp-wifi-external config for ESP32-C6 esp_wifi_hosted via SDIO
# (default options for esp32-p4-function-ev-board)
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y
CONFIG_LWIP_IPV6=y
CONFIG_WIFI_RMT_EXTRA_IRAM_OPT=n
CONFIG_WIFI_RMT_SLP_IRAM_OPT=n

# Support esp32p4 pre-release
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
2 changes: 2 additions & 0 deletions src/platforms/esp32/test/main/test_erl_sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ compile_erlang(test_ssl)
compile_erlang(test_time_and_processes)
compile_erlang(test_twdt)
compile_erlang(test_tz)
compile_erlang(test_deep_sleep_hold)

set(erlang_test_beams
test_esp_partition.beam
Expand All @@ -96,6 +97,7 @@ set(erlang_test_beams
test_time_and_processes.beam
test_twdt.beam
test_tz.beam
test_deep_sleep_hold.beam
)

if(NOT AVM_DISABLE_JIT)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%
% This file is part of AtomVM.
%
% Copyright 2026 Peter M <petermm@gmail.com>
%
% 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.
%
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
%

-module(test_deep_sleep_hold).
-export([start/0]).

start() ->
Sysinfo = erlang:system_info(esp32_chip_info),
Model =
if
is_map(Sysinfo) -> maps:get(model, Sysinfo);
true -> undefined
end,
case Model of
% esp32_p4 has no support on earlier revisions, and thus left out here.
M when M =:= esp32; M =:= esp32_s2; M =:= esp32_c3; M =:= esp32_s3; M =:= esp32_c2 ->
io:format("Testing: deep_sleep_hold_en/dis\n"),
ok = gpio:deep_sleep_hold_en(),
ok = gpio:deep_sleep_hold_dis();
_ ->
io:format("Not testing: deep_sleep_hold_en/dis\n"),
ok
end,
ok.
8 changes: 7 additions & 1 deletion src/platforms/esp32/test/main/test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ TEST_CASE("test_tz", "[test_run]")
TEST_ASSERT(ret_value == OK_ATOM);
}

TEST_CASE("test_deep_sleep_hold", "[test_run]")
{
term ret_value = avm_test_case("test_deep_sleep_hold.beam");
TEST_ASSERT(ret_value == OK_ATOM);
}

#ifndef AVM_NO_SMP
TEST_CASE("atomvm_smp_0", "[smp]")
{
Expand Down Expand Up @@ -613,7 +619,7 @@ TEST_CASE("test_wifi_example", "[test_run]")
#endif

// Works C3 on local runs, but fails GH actions
#if (ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_IDF_TARGET_ESP32C3) || (ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_ETH_USE_OPENETH)
#if (ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32P4) || (ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_IDF_TARGET_ESP32P4 && !CONFIG_ETH_USE_OPENETH)
TEST_CASE("test_twdt", "[test_run]")
{
term ret_value = avm_test_case("test_twdt.beam");
Expand Down
1 change: 0 additions & 1 deletion src/platforms/esp32/test/sdkconfig.ci.wokwi
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
CONFIG_LWIP_IPV6=n
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=n
Loading