Skip to content

Commit 13b327d

Browse files
committed
Forward port changes from v0.6 release branch
Merge fixes and initial ESP32-P4 support from release-0.6 into main branch.
2 parents ddb1c2e + f802020 commit 13b327d

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

.github/workflows/esp32-mkimage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
elixir_version: ["1.17"]
4646
rebar3_version: ["3.24.0"]
4747
compiler_pkgs: ["clang-14"]
48-
soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c6", "esp32h2"]
48+
soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c6", "esp32h2", "esp32p4"]
4949
flavor: ["", "-elixir"]
5050

5151
env:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626

2727
- Added the ability to run beams from the CLI for Generic Unix platform (it was already possible with nodejs and emscripten).
2828
- Added support for 'erlang:--/2'.
29+
- Added preliminary support for ESP32P4 (no networking support yet).
2930

3031
### Fixed
3132

@@ -47,6 +48,7 @@ certain VM instructions are used.
4748
- Fixed a race condition affecting multi-core MCUs where a timeout would not be properly cleared
4849
- Fixed a double free when esp32 uart driver was closed, yielding an assert abort
4950
- Fixed compilation with latest debian gcc-arm-none-eabi
51+
- Fix `network:stop/0` on ESP32 so the network can be started again
5052

5153
## [0.6.5] - 2024-10-15
5254

libs/estdlib/src/erlang.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ process_info(_Pid, _Key) ->
267267
%% <li><b>esp32_free_heap_size</b> the number of (noncontiguous) free bytes in the ESP32 heap (integer)</li>
268268
%% <li><b>esp32_largest_free_block</b> the number of the largest contiguous free bytes in the ESP32 heap (integer)</li>
269269
%% <li><b>esp32_minimum_free_size</b> the smallest number of free bytes in the ESP32 heap since boot (integer)</li>
270+
%% <li><b>esp32_chip_info</b> Details about the model and capabilities of the ESP32 device (map)</li>
270271
%% </ul>
271272
%%
272273
%% Additional keys may be supported on some platforms that are not documented here.

src/platforms/esp32/components/avm_builtins/network_driver.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,9 @@ static void stop_network(Context *ctx)
814814
{
815815
// Stop unregister event callbacks so they dont trigger during shutdown.
816816
esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler);
817+
esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler);
818+
esp_event_handler_unregister(IP_EVENT, IP_EVENT_AP_STAIPASSIGNED, &event_handler);
819+
esp_event_handler_unregister(sntp_event_base, SNTP_EVENT_BASE_SYNC, &event_handler);
817820

818821
esp_netif_t *sta_wifi_interface = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
819822
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)
833836
// Stop sntp (ignore OK, or not configured error)
834837
esp_sntp_stop();
835838

836-
// Delete network event loop
837-
esp_err_t err = esp_event_loop_delete_default();
838-
if (err != ESP_OK) {
839-
ESP_LOGE(TAG, "Invalid state error while deleting event loop, continuing network shutdown...");
840-
}
841-
842839
// Destroy existing netif interfaces
843840
if (ap_wifi_interface != NULL) {
844841
esp_netif_destroy_default_wifi(ap_wifi_interface);

src/platforms/esp32/components/avm_sys/sys.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ static const char *const esp32_c2_atom = "\x8" "esp32_c2";
8787
static const char *const esp32_c3_atom = "\x8" "esp32_c3";
8888
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
8989
static const char *const esp32_c6_atom = "\x8" "esp32_c6";
90-
#endif
9190
static const char *const esp32_h2_atom = "\x8" "esp32_h2";
9291
#endif
92+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
93+
static const char *const esp32_p4_atom = "\x8" "esp32_p4";
94+
#endif
95+
#endif
9396
static const char *const emb_flash_atom = "\x9" "emb_flash";
9497
static const char *const bgn_atom = "\x3" "bgn";
9598
static const char *const ble_atom = "\x3" "ble";
@@ -457,9 +460,13 @@ static term get_model(Context *ctx, esp_chip_model_t model)
457460
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
458461
case CHIP_ESP32C6:
459462
return globalcontext_make_atom(ctx->global, esp32_c6_atom);
460-
#endif
461463
case CHIP_ESP32H2:
462464
return globalcontext_make_atom(ctx->global, esp32_h2_atom);
465+
#endif
466+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
467+
case CHIP_ESP32P4:
468+
return globalcontext_make_atom(ctx->global, esp32_p4_atom);
469+
#endif
463470
default:
464471
return UNDEFINED_ATOM;
465472
}

src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
start() ->
2626
case verify_platform(atomvm:platform()) of
2727
ok ->
28+
ok = start_network(),
29+
ok = network:stop(),
2830
start_network(),
2931
loop(0);
3032
Error ->

src/platforms/stm32/src/lib/stm_sys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,7 @@ void sys_enable_flash_cache(void);
8282
void *_sbrk_r(struct _reent *, ptrdiff_t);
8383
// This function may be defined to relocate the heap.
8484
void local_heap_setup(uint8_t **start, uint8_t **end);
85+
void sys_enable_core_periph_clocks();
86+
bool sys_lock_pin(GlobalContext *glb, uint32_t gpio_bank, uint16_t pin_num);
8587

8688
#endif /* _STM_SYS_H_ */

0 commit comments

Comments
 (0)