mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-26 23:36:37 -04:00
iAudio X5 bootloader, plus some cleanup
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9180 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8f186803a5
commit
ce6527b7d2
1 changed files with 101 additions and 28 deletions
|
|
@ -37,6 +37,10 @@
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "uda1380.h"
|
#include "uda1380.h"
|
||||||
|
|
||||||
|
#include "pcf50606.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#define DRAM_START 0x31000000
|
#define DRAM_START 0x31000000
|
||||||
|
|
||||||
int line = 0;
|
int line = 0;
|
||||||
|
|
@ -48,6 +52,25 @@ int usb_screen(void)
|
||||||
|
|
||||||
char version[] = APPSVERSION;
|
char version[] = APPSVERSION;
|
||||||
|
|
||||||
|
char printfbuf[256];
|
||||||
|
|
||||||
|
void printf(const char *format, ...)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
unsigned char *ptr;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
|
||||||
|
ptr = printfbuf;
|
||||||
|
len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
lcd_puts(0, line++, ptr);
|
||||||
|
lcd_update();
|
||||||
|
if(line >= 16)
|
||||||
|
line = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void start_iriver_fw(void)
|
void start_iriver_fw(void)
|
||||||
{
|
{
|
||||||
asm(" move.w #0x2700,%sr");
|
asm(" move.w #0x2700,%sr");
|
||||||
|
|
@ -70,7 +93,6 @@ int load_firmware(void)
|
||||||
unsigned long sum;
|
unsigned long sum;
|
||||||
int i;
|
int i;
|
||||||
unsigned char *buf = (unsigned char *)DRAM_START;
|
unsigned char *buf = (unsigned char *)DRAM_START;
|
||||||
char str[80];
|
|
||||||
|
|
||||||
fd = open("/.rockbox/" BOOTFILE, O_RDONLY);
|
fd = open("/.rockbox/" BOOTFILE, O_RDONLY);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
|
|
@ -82,8 +104,7 @@ int load_firmware(void)
|
||||||
|
|
||||||
len = filesize(fd) - 8;
|
len = filesize(fd) - 8;
|
||||||
|
|
||||||
snprintf(str, 80, "Length: %x", len);
|
printf("Length: %x", len);
|
||||||
lcd_puts(0, line++, str);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET);
|
lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET);
|
||||||
|
|
@ -92,8 +113,7 @@ int load_firmware(void)
|
||||||
if(rc < 4)
|
if(rc < 4)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
snprintf(str, 80, "Checksum: %x", chksum);
|
printf("Checksum: %x", chksum);
|
||||||
lcd_puts(0, line++, str);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
rc = read(fd, model, 4);
|
rc = read(fd, model, 4);
|
||||||
|
|
@ -102,8 +122,7 @@ int load_firmware(void)
|
||||||
|
|
||||||
model[4] = 0;
|
model[4] = 0;
|
||||||
|
|
||||||
snprintf(str, 80, "Model name: %s", model);
|
printf("Model name: %s", model);
|
||||||
lcd_puts(0, line++, str);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
|
lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
|
||||||
|
|
@ -120,8 +139,7 @@ int load_firmware(void)
|
||||||
sum += buf[i];
|
sum += buf[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(str, 80, "Sum: %x", sum);
|
printf("Sum: %x", sum);
|
||||||
lcd_puts(0, line++, str);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
if(sum != chksum)
|
if(sum != chksum)
|
||||||
|
|
@ -148,12 +166,71 @@ void main(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int rc;
|
int rc;
|
||||||
char buf[256];
|
|
||||||
bool rc_on_button = false;
|
bool rc_on_button = false;
|
||||||
bool on_button = false;
|
bool on_button = false;
|
||||||
int data;
|
int data;
|
||||||
int adc_battery, battery_voltage, batt_int, batt_frac;
|
int adc_battery, battery_voltage, batt_int, batt_frac;
|
||||||
|
|
||||||
|
#ifdef IAUDIO_X5
|
||||||
|
(void)rc_on_button;
|
||||||
|
(void)on_button;
|
||||||
|
(void)data;
|
||||||
|
power_init();
|
||||||
|
|
||||||
|
system_init();
|
||||||
|
kernel_init();
|
||||||
|
|
||||||
|
set_cpu_frequency(CPUFREQ_NORMAL);
|
||||||
|
|
||||||
|
set_irq_level(0);
|
||||||
|
lcd_init();
|
||||||
|
font_init();
|
||||||
|
adc_init();
|
||||||
|
button_init();
|
||||||
|
|
||||||
|
printf("Rockbox boot loader");
|
||||||
|
printf("Version %s", version);
|
||||||
|
lcd_update();
|
||||||
|
|
||||||
|
adc_battery = adc_read(ADC_BATTERY);
|
||||||
|
|
||||||
|
battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000;
|
||||||
|
batt_int = battery_voltage / 100;
|
||||||
|
batt_frac = battery_voltage % 100;
|
||||||
|
|
||||||
|
printf("Batt: %d.%02dV", batt_int, batt_frac);
|
||||||
|
lcd_update();
|
||||||
|
|
||||||
|
rc = ata_init();
|
||||||
|
if(rc)
|
||||||
|
{
|
||||||
|
printf("ATA error: %d", rc);
|
||||||
|
sleep(HZ*5);
|
||||||
|
power_off();
|
||||||
|
}
|
||||||
|
|
||||||
|
disk_init();
|
||||||
|
|
||||||
|
rc = disk_mount_all();
|
||||||
|
if (rc<=0)
|
||||||
|
{
|
||||||
|
printf("No partition found");
|
||||||
|
sleep(HZ*5);
|
||||||
|
power_off();
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Loading firmware");
|
||||||
|
lcd_update();
|
||||||
|
i = load_firmware();
|
||||||
|
printf("Result: %d", i);
|
||||||
|
lcd_update();
|
||||||
|
|
||||||
|
if(i == 0)
|
||||||
|
start_firmware();
|
||||||
|
|
||||||
|
power_off();
|
||||||
|
|
||||||
|
#else
|
||||||
/* We want to read the buttons as early as possible, before the user
|
/* We want to read the buttons as early as possible, before the user
|
||||||
releases the ON button */
|
releases the ON button */
|
||||||
|
|
||||||
|
|
@ -225,9 +302,8 @@ void main(void)
|
||||||
|
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
|
|
||||||
lcd_puts(0, line++, "Rockbox boot loader");
|
printf("Rockbox boot loader");
|
||||||
snprintf(buf, sizeof(buf), "Version %s", version);
|
printf("Version %s", version);
|
||||||
lcd_puts(0, line++, buf);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
sleep(HZ/50); /* Allow the button driver to check the buttons */
|
sleep(HZ/50); /* Allow the button driver to check the buttons */
|
||||||
|
|
@ -235,7 +311,7 @@ void main(void)
|
||||||
/* Holding REC while starting runs the original firmware */
|
/* Holding REC while starting runs the original firmware */
|
||||||
if(((button_status() & BUTTON_REC) == BUTTON_REC) ||
|
if(((button_status() & BUTTON_REC) == BUTTON_REC) ||
|
||||||
((button_status() & BUTTON_RC_REC) == BUTTON_RC_REC)) {
|
((button_status() & BUTTON_RC_REC) == BUTTON_RC_REC)) {
|
||||||
lcd_puts(0, 8, "Starting original firmware...");
|
printf("Starting original firmware...");
|
||||||
lcd_update();
|
lcd_update();
|
||||||
start_iriver_fw();
|
start_iriver_fw();
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +320,7 @@ void main(void)
|
||||||
are starting with */
|
are starting with */
|
||||||
if(!usb_detect() && ((on_button && button_hold()) ||
|
if(!usb_detect() && ((on_button && button_hold()) ||
|
||||||
(rc_on_button && remote_button_hold()))) {
|
(rc_on_button && remote_button_hold()))) {
|
||||||
lcd_puts(0, 8, "HOLD switch on, power off...");
|
printf("HOLD switch on, power off...");
|
||||||
lcd_update();
|
lcd_update();
|
||||||
sleep(HZ*2);
|
sleep(HZ*2);
|
||||||
|
|
||||||
|
|
@ -270,13 +346,11 @@ void main(void)
|
||||||
batt_int = battery_voltage / 100;
|
batt_int = battery_voltage / 100;
|
||||||
batt_frac = battery_voltage % 100;
|
batt_frac = battery_voltage % 100;
|
||||||
|
|
||||||
snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac);
|
printf("Batt: %d.%02dV", batt_int, batt_frac);
|
||||||
lcd_puts(0, line++, buf);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
if(battery_voltage <= 300) {
|
if(battery_voltage <= 300) {
|
||||||
line++;
|
printf("WARNING! BATTERY LOW!!");
|
||||||
lcd_puts(0, line++, "WARNING! BATTERY LOW!!");
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
sleep(HZ*2);
|
sleep(HZ*2);
|
||||||
}
|
}
|
||||||
|
|
@ -284,12 +358,10 @@ void main(void)
|
||||||
rc = ata_init();
|
rc = ata_init();
|
||||||
if(rc)
|
if(rc)
|
||||||
{
|
{
|
||||||
char str[32];
|
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
snprintf(str, 31, "ATA error: %d", rc);
|
printf("ATA error: %d", rc);
|
||||||
lcd_puts(0, line++, str);
|
printf("Insert USB cable and press");
|
||||||
lcd_puts(0, line++, "Insert USB cable and press");
|
printf("a button");
|
||||||
lcd_puts(0, line++, "a button");
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
while(!(button_get(true) & BUTTON_REL));
|
while(!(button_get(true) & BUTTON_REL));
|
||||||
}
|
}
|
||||||
|
|
@ -336,21 +408,22 @@ void main(void)
|
||||||
if (rc<=0)
|
if (rc<=0)
|
||||||
{
|
{
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
lcd_puts(0, 0, "No partition found");
|
printf("No partition found");
|
||||||
|
lcd_update();
|
||||||
while(button_get(true) != SYS_USB_CONNECTED) {};
|
while(button_get(true) != SYS_USB_CONNECTED) {};
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_puts(0, line++, "Loading firmware");
|
printf("Loading firmware");
|
||||||
lcd_update();
|
lcd_update();
|
||||||
i = load_firmware();
|
i = load_firmware();
|
||||||
snprintf(buf, 256, "Result: %d", i);
|
printf("Result: %d", i);
|
||||||
lcd_puts(0, line++, buf);
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
start_firmware();
|
start_firmware();
|
||||||
|
|
||||||
start_iriver_fw();
|
start_iriver_fw();
|
||||||
|
#endif /* IAUDIO_X5 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These functions are present in the firmware library, but we reimplement
|
/* These functions are present in the firmware library, but we reimplement
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue