blob: 4088065550610e1d87db039f2d425d89060902a5 [file] [log] [blame]
Dominik Wenger41c49702009-10-19 18:14:27 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Dominik Wenger5b4938a2009-10-22 17:45:02 +00008 * $Id$
Dominik Wenger41c49702009-10-19 18:14:27 +00009 *
10 * Copyright (C) 2009 by Bob Cousins, Lyre Project
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* Include Standard files */
23#include <stdlib.h>
24#include <stdio.h>
25#include "inttypes.h"
26#include "string.h"
27#include "cpu.h"
28#include "system.h"
29#include "lcd.h"
Michael Sevakis4ea4cdf2014-08-08 02:28:11 -040030#include "../kernel-internal.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000031#include "storage.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040032#include "file_internal.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000033#include "fat.h"
34#include "disk.h"
35#include "font.h"
36#include "backlight.h"
37#include "button.h"
38#include "panic.h"
39#include "power.h"
40#include "file.h"
41#include "common.h"
Marcin Bukat0b296912012-03-04 15:34:29 +010042#include "rb-loader.h"
43#include "loader_strerror.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000044#include "sd.h"
45#include "backlight-target.h"
46#include "lcd-target.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000047#include "dma-target.h"
48#include "uart-s3c2440.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000049#include "led-mini2440.h"
Rafaël Carré5d236b22010-05-27 09:41:46 +000050#include "version.h"
Dominik Wenger41c49702009-10-19 18:14:27 +000051
Dominik Wenger41c49702009-10-19 18:14:27 +000052
53int main(void)
54{
Dominik Wenger41c49702009-10-19 18:14:27 +000055 unsigned char* loadbuffer;
56 int buffer_size;
57 int rc;
58 int(*kernel_entry)(void);
Dominik Wenger41c49702009-10-19 18:14:27 +000059
60 led_init();
61 clear_leds(LED_ALL);
62 /* NB: something in system_init() prevents H-JTAG from downloading */
63/* system_init(); */
64 kernel_init();
65/* enable_interrupt(IRQ_FIQ_STATUS); */
66 backlight_init();
67 lcd_init();
68 lcd_setfont(FONT_SYSFIXED);
69 button_init();
Dominik Wenger41c49702009-10-19 18:14:27 +000070 dma_init();
Dominik Wenger90b576f2009-10-26 18:16:58 +000071
72 uart_init();
73 uart_init_device(DEBUG_UART_PORT);
Dominik Wenger41c49702009-10-19 18:14:27 +000074
Dominik Wenger5b4938a2009-10-22 17:45:02 +000075/* mini2440_test(); */
76
Dominik Wenger41c49702009-10-19 18:14:27 +000077 /* Show debug messages if button is pressed */
Dominik Wengerd25baec2009-10-31 16:48:08 +000078 int touch_data;
79 if(button_read_device(&touch_data) & BUTTON_MENU)
Dominik Wenger41c49702009-10-19 18:14:27 +000080 verbose = true;
81
82 printf("Rockbox boot loader");
Michael Sevakis95a4c3a2014-08-28 10:26:45 -040083 printf("Version %s", rbversion);
Dominik Wenger41c49702009-10-19 18:14:27 +000084
85 rc = storage_init();
86 if(rc)
87 {
88 reset_screen();
Rafaël Carré1ec82122010-06-23 05:08:36 +000089 error(EATA, rc, true);
Dominik Wenger41c49702009-10-19 18:14:27 +000090 }
91
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040092 filesystem_init();
Dominik Wenger41c49702009-10-19 18:14:27 +000093 rc = disk_mount_all();
94 if (rc<=0)
95 {
Rafaël Carré1ec82122010-06-23 05:08:36 +000096 error(EDISK,rc, true);
Dominik Wenger41c49702009-10-19 18:14:27 +000097 }
98
99 printf("Loading firmware");
100
101 /* Flush out anything pending first */
Marcin Bukat0b296912012-03-04 15:34:29 +0100102 commit_discard_idcache();
Dominik Wenger41c49702009-10-19 18:14:27 +0000103
104 loadbuffer = (unsigned char*) 0x31000000;
105 buffer_size = (unsigned char*)0x31400000 - loadbuffer;
106
107 rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
Marcin Bukat0b296912012-03-04 15:34:29 +0100108 if(rc <= 0)
Rafaël Carré1ec82122010-06-23 05:08:36 +0000109 error(EBOOTFILE, rc, true);
Marcin Bukat0b296912012-03-04 15:34:29 +0100110
Dominik Wenger41c49702009-10-19 18:14:27 +0000111 printf("Loaded firmware %d\n", rc);
112
113/* storage_close(); */
114 system_prepare_fw_start();
115
Marcin Bukat0b296912012-03-04 15:34:29 +0100116 commit_discard_idcache();
117 kernel_entry = (void*) loadbuffer;
118 rc = kernel_entry();
Dominik Wenger41c49702009-10-19 18:14:27 +0000119
Dominik Wenger41c49702009-10-19 18:14:27 +0000120 /* end stop - should not get here */
121 led_flash(LED_ALL, LED_NONE);
122 while (1); /* avoid warning */
123}