Skip to content

Commit 809e7ae

Browse files
committed
Add ESP32 system_info/1 memory keys to match new STM32 keys with atomvm_ prefix
Adds new ESP32 system_info/1 heap memory keys atomvm_free_heap_size for esp32_free_heap_size and atomvm_minimum_free_size for esp32_minimum_free_size to match newly added STM32 memory keys. When the old keys are used a warning will be printed to the console to update the keys to the new key names so the old keys can be depricated in some future release cycle. Signed-off-by: Winford <winford@object.stream>
1 parent 7119a70 commit 809e7ae

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5656
- Removed `externalterm_to_term_copy` added in [0.6.5] and introduced flags to `externalterm_to_term` to perform copy.
5757
- Release images for ESP32 chips are built with ESP-IDF v5.4
5858
- ESP32: SPI peripheral defaults to `"spi2"` instead of deprecated `hspi`
59+
- Add transitional ESP32 `system_info/1` memory keys; `atomvm_free_heap_size` for `esp32_free_heap_size` and
60+
`atomvm_minimum_free_size` for `esp32_minimum_free_size` to match newly added STM32 memory keys, with
61+
warning to update applications when the old keys are used.
5962

6063
### Fixed
6164

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

Lines changed: 14 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";
@@ -500,12 +502,24 @@ term sys_get_info(Context *ctx, term key)
500502
{
501503
GlobalContext *glb = ctx->global;
502504
if (key == globalcontext_make_atom(glb, esp_free_heap_size_atom)) {
505+
ESP_LOGW(TAG, "The system_info/1 key 'esp32_free_heap_size' has been updated to the muti-platform key \
506+
'atomvm_free_heap_size'. This key will be deprecated in a future release, please update your application \
507+
to use 'atomvm_free_heap_size'.");
508+
return term_from_int32(esp_get_free_heap_size());
509+
}
510+
if (key == globalcontext_make_atom(glb, atomvm_free_heap_size_atom)) {
503511
return term_from_int32(esp_get_free_heap_size());
504512
}
505513
if (key == globalcontext_make_atom(glb, esp_largest_free_block_atom)) {
506514
return term_from_int32(heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT));
507515
}
508516
if (key == globalcontext_make_atom(glb, esp_get_minimum_free_size_atom)) {
517+
ESP_LOGW(TAG, "The system_info/1 key 'esp32_minimum_free_size' has been updated to the muti-platform key \
518+
'atomvm_minimum_free_size'. This key will be deprecated in a future release, please update your application \
519+
to use 'atomvm_minimum_free_size'.");
520+
return term_from_int32(esp_get_minimum_free_heap_size());
521+
}
522+
if (key == globalcontext_make_atom(glb, atomvm_get_minimum_free_size_atom)) {
509523
return term_from_int32(esp_get_minimum_free_heap_size());
510524
}
511525
if (key == globalcontext_make_atom(glb, esp_chip_info_atom)) {

0 commit comments

Comments
 (0)