1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-06-19 08:00:27 -07:00

Factory reset

This commit is contained in:
Peter Antypas 2023-01-16 21:04:58 -08:00
parent 0ad710f2ff
commit 2df4e596e2
8 changed files with 64 additions and 14 deletions

View File

@ -1,10 +1,6 @@
# Build directory
build
build_dev/
build_prod/
build_factory/
build_sample/
sdkconfig
*.lock

View File

@ -5,6 +5,6 @@
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(EXTRA_COMPONENT_DIRS bsp core html)
set(EXTRA_COMPONENT_DIRS bsp core html bootloader_components)
list (APPEND EXTRA_COMPONENT_DIRS components)
project(MaianaWiFiAdapter)

View File

@ -0,0 +1,6 @@
idf_component_register(SRCS
"bootloader_hooks.c"
PRIV_REQUIRES hal
)

View File

@ -0,0 +1,35 @@
#include <hal/gpio_hal.h>
#include <unistd.h>
#include <esp_log.h>
#define GPIO_RED_LED GPIO_NUM_5
#define GPIO_GREEN_LED GPIO_NUM_4
void bootloader_hooks_include(void)
{
}
void bootloader_before_init(void)
{
ESP_LOGI("hook", "Custom hook (before init)");
}
void bootloader_after_init(void)
{
/**
* @brief Turn on both LEDs immediately. This way, if firmware is hosed and can't run,
* at least there's an indication that the system is on.
*
*/
ESP_LOGI("hook", "Custom hook (after init)");
gpio_ll_output_enable(&GPIO, GPIO_GREEN_LED);
gpio_ll_output_enable(&GPIO, GPIO_RED_LED);
gpio_ll_set_level(&GPIO, GPIO_GREEN_LED, 1);
gpio_ll_set_level(&GPIO, GPIO_RED_LED, 1);
//sleep(1);
}

View File

@ -20,6 +20,8 @@ uint8_t dtmp[RD_BUF_SIZE];
#define GPIO_UART1_RX GPIO_NUM_25
#define GPIO_UART1_TX GPIO_NUM_26
#define GPIO_TX_BUTTON GPIO_NUM_34
#define GPIO_RED_LED GPIO_NUM_5
#define GPIO_GREEN_LED GPIO_NUM_4
void uart_rx_task(void *params)
{
@ -111,6 +113,17 @@ void bsp_hw_init()
gpio_set_direction(GPIO_TX_BUTTON, GPIO_MODE_INPUT);
gpio_set_intr_type(GPIO_TX_BUTTON, GPIO_INTR_NEGEDGE);
config_gpio(GPIO_RED_LED, GPIO_MODE_OUTPUT, false, false);
config_gpio(GPIO_GREEN_LED, GPIO_MODE_OUTPUT, false, false);
#if 0
gpio_set_direction(GPIO_RED_LED, GPIO_MODE_OUTPUT);
gpio_set_direction(GPIO_GREEN_LED, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_RED_LED, 1);
gpio_set_level(GPIO_GREEN_LED, 1);
#endif
gpio_install_isr_service(0);
gpio_isr_handler_add(GPIO_TX_BUTTON, btn_isr, NULL);
bsp_timer_init();

View File

@ -29,7 +29,7 @@ void app_main(void)
esp_event_loop_create_default();
esp_event_handler_register(MAIANA_EVENT, REBOOT_EVENT, reboot_handler, NULL);
//sleep(5);
config_init();
//config_reset_all();

View File

@ -3,6 +3,6 @@
nvs, data, nvs, 0x9000, 16K
otadata, data, ota, , 8K
phy_init, data, phy, , 4K
factory, app, factory, , 1536K
ota_0, app, ota_0, , 1536K
ota_1, app, ota_1, , 1536K
storage, data, fat, , 900K

1 # Partition Table
3 nvs, data, nvs, 0x9000, 16K
4 otadata, data, ota, , 8K
5 phy_init, data, phy, , 4K
6 factory, app, factory, , 1536K
7 ota_0, app, ota_0, , 1536K
ota_1, app, ota_1, , 1536K
8 storage, data, fat, , 900K

View File

@ -43,13 +43,13 @@ CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_INFO is not set
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set
CONFIG_BOOTLOADER_LOG_LEVEL=0
CONFIG_BOOTLOADER_LOG_LEVEL=3
# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set
CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y
CONFIG_BOOTLOADER_FACTORY_RESET=y
@ -1225,13 +1225,13 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
# Deprecated options for backward compatibility
CONFIG_TOOLPREFIX="xtensa-esp32-elf-"
CONFIG_LOG_BOOTLOADER_LEVEL_NONE=y
# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_INFO is not set
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y
# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set
CONFIG_LOG_BOOTLOADER_LEVEL=0
CONFIG_LOG_BOOTLOADER_LEVEL=3
# CONFIG_APP_ROLLBACK_ENABLE is not set
# CONFIG_FLASH_ENCRYPTION_ENABLED is not set
# CONFIG_FLASHMODE_QIO is not set