-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memfault Firmware SDK 0.31.0 (Build 451641)
- Loading branch information
Memfault Inc
committed
Jun 6, 2022
1 parent
bdacc2d
commit cdb5fdb
Showing
22 changed files
with
741 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
cmake | ||
examples | ||
makefile | ||
ports/atmel | ||
ports/dialog | ||
ports/emlib | ||
ports/esp8266_sdk | ||
ports/esp_idf | ||
ports/mynewt | ||
ports/nrf5_sdk | ||
ports/nxp | ||
ports/particle | ||
ports/qp | ||
ports/s32sdk | ||
ports/stm32cube | ||
ports/templates | ||
ports/zephyr | ||
scripts | ||
tests | ||
$(SEARCH_memfault-firmware-sdk)/components/include/memfault/core | ||
$(SEARCH_memfault-firmware-sdk)/components/include/memfault/demo | ||
$(SEARCH_memfault-firmware-sdk)/components/include/memfault/http | ||
$(SEARCH_memfault-firmware-sdk)/components/include/memfault/metrics | ||
$(SEARCH_memfault-firmware-sdk)/components/include/memfault/panics | ||
$(SEARCH_memfault-firmware-sdk)/components/include/memfault/util | ||
$(SEARCH_memfault-firmware-sdk)/ports/include/memfault/ports/ble | ||
$(SEARCH_memfault-firmware-sdk)/ports/include/memfault/ports/stm32cube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
BUILD ID: 447316 | ||
GIT COMMIT: 77b7799c5 | ||
BUILD ID: 451641 | ||
GIT COMMIT: 963211879 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! @file | ||
//! | ||
//! Copyright (c) Memfault, Inc. | ||
//! See License.txt for details | ||
//! | ||
//! @brief | ||
//! Implements conveninece API for posting a single chunk of Memfault data | ||
|
||
#include "memfault/http/http_client.h" | ||
|
||
#include "memfault/core/debug_log.h" | ||
#include "memfault/core/errors.h" | ||
#include "memfault/core/data_packetizer.h" | ||
|
||
int memfault_http_client_post_chunk(void) { | ||
// A pre-flight check before we attempt to setup an HTTP client | ||
// If there's no data to send, just early return | ||
bool more_data = memfault_packetizer_data_available(); | ||
if (!more_data) { | ||
// no new data to post | ||
return kMfltPostDataStatus_NoDataFound; | ||
} | ||
|
||
sMfltHttpClient *http_client = memfault_http_client_create(); | ||
if (!http_client) { | ||
MEMFAULT_LOG_ERROR("Failed to create HTTP client"); | ||
return MemfaultInternalReturnCode_Error; | ||
} | ||
|
||
const int rv = memfault_http_client_post_data(http_client); | ||
if ((eMfltPostDataStatus)rv != kMfltPostDataStatus_Success) { | ||
MEMFAULT_LOG_ERROR("Failed to post chunk: rv=%d", rv); | ||
} | ||
const uint32_t timeout_ms = 30 * 1000; | ||
memfault_http_client_wait_until_requests_completed(http_client, timeout_ms); | ||
memfault_http_client_destroy(http_client); | ||
return rv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
NAME := MemfaultHttp | ||
|
||
$(NAME)_SOURCES := src/memfault_http_client.c \ | ||
$(NAME)_SOURCES := \ | ||
src/memfault_http_client.c \ | ||
src/memfault_http_client_post_chunk.c | ||
|
||
|
||
$(NAME)_COMPONENTS := libraries/memfault/core \ | ||
libraries/memfault/panics \ | ||
protocols/HTTP_client \ | ||
|
||
$(NAME)_COMPONENTS := \ | ||
libraries/memfault/core \ | ||
libraries/memfault/panics \ | ||
protocols/HTTP_client | ||
|
||
$(NAME)_INCLUDES += include | ||
|
||
GLOBAL_INCLUDES += include | ||
|
||
VALID_OSNS_COMBOS := ThreadX-NetX_Duo FreeRTOS-LwIP | ||
VALID_PLATFORMS := BCM943362WCD4 \ | ||
BCM943362WCD6 \ | ||
BCM943362WCD8 \ | ||
BCM943364WCD1 \ | ||
CYW94343WWCD1_EVB \ | ||
BCM943438WCD1 \ | ||
BCM94343WWCD2 \ | ||
CY8CKIT_062 \ | ||
NEB1DX* \ | ||
CYW9MCU7X9N364 \ | ||
CYW943907AEVAL1F \ | ||
CYW954907AEVAL1F \ | ||
CYW9WCD2REFAD2* \ | ||
CYW9WCD760PINSDAD2 \ | ||
CYW943455EVB* \ | ||
CYW943012EVB* | ||
VALID_PLATFORMS := \ | ||
BCM943362WCD4 \ | ||
BCM943362WCD6 \ | ||
BCM943362WCD8 \ | ||
BCM943364WCD1 \ | ||
CYW94343WWCD1_EVB \ | ||
BCM943438WCD1 \ | ||
BCM94343WWCD2 \ | ||
CY8CKIT_062 \ | ||
NEB1DX* \ | ||
CYW9MCU7X9N364 \ | ||
CYW943907AEVAL1F \ | ||
CYW954907AEVAL1F \ | ||
CYW9WCD2REFAD2* \ | ||
CYW9WCD760PINSDAD2 \ | ||
CYW943455EVB* \ | ||
CYW943012EVB* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Memfault Library for ModusToolbox:tm: | ||
|
||
To get started with the Memfault ModusToolbox:tm: port see the integration guide | ||
available [here](https://mflt.io/mtb-integration-guide). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Custom section to be included in the linker command file to support recovery of all FreeRTOS tasks when | ||
a coredump is collected. | ||
*/ | ||
|
||
SECTIONS | ||
{ | ||
.mflt_bss (NOLOAD) : | ||
{ | ||
__memfault_capture_bss_start = .; | ||
*tasks.o(.bss COMMON .bss*) | ||
*timers*.o(.bss COMMON .bss*) | ||
__memfault_capture_bss_end = .; | ||
} | ||
} | ||
INSERT BEFORE .bss; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! @file | ||
//! | ||
//! Copyright (c) Memfault, Inc. | ||
//! See License.txt for details | ||
//! | ||
//! @brief | ||
//! Implementation of core dependencies and setup for PSOC6 based products that are using the | ||
//! ModusToolbox SDK | ||
|
||
#include "memfault/components.h" | ||
#include "memfault/ports/reboot_reason.h" | ||
#include "memfault/ports/freertos.h" | ||
|
||
#ifndef MEMFAULT_EVENT_STORAGE_RAM_SIZE | ||
#define MEMFAULT_EVENT_STORAGE_RAM_SIZE 1024 | ||
#endif | ||
|
||
MEMFAULT_WEAK | ||
void memfault_platform_reboot(void) { | ||
NVIC_SystemReset(); | ||
while (1) { } // unreachable | ||
} | ||
|
||
size_t memfault_platform_sanitize_address_range(void *start_addr, size_t desired_size) { | ||
static const struct { | ||
uint32_t start_addr; | ||
size_t length; | ||
} s_mcu_mem_regions[] = { | ||
{.start_addr = CY_SRAM_BASE, .length = CY_SRAM_SIZE}, | ||
}; | ||
|
||
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(s_mcu_mem_regions); i++) { | ||
const uint32_t lower_addr = s_mcu_mem_regions[i].start_addr; | ||
const uint32_t upper_addr = lower_addr + s_mcu_mem_regions[i].length; | ||
if ((uint32_t)start_addr >= lower_addr && ((uint32_t)start_addr < upper_addr)) { | ||
return MEMFAULT_MIN(desired_size, upper_addr - (uint32_t)start_addr); | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int memfault_platform_boot(void) { | ||
memfault_build_info_dump(); | ||
memfault_device_info_dump(); | ||
|
||
memfault_freertos_port_boot(); | ||
memfault_platform_reboot_tracking_boot(); | ||
|
||
static uint8_t s_event_storage[MEMFAULT_EVENT_STORAGE_RAM_SIZE]; | ||
const sMemfaultEventStorageImpl *evt_storage = | ||
memfault_events_storage_boot(s_event_storage, sizeof(s_event_storage)); | ||
memfault_trace_event_boot(evt_storage); | ||
|
||
memfault_reboot_tracking_collect_reset_info(evt_storage); | ||
|
||
sMemfaultMetricBootInfo boot_info = { | ||
.unexpected_reboot_count = memfault_reboot_tracking_get_crash_count(), | ||
}; | ||
memfault_metrics_boot(evt_storage, &boot_info); | ||
|
||
MEMFAULT_LOG_INFO("Memfault Initialized!"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
//! @file | ||
//! | ||
//! Copyright (c) Memfault, Inc. | ||
//! See License.txt for details | ||
//! | ||
//! @brief | ||
//! A coredump port which scoops up all the FreeRTOS state in the system at the time of crash | ||
//! To override and provide a custom port, simply add this file to the .cyignore for your project | ||
//! so it is not included in the build: | ||
//! (i.e $(SEARCH_memfault-firmware-sdk)/ports/cypress/psoc6/memfault_platform_coredump_regions.c) | ||
|
||
#include <stddef.h> | ||
#include <string.h> | ||
|
||
#include "memfault/components.h" | ||
#include "memfault/panics/arch/arm/cortex_m.h" | ||
#include "memfault/ports/freertos_coredump.h" | ||
|
||
#include "cy_syslib.h" | ||
#include "cy_device_headers.h" | ||
|
||
#define MEMFAULT_COREDUMP_MAX_TASK_REGIONS ((MEMFAULT_PLATFORM_MAX_TRACKED_TASKS) * 2) | ||
|
||
static sMfltCoredumpRegion s_coredump_regions[ | ||
MEMFAULT_COREDUMP_MAX_TASK_REGIONS | ||
+ 2 /* active stack(s) */ | ||
+ 1 /* _kernel variable */ | ||
+ 1 /* __memfault_capture_start */ | ||
]; | ||
|
||
//! Note: If you get a linker error because these symbols are missing, your forgot to add the Memfault ld file | ||
//! to you LDFLAGS: | ||
//! LDFLAGS += -T$(SEARCH_memfault-firmware-sdk)/ports/cypress/psoc6/memfault_bss.ld | ||
extern uint32_t __memfault_capture_bss_end; | ||
extern uint32_t __memfault_capture_bss_start; | ||
|
||
//! Note: This function is called early on boot before the C runtime is loaded | ||
//! We hook into this function in order to scrub the | ||
void Cy_OnResetUser(void) { | ||
const size_t memfault_region_size = (uint32_t)&__memfault_capture_bss_end - | ||
(uint32_t)&__memfault_capture_bss_start; | ||
memset((uint32_t*)&__memfault_capture_bss_start, 0x0, memfault_region_size); | ||
} | ||
|
||
const sMfltCoredumpRegion *memfault_platform_coredump_get_regions( | ||
const sCoredumpCrashInfo *crash_info, size_t *num_regions) { | ||
int region_idx = 0; | ||
const size_t active_stack_size_to_collect = 512; | ||
|
||
// first, capture the active stack (and ISR if applicable) | ||
const bool msp_was_active = (crash_info->exception_reg_state->exc_return & (1 << 2)) == 0; | ||
|
||
size_t stack_size_to_collect = memfault_platform_sanitize_address_range( | ||
crash_info->stack_address, MEMFAULT_PLATFORM_ACTIVE_STACK_SIZE_TO_COLLECT); | ||
|
||
s_coredump_regions[region_idx] = MEMFAULT_COREDUMP_MEMORY_REGION_INIT( | ||
crash_info->stack_address, stack_size_to_collect); | ||
region_idx++; | ||
|
||
if (msp_was_active) { | ||
// System crashed in an ISR but the running task state is on PSP so grab that too | ||
void *psp = (void *)(uintptr_t)__get_PSP(); | ||
|
||
// Collect a little bit more stack for the PSP since there is an | ||
// exception frame that will have been stacked on it as well | ||
const uint32_t extra_stack_bytes = 128; | ||
stack_size_to_collect = memfault_platform_sanitize_address_range( | ||
psp, active_stack_size_to_collect + extra_stack_bytes); | ||
s_coredump_regions[region_idx] = MEMFAULT_COREDUMP_MEMORY_REGION_INIT( | ||
psp, stack_size_to_collect); | ||
region_idx++; | ||
} | ||
|
||
// Scoop up memory regions necessary to perform unwinds of the FreeRTOS tasks | ||
const size_t memfault_region_size = (uint32_t)&__memfault_capture_bss_end - | ||
(uint32_t)&__memfault_capture_bss_start; | ||
|
||
s_coredump_regions[region_idx] = MEMFAULT_COREDUMP_MEMORY_REGION_INIT( | ||
&__memfault_capture_bss_start, memfault_region_size); | ||
region_idx++; | ||
|
||
region_idx += memfault_freertos_get_task_regions(&s_coredump_regions[region_idx], | ||
MEMFAULT_ARRAY_SIZE(s_coredump_regions) - region_idx); | ||
|
||
*num_regions = region_idx; | ||
return &s_coredump_regions[0]; | ||
} |
Oops, something went wrong.