Skip to content

Commit c758473

Browse files
authored
chore: sync app with latest unreleased sdk + bump sdk version (#2)
### Summary Sync this app with latest (unreleased) SDK. Needed for internal CI to pass. Additionally, the SDK has been bumped to latest (1.15.0). Confirmed only expected differences between this app and the current unreleased sdk: <details> ``` Only in .: .git Only in .: .github diff --color -r /Users/gminnehan/memfault/sdk/embedded/examples/esp32/apps/memfault_demo_app/.gitignore ./.gitignore 0a1 > /build Only in .: .gitmodules diff --color -r /Users/gminnehan/memfault/sdk/embedded/examples/esp32/apps/memfault_demo_app/CMakeLists.txt ./CMakeLists.txt 17a18,21 > # Look for the Memfault SDK in a subdirectory first, when this app is used > # standalone (not from within the Memfault SDK) > get_filename_component(memfault_firmware_sdk_dir third-party/memfault-firmware-sdk ABSOLUTE) > if(NOT EXISTS ${memfault_firmware_sdk_dir}) 19,36d22 < # If we found the Memfault SDK, include it in the build < if(EXISTS ${memfault_firmware_sdk_dir}/ports/esp_idf/memfault.cmake) < include(${memfault_firmware_sdk_dir}/ports/esp_idf/memfault.cmake) < else() < # Otherwise, append this to the main/idf_component.yml file: < # memfault/memfault-firmware-sdk: "*" < # Ideally we'd push an environment variable and use a conditional dependency < # https://docs.espressif.com/projects/idf-component-manager/en/latest/reference/manifest_file.html#conditional-dependencies < # But that requires idf-component-manager v2+, which is not available on all < # esp-idf versions < < # if the string "memfault/memfault-firmware-sdk" isn't in the file, append it: < file(READ ${CMAKE_CURRENT_SOURCE_DIR}/main/idf_component.yml idf_component_yml) < if(NOT idf_component_yml MATCHES "memfault/memfault-firmware-sdk") < file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/main/idf_component.yml < " memfault/memfault-firmware-sdk: \"*\"\n" < ) < endif() 37a24 > include(${memfault_firmware_sdk_dir}/ports/esp_idf/memfault.cmake) Only in .: sdkconfig Only in .: third-party ``` </details> ### Test Plan - CI - Flashed an esp32c3 devkitm
2 parents 5dba719 + 4572252 commit c758473

29 files changed

+76
-647
lines changed

CMakeLists.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,3 @@ if (INVALID_PARTITION_TABLE)
6363
If this error occurs repeatedly run `idf.py fullclean && rm sdkconfig`"
6464
)
6565
endif()
66-
67-
if (CONFIG_MEMFAULT)
68-
# Add the Memfault Build ID so each build can have a unique version.
69-
set(IDF_PROJECT_EXECUTABLE ${PROJECT_NAME}.elf)
70-
add_custom_command(TARGET ${IDF_PROJECT_EXECUTABLE}
71-
POST_BUILD
72-
# Compute and insert the build id
73-
COMMAND python ${memfault_firmware_sdk_dir}/scripts/fw_build_id.py ${IDF_PROJECT_EXECUTABLE}
74-
# Save a copy of the ELF that includes the 'log_fmt' section
75-
BYPRODUCTS ${IDF_PROJECT_EXECUTABLE}.memfault_log_fmt
76-
# Compress debug sections; this reduces the elf file size from ~10MB -> ~4.8MB
77-
COMMAND ${CMAKE_OBJCOPY} --compress-debug-sections ${IDF_PROJECT_EXECUTABLE}
78-
COMMAND ${CMAKE_COMMAND} -E copy ${IDF_PROJECT_EXECUTABLE} ${IDF_PROJECT_EXECUTABLE}.memfault_log_fmt
79-
COMMAND ${CMAKE_COMMAND} -E echo "*** NOTE: the symbol file to upload to app.memfault.com is ${IDF_PROJECT_EXECUTABLE}.memfault_log_fmt ***"
80-
# Remove the 'log_fmt' compact log section, which confuses elf2image
81-
COMMAND ${CMAKE_OBJCOPY} --remove-section log_fmt ${IDF_PROJECT_EXECUTABLE}
82-
)
83-
endif() # NOT CONFIG_MEMFAULT_DISABLE

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can either follow the steps outlined here or use your own MQTT setup.
1212

1313
### Broker Setup
1414

15-
1. Install a local installtion of Cedalo by following the [installation guide](https://docs.cedalo.com/management-center/installation/)
15+
1. Install a local installation of Cedalo by following the [installation guide](https://docs.cedalo.com/management-center/installation/)
1616
2. Login to Cedalo at <http://localhost:8088>
1717
3. Create a new client login for the device
1818
- Ensure device client has the "client" role to allow publishing data
@@ -21,7 +21,8 @@ You can either follow the steps outlined here or use your own MQTT setup.
2121

2222
### Service Setup
2323

24-
1. Modify the script found in Docs->Best Practices->MQTT with Memfault with the the following:
24+
1. Modify the script found in [Docs->Best Practices->MQTT](https://docs.memfault.com/docs/best-practices/mqtt-with-memfault#service-examples)
25+
with Memfault with the the following:
2526
1. The service client login information previously created
2627
2. Connection info for your local broker
2728
3. Map of Memfault projects to project keys

main/Kconfig.projbuild

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ config MEMFAULT_APP_WIFI_AUTOJOIN
2424
help
2525
Automatically join if credentials are configured.
2626

27+
config MEMFAULT_APP_HEAP_TRACING
28+
bool "Print allocation tracing information at runtime"
29+
default n
30+
depends on HEAP_USE_HOOKS
31+
2732
choice APP_MEMFAULT_TRANSPORT
2833
prompt "Protocol to send chunks over"
2934
default APP_MEMFAULT_TRANSPORT_HTTP

main/app_memfault_transport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55

66
#pragma once
77

main/app_memfault_transport_http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55

66
#include "app_memfault_transport.h"
77
#include "memfault/esp_port/http_client.h"

main/app_memfault_transport_mqtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55

66
#include <stddef.h>
77
#include <stdint.h>

main/button.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55
//!
66
//! Button setup and handling
77

@@ -11,15 +11,21 @@
1111
#include "esp_attr.h"
1212
#include "esp_log.h"
1313
#include "esp_system.h"
14+
#include "freertos/FreeRTOS.h"
1415

1516
static const char *TAG = "button";
17+
static portMUX_TYPE s_button_spinlock = portMUX_INITIALIZER_UNLOCKED;
1618

1719
static void IRAM_ATTR prv_gpio_isr_handler(void *arg) {
18-
uint32_t gpio_num = (uint32_t)arg;
20+
// Make volatile to prevent compiler optimization in while loop
21+
volatile uint32_t gpio_num = (uint32_t)arg;
1922

20-
// dereference a null point to trigger a crash
21-
volatile uint32_t *ptr = NULL;
22-
*ptr = gpio_num;
23+
// Grab a spinlock to ensure this ISR does not get interrupted
24+
portENTER_CRITICAL_ISR(&s_button_spinlock);
25+
// Hang the interrupt to trigger a fault from the interrupt watchdog
26+
while (true) {
27+
gpio_num++;
28+
}
2329
}
2430

2531
// The flex glitch filter is only available on 5.1. Skip it for earlier SDKs.

main/button.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55
//!
66
//! Button setup and handling
77

main/cmd_app.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55
//! Miscellaneous commands specific to this example app
66
//!
77

@@ -31,17 +31,16 @@ static int test_task_watchdog(int argc, char **argv) {
3131
}
3232
#endif
3333

34-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
35-
#if defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) || \
36-
!defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
37-
#define OVERFLOW_TASK_STACK_SIZE 4096
34+
#if defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) || \
35+
!defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
36+
#define OVERFLOW_TASK_STACK_SIZE 4096
3837

3938
static StaticTask_t s_overflow_task_tcb;
4039
static StackType_t s_overflow_task_stack[OVERFLOW_TASK_STACK_SIZE];
4140
static TaskHandle_t s_overflow_task_handle = NULL;
4241

4342
static void prv_trigger_stack_overflow(void) {
44-
#if defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL)
43+
#if defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL)
4544
// General idea is to allocate a bunch of memory on the stack but not too much
4645
// to hose FreeRTOS Then yield and the FreeRTOS stack overflow check (on task
4746
// switch) should kick in due to stack pointer limits
@@ -60,11 +59,11 @@ static void prv_trigger_stack_overflow(void) {
6059
stack_array[i] = i;
6160
taskYIELD();
6261
}
63-
#else
62+
#else
6463
// The canary checks only look at the last bytes (lowest addresses) of the
6564
// stack Execute a write over the last 32 bytes to trigger the watchpoint
6665
memset(s_overflow_task_stack, 0, 32);
67-
#endif // defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTR)
66+
#endif // defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTR)
6867
}
6968

7069
/**
@@ -107,9 +106,8 @@ static void prv_init_stack_overflow_test(void) {
107106
};
108107
ESP_ERROR_CHECK(esp_console_cmd_register(&test_stack_overflow_cmd));
109108
}
110-
#endif // defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) ||
111-
// !defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
112-
#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
109+
#endif // defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) ||
110+
// !defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
113111

114112
#if defined(CONFIG_HEAP_TASK_TRACKING)
115113
// Print out per-task heap allocations. This is lifted from the example here:
@@ -173,12 +171,9 @@ void register_app(void) {
173171
ESP_ERROR_CHECK(esp_console_cmd_register(&heap_task_stats_cmd));
174172
#endif
175173

176-
// Only support the stack overflow test on esp-idf >= 4.3.0
177-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
178-
#if defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) || \
179-
!defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
174+
#if defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) || \
175+
!defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
180176
prv_init_stack_overflow_test();
181-
#endif // defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) ||
182-
// !defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
183-
#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
177+
#endif // defined(CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK) ||
178+
// !defined(CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE)
184179
}

main/cmd_wifi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! @file
22
//!
33
//! Copyright (c) Memfault, Inc.
4-
//! See License.txt for details
4+
//! See LICENSE for details
55
//!
66
//! Wifi-specific commands for the ESP32 console.
77

0 commit comments

Comments
 (0)