Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 2, 2024
1 parent b62f38d commit 4a43791
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
26 changes: 26 additions & 0 deletions common/droidboot_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down
2 changes: 1 addition & 1 deletion common/droidboot_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion config_parser/droidboot_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion droidboot_platforms
8 changes: 5 additions & 3 deletions dualboot_gui/dualboot_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ 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");

char s[128]="";
sprintf(s,"%u", index);
ret=ext4_fwrite(&f, s, 128, 0);
ret=ext4_fclose(&f);
#endif

if(!strcmp((droidboot_entry_list + index)->kernel, "null"))
{
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions lib/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a43791

Please sign in to comment.