Skip to content

Commit 161b167

Browse files
sanketwadekarme-no-dev
andauthoredDec 22, 2022
Draft: Esp insights library support (espressif#7566)
* ESP Insights: Added library support * ESP Insights: Added Examples * ESP Insights: Added custom partitions file * ESP Insights: Added API documentation. * Added recipe and script to create Insights package * Updated ESP Insights examples. * Changed Insights Firmware package output directory * Changed license to include SPDX license * Fix Insights package for Windows * Updated .exe of insights script * Added coredump partition to all schemes * Updated header files of Insights diagnostics * hotfix: Added elf-sha256-offset flag in elf2bin builder * Update API to be more Arduino-like and partitions offsets Co-authored-by: Me No Dev <[email protected]>
1 parent bb8c855 commit 161b167

35 files changed

+1015
-24
lines changed
 

‎CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ set(LIBRARY_SRCS
8888
libraries/HTTPClient/src/HTTPClient.cpp
8989
libraries/HTTPUpdate/src/HTTPUpdate.cpp
9090
libraries/LittleFS/src/LittleFS.cpp
91+
libraries/Insights/src/Insights.cpp
9192
libraries/I2S/src/I2S.cpp
9293
libraries/NetBIOS/src/NetBIOS.cpp
9394
libraries/Preferences/src/Preferences.cpp
@@ -184,6 +185,7 @@ set(includedirs
184185
libraries/HTTPClient/src
185186
libraries/HTTPUpdate/src
186187
libraries/LittleFS/src
188+
libraries/Insights/src
187189
libraries/I2S/src
188190
libraries/NetBIOS/src
189191
libraries/Preferences/src

‎boards.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17110,7 +17110,7 @@ deneyapminiv2.menu.DebugLevel.verbose.build.code_debug=5
1711017110
deneyapminiv2.menu.EraseFlash.none=Disabled
1711117111
deneyapminiv2.menu.EraseFlash.none.upload.erase_cmd=
1711217112
deneyapminiv2.menu.EraseFlash.all=Enabled
17113-
deneyapminiv2.menu.EraseFlash.all.upload.erase_cmd=-e
17113+
deneyapminiv2.menu.EraseFlash.all.upload.erase_cmd=-
1711417114

1711517115
##############################################################
1711617116

‎docs/source/api/insights.rst

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
############
2+
ESP Insights
3+
############
4+
5+
About
6+
-----
7+
8+
ESP Insights is a remote diagnostics solution that allows users to remotely monitor the health of ESP devices in the field.
9+
10+
Developers normally prefer debugging issues by physically probing them using gdb or observing the logs. This surely helps debug issues, but there are often cases wherein issues are seen only in specific environments under specific conditions. Even things like casings and placement of the product can affect the behaviour. A few examples are
11+
12+
- Wi-Fi disconnections for a smart switch concealed in a wall.
13+
- Smart speakers crashing during some specific usage pattern.
14+
- Appliance frequently rebooting due to power supply issues.
15+
16+
Additional information about ESP Insights can be found `here <https://insights.espressif.com/>`__.
17+
18+
ESP Insights Agent API
19+
----------------------
20+
21+
Insights.begin
22+
**************
23+
24+
This initializes the ESP Insights agent.
25+
26+
.. code-block:: arduino
27+
28+
bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false);
29+
30+
* ``auth_key`` Auth key generated using Insights dashboard
31+
* ``log_type`` Type of logs to be captured (value can be a mask of ESP_DIAG_LOG_TYPE_ERROR, ESP_DIAG_LOG_TYPE_WARNING and ESP_DIAG_LOG_TYPE_EVENT)
32+
33+
This function will return
34+
35+
1. true : On success
36+
2. false in case of failure
37+
38+
Insights.send
39+
*************
40+
41+
Read insights data from buffers and send it to the cloud. Call to this function is asynchronous, it may take some time to send the data.
42+
43+
.. code-block:: arduino
44+
45+
bool sendData()
46+
47+
This function will return
48+
49+
1. true : On success
50+
2. false in case of failure
51+
52+
Insights.end
53+
************
54+
55+
Deinitialize ESP Insights.
56+
57+
.. code-block:: arduino
58+
59+
void end();
60+
61+
Insights.disable
62+
****************
63+
64+
Disable ESP Insights.
65+
66+
.. code-block:: arduino
67+
68+
void disable();
69+
70+
ESP Insights Metrics API
71+
------------------------
72+
73+
`metrics` object of `Insights` class expose API's for using metrics.
74+
75+
Insights.metrics.addX
76+
*********************
77+
78+
Register a metric of type X, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
79+
80+
.. code-block:: arduino
81+
82+
bool addX(const char *tag, const char *key, const char *label, const char *path);
83+
84+
* ``tag`` : Tag of metrics
85+
* ``key`` : Unique key for the metrics
86+
* ``label`` : Label for the metrics
87+
* ``path`` : Hierarchical path for key, must be separated by '.' for more than one level
88+
89+
This function will return
90+
91+
1. true : On success
92+
2. false in case of failure
93+
94+
Insights.metrics.remove
95+
***********************
96+
97+
Unregister a diagnostics metrics
98+
99+
.. code-block:: arduino
100+
101+
bool remove(const char *key);
102+
103+
* ``key`` : Key for the metrics
104+
105+
This function will return
106+
107+
1. true : On success
108+
2. false in case of failure
109+
110+
Insights.metrics.removeAll
111+
**************************
112+
113+
Unregister all previously registered metrics
114+
115+
.. code-block:: arduino
116+
117+
bool removeAll();
118+
119+
This function will return
120+
121+
1. true : On success
122+
2. false in case of failure
123+
124+
Insights.metrics.setX
125+
*********************
126+
127+
Add metrics of type X to storage, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
128+
129+
.. code-block:: arduino
130+
131+
bool setX(const char *key, const void val);
132+
133+
* ``key`` : Key of metrics
134+
* ``val`` : Value of metrics
135+
136+
This function will return
137+
138+
1. `ESP_OK` : On success
139+
2. Error in case of failure
140+
141+
Insights.metrics.dumpHeap
142+
*************************
143+
144+
Dumps the heap metrics and prints them to the console.
145+
This API collects and reports metrics value at any give point in time.
146+
147+
.. code-block:: arduino
148+
149+
bool dumpHeap();
150+
151+
This function will return
152+
153+
1. true : On success
154+
2. false in case of failure
155+
156+
Insights.metrics.dumpWiFi
157+
*************************
158+
159+
Dumps the wifi metrics and prints them to the console.
160+
This API can be used to collect wifi metrics at any given point in time.
161+
162+
.. code-block:: arduino
163+
164+
bool dumpWiFi();
165+
166+
This function will return
167+
168+
1. true : On success
169+
2. false in case of failure
170+
171+
Insights.metrics.setHeapPeriod
172+
******************************
173+
174+
Reset the periodic interval
175+
By default, heap metrics are collected every 30 seconds, this function can be used to change the interval.
176+
If the interval is set to 0, heap metrics collection disabled.
177+
178+
.. code-block:: arduino
179+
180+
void setHeapPeriod(uint32_t period);
181+
182+
* ``period`` : Period interval in seconds
183+
184+
Insights.metrics.setWiFiPeriod
185+
******************************
186+
187+
Reset the periodic interval
188+
By default, wifi metrics are collected every 30 seconds, this function can be used to change the interval.
189+
If the interval is set to 0, wifi metrics collection disabled.
190+
191+
.. code-block:: arduino
192+
193+
void setHeapPeriod(uint32_t period);
194+
195+
* ``period`` : Period interval in seconds
196+
197+
ESP Insights Variables API
198+
--------------------------
199+
200+
`variables` object of `Insights` class expose API's for using variables.
201+
202+
Insights.variables.addX
203+
***********************
204+
205+
Register a variable of type X, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
206+
207+
.. code-block:: arduino
208+
209+
bool addX(const char *tag, const char *key, const char *label, const char *path);
210+
211+
* ``tag`` : Tag of variable
212+
* ``key`` : Unique key for the variable
213+
* ``label`` : Label for the variable
214+
* ``path`` : Hierarchical path for key, must be separated by '.' for more than one level
215+
216+
This function will return
217+
218+
1. true : On success
219+
2. false in case of failure
220+
221+
Insights.variables.remove
222+
*************************
223+
224+
Unregister a diagnostics variable
225+
226+
.. code-block:: arduino
227+
228+
bool remove(const char *key);
229+
230+
* ``key`` : Key for the variable
231+
232+
This function will return
233+
234+
1. true : On success
235+
2. false in case of failure
236+
237+
Insights.variables.removeAll
238+
****************************
239+
240+
Unregister all previously registered variables
241+
242+
.. code-block:: arduino
243+
244+
bool unregisterAll();
245+
246+
This function will return
247+
248+
1. true : On success
249+
2. false in case of failure
250+
251+
Insights.variables.setX
252+
***********************
253+
254+
Add variable of type X to storage, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC
255+
256+
.. code-block:: arduino
257+
258+
bool setX(const char *key, const void val);
259+
260+
* ``key`` : Key of metrics
261+
* ``val`` : Value of metrics
262+
263+
This function will return
264+
265+
1. true : On success
266+
2. false in case of failure
267+
268+
Example
269+
-------
270+
271+
To get started with Insights, you can try:
272+
273+
.. literalinclude:: ../../../libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino
274+
:language: arduino
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#include "Insights.h"
2+
#include "WiFi.h"
3+
#include "inttypes.h"
4+
#include "esp_err.h"
5+
6+
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
7+
8+
#define WIFI_SSID "<ENTER YOUR SSID>"
9+
#define WIFI_PASSPHRASE "<ENTER YOUR PASSWORD>"
10+
11+
#define MAX_CRASHES 5
12+
#define MAX_PTRS 30
13+
#define TAG "sketch"
14+
15+
RTC_NOINIT_ATTR static uint32_t s_reset_count;
16+
static void *s_ptrs[MAX_PTRS];
17+
18+
static void smoke_test()
19+
{
20+
int dice;
21+
int count = 0;
22+
bool allocating = false;
23+
24+
while (1) {
25+
dice = esp_random() % 500;
26+
log_i("dice=%d", dice);
27+
if (dice > 0 && dice < 150) {
28+
log_e("[count][%d]", count);
29+
} else if (dice > 150 && dice < 300) {
30+
log_w("[count][%d]", count);
31+
} else if (dice > 300 && dice < 470) {
32+
Insights.event(TAG, "[count][%d]", count);
33+
} else {
34+
/* 30 in 500 probability to crash */
35+
if (s_reset_count > MAX_CRASHES) {
36+
Insights.event(TAG, "[count][%d]", count);
37+
} else {
38+
log_e("[count][%d] [crash_count][%" PRIu32 "] [excvaddr][0x0f] Crashing...", count, s_reset_count);
39+
*(int *)0x0F = 0x10;
40+
}
41+
}
42+
43+
Insights.metrics.dumpHeap();
44+
if (count % MAX_PTRS == 0) {
45+
allocating = !allocating;
46+
log_i("Allocating:%s\n", allocating ? "true" : "false");
47+
}
48+
if (allocating) {
49+
uint32_t size = 1024 * (esp_random() % 8);
50+
void *p = malloc(size);
51+
if (p) {
52+
memset(p, size, 'A' + (esp_random() % 26));
53+
log_i("Allocated %" PRIu32 " bytes", size);
54+
}
55+
s_ptrs[count % MAX_PTRS] = p;
56+
} else {
57+
free(s_ptrs[count % MAX_PTRS]);
58+
s_ptrs[count % MAX_PTRS] = NULL;
59+
log_i("Freeing some memory...");
60+
}
61+
62+
count++;
63+
delay(1000);
64+
}
65+
}
66+
67+
void setup()
68+
{
69+
Serial.begin(115200);
70+
WiFi.mode(WIFI_STA);
71+
WiFi.begin(WIFI_SSID, WIFI_PASSPHRASE);
72+
while (WiFi.status() != WL_CONNECTED) {
73+
delay(500);
74+
Serial.print(".");
75+
}
76+
Serial.println("");
77+
Serial.println("WiFi connected");
78+
79+
if(!Insights.begin(insights_auth_key)){
80+
return;
81+
}
82+
Serial.println("=========================================");
83+
Serial.printf("ESP Insights enabled Node ID %s\n", Insights.nodeID());
84+
Serial.println("=========================================");
85+
86+
if (esp_reset_reason() == ESP_RST_POWERON) {
87+
s_reset_count = 1;
88+
} else {
89+
s_reset_count++;
90+
}
91+
}
92+
93+
void loop()
94+
{
95+
smoke_test();
96+
delay(100);
97+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Smoke Test App
2+
3+
## What to expect in this example?
4+
5+
- This example is expected to exercise the various features of the ESP Insights framework
6+
- As a smoke test, this allows you to validate, by a quick perusal of the ESP Insights dashboard, the functioning of all the high-level features
7+
8+
9+
## End-to-End Tests
10+
11+
### Lifecycle of the test (Hard reset resets the cycle)
12+
* Device boots up and logs errors/warnings/events in random order every 10 seconds
13+
* Every error/warning/event log with "diag_smoke" tag is associated with an incremental counter
14+
* There's a 30/500 probability that device will crash, this is done for verification of crash
15+
* Device will crash only five times and hard reset will reset the counter to 1
16+
* On sixth boot onwards device will not crash and logs errors/warnings/events and adds heap metrics
17+
18+
### Facilitate the Auth Key
19+
In this example we will be using the auth key that we downloaded while [setting up ESP Insights account](https://github.com/espressif/esp-insights/tree/main/examples#set-up-esp-insights-account).
20+
21+
Copy Auth Key to the example
22+
```
23+
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
24+
```
25+
26+
### Enter WiFi Credentials
27+
Inside the example sketch, enter your WiFi credentials in `WIFI_SSID` and `WIFI_PASSPHRASE` macros.
28+
29+
### Setup
30+
* Build and flash the sketch and monitor the console
31+
* Device will eventually crash after some time
32+
* Before every crash you will see below log print
33+
```
34+
E (75826) diag_smoke: [count][7] [crash_count][1] [excvaddr][0x0f] Crashing...
35+
// [count][7]: count associated with the log
36+
// [crash_count][1]: This is the first crash since device boot up, this number will increment as the crash count increases
37+
// [excvaddr][0x0f]: Exception vaddr, will see this in crash verification part below
38+
```
39+
* You'll see five crashes([crash_count][5]) and after that device will not crash and will keep on logging and adding metrics
40+
* Onwards this point keep device running for more than 30 minutes
41+
* Now we are all set to visit the [dashboard](https://dashboard.insights.espressif.com)
42+
* Select the node-id printed on the console, look for the below log. It is printed early when device boots up
43+
```
44+
ESP Insights enabled for Node ID ----- wx3vEoGgJPk7Rn5JvRUFs9
45+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "Insights.h"
2+
#include "WiFi.h"
3+
4+
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
5+
6+
#define WIFI_SSID "<ENTER YOUR SSID>"
7+
#define WIFI_PASSPHRASE "<ENTER YOUR PASSWORD>"
8+
9+
void setup()
10+
{
11+
Serial.begin(115200);
12+
WiFi.mode(WIFI_STA);
13+
WiFi.begin(WIFI_SSID, WIFI_PASSPHRASE);
14+
while (WiFi.status() != WL_CONNECTED) {
15+
delay(500);
16+
Serial.print(".");
17+
}
18+
Serial.println("");
19+
Serial.println("WiFi connected");
20+
if(!Insights.begin(insights_auth_key)){
21+
return;
22+
}
23+
Serial.println("=========================================");
24+
Serial.printf("ESP Insights enabled Node ID %s\n", Insights.nodeID());
25+
Serial.println("=========================================");
26+
}
27+
28+
void loop()
29+
{
30+
delay(1000);
31+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Minimal Diagnostics example
2+
- [What to expect in this example](#what-to-expect-in-this-example)
3+
- [Try out the example](#try-out-the-example)
4+
- [Insights Dashboard](#insights-dashboard)
5+
6+
## What to expect in this example?
7+
- This example demonstrates the use of ESP Insights framework in minimal way
8+
- Device will try to connect with the configured WiFi network
9+
- ESP Insights is enabled in this example, so any error/warning logs, crashes will be reported to cloud
10+
- This example collects heap and wifi metrics every 10 minutes and network variables are collected when they change
11+
12+
## Try out the example
13+
14+
### Facilitate the Auth Key
15+
In this example we will be using the auth key that we downloaded while [setting up ESP Insights account](https://github.com/espressif/esp-insights/tree/main/examples#set-up-esp-insights-account).
16+
17+
Copy Auth Key to the example
18+
```
19+
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
20+
```
21+
22+
### Enter WiFi Credentials
23+
Inside the example sketch, enter your WiFi credentials in `WIFI_SSID` and `WIFI_PASSPHRASE` macros.
24+
25+
### Get the Node ID
26+
- Start the Serial monitor
27+
28+
- Once the device boots, it will connect to the Wi-Fi network, look for logs similar to below and make a note of Node ID.
29+
```
30+
I (4161) esp_insights: =========================================
31+
I (4171) esp_insights: Insights enabled for Node ID 246F2880371C
32+
I (4181) esp_insights: =========================================
33+
```
34+
35+
36+
## Insights Dashboard
37+
Once everything is set up, any diagnostics information reported will show up on the [Insights Dashboard](https://dashboard.insights.espressif.com). Sign in using the your credentials.
38+
39+
40+
### Monitor the device diagnostics
41+
Visit [Nodes](https://dashboard.insights.espressif.com/home/nodes) section on the dashboard and click on the Node ID to monitor device diagnostics information.
42+
43+
> Note: Diagnostics data is reported dynamically or when the buffers are filled to configured threshold. So, it can take some time for the logs to reflect on the dashboard. Moreover, if a large number of logs are generated then data will be sent to cloud but, if it fails(eg reasons: Wi-Fi failure, No internet) then any newer logs will be dropped.

‎libraries/Insights/library.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name=ESP Insights
2+
version=1.0.0
3+
author=Sanket Wadekar <sanket.wadekar@espressif.com>
4+
maintainer=Sanket Wadekar <sanket.wadekar@espressif.com>
5+
sentence=ESP Insights
6+
paragraph=With this library you can remotely monitor your device error logs, Network variables, WiFi/Heap Metrics, and also custom varibles / metrics.
7+
url=https://insights.espressif.com
8+
architectures=esp32

‎libraries/Insights/src/Insights.cpp

Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include "Insights.h"
7+
#ifdef CONFIG_ESP_INSIGHTS_ENABLED
8+
#include "esp_insights.h"
9+
#include "esp_diagnostics.h"
10+
#include "esp_diagnostics_metrics.h"
11+
#include "esp_diagnostics_system_metrics.h"
12+
#include "esp_diagnostics_variables.h"
13+
#include "esp_diagnostics_network_variables.h"
14+
15+
const char * ERROR_INSIGHTS_NOT_INIT = "ESP Insights not initialized";
16+
17+
#define BOOL_FN_OR_ERROR(f,e) \
18+
if(!initialized){ \
19+
log_e("%s",ERROR_INSIGHTS_NOT_INIT); \
20+
return false; \
21+
} \
22+
esp_err_t err = f; \
23+
if (err != ESP_OK) { \
24+
log_e("ESP Insights " e ", err:0x%x", err); \
25+
} \
26+
return err == ESP_OK;
27+
28+
#define BOOL_FN_OR_ERROR_ARG(f,e,a) \
29+
if(!initialized){ \
30+
log_e("%s",ERROR_INSIGHTS_NOT_INIT); \
31+
return false; \
32+
} \
33+
esp_err_t err = f; \
34+
if (err != ESP_OK) { \
35+
log_e("ESP Insights " e ", err:0x%x", a, err); \
36+
} \
37+
return err == ESP_OK;
38+
39+
#define VOID_FN_OR_ERROR(f) \
40+
if(!initialized){ \
41+
log_e("%s",ERROR_INSIGHTS_NOT_INIT); \
42+
return; \
43+
} \
44+
f;
45+
46+
ESPInsightsClass::ESPInsightsClass(): initialized(false){}
47+
48+
ESPInsightsClass::~ESPInsightsClass(){
49+
end();
50+
}
51+
52+
bool ESPInsightsClass::begin(const char *auth_key, const char *node_id, uint32_t log_type, bool alloc_ext_ram){
53+
if(!initialized){
54+
if(log_type == 0xFFFFFFFF){
55+
log_type = (ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING | ESP_DIAG_LOG_TYPE_EVENT);
56+
}
57+
esp_insights_config_t config = {.log_type = log_type, .node_id = node_id, .auth_key = auth_key, .alloc_ext_ram = alloc_ext_ram};
58+
esp_err_t err = esp_insights_init(&config);
59+
if (err != ESP_OK) {
60+
log_e("Failed to initialize ESP Insights, err:0x%x", err);
61+
}
62+
initialized = err == ESP_OK;
63+
metrics.setInitialized(initialized);
64+
variables.setInitialized(initialized);
65+
} else {
66+
log_i("ESP Insights already initialized");
67+
}
68+
return initialized;
69+
}
70+
71+
void ESPInsightsClass::end(){
72+
if(initialized){
73+
esp_insights_deinit();
74+
initialized = false;
75+
metrics.setInitialized(initialized);
76+
variables.setInitialized(initialized);
77+
}
78+
}
79+
80+
const char * ESPInsightsClass::nodeID(){
81+
if(!initialized){
82+
log_e("%s",ERROR_INSIGHTS_NOT_INIT);
83+
return "";
84+
}
85+
return esp_insights_get_node_id();
86+
}
87+
88+
bool ESPInsightsClass::event(const char *tag, const char *format, ...){
89+
if(!initialized){
90+
log_e("%s",ERROR_INSIGHTS_NOT_INIT);
91+
return false;
92+
}
93+
94+
char loc_buf[64];
95+
char * temp = loc_buf;
96+
va_list arg;
97+
va_list copy;
98+
va_start(arg, format);
99+
va_copy(copy, arg);
100+
int len = vsnprintf(temp, sizeof(loc_buf), format, copy);
101+
va_end(copy);
102+
if(len < 0) {
103+
va_end(arg);
104+
return false;
105+
};
106+
if(len >= (int)sizeof(loc_buf)){ // comparation of same sign type for the compiler
107+
temp = (char*) malloc(len+1);
108+
if(temp == NULL) {
109+
va_end(arg);
110+
return false;
111+
}
112+
len = vsnprintf(temp, len+1, format, arg);
113+
}
114+
va_end(arg);
115+
esp_err_t err = esp_diag_log_event(tag, "%s", temp);
116+
if(temp != loc_buf){
117+
free(temp);
118+
}
119+
if (err != ESP_OK) {
120+
log_e("Failed to send ESP Insights event, err:0x%x", err);
121+
}
122+
return err == ESP_OK;
123+
}
124+
125+
bool ESPInsightsClass::send(){
126+
BOOL_FN_OR_ERROR(esp_insights_send_data(),"Failed to send");
127+
}
128+
129+
void ESPInsightsClass::dumpTasksStatus(){
130+
VOID_FN_OR_ERROR(esp_diag_task_snapshot_dump());
131+
}
132+
133+
// ESPInsightsMetricsClass
134+
135+
bool ESPInsightsMetricsClass::addBool(const char *tag, const char *key, const char *label, const char *path){
136+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_BOOL),"Failed to add metric '%s'",key);
137+
}
138+
139+
bool ESPInsightsMetricsClass::addInt(const char *tag, const char *key, const char *label, const char *path){
140+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_INT),"Failed to add metric '%s'",key);
141+
}
142+
143+
bool ESPInsightsMetricsClass::addUint(const char *tag, const char *key, const char *label, const char *path){
144+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_UINT),"Failed to add metric '%s'",key);
145+
}
146+
147+
bool ESPInsightsMetricsClass::addFloat(const char *tag, const char *key, const char *label, const char *path){
148+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_FLOAT),"Failed to add metric '%s'",key);
149+
}
150+
151+
bool ESPInsightsMetricsClass::addString(const char *tag, const char *key, const char *label, const char *path){
152+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_STR),"Failed to add metric '%s'",key);
153+
}
154+
155+
bool ESPInsightsMetricsClass::addIPv4(const char *tag, const char *key, const char *label, const char *path){
156+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_IPv4),"Failed to add metric '%s'",key);
157+
}
158+
159+
bool ESPInsightsMetricsClass::addMAC(const char *tag, const char *key, const char *label, const char *path){
160+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_MAC),"Failed to add metric '%s'",key);
161+
}
162+
163+
bool ESPInsightsMetricsClass::setBool(const char *key, bool b){
164+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_bool(key, b),"Failed to set metric '%s'",key);
165+
}
166+
167+
bool ESPInsightsMetricsClass::setInt(const char *key, int32_t i){
168+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_int(key, i),"Failed to set metric '%s'",key);
169+
}
170+
171+
bool ESPInsightsMetricsClass::setUint(const char *key, uint32_t u){
172+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_uint(key, u),"Failed to set metric '%s'",key);
173+
}
174+
175+
bool ESPInsightsMetricsClass::setFloat(const char *key, float f){
176+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_float(key, f),"Failed to set metric '%s'",key);
177+
}
178+
179+
bool ESPInsightsMetricsClass::setString(const char *key, const char *str){
180+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_str(key, str),"Failed to set metric '%s'",key);
181+
}
182+
183+
bool ESPInsightsMetricsClass::setIPv4(const char *key, uint32_t ip){
184+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_ipv4(key, ip),"Failed to set metric '%s'",key);
185+
}
186+
187+
bool ESPInsightsMetricsClass::setMAC(const char *key, uint8_t *mac){
188+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_add_mac(key, mac),"Failed to set metric '%s'",key);
189+
}
190+
191+
bool ESPInsightsMetricsClass::remove(const char *key){
192+
BOOL_FN_OR_ERROR_ARG(esp_diag_metrics_unregister(key),"Failed to remove metric '%s'",key);
193+
}
194+
195+
bool ESPInsightsMetricsClass::removeAll(){
196+
BOOL_FN_OR_ERROR(esp_diag_metrics_unregister_all(),"Failed to remove metrics");
197+
}
198+
199+
void ESPInsightsMetricsClass::setHeapPeriod(uint32_t seconds){
200+
VOID_FN_OR_ERROR(esp_diag_heap_metrics_reset_interval(seconds));
201+
}
202+
203+
bool ESPInsightsMetricsClass::dumpHeap(){
204+
BOOL_FN_OR_ERROR(esp_diag_heap_metrics_dump(),"Failed to send heap metrics");
205+
}
206+
207+
void ESPInsightsMetricsClass::setWiFiPeriod(uint32_t seconds){
208+
VOID_FN_OR_ERROR(esp_diag_wifi_metrics_reset_interval(seconds));
209+
}
210+
211+
bool ESPInsightsMetricsClass::dumpWiFi(){
212+
BOOL_FN_OR_ERROR(esp_diag_wifi_metrics_dump(),"Failed to send wifi metrics");
213+
}
214+
215+
// ESPInsightsVariablesClass
216+
217+
bool ESPInsightsVariablesClass::addBool(const char *tag, const char *key, const char *label, const char *path){
218+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_BOOL),"Failed to add variable '%s'",key);
219+
}
220+
221+
bool ESPInsightsVariablesClass::addInt(const char *tag, const char *key, const char *label, const char *path){
222+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_INT),"Failed to add variable '%s'",key);
223+
}
224+
225+
bool ESPInsightsVariablesClass::addUint(const char *tag, const char *key, const char *label, const char *path){
226+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_UINT),"Failed to add variable '%s'",key);
227+
}
228+
229+
bool ESPInsightsVariablesClass::addFloat(const char *tag, const char *key, const char *label, const char *path){
230+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_FLOAT),"Failed to add variable '%s'",key);
231+
}
232+
233+
bool ESPInsightsVariablesClass::addString(const char *tag, const char *key, const char *label, const char *path){
234+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_STR),"Failed to add variable '%s'",key);
235+
}
236+
237+
bool ESPInsightsVariablesClass::addIPv4(const char *tag, const char *key, const char *label, const char *path){
238+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_IPv4),"Failed to add variable '%s'",key);
239+
}
240+
241+
bool ESPInsightsVariablesClass::addMAC(const char *tag, const char *key, const char *label, const char *path){
242+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_register(tag, key, label, path, ESP_DIAG_DATA_TYPE_MAC),"Failed to add variable '%s'",key);
243+
}
244+
245+
bool ESPInsightsVariablesClass::setBool(const char *key, bool b){
246+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_bool(key, b),"Failed to set variable '%s'",key);
247+
}
248+
249+
bool ESPInsightsVariablesClass::setInt(const char *key, int32_t i){
250+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_int(key, i),"Failed to set variable '%s'",key);
251+
}
252+
253+
bool ESPInsightsVariablesClass::setUint(const char *key, uint32_t u){
254+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_uint(key, u),"Failed to set variable '%s'",key);
255+
}
256+
257+
bool ESPInsightsVariablesClass::setFloat(const char *key, float f){
258+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_float(key, f),"Failed to set variable '%s'",key);
259+
}
260+
261+
bool ESPInsightsVariablesClass::setString(const char *key, const char *str){
262+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_str(key, str),"Failed to set variable '%s'",key);
263+
}
264+
265+
bool ESPInsightsVariablesClass::setIPv4(const char *key, uint32_t ip){
266+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_ipv4(key, ip),"Failed to set variable '%s'",key);
267+
}
268+
269+
bool ESPInsightsVariablesClass::setMAC(const char *key, uint8_t *mac){
270+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_add_mac(key, mac),"Failed to set variable '%s'",key);
271+
}
272+
273+
bool ESPInsightsVariablesClass::remove(const char *key){
274+
BOOL_FN_OR_ERROR_ARG(esp_diag_variable_unregister(key),"Failed to remove variable '%s'",key);
275+
}
276+
277+
bool ESPInsightsVariablesClass::removeAll(){
278+
BOOL_FN_OR_ERROR(esp_diag_variable_unregister_all(),"Failed to remove variables");
279+
}
280+
281+
ESPInsightsClass Insights;
282+
283+
#endif

‎libraries/Insights/src/Insights.h

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
#include "sdkconfig.h"
8+
#ifdef CONFIG_ESP_INSIGHTS_ENABLED
9+
#include "Arduino.h"
10+
11+
#ifdef __cplusplus
12+
13+
class ESPInsightsMetricsClass
14+
{
15+
private:
16+
bool initialized;
17+
18+
public:
19+
ESPInsightsMetricsClass():initialized(false){}
20+
21+
bool addBool(const char *tag, const char *key, const char *label, const char *path);
22+
bool addInt(const char *tag, const char *key, const char *label, const char *path);
23+
bool addUint(const char *tag, const char *key, const char *label, const char *path);
24+
bool addFloat(const char *tag, const char *key, const char *label, const char *path);
25+
bool addString(const char *tag, const char *key, const char *label, const char *path);
26+
bool addIPv4(const char *tag, const char *key, const char *label, const char *path);
27+
bool addMAC(const char *tag, const char *key, const char *label, const char *path);
28+
29+
bool setBool(const char *key, bool b);
30+
bool setInt(const char *key, int32_t i);
31+
bool setUint(const char *key, uint32_t u);
32+
bool setFloat(const char *key, float f);
33+
bool setString(const char *key, const char *str);
34+
bool setIPv4(const char *key, uint32_t ip);
35+
bool setMAC(const char *key, uint8_t *mac);
36+
37+
bool remove(const char *key);
38+
bool removeAll();
39+
40+
void setHeapPeriod(uint32_t seconds);
41+
void setWiFiPeriod(uint32_t seconds);
42+
43+
bool dumpHeap();
44+
bool dumpWiFi();
45+
46+
//internal use
47+
void setInitialized(bool init){ initialized = init; }
48+
};
49+
50+
class ESPInsightsVariablesClass
51+
{
52+
private:
53+
bool initialized;
54+
55+
public:
56+
ESPInsightsVariablesClass():initialized(false){}
57+
58+
bool addBool(const char *tag, const char *key, const char *label, const char *path);
59+
bool addInt(const char *tag, const char *key, const char *label, const char *path);
60+
bool addUint(const char *tag, const char *key, const char *label, const char *path);
61+
bool addFloat(const char *tag, const char *key, const char *label, const char *path);
62+
bool addString(const char *tag, const char *key, const char *label, const char *path);
63+
bool addIPv4(const char *tag, const char *key, const char *label, const char *path);
64+
bool addMAC(const char *tag, const char *key, const char *label, const char *path);
65+
66+
bool setBool(const char *key, bool b);
67+
bool setInt(const char *key, int32_t i);
68+
bool setUint(const char *key, uint32_t u);
69+
bool setFloat(const char *key, float f);
70+
bool setString(const char *key, const char *str);
71+
bool setIPv4(const char *key, uint32_t ip);
72+
bool setMAC(const char *key, uint8_t *mac);
73+
74+
bool remove(const char *key);
75+
bool removeAll();
76+
77+
//internal use
78+
void setInitialized(bool init){ initialized = init; }
79+
};
80+
81+
class ESPInsightsClass
82+
{
83+
private:
84+
bool initialized;
85+
86+
public:
87+
ESPInsightsMetricsClass metrics;
88+
ESPInsightsVariablesClass variables;
89+
90+
ESPInsightsClass();
91+
~ESPInsightsClass();
92+
93+
bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false);
94+
void end();
95+
bool send();
96+
const char * nodeID();
97+
98+
void dumpTasksStatus();
99+
100+
bool event(const char *tag, const char *format, ...);
101+
};
102+
103+
extern ESPInsightsClass Insights;
104+
105+
extern "C"
106+
{
107+
#endif
108+
109+
#include "esp_err.h"
110+
#include "esp_log.h"
111+
esp_err_t esp_diag_log_event(const char *tag, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
112+
#define insightsEvent(tag, format, ...) {esp_diag_log_event(tag, "EV (%" PRIu32 ") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__);}
113+
114+
#ifdef __cplusplus
115+
}
116+
#endif
117+
118+
#endif

‎platform.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ tools.esp_ota.cmd.windows="{runtime.platform.path}/tools/espota.exe" -r
2424
tools.gen_esp32part.cmd=python3 "{runtime.platform.path}/tools/gen_esp32part.py"
2525
tools.gen_esp32part.cmd.windows="{runtime.platform.path}/tools/gen_esp32part.exe"
2626

27+
tools.gen_insights_pkg.cmd=python3 "{runtime.platform.path}"/tools/gen_insights_package.py
28+
tools.gen_insights_pkg.cmd.windows="{runtime.platform.path}/tools/gen_insights_package.exe"
29+
2730
compiler.path={runtime.tools.{build.tarch}-{build.target}-elf-gcc.path}/bin/
2831
compiler.sdk.path={runtime.platform.path}/tools/sdk/{build.mcu}
2932
compiler.prefix={build.tarch}-{build.target}-elf-
@@ -211,10 +214,15 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-Wl,--Map={build
211214
recipe.objcopy.partitions.bin.pattern={tools.gen_esp32part.cmd} -q "{build.path}/partitions.csv" "{build.path}/{build.project_name}.partitions.bin"
212215

213216
## Create bin
214-
recipe.objcopy.bin.pattern_args=--chip {build.mcu} elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" --flash_size "{build.flash_size}" -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
217+
recipe.objcopy.bin.pattern_args=--chip {build.mcu} elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" --flash_size "{build.flash_size}" --elf-sha256-offset 0xb0 -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
215218
recipe.objcopy.bin.pattern="{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.objcopy.bin.pattern_args}
216219
recipe.objcopy.bin.pattern.linux=python3 "{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.objcopy.bin.pattern_args}
217220

221+
## Create Insights Firmware Package
222+
recipe.hooks.objcopy.postobjcopy.1.pattern_args={build.path} {build.project_name} "{build.source.path}"
223+
recipe.hooks.objcopy.postobjcopy.1.pattern=bash -c "[ ! -d "{build.path}"/libraries/Insights ] || {tools.gen_insights_pkg.cmd} {recipe.hooks.objcopy.postobjcopy.1.pattern_args}"
224+
recipe.hooks.objcopy.postobjcopy.1.pattern.windows=cmd /c if exist "{build.path}\libraries\Insights" {tools.gen_insights_pkg.cmd} {recipe.hooks.objcopy.postobjcopy.1.pattern_args}
225+
218226
## Save bin
219227
recipe.output.tmp_file={build.project_name}.bin
220228
recipe.output.save_file={build.project_name}.{build.variant}.bin

‎tools/gen_insights_package.exe

3.62 MB
Binary file not shown.

‎tools/gen_insights_package.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import os
2+
import sys
3+
import shutil
4+
import json
5+
6+
APP_HEADER_SIZE = 32
7+
VERSION_NAME_OFFSET = APP_HEADER_SIZE + 16
8+
VERSION_NAME_SIZE = 32
9+
PROJECT_NAME_OFFSET = VERSION_NAME_OFFSET + VERSION_NAME_SIZE
10+
PROJECT_NAME_SIZE = 32
11+
12+
# Input path of temporary build directory created by Arduino
13+
BUILD_DIR=sys.argv[1]
14+
# Input project name
15+
PROJ_NAME=sys.argv[2]
16+
# Input path to create output package
17+
TARGET_PATH=sys.argv[3]
18+
19+
def main():
20+
print("Creating ESP Insights Firmware Package.")
21+
archive_path = os.path.join(BUILD_DIR, PROJ_NAME)
22+
out_path = os.path.join(TARGET_PATH, PROJ_NAME)
23+
24+
# Create target archive directories
25+
os.makedirs(archive_path, exist_ok = True)
26+
os.makedirs(os.path.join(archive_path, "partition_table"), exist_ok = True)
27+
os.makedirs(os.path.join(archive_path, "bootloader"), exist_ok = True)
28+
29+
# Copy files from build directory to archive directory
30+
shutil.copy2(os.path.join(BUILD_DIR, PROJ_NAME + ".bin"), archive_path)
31+
shutil.copy2(os.path.join(BUILD_DIR, PROJ_NAME + ".elf"), archive_path)
32+
shutil.copy2(os.path.join(BUILD_DIR, PROJ_NAME + ".map"), archive_path)
33+
shutil.copy2(os.path.join(BUILD_DIR, "partitions.csv"), archive_path)
34+
shutil.copy2(os.path.join(BUILD_DIR, PROJ_NAME + ".bootloader.bin"), os.path.join(archive_path, "bootloader"))
35+
shutil.copy2(os.path.join(BUILD_DIR, PROJ_NAME + ".partitions.bin"), os.path.join(archive_path, "partition_table"))
36+
37+
with open(os.path.join(BUILD_DIR, PROJ_NAME + ".bin"), 'rb') as bin_file:
38+
bin_file.seek(VERSION_NAME_OFFSET)
39+
version_name = (bin_file.read(VERSION_NAME_SIZE).decode('utf-8')).split('\x00', 1)[0]
40+
bin_file.seek(PROJECT_NAME_OFFSET)
41+
project_name = (bin_file.read(PROJECT_NAME_SIZE).decode('utf-8')).split('\x00', 1)[0]
42+
project_build_config_obj = {
43+
"project" : {
44+
"name" : project_name,
45+
"version": version_name
46+
}
47+
}
48+
with open(os.path.join(archive_path, "project_build_config.json"), "w") as json_file:
49+
json_file.write(json.dumps(project_build_config_obj))
50+
51+
shutil.make_archive(out_path, "zip", BUILD_DIR, PROJ_NAME)
52+
print("Archive created at {}".format(out_path + ".zip"))
53+
return
54+
55+
if __name__ == '__main__':
56+
main()

‎tools/partitions/app3M_fat9M_16MB.csv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x300000,
55
app1, app, ota_1, 0x310000,0x300000,
6-
ffat, data, fat, 0x610000,0x9F0000,
7-
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage
6+
ffat, data, fat, 0x610000,0x9E0000,
7+
coredump, data, coredump,0xFF0000,0x10000,
8+
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

‎tools/partitions/bare_minimum_2MB.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Name, Type, SubType, Offset, Size, Flags
22
nvs, data, nvs, 36K, 20K,
3-
factory, app, factory, 64K, 1900K,
3+
factory, app, factory, 64K, 1900K,

‎tools/partitions/default.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x140000,
55
app1, app, ota_1, 0x150000,0x140000,
6-
spiffs, data, spiffs, 0x290000,0x170000,
6+
spiffs, data, spiffs, 0x290000,0x160000,
7+
coredump, data, coredump,0x3F0000,0x10000,

‎tools/partitions/default_16MB.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x640000,
55
app1, app, ota_1, 0x650000,0x640000,
6-
spiffs, data, spiffs, 0xc90000,0x370000,
6+
spiffs, data, spiffs, 0xc90000,0x360000,
7+
coredump, data, coredump,0xFF0000,0x10000,

‎tools/partitions/default_8MB.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x330000,
55
app1, app, ota_1, 0x340000,0x330000,
6-
spiffs, data, spiffs, 0x670000,0x190000,
6+
spiffs, data, spiffs, 0x670000,0x180000,
7+
coredump, data, coredump,0x7F0000,0x10000,

‎tools/partitions/default_ffat.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x140000,
55
app1, app, ota_1, 0x150000,0x140000,
6-
ffat, data, fat, 0x290000,0x170000,
6+
ffat, data, fat, 0x290000,0x160000,
7+
coredump, data, coredump,0x3F0000,0x10000,

‎tools/partitions/ffat.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x200000,
55
app1, app, ota_1, 0x210000,0x200000,
6-
ffat, data, fat, 0x410000,0xBF0000,
6+
ffat, data, fat, 0x410000,0xBE0000,
7+
coredump, data, coredump,0xFF0000,0x10000,
78
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

‎tools/partitions/huge_app.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x300000,
5-
spiffs, data, spiffs, 0x310000,0xF0000,
5+
spiffs, data, spiffs, 0x310000,0xE0000,
6+
coredump, data, coredump,0x3F0000,0x10000,

‎tools/partitions/large_spiffs_16MB.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x480000,
55
app1, app, ota_1, 0x490000,0x480000,
6-
spiffs, data, spiffs, 0x910000,0x6F0000,
6+
spiffs, data, spiffs, 0x910000,0x6E0000,
7+
coredump, data, coredump,0xFF0000,0x10000,

‎tools/partitions/max_app_8MB.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Name, Type, SubType, Offset, Size, Flags
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
4-
app0, app, factory, 0x10000, 0x7F0000,
4+
app0, app, factory, 0x10000, 0x7E0000,
5+
coredump, data, coredump,0x7F0000,0x10000,

‎tools/partitions/min_spiffs.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x1E0000,
55
app1, app, ota_1, 0x1F0000,0x1E0000,
6-
spiffs, data, spiffs, 0x3D0000,0x30000,
6+
spiffs, data, spiffs, 0x3D0000,0x20000,
7+
coredump, data, coredump,0x3F0000,0x10000,

‎tools/partitions/minimal.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x140000,
5-
spiffs, data, spiffs, 0x150000, 0xB0000,
5+
spiffs, data, spiffs, 0x150000, 0xA0000,
6+
coredump, data, coredump,0x1F0000, 0x10000,

‎tools/partitions/no_ota.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x200000,
5-
spiffs, data, spiffs, 0x210000,0x1F0000,
5+
spiffs, data, spiffs, 0x210000,0x1E0000,
6+
coredump, data, coredump,0x3F0000,0x10000,

‎tools/partitions/noota_3g.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x100000,
5-
spiffs, data, spiffs, 0x110000,0x2F0000,
5+
spiffs, data, spiffs, 0x110000,0x2E0000,
6+
coredump, data, coredump,0x3F0000,0x10000,

‎tools/partitions/noota_3gffat.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x100000,
5-
ffat, data, fat, 0x110000,0x2F0000,
5+
ffat, data, fat, 0x110000,0x2E0000,
6+
coredump, data, coredump,0x3F0000,0x10000,
67
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

‎tools/partitions/noota_ffat.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
nvs, data, nvs, 0x9000, 0x5000,
33
otadata, data, ota, 0xe000, 0x2000,
44
app0, app, ota_0, 0x10000, 0x200000,
5-
ffat, data, fat, 0x210000,0x1F0000,
5+
ffat, data, fat, 0x210000,0x1E0000,
6+
coredump, data, coredump,0x3F0000,0x10000,
67
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

‎tools/partitions/rainmaker.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ otadata, data, ota, 0xe000, 0x2000,
44
ota_0, app, ota_0, 0x10000, 0x1E0000,
55
ota_1, app, ota_1, 0x1F0000, 0x1E0000,
66
fctry, data, nvs, 0x3D0000, 0x6000,
7+
coredump, data, coredump, 0x3F0000, 0x10000,

‎tools/platformio-build.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py
2626

2727
from os.path import abspath, basename, isdir, isfile, join
28-
28+
from copy import deepcopy
2929
from SCons.Script import DefaultEnvironment, SConscript
3030

3131
env = DefaultEnvironment()
@@ -237,3 +237,13 @@ def add_tinyuf2_extra_image():
237237
),
238238
)
239239
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)
240+
241+
#
242+
# Adjust the `esptoolpy` command in the `ElfToBin` builder with firmware checksum offset
243+
#
244+
245+
action = deepcopy(env["BUILDERS"]["ElfToBin"].action)
246+
action.cmd_list = env["BUILDERS"]["ElfToBin"].action.cmd_list.replace(
247+
"-o", "--elf-sha256-offset 0xb0 -o"
248+
)
249+
env["BUILDERS"]["ElfToBin"].action = action

‎tools/sdk/esp32/include/esp_diagnostics/include/esp_diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ esp_err_t esp_diag_log_event(const char *tag, const char *format, ...) __attribu
238238
*/
239239
#define ESP_DIAG_EVENT(tag, format, ...) \
240240
{ \
241-
esp_diag_log_event(tag, "EV (%"PRIu32") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
241+
esp_diag_log_event(tag, "EV (%" PRIu32 ") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
242242
ESP_LOGI(tag, format, ##__VA_ARGS__); \
243243
}
244244

‎tools/sdk/esp32c3/include/esp_diagnostics/include/esp_diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ esp_err_t esp_diag_log_event(const char *tag, const char *format, ...) __attribu
238238
*/
239239
#define ESP_DIAG_EVENT(tag, format, ...) \
240240
{ \
241-
esp_diag_log_event(tag, "EV (%"PRIu32") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
241+
esp_diag_log_event(tag, "EV (%" PRIu32 ") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
242242
ESP_LOGI(tag, format, ##__VA_ARGS__); \
243243
}
244244

‎tools/sdk/esp32s2/include/esp_diagnostics/include/esp_diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ esp_err_t esp_diag_log_event(const char *tag, const char *format, ...) __attribu
238238
*/
239239
#define ESP_DIAG_EVENT(tag, format, ...) \
240240
{ \
241-
esp_diag_log_event(tag, "EV (%"PRIu32") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
241+
esp_diag_log_event(tag, "EV (%" PRIu32 ") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
242242
ESP_LOGI(tag, format, ##__VA_ARGS__); \
243243
}
244244

‎tools/sdk/esp32s3/include/esp_diagnostics/include/esp_diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ esp_err_t esp_diag_log_event(const char *tag, const char *format, ...) __attribu
238238
*/
239239
#define ESP_DIAG_EVENT(tag, format, ...) \
240240
{ \
241-
esp_diag_log_event(tag, "EV (%"PRIu32") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
241+
esp_diag_log_event(tag, "EV (%" PRIu32 ") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); \
242242
ESP_LOGI(tag, format, ##__VA_ARGS__); \
243243
}
244244

0 commit comments

Comments
 (0)
Please sign in to comment.