Skip to content

Commit

Permalink
Forward port changes from v0.6 release branch
Browse files Browse the repository at this point in the history
Merge fixes and initial ESP32-P4 support from release-0.6 into main branch.
  • Loading branch information
bettio committed Jan 11, 2025
2 parents ddb1c2e + f802020 commit 13b327d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/esp32-mkimage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions libs/estdlib/src/erlang.erl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ process_info(_Pid, _Key) ->
%% <li><b>esp32_free_heap_size</b> the number of (noncontiguous) free bytes in the ESP32 heap (integer)</li>
%% <li><b>esp32_largest_free_block</b> the number of the largest contiguous free bytes in the ESP32 heap (integer)</li>
%% <li><b>esp32_minimum_free_size</b> the smallest number of free bytes in the ESP32 heap since boot (integer)</li>
%% <li><b>esp32_chip_info</b> Details about the model and capabilities of the ESP32 device (map)</li>
%% </ul>
%%
%% Additional keys may be supported on some platforms that are not documented here.
Expand Down
9 changes: 3 additions & 6 deletions src/platforms/esp32/components/avm_builtins/network_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions src/platforms/esp32/components/avm_sys/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
start() ->
case verify_platform(atomvm:platform()) of
ok ->
ok = start_network(),
ok = network:stop(),
start_network(),
loop(0);
Error ->
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/stm32/src/lib/stm_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit 13b327d

Please sign in to comment.