From 6a9e4b4f94a7fcf59c7d04fcc2582ddaacc0f14a Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Thu, 7 Oct 2004 17:16:27 +0000 Subject: Ondio flash support git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5213 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/SOURCES | 2 +- apps/plugins/firmware_flash.c | 45 ++++++++++++++++++++++++++++++++++--------- apps/plugins/rockbox_flash.c | 42 ++++++++++++++++++++++++++++++++-------- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 6db328b5a4..2baaa6ba55 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -3,6 +3,7 @@ chessclock.c favorites.c firmware_flash.c helloworld.c +rockbox_flash.c search.c sort.c vbrfix.c @@ -10,7 +11,6 @@ vbrfix.c /* gradually bring in the ones not working yet */ battery_test.c metronome.c -rockbox_flash.c stopwatch.c viewer.c #endif /* #if CONFIG_KEYPAD != ONDIO_PAD */ diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c index 751284aed1..2a90d33aa6 100644 --- a/apps/plugins/firmware_flash.c +++ b/apps/plugins/firmware_flash.c @@ -43,6 +43,8 @@ #define ID_FM 1 #define ID_PLAYER 2 #define ID_REC_V2 3 +#define ID_ONDIO_FM 4 +#define ID_ONDIO_SP 5 /* Here I have to check for ARCHOS_* defines in source code, which is generally strongly discouraged. But here I'm not checking for a certain @@ -63,12 +65,36 @@ #define FILE_TYPE "fm" #define KEEP MASK_ADR /* keep the mask value */ #define PLATFORM_ID ID_FM +#elif defined(ARCHOS_ONDIOFM) +#define FILE_TYPE "ondiofm" +#define KEEP MASK_ADR /* keep the mask value */ +#define PLATFORM_ID ID_ONDIO_FM +#elif defined(ARCHOS_ONDIOSP) +#define FILE_TYPE "ondiosp" +#define KEEP MASK_ADR /* keep the mask value */ +#define PLATFORM_ID ID_ONDIO_SP #else #undef PLATFORM_ID /* this platform is not (yet) flashable */ #endif #ifdef PLATFORM_ID +#if CONFIG_KEYPAD == ONDIO_PAD /* limited keypad */ +#define KEY1 BUTTON_UP +#define KEY2 BUTTON_RIGHT +#define KEY3 BUTTON_DOWN +#define KEYNAME1 "[UP]" +#define KEYNAME2 "[RIGHT]" +#define KEYNAME3 "[DOWN]" +#else /* recorder keypad */ +#define KEY1 BUTTON_F1 +#define KEY2 BUTTON_F2 +#define KEY3 BUTTON_F3 +#define KEYNAME1 "[F1]" +#define KEYNAME2 "[F2]" +#define KEYNAME3 "[F3]" +#endif + /* result of the CheckFirmwareFile() function */ typedef enum { @@ -284,8 +310,9 @@ bool CheckPlatform(int platform_id, UINT16 version) return (platform_id == ID_FM || platform_id == ID_REC_V2); } else if (version == 132) - { /* seen on a V2 recorder */ - return (platform_id == ID_REC_V2); + { /* Ondio, and seen on a V2 recorder */ + return (platform_id == ID_ONDIO_SP || platform_id == ID_ONDIO_FM + || platform_id == ID_REC_V2); } else if (version >= 115 && version <= 129) { /* the range of Recorders seen so far */ @@ -385,7 +412,7 @@ tCheckResult CheckFirmwareFile(char* filename, int chipsize, bool is_romless) return eBadContent; } - for (i = 0x30; ilcd_puts(0, 3, "using file:"); rb->lcd_puts_scroll(0, 4, filename); - rb->lcd_puts(0, 6, "[F1] to check file"); + rb->lcd_puts(0, 6, KEYNAME1 " to check file"); rb->lcd_puts(0, 7, "other key to exit"); rb->lcd_update(); button = WaitForButton(); - if (button != BUTTON_F1) + if (button != KEY1) { return; } @@ -718,7 +745,7 @@ void DoUserDialog(char* filename) if (rc == eOK) { - rb->lcd_puts(0, 6, "[F2] to program"); + rb->lcd_puts(0, 6, KEYNAME2 " to program"); rb->lcd_puts(0, 7, "other key to exit"); } else @@ -729,7 +756,7 @@ void DoUserDialog(char* filename) rb->lcd_update(); button = WaitForButton(); - if (button != BUTTON_F2 || rc != eOK) + if (button != KEY2 || rc != eOK) { return; } @@ -741,12 +768,12 @@ void DoUserDialog(char* filename) rb->lcd_puts(0, 3, "it kills your box!"); rb->lcd_puts(0, 4, "See documentation."); - rb->lcd_puts(0, 6, "[F3] to proceed"); + rb->lcd_puts(0, 6, KEYNAME3 " to proceed"); rb->lcd_puts(0, 7, "other key to exit"); rb->lcd_update(); button = WaitForButton(); - if (button != BUTTON_F3) + if (button != KEY3) { return; } diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c index e393f20058..37e4458b8b 100644 --- a/apps/plugins/rockbox_flash.c +++ b/apps/plugins/rockbox_flash.c @@ -26,6 +26,8 @@ /* define DUMMY if you only want to "play" with the UI, does no harm */ /* #define DUMMY */ +#define LATEST_BOOTLOADER_VERSION 1 /* update this with the bootloader */ + #ifndef UINT8 #define UINT8 unsigned char #endif @@ -45,9 +47,24 @@ static volatile UINT8* FB = (UINT8*)0x02000000; /* Flash base address */ #define ROCKBOX_DEST 0x09000000 #define ROCKBOX_EXEC 0x09000200 #define DEFAULT_FILENAME "/rockbox.ucl" -#define VERS_ADR 0xFE /* position of firmware version value in Flash */ +#define BOOT_VERS_ADR 0xFA /* position of bootloader version value in Flash */ +#define FW_VERS_ADR 0xFE /* position of firmware version value in Flash */ #define UCL_HEADER 26 /* size of the header generated by uclpack */ +#if CONFIG_KEYPAD == ONDIO_PAD /* limited keypad */ +#define KEY1 BUTTON_UP +#define KEY2 BUTTON_RIGHT +#define KEY3 BUTTON_DOWN +#define KEYNAME1 "UP" +#define KEYNAME2 "RIGHT" +#else /* recorder keypad */ +#define KEY1 BUTTON_F1 +#define KEY2 BUTTON_F2 +#define KEY3 BUTTON_F3 +#define KEYNAME1 "F1" +#define KEYNAME2 "F2" +#endif + typedef struct { UINT32 destination; /* address to copy it to */ @@ -301,6 +318,15 @@ unsigned CheckBootloader(void) { unsigned crc; UINT32* pFlash = (UINT32*)FB; + int bootloader_version = FB[BOOT_VERS_ADR]; + + if (bootloader_version) /* this is a newer image, with a version number */ + { + if (bootloader_version < LATEST_BOOTLOADER_VERSION) + return bootloader_version; + else + return 0; + } /* checksum the bootloader, unfortunately I have no version info yet */ crc = crc_32((unsigned char*)pFlash[2], pFlash[3], -1); @@ -638,7 +664,7 @@ void DoUserDialog(char* filename, bool show_greet) crc = CheckBootloader(); if (crc) /* outdated version found */ { - rb->snprintf(buf, sizeof(buf), " (CRC=0x%08x) ", crc); + rb->snprintf(buf, sizeof(buf), "(check=0x%08x)", crc); rb->lcd_puts(0, 0, buf); rb->lcd_puts(0, 1, "Hint: You're not "); rb->lcd_puts(0, 2, "using the latest "); @@ -646,10 +672,10 @@ void DoUserDialog(char* filename, bool show_greet) rb->lcd_puts(0, 4, "A full reflash is "); rb->lcd_puts(0, 5, "recommended, but "); rb->lcd_puts(0, 6, "not required. "); - rb->lcd_puts(0, 7, "Press F1 to ignore"); + rb->lcd_puts(0, 7, "Press " KEYNAME1 " to ignore"); rb->lcd_update(); - if (WaitForButton() != BUTTON_F1) + if (WaitForButton() != KEY1) { return; } @@ -660,11 +686,11 @@ void DoUserDialog(char* filename, bool show_greet) { rb->lcd_puts(0, 3, "using file:"); rb->lcd_puts_scroll(0, 4, filename); - rb->lcd_puts(0, 6, "[F1] to check file"); + rb->lcd_puts(0, 6, "[" KEYNAME1 "] to check file"); rb->lcd_puts(0, 7, "other key to exit"); rb->lcd_update(); - if (WaitForButton() != BUTTON_F1) + if (WaitForButton() != KEY1) { return; } @@ -728,7 +754,7 @@ void DoUserDialog(char* filename, bool show_greet) if (rc == eOK) { /* was OK */ - rb->lcd_puts(0, 6, "[F2] to program"); + rb->lcd_puts(0, 6, "[" KEYNAME2 "] to program"); rb->lcd_puts(0, 7, "other key to exit"); } else @@ -738,7 +764,7 @@ void DoUserDialog(char* filename, bool show_greet) rb->lcd_update(); button = WaitForButton(); - if (rc != eOK || button != BUTTON_F2) + if (rc != eOK || button != KEY2) { return; } -- cgit v1.2.3