From 3b46671a40f4338b7ace8cdb64cf716f73626f31 Mon Sep 17 00:00:00 2001 From: Rob Purchase Date: Sat, 29 Mar 2008 17:26:16 +0000 Subject: Make the Telechips bootloader slightly less messy, kill some warnings and allow entry to the bootloader debug screen via the D2's hold switch. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16879 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/telechips.c | 125 +++++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 57 deletions(-) (limited to 'bootloader') diff --git a/bootloader/telechips.c b/bootloader/telechips.c index 305bdf3..4c8b6ef 100644 --- a/bootloader/telechips.c +++ b/bootloader/telechips.c @@ -35,6 +35,7 @@ #include "button.h" #include "adc.h" #include "adc-target.h" +#include "backlight.h" #include "backlight-target.h" #include "panic.h" #include "power.h" @@ -52,66 +53,12 @@ extern int line; #define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */ -void* main(void) +void show_debug_screen(void) { int button; int power_count = 0; int count = 0; bool do_power_off = false; - -#if defined(COWON_D2) && defined(TCCBOOT) - int rc; - unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS; -#endif - - power_init(); - system_init(); - lcd_init(); - - adc_init(); - button_init(); - backlight_init(); - - font_init(); - lcd_setfont(FONT_SYSFIXED); - - _backlight_on(); - -/* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is - available for loading the firmware. Otherwise display the debug screen. */ -#if defined(COWON_D2) && defined(TCCBOOT) - printf("Rockbox boot loader"); - printf("Version %s", version); - - printf("ATA"); - rc = ata_init(); - if(rc) - { - reset_screen(); - error(EATA, rc); - } - - printf("mount"); - rc = disk_mount_all(); - if (rc<=0) - { - error(EDISK,rc); - } - - rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE); - - if (rc < 0) - { - error(EBOOTFILE,rc); - } - else if (rc == EOK) - { - int(*kernel_entry)(void); - - kernel_entry = (void*) loadbuffer; - rc = kernel_entry(); - } -#else while(!do_power_off) { line = 0; @@ -140,7 +87,7 @@ void* main(void) printf("GPIOC: 0x%08x",GPIOC); printf("GPIOD: 0x%08x",GPIOD); printf("GPIOE: 0x%08x",GPIOE); - + for (i = 0; i<4; i++) { printf("ADC%d: 0x%04x",i,adc_read(i)); @@ -163,7 +110,7 @@ void* main(void) y = (y*LCD_HEIGHT) / 1024; lcd_hline(x-5, x+5, y); lcd_vline(x, y-5, y+5); - + buf[0] = 0x2f; buf[1] = (0xF<<1) | 1; /* ADC start for P1+P2 */ i2c_write(0x10, buf, 2); @@ -186,7 +133,71 @@ void* main(void) power_off(); printf("(NOT) POWERED OFF"); + while (true); +} + + +void* main(void) +{ +#if defined(COWON_D2) && defined(TCCBOOT) + int rc; + unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS; +#endif + + power_init(); + system_init(); + lcd_init(); + + adc_init(); + button_init(); + backlight_init(); + + font_init(); + lcd_setfont(FONT_SYSFIXED); + + _backlight_on(); + +/* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is + available for loading the firmware. Otherwise display the debug screen. */ +#if defined(COWON_D2) && defined(TCCBOOT) + printf("Rockbox boot loader"); + printf("Version %s", version); + + printf("ATA"); + rc = ata_init(); + if(rc) + { + reset_screen(); + error(EATA, rc); + } + + printf("mount"); + rc = disk_mount_all(); + if (rc<=0) + { + error(EDISK,rc); + } + + rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE); + + if (rc < 0) + { + error(EBOOTFILE,rc); + } + else if (rc == EOK) + { + int(*kernel_entry)(void); + + /* wait for button release to allow debug statememts to be read */ + while (button_read_device()) {}; + + kernel_entry = (void*) loadbuffer; + + /* allow entry to the debug screen if hold is on */ + if (!button_hold()) rc = kernel_entry(); + } #endif + show_debug_screen(); return 0; } -- cgit v1.1