Skip to content

Commit

Permalink
abm bringup
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Jul 30, 2024
1 parent 121c898 commit 09e8beb
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 102 deletions.
2 changes: 1 addition & 1 deletion app/droidboot_gui
60 changes: 51 additions & 9 deletions app/mt_boot/mt_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ extern void *g_fdt;

int boot_linux_fdt(void *kernel, unsigned *tags,
unsigned machtype,
void *ramdisk, unsigned ramdisk_sz)
void *ramdisk, unsigned ramdisk_sz, unsigned char *kernel_raw, off_t kernel_raw_size)
{
void *fdt = tags;
int ret;
Expand Down Expand Up @@ -841,10 +841,19 @@ int boot_linux_fdt(void *kernel, unsigned *tags,
* LK start: 0x41E00000, Kernel Start: 0x40080000
* Max is 0x41E00000 - 0x40080000 = 0x1D80000.
* using 0x1C00000=28MB for decompressed kernel image size */
if (decompress_kernel((unsigned char *)(kernel_load_addr),
(void *)kernel_target_addr, (int)zimage_size,
(int)kernel_sz_mb)) {
panic("decompress kernel image fail!!!\n");
if(kernel_raw==NULL){
if (decompress_kernel((unsigned char *)(kernel_load_addr),
(void *)kernel_target_addr, (int)zimage_size,
(int)kernel_sz_mb)) {
panic("decompress kernel image fail!!!\n");
}
} else {
video_printf("Custom kernel found, decomressing it\n");
if (decompress_kernel((unsigned char *)(kernel_raw),
(void *)kernel_target_addr, (int)kernel_raw_size,
(int)kernel_sz_mb)) {
panic("decompress kernel image fail!!!\n");
}
}
} else {
pal_log_info("32 bits kernel\n");
Expand Down Expand Up @@ -1678,12 +1687,12 @@ int boot_linux_fdt(void *kernel, unsigned *tags,

void boot_linux(void *kernel, unsigned *tags,
unsigned machtype,
void *ramdisk, unsigned ramdisk_sz)
void *ramdisk, unsigned ramdisk_sz, unsigned char *kernel_raw, off_t kernel_raw_size)
{
#ifdef DEVICE_TREE_SUPPORT
boot_linux_fdt((void *)kernel, (unsigned *)tags,
machtype,
(void *)ramdisk, ramdisk_sz);
(void *)ramdisk, ramdisk_sz, kernel_raw, kernel_raw_size);
panic("%s Fail to enter EL1\n", __func__);
#endif
}
Expand Down Expand Up @@ -1712,6 +1721,30 @@ void get_AB_OTA_name(char *part_name, int size)
#endif /* MTK_AB_OTA_UPDATER */

int boot_linux_from_storage(void)
{
uint32_t kernel_target_addr = 0;
uint32_t ramdisk_target_addr = 0;
uint32_t tags_target_addr = 0;
uint32_t ramdisk_real_sz = 0;
kernel_target_addr = get_kernel_target_addr();
ramdisk_target_addr = get_ramdisk_target_addr();
ramdisk_real_sz = get_ramdisk_real_sz();
tags_target_addr = get_tags_addr();

/* pass related root of trust info via SMC call */
send_root_of_trust_info();
set_boot_phase(BOOT_PHASE_KERNEL);

boot_linux((void *)kernel_target_addr,
(unsigned *)tags_target_addr,
board_machtype(),
(void *)ramdisk_target_addr,
ramdisk_real_sz, NULL, 0);

return 0;
}

static void mtk_pre_boot()
{
int ret = 0;
uint32_t kernel_target_addr = 0;
Expand Down Expand Up @@ -1860,16 +1893,22 @@ int boot_linux_from_storage(void)
} else {
cmdline_append("androidboot.meta_log_disable=0");
}
}

int mtk_boot_linux_from_ram(unsigned char *kernel_raw, off_t kernel_raw_size, unsigned char *ramdisk_raw, off_t ramdisk_size){
uint32_t kernel_target_addr = 0;
uint32_t tags_target_addr = 0;
kernel_target_addr = get_kernel_target_addr();
tags_target_addr = get_tags_addr();
/* pass related root of trust info via SMC call */
send_root_of_trust_info();
set_boot_phase(BOOT_PHASE_KERNEL);

boot_linux((void *)kernel_target_addr,
(unsigned *)tags_target_addr,
board_machtype(),
(void *)ramdisk_target_addr,
ramdisk_real_sz);
(void *)ramdisk_raw,
ramdisk_size, kernel_raw, kernel_raw_size);

return 0;
}
Expand Down Expand Up @@ -2093,6 +2132,9 @@ void mt_boot_init(const struct app_descriptor *app)
#endif

/* Will not return */
mtk_pre_boot();
droidboot_show_dualboot_menu();
video_printf("Going to boot linux from storage");
boot_linux_from_storage();

fastboot:
Expand Down
4 changes: 4 additions & 0 deletions platform/common/boot/boot_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ static uint32_t get_bootimg_ramdisk_load_addr(void)
return (uint32_t)ramdisk_addr;
}

uint32_t get_ramdisk_real_sz() {
return g_boot_info.bootimg_ramdisk_sz;
}

int relocate_ramdisk(uint32_t *ramdisk_addr, uint32_t *ramdisk_real_sz)
{
uint32_t ramdisk_load_addr;
Expand Down
89 changes: 3 additions & 86 deletions platform/common/boot_menu/boot_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,92 +47,9 @@
#include <sys/types.h>
#include <target/cust_key.h>
#include <video.h>

extern void cmdline_append(const char *append_string);
typedef void (*entry_cb)(void);

struct boot_menu {
u8 boot_mode;
const char *item_text;
entry_cb callback;
};

//register the callback function
void ftrace_cb()
{
cmdline_append("androidboot.boot_trace=1");
}

void kmemleak_cb()
{
cmdline_append("kmemleak=on");
}

void initcall_cb()
{
cmdline_append("initcall_debug=1 log_buf_len=4M");
}

struct boot_menu ui_entry[] = {
{RECOVERY_BOOT, "[Recovery Mode]", NULL},
{FASTBOOT, "[Fastboot Mode]", NULL},
{NORMAL_BOOT, "[Normal Boot]", NULL},
#if !defined(USER_LOAD) || defined(MTK_BUILD_ENHANCE_MENU)
{NORMAL_BOOT, "[Normal Boot +ftrace]", ftrace_cb},
{NORMAL_BOOT, "[Normal kmemleak on]", kmemleak_cb},
{NORMAL_BOOT, "[Normal Boot +initcall]", initcall_cb},
#endif
};

static void update_menu(unsigned int index) {
#define LEN 100
const char* title_msg = "Select Boot Mode:\n[VOLUME_UP to select. VOLUME_DOWN is OK.]\n\n";
char str_buf[LEN];
unsigned int i, length;

video_set_cursor(video_get_rows()/2, 0);
video_printf(title_msg);

for (i = 0; i < countof(ui_entry); i++) {
memset(str_buf, 0, LEN);
length = strlen(ui_entry[i].item_text);
snprintf(str_buf, length+1, "%s", ui_entry[i].item_text);
if (i == index) {
dprintf(0, "Switch to %s mode.\n", str_buf);
sprintf(str_buf+length, " <<==\n");
} else
sprintf(str_buf+length, " \n");
video_printf(str_buf);
}
}
#include <droidboot_platforms/lk/common_mtk/src/lk_mtk_common.h>

void boot_menu_select() {
//0=recovery mode 1=fastboot 2=normal boot
//3=normal boot + ftrace 4=kmemleak on 5=Boot + initcall
unsigned int select = 0;

video_clean_screen();
update_menu(0);

while (1) {
if (mtk_detect_key(MT65XX_MENU_SELECT_KEY)) { //VOL_UP
select = (select + 1) % countof(ui_entry);
update_menu(select);
mdelay(300);
} else if (mtk_detect_key(MT65XX_MENU_OK_KEY)) { //VOL_DOWN
//use for OK;
break;
}
}

dprintf(0, "Boot mode:%s is selected!\n", ui_entry[select].item_text);
g_boot_mode = ui_entry[select].boot_mode;

if (ui_entry[select].callback)
ui_entry[select].callback();

video_set_cursor(video_get_rows() / 2 + 8, 0);
video_clean_screen();

return;
video_printf("Enter droidboot_mtk_show_boot_mode_menu");
g_boot_mode=droidboot_mtk_show_boot_mode_menu();
}
2 changes: 1 addition & 1 deletion platform/mt6768/include/platform/mt_disp_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef enum {
// ---------------------------------------------------------------------------
// UBoot Display Export Functions
// ---------------------------------------------------------------------------

void mtkfb_draw_block(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int color);
UINT32 mt_disp_get_vram_size(void);
void mt_disp_init(void *lcdbase);
void mt_disp_power(BOOL on);
Expand Down
6 changes: 3 additions & 3 deletions platform/mt6768/mt_disp_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ int mt_disp_get_dfo_setting(const char *string, unsigned int *value)
}
#endif

static void _mtkfb_draw_block(unsigned int addr, unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int color)
void mtkfb_draw_block(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int color)
{
unsigned int i = 0;
unsigned int j = 0;
void* start_addr = (void*)(addr+ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT)*4*y+x*4);
void* start_addr = (void*)(fb_addr+ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT)*4*y+x*4);
unsigned int pitch = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT)*4;
unsigned int* line_addr = start_addr;

Expand All @@ -184,7 +184,7 @@ static int _mtkfb_internal_test(unsigned int va, unsigned int w, unsigned int h)
for (i = 0; i < w * h / _internal_test_block_size / _internal_test_block_size; i++) {
color = (i & 0x1) * 0xff;
color += 0xff000000U;
_mtkfb_draw_block(va,
mtkfb_draw_block(
i % (w / _internal_test_block_size) * _internal_test_block_size,
i / (w / _internal_test_block_size) * _internal_test_block_size,
_internal_test_block_size, _internal_test_block_size, color);
Expand Down
16 changes: 14 additions & 2 deletions platform/mt6768/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ extern u8 g_oemkey[OEM_PUBK_SZ];
#undef LK_DL_CHECK_BLOCK_LEVEL
#endif

//ABM include file with init functions
#include <droidboot_main.h>
#include <droidboot_boot_logo.h>

extern void platform_early_init_timer();
extern void jump_da(u32 addr, u32 arg1, u32 arg2);
extern int i2c_hw_init(void);
Expand Down Expand Up @@ -716,6 +720,12 @@ void platform_init(void)
#ifndef MACH_FPGA
PROFILING_START("boot mode select");

//ABM: init lvgl stuff
video_printf("Enter droidboot init\n");
mtk_wdt_disable();
droidboot_init();
mt65xx_backlight_on();
video_printf("Droidboot init done\n");
#if !defined(NO_BOOT_MODE_SEL)
boot_mode_select();
#endif
Expand Down Expand Up @@ -761,7 +771,8 @@ void platform_init(void)

#ifndef MACH_FPGA_NO_DISPLAY
PROFILING_START("show logo");
mt_disp_show_boot_logo();
droidboot_show_boot_logo();
video_printf("Droidboot show boot logo done\n");
PROFILING_END();
#endif
video_printf(" => Downloading...\n");
Expand Down Expand Up @@ -801,7 +812,8 @@ void platform_init(void)
mtk_bat_allow_backlight_enable()) {
#ifndef MACH_FPGA_NO_DISPLAY
PROFILING_START("show logo");
mt_disp_show_boot_logo();
droidboot_show_boot_logo();
video_printf("Droidboot show boot logo done\n");
PROFILING_END();
#endif // MACH_FPGA_NO_DISPLAY
#ifndef MACH_FPGA
Expand Down

0 comments on commit 09e8beb

Please sign in to comment.