summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2007-03-12 22:12:20 +0000
committerBarry Wardell <rockbox@barrywardell.net>2007-03-12 22:12:20 +0000
commit2370998a873f8be85825c8a3b0ccca5a9913c20e (patch)
treea6d5ea4bcf007d22a22f07e26fd98e114c6221b7
parent62dbd97e909ccacf4165c65f676ee134bd1b880a (diff)
downloadrockbox-2370998a873f8be85825c8a3b0ccca5a9913c20e.tar.gz
rockbox-2370998a873f8be85825c8a3b0ccca5a9913c20e.zip
Disable bootloader messages in the H10 and Sansa bootloaders unless the PLAY (on H10) or RIGHT (on Sansa) button is being held. Messages are still displayed if an error occurs. This has already been implemented for iPod bootloaders, but still needs implementing for the other bootloaders.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12742 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/common.c29
-rw-r--r--bootloader/common.h6
-rw-r--r--bootloader/main-pp.c42
-rw-r--r--firmware/kernel.c4
4 files changed, 61 insertions, 20 deletions
diff --git a/bootloader/common.c b/bootloader/common.c
index 5f824cf1b8..a382816791 100644
--- a/bootloader/common.c
+++ b/bootloader/common.c
@@ -25,10 +25,13 @@
25#include <stdbool.h> 25#include <stdbool.h>
26#include "cpu.h" 26#include "cpu.h"
27#include "common.h" 27#include "common.h"
28#include "power.h"
29#include "kernel.h"
28 30
29/* TODO: Other bootloaders need to be adjusted to set this variable to true 31/* TODO: Other bootloaders need to be adjusted to set this variable to true
30 on a button press - currently only the ipod version does. */ 32 on a button press - currently only the ipod, H10 and Sansa versions do. */
31#ifdef IPOD_ARCH 33#if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || \
34 defined(SANSA_E200)
32bool verbose = false; 35bool verbose = false;
33#else 36#else
34bool verbose = true; 37bool verbose = true;
@@ -99,6 +102,28 @@ char *strerror(int error)
99 } 102 }
100} 103}
101 104
105void error(int errortype, int error)
106{
107 switch(errortype)
108 {
109 case EATA:
110 printf("ATA error: %d", error);
111 break;
112
113 case EDISK:
114 printf("No partition found");
115 break;
116
117 case EBOOTFILE:
118 printf(strerror(error));
119 break;
120 }
121
122 lcd_update();
123 sleep(5*HZ);
124 power_off();
125}
126
102/* Load firmware image in a format created by tools/scramble */ 127/* Load firmware image in a format created by tools/scramble */
103int load_firmware(unsigned char* buf, char* firmware, int buffer_size) 128int load_firmware(unsigned char* buf, char* firmware, int buffer_size)
104{ 129{
diff --git a/bootloader/common.h b/bootloader/common.h
index adb833fd1d..3607dd0f68 100644
--- a/bootloader/common.h
+++ b/bootloader/common.h
@@ -31,9 +31,15 @@
31/* Set this to true to enable lcd_update() in the printf function */ 31/* Set this to true to enable lcd_update() in the printf function */
32extern bool verbose; 32extern bool verbose;
33 33
34/* Error types */
35#define EATA -1
36#define EDISK -2
37#define EBOOTFILE -3
38
34/* Functions common to all bootloaders */ 39/* Functions common to all bootloaders */
35void reset_screen(void); 40void reset_screen(void);
36void printf(const char *format, ...); 41void printf(const char *format, ...);
37char *strerror(int error); 42char *strerror(int error);
43void error(int errortype, int error);
38int load_firmware(unsigned char* buf, char* firmware, int buffer_size); 44int load_firmware(unsigned char* buf, char* firmware, int buffer_size);
39int load_raw_firmware(unsigned char* buf, char* firmware, int buffer_size); 45int load_raw_firmware(unsigned char* buf, char* firmware, int buffer_size);
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index 5659073457..0f85404fc7 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -29,7 +29,17 @@
29#include "ata.h" 29#include "ata.h"
30#include "button.h" 30#include "button.h"
31#include "disk.h" 31#include "disk.h"
32#include "power.h" 32
33/* Button definitions */
34#if CONFIG_KEYPAD == IRIVER_H10_PAD
35#define BOOTLOADER_VERBOSE BUTTON_PLAY
36#define BOOTLOADER_BOOT_OF BUTTON_LEFT
37
38#elif CONFIG_KEYPAD == SANSA_E200_PAD
39#define BOOTLOADER_VERBOSE BUTTON_RIGHT
40#define BOOTLOADER_BOOT_OF BUTTON_LEFT
41
42#endif
33 43
34/* Maximum allowed firmware image size. 10MB is more than enough */ 44/* Maximum allowed firmware image size. 10MB is more than enough */
35#define MAX_LOADSIZE (10*1024*1024) 45#define MAX_LOADSIZE (10*1024*1024)
@@ -44,6 +54,7 @@ void* main(void)
44{ 54{
45 char buf[256]; 55 char buf[256];
46 int i; 56 int i;
57 int btn;
47 int rc; 58 int rc;
48 unsigned short* identify_info; 59 unsigned short* identify_info;
49 struct partinfo* pinfo; 60 struct partinfo* pinfo;
@@ -54,6 +65,12 @@ void* main(void)
54 font_init(); 65 font_init();
55 button_init(); 66 button_init();
56 67
68 btn = button_read_device();
69
70 /* Enable bootloader messages */
71 if (btn==BOOTLOADER_VERBOSE)
72 verbose = true;
73
57 lcd_setfont(FONT_SYSFIXED); 74 lcd_setfont(FONT_SYSFIXED);
58 75
59 printf("Rockbox boot loader"); 76 printf("Rockbox boot loader");
@@ -73,25 +90,20 @@ void* main(void)
73 } 90 }
74 printf(buf); 91 printf(buf);
75 } else { 92 } else {
76 printf("ATA error: %d", i); 93 error(EATA, i);
77 udelay(5000000);
78 power_off();
79 } 94 }
80 95
81 disk_init(); 96 disk_init();
82 rc = disk_mount_all(); 97 rc = disk_mount_all();
83 if (rc<=0) 98 if (rc<=0)
84 { 99 {
85 printf("No partition found"); 100 error(EDISK,rc);
86 udelay(5000000);
87 power_off();
88 } 101 }
89 102
90 pinfo = disk_partinfo(0); 103 pinfo = disk_partinfo(0);
91 printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048); 104 printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048);
92 105
93 i=button_read_device(); 106 if(btn==BOOTLOADER_BOOT_OF)
94 if(i==BUTTON_LEFT)
95 { 107 {
96 /* Load original mi4 firmware. This expects a file called 108 /* Load original mi4 firmware. This expects a file called
97 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted 109 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted
@@ -101,21 +113,15 @@ void* main(void)
101 printf("Loading original firmware..."); 113 printf("Loading original firmware...");
102 rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE); 114 rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE);
103 if (rc < EOK) { 115 if (rc < EOK) {
104 printf("Error!"); 116 printf("Can't load /System/OF.bin");
105 printf("Can't load /System/OF.bin:"); 117 error(EBOOTFILE, rc);
106 printf(strerror(rc));
107 udelay(5000000);
108 power_off();
109 } 118 }
110 } else { 119 } else {
111 printf("Loading Rockbox..."); 120 printf("Loading Rockbox...");
112 rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE); 121 rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE);
113 if (rc < EOK) { 122 if (rc < EOK) {
114 printf("Error!");
115 printf("Can't load %s:", BOOTFILE); 123 printf("Can't load %s:", BOOTFILE);
116 printf(strerror(rc)); 124 error(EBOOTFILE, rc);
117 udelay(5000000);
118 power_off();
119 } 125 }
120 } 126 }
121 127
diff --git a/firmware/kernel.c b/firmware/kernel.c
index c304e455c2..e794fed3fe 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -72,6 +72,10 @@ void sleep(int ticks)
72 counter = TCNTO4; 72 counter = TCNTO4;
73 } while(counter > 0); 73 } while(counter > 0);
74 74
75#elif defined(CPU_PP) && defined(BOOTLOADER)
76 unsigned stop = USEC_TIMER + ticks * (1000000/HZ);
77 while (TIME_BEFORE(USEC_TIMER, stop))
78 switch_thread(true,NULL);
75#else 79#else
76 sleep_thread(ticks); 80 sleep_thread(ticks);
77#endif 81#endif