Bring back rolo for mi4-based targets (H10 and Sansa).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13550 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3611b4c8d8
commit
54c73a24b6
8 changed files with 144 additions and 75 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "ata.h"
|
||||
#include "button.h"
|
||||
#include "disk.h"
|
||||
#include "crc32-mi4.h"
|
||||
#include <string.h>
|
||||
#ifdef SANSA_E200
|
||||
#include "usb.h"
|
||||
|
@ -250,81 +251,6 @@ static int tea_find_key(struct mi4header_t *mi4header, int fd)
|
|||
|
||||
return key_found;
|
||||
}
|
||||
|
||||
/*
|
||||
* We can't use the CRC32 implementation in the firmware library as it uses a
|
||||
* different polynomial. The polynomial needed is 0xEDB88320L
|
||||
*
|
||||
* CRC32 implementation taken from:
|
||||
*
|
||||
* efone - Distributed internet phone system.
|
||||
*
|
||||
* (c) 1999,2000 Krzysztof Dabrowski
|
||||
* (c) 1999,2000 ElysiuM deeZine
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
*/
|
||||
|
||||
/* based on implementation by Finn Yannick Jacobs */
|
||||
|
||||
|
||||
|
||||
/* crc_tab[] -- this crcTable is being build by chksum_crc32GenTab().
|
||||
* so make sure, you call it before using the other
|
||||
* functions!
|
||||
*/
|
||||
static unsigned int crc_tab[256];
|
||||
|
||||
/* chksum_crc() -- to a given block, this one calculates the
|
||||
* crc32-checksum until the length is
|
||||
* reached. the crc32-checksum will be
|
||||
* the result.
|
||||
*/
|
||||
unsigned int chksum_crc32 (unsigned char *block, unsigned int length)
|
||||
{
|
||||
register unsigned long crc;
|
||||
unsigned long i;
|
||||
|
||||
crc = 0;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
crc = ((crc >> 8) & 0x00FFFFFF) ^ crc_tab[(crc ^ *block++) & 0xFF];
|
||||
}
|
||||
return (crc);
|
||||
}
|
||||
|
||||
/* chksum_crc32gentab() -- to a global crc_tab[256], this one will
|
||||
* calculate the crcTable for crc32-checksums.
|
||||
* it is generated to the polynom [..]
|
||||
*/
|
||||
|
||||
static void chksum_crc32gentab (void)
|
||||
{
|
||||
unsigned long crc, poly;
|
||||
int i, j;
|
||||
|
||||
poly = 0xEDB88320L;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
crc = i;
|
||||
for (j = 8; j > 0; j--)
|
||||
{
|
||||
if (crc & 1)
|
||||
{
|
||||
crc = (crc >> 1) ^ poly;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
crc_tab[i] = crc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Load mi4 format firmware image */
|
||||
|
|
|
@ -23,6 +23,9 @@ debug.c
|
|||
/* Common */
|
||||
common/atoi.c
|
||||
common/crc32.c
|
||||
#ifdef MI4_FORMAT
|
||||
common/crc32-mi4.c
|
||||
#endif
|
||||
common/ctype.c
|
||||
#ifndef SIMULATOR
|
||||
common/dir.c
|
||||
|
|
93
firmware/common/crc32-mi4.c
Normal file
93
firmware/common/crc32-mi4.c
Normal file
|
@ -0,0 +1,93 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: crc32.c 10464 2006-08-05 20:19:10Z miipekk $
|
||||
*
|
||||
* Copyright (C) 2007 Barry Wardell
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* We can't use the CRC32 implementation in the firmware library as it uses a
|
||||
* different polynomial. The polynomial needed is 0xEDB88320L
|
||||
*
|
||||
* CRC32 implementation taken from:
|
||||
*
|
||||
* efone - Distributed internet phone system.
|
||||
*
|
||||
* (c) 1999,2000 Krzysztof Dabrowski
|
||||
* (c) 1999,2000 ElysiuM deeZine
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
*/
|
||||
|
||||
/* based on implementation by Finn Yannick Jacobs */
|
||||
|
||||
|
||||
|
||||
/* crc_tab[] -- this crcTable is being build by chksum_crc32GenTab().
|
||||
* so make sure, you call it before using the other
|
||||
* functions!
|
||||
*/
|
||||
static unsigned int crc_tab[256];
|
||||
|
||||
/* chksum_crc() -- to a given block, this one calculates the
|
||||
* crc32-checksum until the length is
|
||||
* reached. the crc32-checksum will be
|
||||
* the result.
|
||||
*/
|
||||
unsigned int chksum_crc32 (unsigned char *block, unsigned int length)
|
||||
{
|
||||
register unsigned long crc;
|
||||
unsigned long i;
|
||||
|
||||
crc = 0;
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
crc = ((crc >> 8) & 0x00FFFFFF) ^ crc_tab[(crc ^ *block++) & 0xFF];
|
||||
}
|
||||
return (crc);
|
||||
}
|
||||
|
||||
/* chksum_crc32gentab() -- to a global crc_tab[256], this one will
|
||||
* calculate the crcTable for crc32-checksums.
|
||||
* it is generated to the polynom [..]
|
||||
*/
|
||||
|
||||
void chksum_crc32gentab (void)
|
||||
{
|
||||
unsigned long crc, poly;
|
||||
int i, j;
|
||||
|
||||
poly = 0xEDB88320L;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
crc = i;
|
||||
for (j = 8; j > 0; j--)
|
||||
{
|
||||
if (crc & 1)
|
||||
{
|
||||
crc = (crc >> 1) ^ poly;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
crc_tab[i] = crc;
|
||||
}
|
||||
}
|
|
@ -136,6 +136,7 @@
|
|||
/* Define this if you have adjustable CPU frequency */
|
||||
/*#define HAVE_ADJUSTABLE_CPU_FREQ*/
|
||||
|
||||
#define MI4_FORMAT
|
||||
#define BOOTFILE_EXT "mi4"
|
||||
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
||||
#define OLD_BOOTFILE "rockbox.e200"
|
||||
|
|
|
@ -158,6 +158,7 @@
|
|||
/* Define this if you have adjustable CPU frequency */
|
||||
/*#define HAVE_ADJUSTABLE_CPU_FREQ*/
|
||||
|
||||
#define MI4_FORMAT
|
||||
#define BOOTFILE_EXT "mi4"
|
||||
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
||||
#define OLD_BOOTFILE "rockbox.h10"
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
/* Define this if you have adjustable CPU frequency */
|
||||
/*#define HAVE_ADJUSTABLE_CPU_FREQ*/
|
||||
|
||||
#define MI4_FORMAT
|
||||
#define BOOTFILE_EXT "mi4"
|
||||
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
||||
#define OLD_BOOTFILE "rockbox.h10"
|
||||
|
|
25
firmware/include/crc32-mi4.h
Normal file
25
firmware/include/crc32-mi4.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: crc32.h 10464 2006-08-05 20:19:10Z miipekk $
|
||||
*
|
||||
* Copyright (C) 2007 Barry Wardell
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _CRC32_MI4_H
|
||||
#define _CRC32_MI4_H
|
||||
|
||||
unsigned int chksum_crc32 (unsigned char *block, unsigned int length);
|
||||
void chksum_crc32gentab (void);
|
||||
|
||||
#endif
|
|
@ -30,6 +30,14 @@
|
|||
#include "string.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#ifdef MI4_FORMAT
|
||||
#include "crc32-mi4.h"
|
||||
#undef FIRMWARE_OFFSET_FILE_CRC
|
||||
#undef FIRMWARE_OFFSET_FILE_DATA
|
||||
#define FIRMWARE_OFFSET_FILE_CRC 0xC
|
||||
#define FIRMWARE_OFFSET_FILE_DATA 0x200
|
||||
#endif
|
||||
|
||||
#if !defined(IRIVER_IFP7XX_SERIES) && \
|
||||
(CONFIG_CPU != PP5002) && (CONFIG_CPU != S3C2440)
|
||||
/* FIX: this doesn't work on iFP, 3rd Gen ipods */
|
||||
|
@ -152,7 +160,9 @@ int rolo_load(const char* filename)
|
|||
int fd;
|
||||
long length;
|
||||
#if defined(CPU_COLDFIRE) || defined(CPU_PP)
|
||||
#if !defined(MI4_FORMAT)
|
||||
int i;
|
||||
#endif
|
||||
unsigned long checksum,file_checksum;
|
||||
#else
|
||||
long file_length;
|
||||
|
@ -189,8 +199,11 @@ int rolo_load(const char* filename)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if !defined(MI4_FORMAT)
|
||||
/* Rockbox checksums are big-endian */
|
||||
file_checksum = betoh32(file_checksum);
|
||||
#endif
|
||||
|
||||
#ifdef CPU_PP
|
||||
cpu_message = COP_REBOOT;
|
||||
COP_CTL = PROC_WAKE;
|
||||
|
@ -208,11 +221,17 @@ int rolo_load(const char* filename)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef MI4_FORMAT
|
||||
/* Check CRC32 to see if we have a valid file */
|
||||
chksum_crc32gentab();
|
||||
checksum = chksum_crc32 (audiobuf, length);
|
||||
#else
|
||||
checksum = MODEL_NUMBER;
|
||||
|
||||
for(i = 0;i < length;i++) {
|
||||
checksum += audiobuf[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Verify checksum against file header */
|
||||
if (checksum != file_checksum) {
|
||||
|
|
Loading…
Reference in a new issue