From 72ee75a82d560a022ad3c964d34589250e38afb8 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Sun, 6 Nov 2011 23:48:03 +0000 Subject: [PATCH] 1.2: updated --- bin/dmesg_filter.exe | Bin 0 -> 23483 bytes compile | 68 +++++++++++++------------------ dmesg_filter.c | 24 +++++++++++ gau_flash.cfg | 4 ++ lk/app/aboot/aboot.c | 32 +++------------ lk/app/aboot/fastboot.c | 13 ++++++ lk/platform/msm_shared/timer.c | 3 +- lk/platform/qsd8k/rules.mk | 2 +- lk/target/htcleo/atags.c | 15 ++++++- lk/target/htcleo/htcleo_boot.c | 30 ++++++++++++++ lk/target/htcleo/htcleo_boot_s.S | 24 +++++++++++ lk/target/htcleo/init.c | 59 ++++++++++++++++++--------- lk/target/htcleo/keypad.c | 29 +++++-------- lk/target/htcleo/nand.c | 3 +- lk/target/htcleo/rules.mk | 5 ++- lk/target/htcleo/tools/makefile | 35 +++++----------- lk/target/htcleo/tools/tinboot.S | 44 ++++++++++++++++++++ readme_boot.img.txt | 2 +- 18 files changed, 257 insertions(+), 135 deletions(-) create mode 100644 bin/dmesg_filter.exe create mode 100644 dmesg_filter.c create mode 100644 gau_flash.cfg create mode 100644 lk/target/htcleo/htcleo_boot.c create mode 100644 lk/target/htcleo/htcleo_boot_s.S create mode 100644 lk/target/htcleo/tools/tinboot.S diff --git a/bin/dmesg_filter.exe b/bin/dmesg_filter.exe new file mode 100644 index 0000000000000000000000000000000000000000..e3f13e4ef143e45b1fcbb06ddc64c305ec6dd9a6 GIT binary patch literal 23483 zcmeHP4RlmjoxhWhGNp-0C0MLrr!}obA&0af#R|s(k_v5r6oRsR?8{{4C7CjrNoU^h z(L=kblN>uvQ?pv#ZVz=ETi4oUkGKabwz#H*Eg#Y?A}UANE^4|?Hdzm@Eao6K`}^OI z_c1SlWtQXd9J%Mb-1mO>fB#?ie?Q)vd$VGFA1h>x72z5mXKXKWN`C(L(to;8{GMB0 zeGl7n{hPP$^)$SBYg2nT;p>dY+Tw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44Sul>n-c*I3(9;sh zmc(|PIPcKpacdE2*vLokQI>Z!j)WaZ`{snfBVU$@HH?KSKecyHvqv$_ zcA%E?=VOVo(s2+KFA$D_#Ch&iw4|y?uNrDB5UvZ#r87-qG<=8jZKhlC-xbv0l`Dkn zF5k$cC1QPzu?FX|oX!%KPIPG3a-Cd5tA3T!W~3WzP)?gLkR8M6MCX(t%p5^-XY@;t zA&%I#4+6r6hTTugDSDP5c%ZB`I#7GdH4Wl-HJ{vUQ7j@mnb6geK&%M3m*v~nL{otB zhx25ziY)UOF+@uT^3jQN&519^_>oA))bMf1aT>kPc4$B;!@s9V9WFPuxK>uY9l%M9 zuA(Q}N7e{Vc+ci$W0MViyG8XN2sN2xze?|_+~vG)gyP`r3I9#^24JVD6HnP zi-c=1h`3eZZZuC&E2ro5K8IgvAt;CCrkshAGn;JQ(=Oe0Tw~GX!;TuPG2mI=fX~Iu i>{zMtw|==cqv%0!QvXvCFGrMI`zPsl(mV14(*FW9UaJuR literal 0 HcmV?d00001 diff --git a/compile b/compile index e7b40c5..d2c258f 100644 --- a/compile +++ b/compile @@ -1,55 +1,45 @@ #!/bin/bash #use codesourcery toolchain -TOOLCHAIN_PREFIX=arm-none-eabi- +TOOLCHAIN_PREFIX="arm-none-eabi-" export TOOLCHAIN_PREFIX if [ "$1" = "clean" ]; then - rm -rf lk/build-htcleo - rm bin/nbfix - rm bin/lk.bin - rm bin/tinboot - rm tinboot/tinboot - rm tinboot/tinboot.o - rm bin/os.nb.payload - rm bin/os.nb - rm bin/RUU_signed.nbh + cd lk + make htcleo clean + cd .. + rm bin/nbfix fi +rm bin/lk.bin +rm bin/tinboot +rm bin/os.nb.payload +rm bin/os.nb +rm bin/RUU_signed.nbh + -TOOLCHAIN_PREFIX="arm-none-eabi-" -export TOOLCHAIN_PREFIX if [ ! -f bin/nbfix ]; then gcc nbfix.c -o bin/nbfix fi -if [ ! -f bin/lk.bin ]; then - cd lk - make htcleo EMMC_BOOT=0 DEBUG=1 - [ $? -eq 0 ] || exit 1 - cp build-htcleo/lk.bin ../bin/ - cd .. -fi - -if [ ! -f bin/tinboot ]; then - cd tinboot - ${TOOLCHAIN_PREFIX}as tinboot.S -o tinboot.o - ${TOOLCHAIN_PREFIX}objcopy tinboot.o -O binary tinboot - cp tinboot ../bin/ - cd .. -fi - -if [ ! -f bin/RUU_signed.nbh ]; then - cd bin - cp template_os.nb.payload os.nb.payload - wine osnbtool.exe -c os.nb.payload 0 tinboot - mv os.nb.payload.NEW os.nb.payload - ./nbfix - wine NBMerge.exe -kaiser os.nb - wine yang.exe -F RUU_signed.nbh -f os.nb -t 0x400 -s 64 -d PB8110000 -c 11111111 -v CLK1.1 -l WWE - - cd .. -fi +cd lk +make htcleo DEBUG=1 +[ $? -eq 0 ] || exit 1 +cp build-htcleo/lk.bin ../bin/ +cp build-htcleo/tinboot ../bin/ +cd .. + + + +cd bin +cp template_os.nb.payload os.nb.payload +wine osnbtool.exe -c os.nb.payload 0 tinboot +mv os.nb.payload.NEW os.nb.payload +./nbfix +wine NBMerge.exe -kaiser os.nb +wine yang.exe -F RUU_signed.nbh -f os.nb -t 0x400 -s 64 -d PB8110000 -c 11111111 -v CLK1.1 -l WWE +cd .. + diff --git a/dmesg_filter.c b/dmesg_filter.c new file mode 100644 index 0000000..71e5e77 --- /dev/null +++ b/dmesg_filter.c @@ -0,0 +1,24 @@ +#include +#include + +int main() { + char buff[0x40000]; + + char* ptr = buff; + while(!feof(stdin) && fgetc(stdin)!='\n'); + + while(!feof(stdin)) + { + *ptr++=fgetc(stdin);*ptr=0; + + if(ptr-buff>=5 && memcmp(ptr-5,"\nINFO",5)==0) + { + ptr[-5]=0; + if(ptr-buff>=6 && ptr[-6]=='\r' ) ptr[-6]=0; + printf("%s", buff); + ptr=buff; + + } + } + printf("%s", buff); +} diff --git a/gau_flash.cfg b/gau_flash.cfg new file mode 100644 index 0000000..feadaff --- /dev/null +++ b/gau_flash.cfg @@ -0,0 +1,4 @@ +clk_recovery raw|ro 5M +clk_boot raw|ro 5M +system ya|boot|ro filesize system.bin +userdata ya|asize allsize \ No newline at end of file diff --git a/lk/app/aboot/aboot.c b/lk/app/aboot/aboot.c index 0835fe1..cba83c6 100644 --- a/lk/app/aboot/aboot.c +++ b/lk/app/aboot/aboot.c @@ -61,7 +61,9 @@ #define FASTBOOT_MODE 0x77665500 static const char *emmc_cmdline = " androidboot.emmc=true"; -static const char *battchg_pause = " androidboot.battchg_pause=true"; +//static const char *battchg_pause = " androidboot.battchg_pause=true"; +static const char *battchg_pause = " androidboot.mode=offmode_charging"; + static struct udc_device surf_udc_device = { .vendor_id = 0x18d1, @@ -199,37 +201,15 @@ void boot_linux(void *kernel, unsigned *tags, dprintf(INFO, "cmdline: %s\n", cmdline); enter_critical_section(); - //cedesmith: this will hang - //platform_uninit_timer(); + platform_uninit_timer(); arch_disable_cache(UCACHE); arch_disable_mmu(); #if DISPLAY_SPLASH_SCREEN display_shutdown(); #endif - __asm__ volatile ( - "dsb \n" - "isb \n" - ); - - //cedesmith: cotulla's code so kernel will not crash. aux control register - __asm__ volatile ( - "MRC p15, 0, r0, c1, c0, 1 \n" - "BIC r0, r0, #0x40 \n" // (1<<6) Instruction cache reload on a parity error disabled - "BIC r0, r0, #0x200000 \n" // (1<<21) undocumented bit ? - "MCR p15, 0, r0, c1, c0, 1 \n" - ); - - /* - // flash on to see we get here - __asm__ volatile ( - "ldr r4, =0xa9000864 @ bank6_in (phys) \n" - "ldr r5, =0xa9000814 @ bank6_out (phys) \n" - "orr r6, r4, #0x200000 @ 22nd bit for flash \n" - "str r6, [r5, #0] @ store in out (enables bright for 500ms, limited by hardware) \n" - ); - */ - entry(0, machtype, tags); + htcleo_boot(kernel, machtype, tags); + //entry(0, machtype, tags); } unsigned page_size = 0; diff --git a/lk/app/aboot/fastboot.c b/lk/app/aboot/fastboot.c index 6752dde..0e0bde6 100644 --- a/lk/app/aboot/fastboot.c +++ b/lk/app/aboot/fastboot.c @@ -232,6 +232,19 @@ static void cmd_getvar(const char *arg, void *data, unsigned sz) { struct fastboot_var *var; + if(!strcmp(arg,"dmesg")) + { + char response[64]; + for(char* c=(char*) 0x2FFC0000; c<(char*)(0x2FFC0000+0x00040000); c+=59) + { + memcpy(response, "INFO",4);memcpy(response+4, c, 59); response[63]=0; + //snprintf(response, 64, "%s%s", "INFO", c); + usb_write(response, 64); + } + fastboot_okay(""); + return; + } + for (var = varlist; var; var = var->next) { if (!strcmp(var->name, arg)) { fastboot_okay(var->value); diff --git a/lk/platform/msm_shared/timer.c b/lk/platform/msm_shared/timer.c index 9f98ffa..c264bc1 100644 --- a/lk/platform/msm_shared/timer.c +++ b/lk/platform/msm_shared/timer.c @@ -159,7 +159,8 @@ void platform_init_timer(void) static void wait_for_timer_op(void) { -#if PLATFORM_QSD8K || PLATFORM_MSM7X30 || PLATFORM_MSM8X60 + //cedesmith: this will hang on htcleo so removed PLATFORM_QSD8K +#if PLATFORM_MSM7X30 || PLATFORM_MSM8X60 while(readl(SPSS_TIMER_STATUS)) ; #endif } diff --git a/lk/platform/qsd8k/rules.mk b/lk/platform/qsd8k/rules.mk index e49e05d..88ddd40 100644 --- a/lk/platform/qsd8k/rules.mk +++ b/lk/platform/qsd8k/rules.mk @@ -6,7 +6,7 @@ ARM_CPU := cortex-a8 CPU := generic #DEFINES += WITH_CPU_EARLY_INIT=1 WITH_CPU_WARM_BOOT=1 MEMBASE=0 -DEFINES += WITH_CPU_EARLY_INIT=1 +#DEFINES += WITH_CPU_EARLY_INIT=1 INCLUDES += -I$(LOCAL_DIR)/include diff --git a/lk/target/htcleo/atags.c b/lk/target/htcleo/atags.c index 2c87b94..9d8adae 100644 --- a/lk/target/htcleo/atags.c +++ b/lk/target/htcleo/atags.c @@ -8,10 +8,21 @@ unsigned* target_atag_mem(unsigned* ptr) { + + //MEM TAG *ptr++ = 4; *ptr++ = 0x54410002; - *ptr++ = MSM_EBI1_BANK0_SIZE; - *ptr++ = MSM_EBI1_BANK0_BASE; + //*ptr++ = 0x1e400000; //mem size from haret + //*ptr++ = 0x1E7C0000; //mem size from kernel config + *ptr++ = 0x1CFC0000; //mem size from kernel config with bravo dsp + *ptr++ = 0x11800000; //mem base + + + //add atag to notify nand boot + *ptr++ = 4; + *ptr++ = 0x4C47414D; + *ptr++ = 0; + *ptr++ = 0; return ptr; } diff --git a/lk/target/htcleo/htcleo_boot.c b/lk/target/htcleo/htcleo_boot.c new file mode 100644 index 0000000..96564ea --- /dev/null +++ b/lk/target/htcleo/htcleo_boot.c @@ -0,0 +1,30 @@ +#include +#include + +// cedesmith: we need to stop interrupts or kernel will receive dex interrupt to early and crash +#define VIC_REG(off) (MSM_VIC_BASE + (off)) +#define VIC_INT_EN0 VIC_REG(0x0010) +#define VIC_INT_EN1 VIC_REG(0x0014) +#define VIC_INT_CLEAR0 VIC_REG(0x00B0) +#define VIC_INT_CLEAR1 VIC_REG(0x00B4) +#define VIC_INT_MASTEREN VIC_REG(0x0068) /* 1: IRQ, 2: FIQ */ + +void htcleo_disable_interrupts(void) +{ + //clear current pending interrupts + writel(0xffffffff, VIC_INT_CLEAR0); + writel(0xffffffff, VIC_INT_CLEAR1); + + //disable all + writel(0, VIC_INT_EN0); + writel(0, VIC_INT_EN1); + //disable interrupts + writel(0, VIC_INT_MASTEREN); +} + +void htcleo_boot_s(void* kernel,unsigned machtype,void* tags); +void htcleo_boot(void* kernel,unsigned machtype,void* tags) +{ + htcleo_disable_interrupts(); + htcleo_boot_s(kernel, machtype, tags); +} diff --git a/lk/target/htcleo/htcleo_boot_s.S b/lk/target/htcleo/htcleo_boot_s.S new file mode 100644 index 0000000..1469898 --- /dev/null +++ b/lk/target/htcleo/htcleo_boot_s.S @@ -0,0 +1,24 @@ +.text +.code 32 + +.globl htcleo_boot_s +htcleo_boot_s: + // save registers + MOV r9, r0 + + //cedesmith: cotulla's code so kernel will not crash. aux control register + MRC p15, 0, r0, c1, c0, 1 + BIC r0, r0, #0x40 // (1<<6) Instruction cache reload on a parity error disabled + BIC r0, r0, #0x200000 // (1<<21) undocumented bit ? + MCR p15, 0, r0, c1, c0, 1 + + //flashlight to see we get here + //ldr r4, =0xa9000864 @ bank6_in (phys) + //ldr r5, =0xa9000814 @ bank6_out (phys) + //orr r6, r4, #0x200000 @ 22nd bit for flash + //str r6, [r5, #0] @ store in out (enables bright for 500ms, limited by hardware) + + MOV R0, #0 + BLX R9 + +.ltorg diff --git a/lk/target/htcleo/init.c b/lk/target/htcleo/init.c index 606529c..1a66f7a 100644 --- a/lk/target/htcleo/init.c +++ b/lk/target/htcleo/init.c @@ -9,6 +9,9 @@ #include #include #include +#include +#include +#include #define LINUX_MACHTYPE 2524 #define HTCLEO_FLASH_OFFSET 0x219 @@ -43,30 +46,31 @@ static struct ptentry board_part_list[MAX_PTABLE_PARTS] __attribute__ ((aligned }, }; #else -// partition table matching cotulla's build +// partition table matching gau desire hd on my (cedesmith) phone +// allows me to just swap bootloader from magldr to clk and viceversa static struct ptentry board_part_list[MAX_PTABLE_PARTS] __attribute__ ((aligned (512))) = { { .name = "PTABLE-BLK", // or PTABLE-MB for len in MB }, { - .name = "boot", + .name = "recovery", .start = 0x219, - .length = 0x25 /* In blocks */, + .length = 0x28 /* In blocks */, + }, + { + .name = "boot", + .start = 0x241, + .length = 0x28 /* In blocks */, }, { .name = "system", - .start = 0x23E, - .length = 0x831 /* In blocks */, - }, - { - .name = "cache", - .start = 0xA70, - .length = 0x140 /* In blocks */, + .start = 0x269, + .length = 0x68B /* In blocks */, }, { .name = "userdata", - .start = 0xBB0, - .length = 0x390, + .start = 0x8F4, + .length = 0x64C, }, }; #endif @@ -81,6 +85,7 @@ void htcleo_ptable_dump(struct ptable *ptable); void cmd_dmesg(const char *arg, void *data, unsigned sz); void reboot(unsigned reboot_reason); void target_display_init(); +unsigned get_boot_reason(void); void target_init(void) { struct flash_info *flash_info; @@ -88,27 +93,27 @@ void target_init(void) unsigned blocks_per_plen = 1; //blocks per partition length unsigned nand_num_blocks; + keys_init(); keypad_init(); + + uint16_t keys[] = {KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SOFT1, KEY_SEND, KEY_CLEAR, KEY_BACK, KEY_HOME}; for(unsigned i=0; i< sizeof(keys)/sizeof(uint16_t); i++) if (keys_get_state(keys[i]) != 0) { display_init(); _dputs("cedesmith's LK (CLK) v1.1\n"); + dprintf(ALWAYS,"key %d pressed\n", i); break; } dprintf(INFO, "htcleo_init\n"); - // SPL seams to pass something somehow to kernel. - // Without this it hangs on 1st boot and when battery charger is pluged - // with this it just auto restarts - char* cold_boot=(char*)(MEMBASE-1); - if(*cold_boot==0) + // When boot mode is 1 it hangs + if(/*get_boot_reason()==1 ||*/ get_boot_reason()==2) { - *cold_boot=1; - dprintf(INFO, "cold boot detected... reboot\n"); + dprintf(INFO, "reboot needed... \n"); reboot(0); } @@ -181,6 +186,22 @@ void reboot_device(unsigned reboot_reason) reboot(reboot_reason); } +unsigned boot_reason = 0xFFFFFFFF; +unsigned get_boot_reason(void) +{ + if(boot_reason==0xFFFFFFFF) + { + boot_reason = readl(MSM_SHARED_BASE+0xef244); + dprintf(INFO, "boot reason %x\n", boot_reason); + } + return boot_reason; +} +unsigned target_pause_for_battery_charge(void) +{ + if (get_boot_reason() == 2) return 1; + return 0; +} + int target_is_emmc_boot(void) { return 0; diff --git a/lk/target/htcleo/keypad.c b/lk/target/htcleo/keypad.c index a402c3a..5127ca9 100644 --- a/lk/target/htcleo/keypad.c +++ b/lk/target/htcleo/keypad.c @@ -34,25 +34,16 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) - -/* Keypad */ -#define HTCLEO_GPIO_KP_MKOUT0 33 -#define HTCLEO_GPIO_KP_MKOUT1 32 -#define HTCLEO_GPIO_KP_MKOUT2 31 -#define HTCLEO_GPIO_KP_MPIN0 42 -#define HTCLEO_GPIO_KP_MPIN1 41 -#define HTCLEO_GPIO_KP_MPIN2 40 - /* * cedesmith - * NOTE: htcleo kernel differs by havin row swaped to col + * NOTE: htcleo kernel differs by having row swapped to col */ -static unsigned int halibut_row_gpios[] = { 33, 32, 31 }; -static unsigned int halibut_col_gpios[] = { 42, 41, 40 }; +static unsigned int htcleo_row_gpios[] = { 33, 32, 31 }; +static unsigned int htcleo_col_gpios[] = { 42, 41, 40 }; -#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col)) +#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(htcleo_col_gpios) + (col)) -static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = { +static const unsigned short htcleo_keymap[ARRAY_SIZE(htcleo_col_gpios) * ARRAY_SIZE(htcleo_row_gpios)] = { [KEYMAP_INDEX(0, 0)] = KEY_VOLUMEUP, // Volume Up [KEYMAP_INDEX(0, 1)] = KEY_VOLUMEDOWN, // Volume Down [KEYMAP_INDEX(1, 0)] = KEY_SOFT1, // Windows Button @@ -63,11 +54,11 @@ static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY }; static struct gpio_keypad_info halibut_keypad_info = { - .keymap = halibut_keymap, - .output_gpios = halibut_row_gpios, - .input_gpios = halibut_col_gpios, - .noutputs = ARRAY_SIZE(halibut_row_gpios), - .ninputs = ARRAY_SIZE(halibut_col_gpios), + .keymap = htcleo_keymap, + .output_gpios = htcleo_row_gpios, + .input_gpios = htcleo_col_gpios, + .noutputs = ARRAY_SIZE(htcleo_row_gpios), + .ninputs = ARRAY_SIZE(htcleo_col_gpios), .settle_time = 40 /* msec */, .poll_time = 20 /* msec */, .flags = GPIOKPF_DRIVE_INACTIVE, diff --git a/lk/target/htcleo/nand.c b/lk/target/htcleo/nand.c index 9baef2e..15b529a 100644 --- a/lk/target/htcleo/nand.c +++ b/lk/target/htcleo/nand.c @@ -33,8 +33,7 @@ #include #include #include -//#include -#include "nand.h" +#include #include "dmov.h" diff --git a/lk/target/htcleo/rules.mk b/lk/target/htcleo/rules.mk index caf4bda..fbf8d21 100644 --- a/lk/target/htcleo/rules.mk +++ b/lk/target/htcleo/rules.mk @@ -33,7 +33,7 @@ KEYS_USE_GPIO_KEYPAD := 1 #DEFINES += DISPLAY_SPLASH_SCREEN=1 DEFINES += DISPLAY_TYPE_LCDC=1 -CFLAGS += -mlittle-endian +CFLAGS += -mlittle-endian -mfpu=neon LDFLAGS += -EL MODULES += \ @@ -53,3 +53,6 @@ OBJS += \ $(LOCAL_DIR)/nand.o \ $(LOCAL_DIR)/keypad.o \ $(LOCAL_DIR)/atags.o + +OBJS += $(LOCAL_DIR)/htcleo_boot.o \ + $(LOCAL_DIR)/htcleo_boot_s.o \ No newline at end of file diff --git a/lk/target/htcleo/tools/makefile b/lk/target/htcleo/tools/makefile index 9d3897d..21d4a35 100644 --- a/lk/target/htcleo/tools/makefile +++ b/lk/target/htcleo/tools/makefile @@ -1,30 +1,17 @@ -#Makefile to generate appsboot.mbn - -ifeq ($(BOOTLOADER_OUT),.) -APPSBOOTHEADER_DIR := $(BUILDDIR) -else -APPSBOOTHEADER_DIR := $(BOOTLOADER_OUT)/../../ -endif +#Makefile to generate tinboot SRC_DIR := target/$(TARGET)/tools -COMPILER := gcc +EXTRA_CLEANDEPS += tinboot_clean -ifeq ($(BUILD_NANDWRITE), 1) - APPSBOOTHDR_FILES := -else - APPSBOOTHDR_FILES := appsboot.mbn -endif +APPSBOOTHEADER: $(BUILDDIR)/tinboot -APPSBOOTHEADER: $(APPSBOOTHDR_FILES) +$(BUILDDIR)/tinboot.o: $(SRC_DIR)/tinboot.S $(OUTBIN) + $(TOOLCHAIN_PREFIX)as $(SRC_DIR)/tinboot.S -I "$(BUILDDIR)" -o $(BUILDDIR)/tinboot.o + +$(BUILDDIR)/tinboot: $(BUILDDIR)/tinboot.o + $(OBJCOPY) $(BUILDDIR)/tinboot.o -O binary $(BUILDDIR)/tinboot -appsboot.mbn: appsboothd.mbn $(OUTBIN) - cat $(APPSBOOTHEADER_DIR)/appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/appsboot.mbn - rm -rf $(APPSBOOTHEADER_DIR)/appsboothd.mbn - -appsboothd.mbn: mkheader $(OUTBIN) - $(SRC_DIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn - -mkheader: $(SRC_DIR)/mkheader.c - ${COMPILER} $(SRC_DIR)/mkheader.c -o $(SRC_DIR)/mkheader - + +tinboot_clean: + rm -f $(BUILDDIR)/tinboot.o $(BUILDDIR)/tinboot \ No newline at end of file diff --git a/lk/target/htcleo/tools/tinboot.S b/lk/target/htcleo/tools/tinboot.S new file mode 100644 index 0000000..3a39552 --- /dev/null +++ b/lk/target/htcleo/tools/tinboot.S @@ -0,0 +1,44 @@ +@ author: cedesmith +@ license: GPL +@ version 1.0 +@ tiny bootloader wrapper for HTC WM6 phones +@ inspired by Martin Johnson Tinboot for htc vogue + + .org 0 + b boot + + .org 0x40 + .word 0x43454345 + .word romhdr+0x80000000 @ location of wince romhdr + .word romhdr + + + .org 0x00000900 + romhdr: @ 23E6F0 in original rom file + .word 0x0 @ dllfirst FD 01 F9 01 + .word 0x0 @ dlllast 00 00 00 02 + .word 0x80000000 @ physfirst 00 00 00 80 + .word 0x80000000+fin+0x100 @ physlast 48 B4 4D 80 + .word 0 @ nummods 29 00 00 00 + .word 0x80000000+fin+0x200 @ ulRAMStart 00 C0 4D 80 + .word 0x80000000+fin+0x300 @ ulRAMFree 00 B0 5C 80 + .word 0x8E600000 @ ulRAMEnd 00 00 60 8E + .word 0 @ ulCopyEntries 07 00 00 00 + .word 0x80000000+fin+0x400 @ ulCopyOffset DC 24 24 80 + .word 0 @ ulProfileLen 00 00 00 00 + .word 0 @ ulProfileOffset 00 00 00 00 + .word 0 @ numfiles 0E 00 00 00 + .word 0 @ ulKernelFlags 02 00 00 00 + .word 0x04 @ ulFSRamPercent 04 00 00 00 + .word 0 @ ulDrivglobStart 00 00 00 00 + .word 0 @ ulDrivglobLen 00 00 00 00 + .word 0x201c2 @ usCPUType and usMiscFlags (2 shorts) + .word 0x80000000+fin+0x500 @ pExtensions EC 2A 00 80 + .word 0 @ ulTrackingStart 00 00 00 00 + .word 0 @ ulTrackingLen 00 00 00 00 + + .org 0x00001000 +boot: + .incbin "lk.bin" + +fin: diff --git a/readme_boot.img.txt b/readme_boot.img.txt index 678ec95..e492d5a 100644 --- a/readme_boot.img.txt +++ b/readme_boot.img.txt @@ -1,2 +1,2 @@ #make ARCH=arm CROSS_COMPILE=arm-none-eabi- -mkbootimg --kernel zImage --ramdisk initrd.gz --cmdline "console=null" --base 0x11800000 -o android_boot.img +mkbootimg --kernel zImage --ramdisk initrd.gz --cmdline "" --base 0x11800000 -o android_boot.img