coredump httpserver
This commit is contained in:
parent
2000e459c9
commit
7c7d298af1
@ -2,8 +2,9 @@ set(EXTRA_COMPONENT_DIRS ../components)
|
||||
|
||||
idf_component_register(SRC_DIRS . fonts
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES heap nvs_flash meteofrance communication esp_netif image_downloader fatfs sdmmc vfs littlefs wifi_logger protocol_examples_common app_update esp_https_ota bsp_extra esp32_p4_function_ev_board esp_driver_gpio
|
||||
EMBED_TXTFILES ${project_dir}/main/ca_cert.pem)
|
||||
REQUIRES heap espcoredump esp_http_server nvs_flash meteofrance communication esp_netif image_downloader fatfs sdmmc vfs littlefs wifi_logger protocol_examples_common app_update esp_https_ota bsp_extra esp32_p4_function_ev_board esp_driver_gpio
|
||||
EMBED_TXTFILES ${project_dir}/main/ca_cert.pem
|
||||
EMBED_FILES "index.html")
|
||||
|
||||
|
||||
set_source_files_properties(
|
||||
|
||||
80
main/index.html
Normal file
80
main/index.html
Normal file
@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<style>
|
||||
.btn {
|
||||
border: 2px solid black;
|
||||
/* background-color: white; */
|
||||
color: black;
|
||||
padding: 14px 28px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Green */
|
||||
.success {
|
||||
border-color: #4CAF50;
|
||||
color: green;
|
||||
}
|
||||
|
||||
.success:hover {
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Blue */
|
||||
.info {
|
||||
border-color: #2196F3;
|
||||
color: dodgerblue
|
||||
}
|
||||
|
||||
.info:hover {
|
||||
background: #2196F3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Orange */
|
||||
.warning {
|
||||
border-color: #ff9800;
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.warning:hover {
|
||||
background: #ff9800;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Red */
|
||||
.danger {
|
||||
border-color: #f44336;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.danger:hover {
|
||||
background: #f44336;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Gray */
|
||||
.default {
|
||||
border-color: #e7e7e7;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.default:hover {
|
||||
background: #e7e7e7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body onload="init()"><center>
|
||||
<h1>Developed by Mark</h1>
|
||||
<h2>How to save and Download crash dump</h2>
|
||||
</br></br>
|
||||
<button class="btn success"><a href="http://192.168.4.1/download">Download</a></button></br></br>
|
||||
<button class="btn success"><a href="http://192.168.4.1/crash">Crash</a></button>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
105
main/main.c
105
main/main.c
@ -13,6 +13,8 @@
|
||||
#include "sdmmc_cmd.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_http_server.h"
|
||||
|
||||
#include "bsp/esp-bsp.h"
|
||||
|
||||
#include "main.h"
|
||||
@ -292,12 +294,108 @@ void initPirSensor(){
|
||||
static void periodic_timer_callback(void* arg)
|
||||
{
|
||||
int64_t time_since_boot = esp_timer_get_time();
|
||||
ESP_LOGI(TAG, "Periodic timer called, time since boot: %lld us", time_since_boot);
|
||||
if(bsp_display_lock(0)){
|
||||
for (int i = 100; i >= 0; i--)
|
||||
{
|
||||
bsp_display_brightness_set(i);
|
||||
vTaskDelay(20/portTICK_PERIOD_MS);
|
||||
}
|
||||
bsp_display_unlock();
|
||||
}
|
||||
ecranEteint=true;
|
||||
}
|
||||
|
||||
static esp_err_t download_get_handler(httpd_req_t *req) {
|
||||
httpd_resp_set_type(req, "application/octet-stream");
|
||||
httpd_resp_set_hdr(req, "Content-Disposition",
|
||||
"attachment;filename=core.bin");
|
||||
|
||||
esp_partition_iterator_t partition_iterator = esp_partition_find(
|
||||
ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, "coredump");
|
||||
|
||||
const esp_partition_t *partition = esp_partition_get(partition_iterator);
|
||||
|
||||
int file_size = 65536;
|
||||
int chunk_size = 1024;
|
||||
int i = 0;
|
||||
for (i = 0; i < (file_size / chunk_size); i++) {
|
||||
char store_data[chunk_size];
|
||||
ESP_ERROR_CHECK(
|
||||
esp_partition_read(partition, i * chunk_size, store_data, chunk_size));
|
||||
httpd_resp_send_chunk(req, store_data, chunk_size);
|
||||
}
|
||||
uint16_t pending_size = file_size - (i * chunk_size);
|
||||
char pending_data[pending_size];
|
||||
if (pending_size > 0) {
|
||||
ESP_ERROR_CHECK(esp_partition_read(partition, i * chunk_size, pending_data,
|
||||
pending_size));
|
||||
httpd_resp_send_chunk(req, pending_data, pending_size);
|
||||
}
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
extern const unsigned char index_start[] asm("_binary_index_html_start");
|
||||
extern const unsigned char index_end[] asm("_binary_index_html_end");
|
||||
|
||||
static esp_err_t crash_get_handler(httpd_req_t *req) {
|
||||
const size_t index_size = (index_end - index_start);
|
||||
httpd_resp_set_type(req, "text/html");
|
||||
httpd_resp_send_chunk(req, (const char *)index_start, index_size);
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
assert(0);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static const httpd_uri_t download = {
|
||||
.uri = "/download",
|
||||
.method = HTTP_GET,
|
||||
.handler = download_get_handler,
|
||||
.user_ctx = NULL,
|
||||
};
|
||||
|
||||
static const httpd_uri_t crash = {
|
||||
.uri = "/crash",
|
||||
.method = HTTP_GET,
|
||||
.handler = crash_get_handler,
|
||||
.user_ctx = NULL,
|
||||
};
|
||||
static esp_err_t root_get_handler(httpd_req_t *req) {
|
||||
const size_t index_size = (index_end - index_start);
|
||||
httpd_resp_set_type(req, "text/html");
|
||||
httpd_resp_send_chunk(req, (const char *)index_start, index_size);
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
static const httpd_uri_t root = {
|
||||
.uri = "/",
|
||||
.method = HTTP_GET,
|
||||
.handler = root_get_handler,
|
||||
.user_ctx = NULL,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static httpd_handle_t start_webserver(void) {
|
||||
httpd_handle_t server = NULL;
|
||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||
config.max_resp_headers = 1024;
|
||||
config.lru_purge_enable = true;
|
||||
|
||||
// Start the httpd server
|
||||
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
|
||||
if (httpd_start(&server, &config) == ESP_OK) {
|
||||
// Set URI handlers
|
||||
ESP_LOGI(TAG, "Registering URI handlers");
|
||||
httpd_register_uri_handler(server, &root);
|
||||
httpd_register_uri_handler(server, &download);
|
||||
httpd_register_uri_handler(server, &crash);
|
||||
return server;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Error starting server!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
@ -451,6 +549,11 @@ void app_main(void)
|
||||
}
|
||||
|
||||
mqtt_app_start();
|
||||
while(!mainState.wifi_init){
|
||||
vTaskDelay(pdTICKS_TO_MS(10));
|
||||
}
|
||||
start_webserver();
|
||||
|
||||
|
||||
/*
|
||||
// Configuration de la sonde Temp/Humid.
|
||||
|
||||
@ -7,3 +7,4 @@ factory,app,factory,,3M,,
|
||||
ota_0,app,ota_0,,3M,,
|
||||
ota_1,app,ota_1,,3M,,
|
||||
littlefs,data,littlefs,,1M,,
|
||||
coredump, data, coredump,,64K,,
|
||||
|
||||
|
69
sdkconfig
69
sdkconfig
@ -687,24 +687,12 @@ CONFIG_PARTITION_TABLE_MD5=y
|
||||
# end of Partition Table
|
||||
|
||||
#
|
||||
# Example Configuration
|
||||
# Domotic Configuration
|
||||
#
|
||||
CONFIG_ESP_WIFI_SSID="myssid"
|
||||
CONFIG_ESP_WIFI_PASSWORD="mypassword"
|
||||
# CONFIG_ESP_WPA3_SAE_PWE_HUNT_AND_PECK is not set
|
||||
# CONFIG_ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT is not set
|
||||
CONFIG_ESP_WPA3_SAE_PWE_BOTH=y
|
||||
CONFIG_ESP_WIFI_PW_ID=""
|
||||
CONFIG_ESP_MAXIMUM_RETRY=5
|
||||
# CONFIG_ESP_WIFI_AUTH_OPEN is not set
|
||||
# CONFIG_ESP_WIFI_AUTH_WEP is not set
|
||||
# CONFIG_ESP_WIFI_AUTH_WPA_PSK is not set
|
||||
CONFIG_ESP_WIFI_AUTH_WPA2_PSK=y
|
||||
# CONFIG_ESP_WIFI_AUTH_WPA_WPA2_PSK is not set
|
||||
# CONFIG_ESP_WIFI_AUTH_WPA3_PSK is not set
|
||||
# CONFIG_ESP_WIFI_AUTH_WPA2_WPA3_PSK is not set
|
||||
# CONFIG_ESP_WIFI_AUTH_WAPI_PSK is not set
|
||||
# end of Example Configuration
|
||||
CONFIG_GPIO_INPUT_CAPTEUR_PIR=4
|
||||
# end of Domotic Configuration
|
||||
|
||||
#
|
||||
# Example Connection Configuration
|
||||
@ -1037,6 +1025,19 @@ CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y
|
||||
CONFIG_ESP_HTTP_CLIENT_EVENT_POST_TIMEOUT=2000
|
||||
# end of ESP HTTP client
|
||||
|
||||
#
|
||||
# HTTP Server
|
||||
#
|
||||
CONFIG_HTTPD_MAX_REQ_HDR_LEN=512
|
||||
CONFIG_HTTPD_MAX_URI_LEN=512
|
||||
CONFIG_HTTPD_ERR_RESP_NO_DELAY=y
|
||||
CONFIG_HTTPD_PURGE_BUF_LEN=32
|
||||
# CONFIG_HTTPD_LOG_PURGE_DATA is not set
|
||||
# CONFIG_HTTPD_WS_SUPPORT is not set
|
||||
# CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set
|
||||
CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000
|
||||
# end of HTTP Server
|
||||
|
||||
#
|
||||
# ESP HTTPS OTA
|
||||
#
|
||||
@ -1228,10 +1229,7 @@ CONFIG_SPIRAM_MODE_HEX=y
|
||||
CONFIG_SPIRAM_SPEED_200M=y
|
||||
# CONFIG_SPIRAM_SPEED_20M is not set
|
||||
CONFIG_SPIRAM_SPEED=200
|
||||
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
|
||||
CONFIG_SPIRAM_RODATA=y
|
||||
CONFIG_SPIRAM_XIP_FROM_PSRAM=y
|
||||
CONFIG_SPIRAM_FLASH_LOAD_TO_PSRAM=y
|
||||
# CONFIG_SPIRAM_XIP_FROM_PSRAM is not set
|
||||
# CONFIG_SPIRAM_ECC_ENABLE is not set
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
@ -1400,6 +1398,26 @@ CONFIG_ESP_WIFI_TX_HETB_QUEUE_NUM=3
|
||||
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y
|
||||
# end of Wi-Fi
|
||||
|
||||
#
|
||||
# Core dump
|
||||
#
|
||||
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=y
|
||||
# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set
|
||||
# CONFIG_ESP_COREDUMP_ENABLE_TO_NONE is not set
|
||||
# CONFIG_ESP_COREDUMP_DATA_FORMAT_BIN is not set
|
||||
CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=y
|
||||
CONFIG_ESP_COREDUMP_CHECKSUM_CRC32=y
|
||||
# CONFIG_ESP_COREDUMP_CHECKSUM_SHA256 is not set
|
||||
# CONFIG_ESP_COREDUMP_CAPTURE_DRAM is not set
|
||||
CONFIG_ESP_COREDUMP_CHECK_BOOT=y
|
||||
CONFIG_ESP_COREDUMP_ENABLE=y
|
||||
CONFIG_ESP_COREDUMP_LOGS=y
|
||||
CONFIG_ESP_COREDUMP_MAX_TASKS_NUM=64
|
||||
# CONFIG_ESP_COREDUMP_FLASH_NO_OVERWRITE is not set
|
||||
CONFIG_ESP_COREDUMP_STACK_SIZE=0
|
||||
CONFIG_ESP_COREDUMP_SUMMARY_STACKDUMP_SIZE=1024
|
||||
# end of Core dump
|
||||
|
||||
#
|
||||
# FAT Filesystem support
|
||||
#
|
||||
@ -1491,12 +1509,13 @@ CONFIG_FREERTOS_RUN_TIME_COUNTER_TYPE_U32=y
|
||||
#
|
||||
# Port
|
||||
#
|
||||
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
|
||||
# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
|
||||
CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y
|
||||
# CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set
|
||||
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
|
||||
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
|
||||
CONFIG_FREERTOS_ISR_STACKSIZE=1536
|
||||
CONFIG_FREERTOS_ISR_STACKSIZE=2096
|
||||
CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y
|
||||
CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y
|
||||
CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y
|
||||
@ -2969,6 +2988,16 @@ CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y
|
||||
CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y
|
||||
CONFIG_WPA_MBEDTLS_CRYPTO=y
|
||||
CONFIG_WPA_MBEDTLS_TLS_CLIENT=y
|
||||
CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH=y
|
||||
# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set
|
||||
# CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE is not set
|
||||
# CONFIG_ESP32_COREDUMP_DATA_FORMAT_BIN is not set
|
||||
CONFIG_ESP32_COREDUMP_DATA_FORMAT_ELF=y
|
||||
CONFIG_ESP32_COREDUMP_CHECKSUM_CRC32=y
|
||||
# CONFIG_ESP32_COREDUMP_CHECKSUM_SHA256 is not set
|
||||
CONFIG_ESP32_ENABLE_COREDUMP=y
|
||||
CONFIG_ESP32_CORE_DUMP_MAX_TASKS_NUM=64
|
||||
CONFIG_ESP32_CORE_DUMP_STACK_SIZE=0
|
||||
CONFIG_TIMER_TASK_PRIORITY=1
|
||||
CONFIG_TIMER_TASK_STACK_DEPTH=2048
|
||||
CONFIG_TIMER_QUEUE_LENGTH=10
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user