Skip to content

Commit da67e4b

Browse files
committed
Add ESP32 erlang:system_info/1 memory keys to match new STM32 keys with atomvm_ prefix
Adds new ESP32 erlang:system_info/1 heap memory keys `atomvm_free_heap_size` and `atomvm_minimum_free_size` to align with newly added STM32 memory keys. When the old keys are used a deprecation warning will be printed to the console to alert users to update to the new key names before the old keys are removed in the 0.8.x release cycle. Signed-off-by: Winford <winford@object.stream>
1 parent cb52fb0 commit da67e4b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5555
- Removed `externalterm_to_term_copy` added in [0.6.5] and introduced flags to `externalterm_to_term` to perform copy.
5656
- Release images for ESP32 chips are built with ESP-IDF v5.4
5757
- ESP32: SPI peripheral defaults to `"spi2"` instead of deprecated `hspi`
58+
- Deprecated ESP32 `erlang:system_info/1` memory keys `esp32_free_heap_size` and
59+
`esp32_minimum_free_size` in favor of `atomvm_` prefixed keys with warnings to update applications
60+
before the old keys are removed.
5861

5962
### Fixed
6063

UPDATING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ port socket driver, are also represented by a port and some matching code may ne
1313
`is_pid/1` to `is_port/1`.
1414
- Ports and pids can be registered. Function `globalcontext_get_registered_process` result now is
1515
a term that can be a `port()` or a `pid()`.
16+
- ESP32 `erlang:system_info/1` memory keys `esp32_free_heap_size` and `esp32_minimum_free_size` have
17+
been deprecated in favor of `atomvm_` prefixed keys. Applications should be updated to use
18+
`atomvm_free_heap_size` and `atomvm_minimum_free_size` instead.
1619

1720
## v0.6.4 -> v0.6.5
1821

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ static void *select_thread_loop(void *);
7272
static void select_thread_signal(struct ESP32PlatformData *platform);
7373

7474
// clang-format off
75+
static const char *const atomvm_free_heap_size_atom = "\x15" "atomvm_free_heap_size";
7576
static const char *const esp_free_heap_size_atom = "\x14" "esp32_free_heap_size";
7677
static const char *const esp_largest_free_block_atom = "\x18" "esp32_largest_free_block";
78+
static const char *const atomvm_get_minimum_free_size_atom = "\x18" "atomvm_minimum_free_size";
7779
static const char *const esp_get_minimum_free_size_atom = "\x17" "esp32_minimum_free_size";
7880
static const char *const esp_chip_info_atom = "\xF" "esp32_chip_info";
7981
static const char *const esp_idf_version_atom = "\xF" "esp_idf_version";
@@ -499,13 +501,27 @@ static term get_features(Context *ctx, uint32_t features)
499501
term sys_get_info(Context *ctx, term key)
500502
{
501503
GlobalContext *glb = ctx->global;
504+
// TODO: remove this deprecated key for the 0.8.x release cycle
502505
if (key == globalcontext_make_atom(glb, esp_free_heap_size_atom)) {
506+
ESP_LOGW(TAG, "The system_info/1 key 'esp32_free_heap_size' has been deprecated in favor of the \
507+
muti-platform key 'atomvm_free_heap_size'. This key will be removed in a future release, please \
508+
update your application to use 'atomvm_free_heap_size'.");
509+
return term_from_int32(esp_get_free_heap_size());
510+
}
511+
if (key == globalcontext_make_atom(glb, atomvm_free_heap_size_atom)) {
503512
return term_from_int32(esp_get_free_heap_size());
504513
}
505514
if (key == globalcontext_make_atom(glb, esp_largest_free_block_atom)) {
506515
return term_from_int32(heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT));
507516
}
517+
// TODO: remove this deprecated key for the 0.8.x release cycle
508518
if (key == globalcontext_make_atom(glb, esp_get_minimum_free_size_atom)) {
519+
ESP_LOGW(TAG, "The system_info/1 key 'esp32_minimum_free_size' has been deprecated in favor of the \
520+
muti-platform key 'atomvm_minimum_free_size'. This key will be removed in a future release, please \
521+
update your application to use 'atomvm_minimum_free_size'.");
522+
return term_from_int32(esp_get_minimum_free_heap_size());
523+
}
524+
if (key == globalcontext_make_atom(glb, atomvm_get_minimum_free_size_atom)) {
509525
return term_from_int32(esp_get_minimum_free_heap_size());
510526
}
511527
if (key == globalcontext_make_atom(glb, esp_chip_info_atom)) {

0 commit comments

Comments
 (0)