From 4a43791444476d182e231447c3046146b3a6a6c9 Mon Sep 17 00:00:00 2001 From: nift4 Date: Fri, 2 Aug 2024 17:30:07 +0200 Subject: [PATCH] misc changes --- CMakeLists.txt | 4 +--- common/droidboot_init.c | 26 ++++++++++++++++++++++++++ common/droidboot_main.c | 2 +- config_parser/droidboot_config.c | 3 ++- droidboot_platforms | 2 +- dualboot_gui/dualboot_menu.c | 8 +++++--- lib/lv_conf.h | 5 +++-- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc72fe7..2ada481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,4 @@ target_include_directories(droidboot_gui PUBLIC droidboot_platforms/libc-hack/lk include . -) -target_compile_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer) -target_link_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize=undefined) \ No newline at end of file +) \ No newline at end of file diff --git a/common/droidboot_init.c b/common/droidboot_init.c index 1a4f80e..67e0e48 100644 --- a/common/droidboot_init.c +++ b/common/droidboot_init.c @@ -5,7 +5,33 @@ /*A static variable to store the buffers*/ static lv_disp_draw_buf_t disp_buf; +static void droidboot_lvgl_print(const char * buf) { + droidboot_log_level ll = DROIDBOOT_LOG_ERROR; + if (buf[0] == '[' && buf[1] != '\0' && buf[2] != '\0' && buf[3] != '\0' && buf[4] != '\0') { + if (buf[5] == ']') { + if (buf[1] == 'I' && buf[2] == 'n' && buf[3] == 'f' && buf[4] == 'o') { + ll = DROIDBOOT_LOG_TRACE; // LVGL info is relatively useless and equivalent of our TRACE + } + if (buf[1] == 'U' && buf[2] == 's' && buf[3] == 'e' && buf[4] == 'r') { + ll = DROIDBOOT_LOG_ERROR; + } + if (buf[1] == 'W' && buf[2] == 'a' && buf[3] == 'r' && buf[4] == 'n') { + ll = DROIDBOOT_LOG_WARNING; + } + } else if (buf[5] != '\0' && buf[6] == ']') { + if (buf[1] == 'E' && buf[2] == 'r' && buf[3] == 'r' && buf[4] == 'o' && buf[5] == 'r') { + ll = DROIDBOOT_LOG_ERROR; + } + if (buf[1] == 'T' && buf[2] == 'r' && buf[3] == 'a' && buf[4] == 'c' && buf[5] == 'e') { + ll = DROIDBOOT_LOG_TRACE; + } + } + } + droidboot_log(ll, "%s", buf); +} + droidboot_error droidboot_lvgl_init(){ + lv_log_register_print_cb(droidboot_lvgl_print); lv_init(); /*Use double buffering*/ diff --git a/common/droidboot_main.c b/common/droidboot_main.c index d7eac67..ff2afb8 100644 --- a/common/droidboot_main.c +++ b/common/droidboot_main.c @@ -66,7 +66,7 @@ void droidboot_show_dualboot_menu() droidboot_log(DROIDBOOT_LOG_INFO, "droidboot main: found %d entries\n", droidboot_num_of_boot_entries); // Init styles - //droidboot_style_init(droidboot_global_config); + droidboot_style_init(droidboot_global_config); // Show dualboot menu droidboot_draw_dualboot_menu(droidboot_entry_list, droidboot_global_config, droidboot_num_of_boot_entries); diff --git a/config_parser/droidboot_config.c b/config_parser/droidboot_config.c index c856bc2..2ac0fc5 100644 --- a/config_parser/droidboot_config.c +++ b/config_parser/droidboot_config.c @@ -172,7 +172,6 @@ int get_dualboot_entry_count(void) { int parse_boot_entries(struct boot_entry **_entry_list) { int ret; droidboot_log(DROIDBOOT_LOG_TRACE, "hi from entries parse \n"); - struct boot_entry *entry_list=malloc(sizeof(struct boot_entry)*dir_count_entries(ENTRIES_DIR)); //ret=ext4_mount("abm_settings", "/boot/", false); // if(ret!=DROIDBOOT_EOK) @@ -185,7 +184,9 @@ int parse_boot_entries(struct boot_entry **_entry_list) { droidboot_log(DROIDBOOT_LOG_TRACE, "config_parser: found %d entries\n"); if (ret < 0) { entry_count = 0; + return ret; } + struct boot_entry *entry_list=malloc(sizeof(struct boot_entry)*entry_count); const ext4_direntry *de; ext4_dir d; diff --git a/droidboot_platforms b/droidboot_platforms index 81020d6..d00f658 160000 --- a/droidboot_platforms +++ b/droidboot_platforms @@ -1 +1 @@ -Subproject commit 81020d60b95888d8e9ac0467cd6484b0a7206bc4 +Subproject commit d00f658a25180c104c9e14fee8e055883e1f2db2 diff --git a/dualboot_gui/dualboot_menu.c b/dualboot_gui/dualboot_menu.c index e50e518..d86963a 100644 --- a/dualboot_gui/dualboot_menu.c +++ b/dualboot_gui/dualboot_menu.c @@ -37,6 +37,7 @@ static void event_handler(lv_event_t * e) if(code == LV_EVENT_CLICKED) { //lvgl_show_boot_logo(); // Lets firstly write index to metadata +#ifndef PLATFORM_SIMULATOR ext4_file f; int ret = ext4_fopen(&f, "/boot/db/last_index", "wb"); @@ -44,6 +45,7 @@ static void event_handler(lv_event_t * e) sprintf(s,"%u", index); ret=ext4_fwrite(&f, s, 128, 0); ret=ext4_fclose(&f); +#endif if(!strcmp((droidboot_entry_list + index)->kernel, "null")) { @@ -191,14 +193,14 @@ void droidboot_draw_dualboot_menu(struct boot_entry *droidboot_entry_list1, stru lv_obj_set_size(win, lv_pct(100), lv_pct(100)); lv_obj_t * win_title = lv_win_add_title(win, "Select OS"); lv_obj_set_pos(win_title, 0, 0); - //lv_obj_add_style(lv_win_get_header(win), &droidboot_win_style, 0); - //lv_obj_add_style(win, &droidboot_win_style, 0); + lv_obj_add_style(lv_win_get_header(win), &droidboot_win_style, 0); + lv_obj_add_style(win, &droidboot_win_style, 0); lv_obj_t * list1 = lv_list_create(win); lv_obj_set_size(list1, lv_pct(100), lv_pct(100)); lv_obj_set_pos(list1, 0, 00); lv_obj_align(list1, LV_ALIGN_BOTTOM_MID, 0, 0); - //lv_obj_add_style(list1, &droidboot_list_style, 0); + lv_obj_add_style(list1, &droidboot_list_style, 0); droidboot_add_dualboot_menu_buttons(list1); no_autoboot = false; diff --git a/lib/lv_conf.h b/lib/lv_conf.h index 3f7fde7..29b0b95 100644 --- a/lib/lv_conf.h +++ b/lib/lv_conf.h @@ -204,11 +204,12 @@ *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ - #define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR + // this is redirected to appropriate droidboot log level so INFO is fine too + #define LV_LOG_LEVEL LV_LOG_LEVEL_INFO /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ - #define LV_LOG_PRINTF 1 + #define LV_LOG_PRINTF 0 /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ #define LV_LOG_TRACE_MEM 1