diff --git a/.github/workflows/esp32-mkimage.yaml b/.github/workflows/esp32-mkimage.yaml
index 74e52698d..d3ca273a5 100644
--- a/.github/workflows/esp32-mkimage.yaml
+++ b/.github/workflows/esp32-mkimage.yaml
@@ -45,7 +45,7 @@ jobs:
elixir_version: ["1.17"]
rebar3_version: ["3.24.0"]
compiler_pkgs: ["clang-14"]
- soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c6", "esp32h2"]
+ soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c6", "esp32h2", "esp32p4"]
flavor: ["", "-elixir"]
env:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f520848c6..d589e33e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added the ability to run beams from the CLI for Generic Unix platform (it was already possible with nodejs and emscripten).
- Added support for 'erlang:--/2'.
+- Added preliminary support for ESP32P4 (no networking support yet).
### Fixed
@@ -47,6 +48,7 @@ certain VM instructions are used.
- Fixed a race condition affecting multi-core MCUs where a timeout would not be properly cleared
- Fixed a double free when esp32 uart driver was closed, yielding an assert abort
- Fixed compilation with latest debian gcc-arm-none-eabi
+- Fix `network:stop/0` on ESP32 so the network can be started again
## [0.6.5] - 2024-10-15
diff --git a/libs/estdlib/src/erlang.erl b/libs/estdlib/src/erlang.erl
index 0a00c0418..db829e3e1 100644
--- a/libs/estdlib/src/erlang.erl
+++ b/libs/estdlib/src/erlang.erl
@@ -267,6 +267,7 @@ process_info(_Pid, _Key) ->
%%
esp32_free_heap_size the number of (noncontiguous) free bytes in the ESP32 heap (integer)
%% esp32_largest_free_block the number of the largest contiguous free bytes in the ESP32 heap (integer)
%% esp32_minimum_free_size the smallest number of free bytes in the ESP32 heap since boot (integer)
+%% esp32_chip_info Details about the model and capabilities of the ESP32 device (map)
%%
%%
%% Additional keys may be supported on some platforms that are not documented here.
diff --git a/src/platforms/esp32/components/avm_builtins/network_driver.c b/src/platforms/esp32/components/avm_builtins/network_driver.c
index ff403dde3..234827875 100644
--- a/src/platforms/esp32/components/avm_builtins/network_driver.c
+++ b/src/platforms/esp32/components/avm_builtins/network_driver.c
@@ -814,6 +814,9 @@ static void stop_network(Context *ctx)
{
// Stop unregister event callbacks so they dont trigger during shutdown.
esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler);
+ esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler);
+ esp_event_handler_unregister(IP_EVENT, IP_EVENT_AP_STAIPASSIGNED, &event_handler);
+ esp_event_handler_unregister(sntp_event_base, SNTP_EVENT_BASE_SYNC, &event_handler);
esp_netif_t *sta_wifi_interface = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
esp_netif_t *ap_wifi_interface = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
@@ -833,12 +836,6 @@ static void stop_network(Context *ctx)
// Stop sntp (ignore OK, or not configured error)
esp_sntp_stop();
- // Delete network event loop
- esp_err_t err = esp_event_loop_delete_default();
- if (err != ESP_OK) {
- ESP_LOGE(TAG, "Invalid state error while deleting event loop, continuing network shutdown...");
- }
-
// Destroy existing netif interfaces
if (ap_wifi_interface != NULL) {
esp_netif_destroy_default_wifi(ap_wifi_interface);
diff --git a/src/platforms/esp32/components/avm_sys/sys.c b/src/platforms/esp32/components/avm_sys/sys.c
index d300138c8..8318ae759 100644
--- a/src/platforms/esp32/components/avm_sys/sys.c
+++ b/src/platforms/esp32/components/avm_sys/sys.c
@@ -87,9 +87,12 @@ static const char *const esp32_c2_atom = "\x8" "esp32_c2";
static const char *const esp32_c3_atom = "\x8" "esp32_c3";
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
static const char *const esp32_c6_atom = "\x8" "esp32_c6";
-#endif
static const char *const esp32_h2_atom = "\x8" "esp32_h2";
#endif
+#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
+static const char *const esp32_p4_atom = "\x8" "esp32_p4";
+#endif
+#endif
static const char *const emb_flash_atom = "\x9" "emb_flash";
static const char *const bgn_atom = "\x3" "bgn";
static const char *const ble_atom = "\x3" "ble";
@@ -457,9 +460,13 @@ static term get_model(Context *ctx, esp_chip_model_t model)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
case CHIP_ESP32C6:
return globalcontext_make_atom(ctx->global, esp32_c6_atom);
-#endif
case CHIP_ESP32H2:
return globalcontext_make_atom(ctx->global, esp32_h2_atom);
+#endif
+#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
+ case CHIP_ESP32P4:
+ return globalcontext_make_atom(ctx->global, esp32_p4_atom);
+#endif
default:
return UNDEFINED_ATOM;
}
diff --git a/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl b/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl
index 44500e589..be9a282cc 100644
--- a/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl
+++ b/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl
@@ -25,6 +25,8 @@
start() ->
case verify_platform(atomvm:platform()) of
ok ->
+ ok = start_network(),
+ ok = network:stop(),
start_network(),
loop(0);
Error ->
diff --git a/src/platforms/stm32/src/lib/stm_sys.h b/src/platforms/stm32/src/lib/stm_sys.h
index 75f7bdc49..d40a39690 100644
--- a/src/platforms/stm32/src/lib/stm_sys.h
+++ b/src/platforms/stm32/src/lib/stm_sys.h
@@ -82,5 +82,7 @@ void sys_enable_flash_cache(void);
void *_sbrk_r(struct _reent *, ptrdiff_t);
// This function may be defined to relocate the heap.
void local_heap_setup(uint8_t **start, uint8_t **end);
+void sys_enable_core_periph_clocks();
+bool sys_lock_pin(GlobalContext *glb, uint32_t gpio_bank, uint16_t pin_num);
#endif /* _STM_SYS_H_ */