idf.py app now builds both squeezelite and recovery in a single pass

This commit is contained in:
Sebastien
2020-03-09 23:47:15 -04:00
parent d93e691534
commit 879272dfe4
35 changed files with 176 additions and 217 deletions

View File

@@ -1,5 +1,17 @@
idf_component_register( SRC_DIRS .
idf_component_register( SRCS
cmd_i2ctools.c
cmd_nvs.c
cmd_ota.c
cmd_system.c
cmd_wifi.c
platform_console.c
INCLUDE_DIRS .
REQUIRES nvs_flash
PRIV_REQUIRES console tools services spi_flash app_update platform_config vfs pthread wifi-manager platform_config squeezelite )
PRIV_REQUIRES console tools services spi_flash app_update platform_config vfs pthread wifi-manager platform_config codecs newlib )
#target_link_libraries(__idf_platform_console $<IF:${recovery_build}, ${build_dir}/esp-idf/app_recovery/libapp_recovery.a,${build_dir}/esp-idf/app_squeezelite/libapp_squeezelite.a > )
message($<TARGET_PROPERTY:RECOVERY_PREFIX>)
target_link_libraries(__idf_platform_console ${build_dir}/esp-idf/$<TARGET_PROPERTY:RECOVERY_PREFIX>/lib$<TARGET_PROPERTY:RECOVERY_PREFIX>.a )
#target_link_libraries(__idf_platform_console $<NOT ${recovery_build}:${build_dir}/esp-idf/app_squeezelite/libapp_squeezelite )

View File

@@ -0,0 +1,13 @@
idf_component_register( SRC_DIRS .
INCLUDE_DIRS .
)
#idf_build_get_property(IS_RECOVERY 0 )
#target_link_options(__idf_platform_console PUBLIC $<$<EQUAL:${IS_RECOVERY},1>:${COMPONENT_LIB}>)
#add_library(libcmd_squeezelite STATIC cmd_squeezelite.c )
#__component_add_include_dirs(libcmd_squeezelite "${__INCLUDE_DIRS}" INTERFACE)
#set_property(TARGET libcmd_squeezelite APPEND PROPERTY LINK_LIBRARIES console)
#set_property(TARGET libcmd_squeezelite APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<LINK_ONLY:console>)
#
#
#add_library(librecovery STATIC recovery.c )
#target_link_options(${COMPONENT_LIB} PUBLIC $<IF:${IS_RECOVERY},librecovery.a,libcmd_squeezelite.a>)

View File

@@ -0,0 +1,5 @@
int main(int argc, char **argv){
return 1;
}
void register_squeezelite(){
}

View File

@@ -0,0 +1,4 @@
idf_component_register( SRC_DIRS .
INCLUDE_DIRS .
PRIV_REQUIRES console squeezelite pthread tools platform_config)

View File

@@ -1,10 +1,5 @@
//size_t esp_console_split_argv(char *line, char **argv, size_t argv_size);
#include "cmd_squeezelite.h"
#include <stdio.h>
#include <string.h>
#include "cmd_decl.h"
#include "esp_log.h"
#include "esp_console.h"

View File

@@ -1,13 +0,0 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
// Register WiFi functions
void register_squeezelite();
#ifdef __cplusplus
}
#endif

View File

@@ -99,7 +99,7 @@ static void register_version()
esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
{
#if RECOVERY_APPLICATION
if(is_recovery_running){
if(partition_subtype ==ESP_PARTITION_SUBTYPE_APP_FACTORY){
ESP_LOGW(TAG,"RECOVERY application is already active");
if(!wait_for_commit()){
@@ -110,7 +110,8 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
esp_restart();
return ESP_OK;
}
#else
}
else {
if(partition_subtype !=ESP_PARTITION_SUBTYPE_APP_FACTORY){
ESP_LOGW(TAG,"SQUEEZELITE application is already active");
if(!wait_for_commit()){
@@ -121,7 +122,7 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
esp_restart();
return ESP_OK;
}
#endif
}
esp_err_t err = ESP_OK;
bool bFound=false;
ESP_LOGI(TAG, "Looking for partition type %u",partition_subtype);

View File

@@ -27,14 +27,13 @@
#include "cmd_decl.h"
#include "wifi_manager.h"
#include "cmd_squeezelite.h"
#include "platform_config.h"
pthread_t thread_console;
static void * console_thread();
void console_start();
static const char * TAG = "console";
extern bool bypass_wifi_manager;
extern void register_squeezelite();
/* Prompt to be printed before each line.
* This can be customized, made dynamic, etc.
@@ -60,10 +59,9 @@ void process_autoexec(){
if(!bypass_wifi_manager){
ESP_LOGW(TAG, "Processing autoexec commands while wifi_manager active. Wifi related commands will be ignored.");
}
#if RECOVERY_APPLICATION
ESP_LOGD(TAG, "Processing autoexec commands in recovery mode. Squeezelite commands will be ignored.");
#endif
if(is_recovery_running){
ESP_LOGD(TAG, "Processing autoexec commands in recovery mode. Squeezelite commands will be ignored.");
}
if(str_flag !=NULL ){
autoexec_flag=atoi(str_flag);
ESP_LOGI(TAG,"autoexec is set to %s auto-process", autoexec_flag>0?"perform":"skip");
@@ -76,11 +74,9 @@ void process_autoexec(){
if(!bypass_wifi_manager && strstr(autoexec_value, "join ")!=NULL ){
ESP_LOGW(TAG,"Ignoring wifi join command.");
}
#if RECOVERY_APPLICATION
else if(!strstr(autoexec_value, "squeezelite " ) ){
else if(is_recovery_running && !strstr(autoexec_value, "squeezelite " ) ){
ESP_LOGW(TAG,"Ignoring command. ");
}
#endif
else {
ESP_LOGI(TAG,"Running command %s = %s", autoexec_name, autoexec_value);
run_command(autoexec_value);
@@ -164,32 +160,30 @@ void console_start() {
register_system();
register_nvs();
register_wifi();
#if RECOVERY_APPLICATION!=1
register_squeezelite();
#elif RECOVERY_APPLICATION==1
register_ota_cmd();
#else
#error "Unknown build configuration"
#endif
if(!is_recovery_running){
register_squeezelite();
}
else {
register_ota_cmd();
}
register_i2ctools();
printf("\n"
#if RECOVERY_APPLICATION
"****************************************************************\n"
"RECOVERY APPLICATION\n"
"This mode is used to flash Squeezelite into the OTA partition\n"
"****\n\n"
#endif
"Type 'help' to get the list of commands.\n"
"Use UP/DOWN arrows to navigate through command history.\n"
"Press TAB when typing command name to auto-complete.\n"
"\n"
#if !RECOVERY_APPLICATION
"To automatically execute lines at startup:\n"
"\tSet NVS variable autoexec (U8) = 1 to enable, 0 to disable automatic execution.\n"
"\tSet NVS variable autoexec[1~9] (string)to a command that should be executed automatically\n"
#endif
"\n"
"\n");
printf("\n");
if(is_recovery_running){
printf("****************************************************************\n"
"RECOVERY APPLICATION\n"
"This mode is used to flash Squeezelite into the OTA partition\n"
"****\n\n");
}
printf("Type 'help' to get the list of commands.\n"
"Use UP/DOWN arrows to navigate through command history.\n"
"Press TAB when typing command name to auto-complete.\n"
"\n");
if(!is_recovery_running){
printf("To automatically execute lines at startup:\n"
"\tSet NVS variable autoexec (U8) = 1 to enable, 0 to disable automatic execution.\n"
"\tSet NVS variable autoexec[1~9] (string)to a command that should be executed automatically\n");
}
printf("\n\n");
/* Figure out if the terminal supports escape sequences */
int probe_status = linenoiseProbe();
@@ -211,9 +205,9 @@ void console_start() {
esp_pthread_cfg_t cfg = esp_pthread_get_default_config();
cfg.thread_name= "console";
cfg.inherit_cfg = true;
#if RECOVERY_APPLICATION
cfg.stack_size = 4096 ;
#endif
if(is_recovery_running){
cfg.stack_size = 4096 ;
}
esp_pthread_set_cfg(&cfg);
pthread_attr_t attr;
pthread_attr_init(&attr);
@@ -238,9 +232,9 @@ void run_command(char * line){
}
}
static void * console_thread() {
#if !RECOVERY_APPLICATION
process_autoexec();
#endif
if(!is_recovery_running){
process_autoexec();
}
/* Main loop */
while (1) {
/* Get a line using linenoise.