diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-06-21 00:11:14 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-06-21 00:11:14 +0000 |
commit | 9cfa47a22647a293ea1697456fcdbaddc975830c (patch) | |
tree | 81c5bb8ab3e27f28b4261cff76a2d86b9da809b4 /flash/bootbox | |
parent | b6bd58261a253577dad9a7a5496d7717f9f6e4b8 (diff) | |
download | rockbox-9cfa47a22647a293ea1697456fcdbaddc975830c.tar.gz rockbox-9cfa47a22647a293ea1697456fcdbaddc975830c.zip |
"Bootbox" is a minimalistic rescue firmware for Archos models. Not working yet (Rolo problems). Created by configure script as bootloader.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6786 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'flash/bootbox')
-rw-r--r-- | flash/bootbox/FILES | 4 | ||||
-rw-r--r-- | flash/bootbox/Makefile | 85 | ||||
-rw-r--r-- | flash/bootbox/SOURCES | 1 | ||||
-rw-r--r-- | flash/bootbox/main.c | 237 |
4 files changed, 327 insertions, 0 deletions
diff --git a/flash/bootbox/FILES b/flash/bootbox/FILES new file mode 100644 index 0000000000..22e7774f20 --- /dev/null +++ b/flash/bootbox/FILES | |||
@@ -0,0 +1,4 @@ | |||
1 | Makefile | ||
2 | SOURCES | ||
3 | FILES | ||
4 | *.c | ||
diff --git a/flash/bootbox/Makefile b/flash/bootbox/Makefile new file mode 100644 index 0000000000..26de92fb57 --- /dev/null +++ b/flash/bootbox/Makefile | |||
@@ -0,0 +1,85 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | |||
10 | INCLUDES= -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \ | ||
11 | -I$(BUILDDIR) | ||
12 | |||
13 | DEPFILE = $(OBJDIR)/dep-bootbox | ||
14 | LDS := $(FIRMDIR)/app.lds | ||
15 | |||
16 | ifdef DEBUG | ||
17 | DEFINES := -DDEBUG | ||
18 | CFLAGS += -g | ||
19 | endif | ||
20 | |||
21 | SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - ) | ||
22 | DIRS = . | ||
23 | |||
24 | ifdef APPEXTRA | ||
25 | DIRS += $(APPEXTRA) | ||
26 | INCLUDES += -I$(APPEXTRA) | ||
27 | endif | ||
28 | |||
29 | CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \ | ||
30 | -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} | ||
31 | |||
32 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) | ||
33 | SOURCES = $(SRC) | ||
34 | LINKFILE = $(OBJDIR)/linkage.lds | ||
35 | MAXINFILE = $(OBJDIR)/romstart.temp | ||
36 | MAXOUTFILE = $(OBJDIR)/romstart | ||
37 | |||
38 | all: $(BUILDDIR)/$(BINARY) $(FLASHFILE) | ||
39 | |||
40 | dep: $(DEPFILE) | ||
41 | |||
42 | $(LINKFILE): $(LDS) | ||
43 | @echo "Build LDS file" | ||
44 | @cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@ | ||
45 | |||
46 | $(MAXOUTFILE): | ||
47 | @echo '#include "config.h"' > $(MAXINFILE) | ||
48 | @echo "ROM_START" >> $(MAXINFILE) | ||
49 | @cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE) | ||
50 | @rm $(MAXINFILE) | ||
51 | |||
52 | $(OBJDIR)/bootbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) | ||
53 | @echo "LD bootbox.elf" | ||
54 | $(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootbox.map | ||
55 | |||
56 | $(OBJDIR)/bootbox.bin : $(OBJDIR)/bootbox.elf | ||
57 | @echo "OBJCOPY $<" | ||
58 | @$(OC) -O binary $< $@ | ||
59 | |||
60 | $(OBJDIR)/bootbox.asm: $(OBJDIR)/bootbox.bin | ||
61 | $(TOOLSDIR)/sh2d -sh1 $< > $@ | ||
62 | |||
63 | $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootbox.bin | ||
64 | @echo "Build bootbox file" | ||
65 | @$(MKFIRMWARE) $< $@ | ||
66 | |||
67 | $(FLASHFILE): $(OBJDIR)/bootbox.bin | ||
68 | @a=`uclpack -h 2>/dev/null`; \ | ||
69 | if test -n "$$a"; then \ | ||
70 | echo "UCLPACK bootbox" ; \ | ||
71 | uclpack --best --2e $< $@ >/dev/null 2>&1; \ | ||
72 | else \ | ||
73 | echo "no uclpack command found, makes a fake bootbox.ucl"; \ | ||
74 | echo "fake" > $@; \ | ||
75 | fi | ||
76 | |||
77 | include $(TOOLSDIR)/make.inc | ||
78 | |||
79 | clean: | ||
80 | @echo "cleaning bootbox" | ||
81 | @-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootbox.asm $(OBJDIR)/rockbox.ucl \ | ||
82 | $(OBJDIR)/bootbox.bin $(OBJDIR)/bootbox.elf $(OBJDIR)/*.map \ | ||
83 | $(LINKFILE) $(MAXOUTFILE) $(DEPFILE) | ||
84 | |||
85 | -include $(DEPFILE) | ||
diff --git a/flash/bootbox/SOURCES b/flash/bootbox/SOURCES new file mode 100644 index 0000000000..e241137f99 --- /dev/null +++ b/flash/bootbox/SOURCES | |||
@@ -0,0 +1 @@ | |||
main.c | |||
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c new file mode 100644 index 0000000000..da9efcf728 --- /dev/null +++ b/flash/bootbox/main.c | |||
@@ -0,0 +1,237 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Jörg Hohensohn aka [IDC]Dragon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | |||
21 | #include <stdlib.h> | ||
22 | #include <stdio.h> | ||
23 | #include "cpu.h" | ||
24 | #include "system.h" | ||
25 | #include "lcd.h" | ||
26 | #include "kernel.h" | ||
27 | #include "thread.h" | ||
28 | #include "ata.h" | ||
29 | #include "disk.h" | ||
30 | #include "font.h" | ||
31 | #include "adc.h" | ||
32 | #include "button.h" | ||
33 | #include "panic.h" | ||
34 | #include "power.h" | ||
35 | #include "file.h" | ||
36 | #include "rolo.h" | ||
37 | #include "usb.h" | ||
38 | #include "powermgmt.h" | ||
39 | |||
40 | int line = 0; | ||
41 | |||
42 | void usb_screen(void) | ||
43 | { | ||
44 | lcd_clear_display(); | ||
45 | lcd_puts(0, 0, "USB mode"); | ||
46 | #ifdef HAVE_LCD_BITMAP | ||
47 | lcd_update(); | ||
48 | #endif | ||
49 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
50 | while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { | ||
51 | } | ||
52 | } | ||
53 | |||
54 | int show_logo(void) | ||
55 | { | ||
56 | lcd_clear_display(); | ||
57 | lcd_puts(0, 0, "Rockbox"); | ||
58 | lcd_puts(0, 1, "Rescue boot"); | ||
59 | #ifdef HAVE_LCD_BITMAP | ||
60 | lcd_update(); | ||
61 | #endif | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | #ifdef HAVE_CHARGING | ||
66 | int charging_screen(void) | ||
67 | { | ||
68 | unsigned int button; | ||
69 | int rc = 0; | ||
70 | #ifdef BUTTON_OFF | ||
71 | const unsigned int offbutton = BUTTON_OFF; | ||
72 | #else | ||
73 | const unsigned int offbutton = BUTTON_STOP; | ||
74 | #endif | ||
75 | |||
76 | ide_power_enable(false); /* power down the disk, else would be spinning */ | ||
77 | |||
78 | lcd_clear_display(); | ||
79 | lcd_puts(0, 0, "charging..."); | ||
80 | #ifdef HAVE_LCD_BITMAP | ||
81 | lcd_update(); | ||
82 | #endif | ||
83 | |||
84 | do | ||
85 | { | ||
86 | button = button_get_w_tmo(HZ/2); | ||
87 | #ifdef BUTTON_ON | ||
88 | if (button == (BUTTON_ON | BUTTON_REL)) | ||
89 | #else | ||
90 | if (button == (BUTTON_RIGHT | BUTTON_REL)) | ||
91 | #endif | ||
92 | rc = 3; | ||
93 | else if (button == offbutton) | ||
94 | rc = 2; | ||
95 | else | ||
96 | { | ||
97 | if (usb_detect()) | ||
98 | rc = 4; | ||
99 | else if (!charger_inserted()) | ||
100 | rc = 1; | ||
101 | } | ||
102 | } while (!rc); | ||
103 | |||
104 | return rc; | ||
105 | } | ||
106 | #endif /* HAVE_CHARGING */ | ||
107 | |||
108 | |||
109 | void main(void) | ||
110 | { | ||
111 | int rc; | ||
112 | |||
113 | power_init(); | ||
114 | system_init(); | ||
115 | kernel_init(); | ||
116 | lcd_init(); | ||
117 | show_logo(); | ||
118 | set_irq_level(0); | ||
119 | adc_init(); | ||
120 | usb_init(); | ||
121 | button_init(); | ||
122 | powermgmt_init(); | ||
123 | |||
124 | #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034) | ||
125 | if (charger_inserted() | ||
126 | #ifdef ATA_POWER_PLAYERSTYLE | ||
127 | && !ide_powered() /* relies on probing result from bootloader */ | ||
128 | #endif | ||
129 | ) | ||
130 | { | ||
131 | rc = charging_screen(); /* display a "charging" screen */ | ||
132 | if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */ | ||
133 | power_off(); | ||
134 | /* "On" pressed or USB connected: proceed */ | ||
135 | show_logo(); /* again, to provide better visual feedback */ | ||
136 | } | ||
137 | #endif | ||
138 | |||
139 | rc = ata_init(); | ||
140 | if(rc) | ||
141 | { | ||
142 | #ifdef HAVE_LCD_BITMAP | ||
143 | char str[32]; | ||
144 | lcd_clear_display(); | ||
145 | snprintf(str, 31, "ATA error: %d", rc); | ||
146 | lcd_puts(0, 1, str); | ||
147 | lcd_update(); | ||
148 | while(!(button_get(true) & BUTTON_REL)); | ||
149 | #endif | ||
150 | panicf("ata: %d", rc); | ||
151 | } | ||
152 | |||
153 | //disk_init(); | ||
154 | usb_start_monitoring(); | ||
155 | while (usb_detect()) | ||
156 | { /* enter USB mode early, before trying to mount */ | ||
157 | if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) | ||
158 | #ifdef HAVE_MMC | ||
159 | if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED)) | ||
160 | #endif | ||
161 | { | ||
162 | usb_screen(); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | rc = disk_mount_all(); | ||
167 | if (rc<=0) | ||
168 | { | ||
169 | lcd_clear_display(); | ||
170 | lcd_puts(0, 0, "No partition"); | ||
171 | lcd_puts(0, 1, "found."); | ||
172 | #ifdef HAVE_LCD_BITMAP | ||
173 | lcd_puts(0, 2, "Insert USB cable"); | ||
174 | lcd_puts(0, 3, "and fix it."); | ||
175 | lcd_update(); | ||
176 | #endif | ||
177 | while(button_get(true) != SYS_USB_CONNECTED) {}; | ||
178 | usb_screen(); | ||
179 | system_reboot(); | ||
180 | } | ||
181 | |||
182 | { // rolo the firmware | ||
183 | int fd; | ||
184 | static const char filename[] = BOOTFILE; | ||
185 | fd = open(filename, O_RDONLY); | ||
186 | if(fd >= 0) /* no complaint if it doesn't exit */ | ||
187 | { | ||
188 | close(fd); | ||
189 | rolo_load((char*)filename); /* start if it does */ | ||
190 | } | ||
191 | |||
192 | lcd_clear_display(); | ||
193 | lcd_puts(0, 0, "No firmware"); | ||
194 | lcd_puts(0, 1, filename); | ||
195 | #ifdef HAVE_LCD_BITMAP | ||
196 | lcd_update(); | ||
197 | #endif | ||
198 | while(!(button_get(true) & BUTTON_REL)); | ||
199 | system_reboot(); | ||
200 | } | ||
201 | |||
202 | |||
203 | } | ||
204 | |||
205 | /* These functions are present in the firmware library, but we reimplement | ||
206 | them here because the originals do a lot more than we want */ | ||
207 | |||
208 | void screen_dump(void) | ||
209 | { | ||
210 | } | ||
211 | |||
212 | int dbg_ports(void) | ||
213 | { | ||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | void audio_stop(void) | ||
218 | { | ||
219 | } | ||
220 | |||
221 | int audio_status(void) | ||
222 | { | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | void mp3_shutdown(void) | ||
227 | { | ||
228 | } | ||
229 | /* | ||
230 | void i2c_init(void) | ||
231 | { | ||
232 | } | ||
233 | |||
234 | void backlight_on(void) | ||
235 | { | ||
236 | } | ||
237 | */ | ||