Submit FS#12196. Adds support for embedded album art (jpg) with APEv2 tags.
[kugel-rb.git] / bootloader / imx233.c
blobf6c5ad9cf47607f3978a2f01fddd46ccd8351ac0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 by amaury Pouly
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
13 * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
25 #include <stdio.h>
26 #include <system.h>
27 #include <inttypes.h>
28 #include "config.h"
29 #include "gcc_extensions.h"
30 #include "lcd.h"
31 #include "backlight.h"
32 #include "button-target.h"
33 #include "common.h"
34 #include "storage.h"
35 #include "disk.h"
36 #include "panic.h"
37 #include "power.h"
38 #include "system-target.h"
39 #include "fmradio_i2c.h"
41 #include "usb.h"
43 void main(uint32_t arg) NORETURN_ATTR;
44 void main(uint32_t arg)
46 unsigned char* loadbuffer;
47 int buffer_size;
48 void(*kernel_entry)(void);
49 int ret;
51 system_init();
52 kernel_init();
54 enable_irq();
56 lcd_init();
57 lcd_clear_display();
58 lcd_update();
60 backlight_init();
62 button_init_device();
64 //button_debug_screen();
65 printf("arg=%c%c%c%c", arg >> 24,
66 (arg >> 16) & 0xff, (arg >> 8) & 0xff, (arg & 0xff));
68 ret = storage_init();
69 if(ret < 0)
70 error(EATA, ret, true);
72 #ifdef HAVE_BOOTLOADER_USB_MODE
73 usb_init();
74 usb_core_enable_driver(USB_DRIVER_SERIAL, true);
75 usb_attach();
76 while(!(button_read_device() & BUTTON_POWER))
77 yield();
78 power_off();
79 #endif /* HAVE_BOOTLOADER_USB_MODE */
81 while(!disk_init(IF_MV(0)))
82 panicf("disk_init failed!");
84 while((ret = disk_mount_all()) <= 0)
86 error(EDISK, ret, true);
89 if(button_read_device() & BUTTON_VOL_UP)
90 printf("Booting from SD card required.");
92 printf("Loading firmware");
94 loadbuffer = (unsigned char*)DRAM_ORIG; /* DRAM */
95 buffer_size = (int)(loadbuffer + DRAM_SIZE - TTB_SIZE);
97 while((ret = load_firmware(loadbuffer, BOOTFILE, buffer_size)) < 0)
99 error(EBOOTFILE, ret, true);
102 kernel_entry = (void*) loadbuffer;
103 //cpucache_invalidate();
104 printf("Executing");
105 kernel_entry();
106 printf("ERR: Failed to boot");
108 /* never returns */
109 while(1) ;