diff --git a/lk/app/aboot/aboot.c b/lk/app/aboot/aboot.c index 4b3bdbd..16f5d12 100644 --- a/lk/app/aboot/aboot.c +++ b/lk/app/aboot/aboot.c @@ -680,6 +680,7 @@ void aboot_init(const struct app_descriptor *app) "to fastboot mode.\n"); fastboot: + htcleo_fastboot_init(); if(!usb_init) udc_init(&surf_udc_device); diff --git a/lk/app/aboot/recovery.c b/lk/app/aboot/recovery.c index 184d829..6adca18 100644 --- a/lk/app/aboot/recovery.c +++ b/lk/app/aboot/recovery.c @@ -223,11 +223,6 @@ int update_firmware_image (struct update_header *header, char *name) int recovery_init (void) { - /** cedesmith: we can't update radio like native android phones - * so there is no need for misc partition just to boot recovery - */ - return -1; - struct recovery_message msg; struct update_header header; char partition_name[32]; @@ -250,12 +245,15 @@ int recovery_init (void) return 0; } +// cedesmith: wince phone update radio and boot loader using spl +#ifndef WSPL_VADDR if (!strcmp("update-radio",msg.command)) { valid_command = 1; strcpy(partition_name, "FOTA"); } //Todo: Add support for bootloader update too. +#endif if(!valid_command) { //We need not to do anything diff --git a/lk/platform/qsd8k/rules.mk b/lk/platform/qsd8k/rules.mk index 88ddd40..73344c4 100644 --- a/lk/platform/qsd8k/rules.mk +++ b/lk/platform/qsd8k/rules.mk @@ -15,7 +15,6 @@ MODULES += dev/fbcon OBJS += \ $(LOCAL_DIR)/arch_init.o \ - $(LOCAL_DIR)/platform.o \ $(LOCAL_DIR)/interrupts.o \ $(LOCAL_DIR)/gpio.o \ $(LOCAL_DIR)/acpuclock.o diff --git a/lk/target/htcleo/htcleo_boot_s.S b/lk/target/htcleo/htcleo_boot_s.S index 0fe9d94..d08ccda 100644 --- a/lk/target/htcleo/htcleo_boot_s.S +++ b/lk/target/htcleo/htcleo_boot_s.S @@ -63,6 +63,16 @@ htcleo_boot_s: .ltorg +.global htcleo_flash +htcleo_flash: + ldr r4, =0xa9000864 + ldr r5, =0xa9000814 + orr r6, r4, #0x200000 + str r6, [r5, #0] + bx lr +.ltorg + + // code to put at 0, get opcode from debug.lst .global pc_reset_vector .global pc_reset_vector_end diff --git a/lk/target/htcleo/include/target/display.h b/lk/target/htcleo/include/target/display.h index 01c1066..f5f02b9 100644 --- a/lk/target/htcleo/include/target/display.h +++ b/lk/target/htcleo/include/target/display.h @@ -35,12 +35,13 @@ #define LCDC_FB_WIDTH 480 #define LCDC_FB_HEIGHT 800 -#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60 -#define LCDC_HSYNC_BACK_PORCH_DCLK 144 -#define LCDC_HSYNC_FRONT_PORCH_DCLK 33 +#define LCDC_HSYNC_PULSE_WIDTH_DCLK 2 +#define LCDC_HSYNC_BACK_PORCH_DCLK 30 +#define LCDC_HSYNC_FRONT_PORCH_DCLK 2 #define LCDC_HSYNC_SKEW_DCLK 0 #define LCDC_VSYNC_PULSE_WIDTH_LINES 2 -#define LCDC_VSYNC_BACK_PORCH_LINES 2 +#define LCDC_VSYNC_BACK_PORCH_LINES 5 #define LCDC_VSYNC_FRONT_PORCH_LINES 2 + #endif diff --git a/lk/target/htcleo/init.c b/lk/target/htcleo/init.c index 690d7e7..d1a4269 100644 --- a/lk/target/htcleo/init.c +++ b/lk/target/htcleo/init.c @@ -90,6 +90,7 @@ extern unsigned boot_into_recovery; void keypad_init(void); void display_init(void); +void display_lk_version(); void htcleo_ptable_dump(struct ptable *ptable); void cmd_dmesg(const char *arg, void *data, unsigned sz); void reboot(unsigned reboot_reason); @@ -110,8 +111,8 @@ void target_init(void) if (keys_get_state(keys[i]) != 0) { display_init(); - _dputs("cedesmith's LK (CLK) v1.1\n"); - dprintf(ALWAYS,"key %d pressed\n", i); + display_lk_version(); + //dprintf(ALWAYS,"key %d pressed\n", i); break; } dprintf(INFO, "htcleo_init\n"); @@ -175,6 +176,23 @@ void target_init(void) htcleo_ptable_dump(&flash_ptable); flash_set_ptable(&flash_ptable); } +void display_lk_version() +{ + _dputs("cedesmith's LK (CLK) v1.3\n"); +} +void htcleo_fastboot_init() +{ + // off charge and recovery boot failed, reboot to normal mode + if(get_boot_reason()==2) reboot(0); + + // display not initialized + if(fbcon_display()==NULL) + { + display_init(); + display_lk_version(); + htcleo_ptable_dump(&flash_ptable); + } +} void target_early_init(void) { //cedesmith: write reset vector while we can as MPU kicks in after flash_init(); diff --git a/lk/target/htcleo/platform.c b/lk/target/htcleo/platform.c new file mode 100644 index 0000000..82321d5 --- /dev/null +++ b/lk/target/htcleo/platform.c @@ -0,0 +1,39 @@ + +#include +#include +#include "target/display.h" +#include + +void platform_init_interrupts(void); +void platform_init_timer(); +void platform_early_init(void) +{ + platform_init_interrupts(); + platform_init_timer(); +} + +void platform_init(void) +{ + dprintf(INFO, "platform_init()\n"); +} + +#define FB_FORMAT_RGB565 0 +#define LCDC_FB_BPP 16 +#define MSM_MDP_BASE1 0xAA200000 + +static struct fbcon_config fb_cfg = { + .height = LCDC_FB_HEIGHT, + .width = LCDC_FB_WIDTH, + .stride = LCDC_FB_WIDTH, + .format = FB_FORMAT_RGB565, + .bpp = LCDC_FB_BPP, + .update_start = NULL, + .update_done = NULL, +}; +void display_init(void) +{ + fb_cfg.base = (unsigned*)readl( MSM_MDP_BASE1 + 0x90008); + fbcon_setup(&fb_cfg); + fbcon_clear(); +} + diff --git a/lk/target/htcleo/rules.mk b/lk/target/htcleo/rules.mk index 3a95c76..7a51567 100644 --- a/lk/target/htcleo/rules.mk +++ b/lk/target/htcleo/rules.mk @@ -6,7 +6,7 @@ PLATFORM := qsd8k #define system partition size (in MB), if not defined my custom (from magldr) layout is used. see init.c #DEFINES += SYSTEM_PARTITION_SIZE=150 -DEFINES += SYSTEM_PARTITION_SIZE=250 +#DEFINES += SYSTEM_PARTITION_SIZE=250 #cedesmith note: MEMBASE requires edit in platform/qsd8k/rules.mk #MEMBASE := 0x20000000 @@ -67,6 +67,8 @@ OBJS += \ $(LOCAL_DIR)/keypad.o \ $(LOCAL_DIR)/atags.o -OBJS += $(LOCAL_DIR)/htcleo_boot.o \ - $(LOCAL_DIR)/htcleo_boot_s.o +OBJS += \ + $(LOCAL_DIR)/htcleo_boot.o \ + $(LOCAL_DIR)/htcleo_boot_s.o\ + $(LOCAL_DIR)/platform.o diff --git a/patches/CWM_off_charge.patch b/patches/CWM_off_charge.patch new file mode 100644 index 0000000..e9b08cf --- /dev/null +++ b/patches/CWM_off_charge.patch @@ -0,0 +1,41 @@ +diff --git a/extendedcommands.c b/extendedcommands.c +index 1ce3bf1..2562e6c 100644 +--- a/extendedcommands.c ++++ b/extendedcommands.c +@@ -1110,21 +1110,25 @@ int volume_main(int argc, char **argv) { + } + + void handle_chargemode() { ++ // old code to read /proc/cmdline was broken because file size is always 0 so file_data was always empty string + const char* filename = "/proc/cmdline"; +- struct stat file_info; +- if (0 != stat(filename, &file_info)) +- return; +- +- int file_len = file_info.st_size; +- char* file_data = (char*)malloc(file_len + 1); + FILE *file = fopen(filename, "rb"); + if (file == NULL) + return; +- fread(file_data, file_len, 1, file); +- // supposedly not necessary, but let's be safe. ++ char file_data[1024]; ++ int file_len=fread(file_data, 1, 1023, file); + file_data[file_len] = '\0'; + fclose(file); +- ++ + if (strstr(file_data, "androidboot.mode=offmode_charging") != NULL) +- reboot(RB_POWER_OFF); ++ { ++ // let recovery kernel charge the battery, reboot on any key press so Android will start as user would expect ++ ev_init(); ++ struct input_event ev; ++ do ++ { ++ ev_get(&ev, 0); ++ } while (ev.type != EV_KEY || ev.code > KEY_MAX); ++ reboot(RB_AUTOBOOT); ++ } + } +\ No newline at end of file diff --git a/patches/cLK_power_collapse.patch b/patches/cLK_power_collapse.patch new file mode 100644 index 0000000..23a4881 --- /dev/null +++ b/patches/cLK_power_collapse.patch @@ -0,0 +1,32 @@ +diff --git a/arch/arm/mach-msm/board-htcleo.c b/arch/arm/mach-msm/board-htcleo.c +index e13205b..ee7680e 100644 +--- a/arch/arm/mach-msm/board-htcleo.c ++++ b/arch/arm/mach-msm/board-htcleo.c +@@ -87,6 +87,7 @@ static int __init parse_tag_nand_boot(const struct tag *tag) + { + struct tag_magldr_entry *mentry = (struct tag_magldr_entry *)(&tag->u); + nand_boot = !(unsigned int)mentry->fNoNandBoot; ++ if(*((unsigned*)&tag->u)==0x004b4c63) nand_boot = 2; // cLK signature + pr_info("Nand Boot: %d\n", nand_boot); + return 0; + } +diff --git a/arch/arm/mach-msm/pm.c b/arch/arm/mach-msm/pm.c +index 8766174..56ccb2a 100644 +--- a/arch/arm/mach-msm/pm.c ++++ b/arch/arm/mach-msm/pm.c +@@ -892,6 +892,15 @@ static int __init msm_pm_init(void) + register_reboot_notifier(&msm_reboot_notifier); + msm_pm_reset_vector = ioremap(0x0, PAGE_SIZE); + ++#if defined(CONFIG_MACH_HTCLEO) ++ // if cLK is bootloader 0x0 is protected and not writtable but cLK changed reset vecotr to jump at address stored at 0x11800004 ++ if(htcleo_is_nand_boot()==2){ ++ pr_info("msm_pm: 0x00000000: %x\n", msm_pm_reset_vector[0]); ++ pr_info("msm_pm: 0x00000004: %x\n", msm_pm_reset_vector[1]); ++ msm_pm_reset_vector = ioremap(0x11800000, PAGE_SIZE); ++ } ++#endif ++ + if (msm_pm_reset_vector == NULL) { + printk(KERN_ERR "msm_pm_init: failed to map reset vector\n"); + return -ENODEV; diff --git a/patches/off_mode_charging_kernel.patch b/patches/off_mode_charging_kernel.patch new file mode 100644 index 0000000..f3f0077 --- /dev/null +++ b/patches/off_mode_charging_kernel.patch @@ -0,0 +1,39 @@ +diff --git a/arch/arm/mach-msm/board-htcleo-panel.c b/arch/arm/mach-msm/board-htcleo-panel.c +index a7a701d..1b98611 100644 +--- a/arch/arm/mach-msm/board-htcleo-panel.c ++++ b/arch/arm/mach-msm/board-htcleo-panel.c +@@ -861,9 +861,17 @@ static void detect_panel_type(void) + } + else + { +- printk(" UNKNOWN, stop system now\n"); + htcleo_panel_type = PANELTYPE_UNKNOWN; +- BUG(); ++ extern int board_mfg_mode(void); ++ if(board_mfg_mode()==5) ++ { ++ printk(" offmode charging, panel is off\n"); ++ } ++ else ++ { ++ printk(" UNKNOWN, stop system now\n"); ++ BUG(); ++ } + } + } + +diff --git a/arch/arm/mach-msm/devices_htc.c b/arch/arm/mach-msm/devices_htc.c +index e5f65e7..6839c0d 100644 +--- a/arch/arm/mach-msm/devices_htc.c ++++ b/arch/arm/mach-msm/devices_htc.c +@@ -457,6 +457,10 @@ int __init board_mfg_mode_init(char *s) + mfg_mode = 2; + else if (!strcmp(s, "charge")) + mfg_mode = 3; ++ else if (!strcmp(s, "power_test")) ++ mfg_mode = 4; ++ else if (!strcmp(s, "offmode_charging")) ++ mfg_mode = 5; + + return 1; + } diff --git a/readme_boot.img.txt b/readme_boot.img.txt index 91c8243..c6574a4 100644 --- a/readme_boot.img.txt +++ b/readme_boot.img.txt @@ -1,3 +1,10 @@ +#compile kernel and make boot.img/recovery.img #make ARCH=arm CROSS_COMPILE=arm-none-eabi- mkbootimg --kernel zImage --ramdisk initrd.gz --cmdline "" --base 0x11800000 -o android_boot.img mkbootimg --base 0x11800000 --cmdline "no_console_suspend=0" --kernel zImage --ramdisk initrd.gz -o android_boot.img + +#create initrd.gz +find . | cpio -o -H newc | gzip > ../initrd.gz + +#flash boot img from zImage and initrd.gz +fastboot -c "" -b 0x11800000 flash:raw boot zImage initrd.gz \ No newline at end of file