Rework c200wipe to use proper partitioning and formatting code, which makes the code size-independent.
Also support the e200 with this code. Apparently it's also possible to get the e200 in a state where .fmt files don't help. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30413 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e9eb5b31ad
commit
2b9e944021
7 changed files with 763 additions and 525 deletions
|
@ -18,10 +18,9 @@ show_logo.c
|
|||
defined(SAMSUNG_YH925) || defined(SANSA_VIEW)
|
||||
#ifdef E200R_INSTALLER
|
||||
main-e200r-installer.c
|
||||
#elif defined(C240_ERASE)
|
||||
main-c240wipe.c
|
||||
#elif defined(C250_ERASE)
|
||||
main-c250wipe.c
|
||||
#elif defined(SANSA_PP_ERASE)
|
||||
main-ppsansawipe.c
|
||||
fat32format.c
|
||||
#else
|
||||
show_logo.c
|
||||
main-pp.c
|
||||
|
|
504
bootloader/fat32format.c
Normal file
504
bootloader/fat32format.c
Normal file
|
@ -0,0 +1,504 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: fat32format.c 30351 2011-08-25 19:58:47Z thomasjfox $
|
||||
*
|
||||
*
|
||||
* FAT32 formatting functions. Based on:
|
||||
*
|
||||
* Fat32 formatter version 1.03
|
||||
* (c) Tom Thornhill 2005
|
||||
* This software is covered by the GPL.
|
||||
* By using this tool, you agree to absolve Ridgecrop of an liabilities for
|
||||
* lost data.
|
||||
* Please backup any data you value before using this tool.
|
||||
*
|
||||
*
|
||||
* Modified June 2007 by Dave Chapman for use in ipodpatcher
|
||||
* Modified September 2011 by Frank Gevaerts for use in sansa eraser
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
#include "cpu.h"
|
||||
#include "file.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "storage.h"
|
||||
#include "button.h"
|
||||
#include "disk.h"
|
||||
#include "crc32-mi4.h"
|
||||
#include <string.h>
|
||||
#include "i2c.h"
|
||||
#include "backlight-target.h"
|
||||
#include "power.h"
|
||||
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
/* The following functions are not the most efficient, but are
|
||||
self-contained and don't require needing to know endianness of CPU
|
||||
at compile-time.
|
||||
|
||||
Note that htole16/htole32 exist on some platforms, so for
|
||||
simplicity we use different names.
|
||||
|
||||
*/
|
||||
|
||||
static uint16_t rb_htole16(uint16_t x)
|
||||
{
|
||||
uint16_t test = 0x1234;
|
||||
unsigned char* p = (unsigned char*)&test;
|
||||
|
||||
if (p[0]==0x12) {
|
||||
/* Big-endian */
|
||||
return swap16(x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t rb_htole32(uint32_t x)
|
||||
{
|
||||
uint32_t test = 0x12345678;
|
||||
unsigned char* p = (unsigned char*)&test;
|
||||
|
||||
if (p[0]==0x12) {
|
||||
/* Big-endian */
|
||||
return swap32(x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* A large aligned buffer for disk I/O */
|
||||
unsigned char sectorbuf[128*SECTOR_SIZE];
|
||||
|
||||
/* TODO: Pass these as parameters to the various create_ functions */
|
||||
|
||||
/* can be zero for default or 1,2,4,8,16,32 or 64 */
|
||||
static int sectors_per_cluster = 0;
|
||||
|
||||
/* Recommended values */
|
||||
static uint32_t ReservedSectCount = 32;
|
||||
static uint32_t NumFATs = 2;
|
||||
static uint32_t BackupBootSect = 6;
|
||||
static uint32_t VolumeId=0; /* calculated before format */
|
||||
|
||||
/* Calculated later */
|
||||
static uint32_t FatSize=0;
|
||||
static uint32_t BytesPerSect=0;
|
||||
static uint32_t SectorsPerCluster=0;
|
||||
static uint32_t TotalSectors=0;
|
||||
static uint32_t SystemAreaSize=0;
|
||||
static uint32_t UserAreaSize=0;
|
||||
static uint8_t VolId[12] = "NO NAME ";
|
||||
|
||||
|
||||
struct FAT_BOOTSECTOR32
|
||||
{
|
||||
/* Common fields. */
|
||||
uint8_t sJmpBoot[3];
|
||||
char sOEMName[8];
|
||||
uint16_t wBytsPerSec;
|
||||
uint8_t bSecPerClus;
|
||||
uint16_t wRsvdSecCnt;
|
||||
uint8_t bNumFATs;
|
||||
uint16_t wRootEntCnt;
|
||||
uint16_t wTotSec16; /* if zero, use dTotSec32 instead */
|
||||
uint8_t bMedia;
|
||||
uint16_t wFATSz16;
|
||||
uint16_t wSecPerTrk;
|
||||
uint16_t wNumHeads;
|
||||
uint32_t dHiddSec;
|
||||
uint32_t dTotSec32;
|
||||
|
||||
/* Fat 32/16 only */
|
||||
uint32_t dFATSz32;
|
||||
uint16_t wExtFlags;
|
||||
uint16_t wFSVer;
|
||||
uint32_t dRootClus;
|
||||
uint16_t wFSInfo;
|
||||
uint16_t wBkBootSec;
|
||||
uint8_t Reserved[12];
|
||||
uint8_t bDrvNum;
|
||||
uint8_t Reserved1;
|
||||
uint8_t bBootSig; /* == 0x29 if next three fields are ok */
|
||||
uint32_t dBS_VolID;
|
||||
uint8_t sVolLab[11];
|
||||
uint8_t sBS_FilSysType[8];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct FAT_FSINFO {
|
||||
uint32_t dLeadSig; // 0x41615252
|
||||
uint8_t sReserved1[480]; // zeros
|
||||
uint32_t dStrucSig; // 0x61417272
|
||||
uint32_t dFree_Count; // 0xFFFFFFFF
|
||||
uint32_t dNxt_Free; // 0xFFFFFFFF
|
||||
uint8_t sReserved2[12]; // zeros
|
||||
uint32_t dTrailSig; // 0xAA550000
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/* Write "count" zero sectors, starting at sector "sector" */
|
||||
static int zero_sectors(uint32_t sector, int count)
|
||||
{
|
||||
int n;
|
||||
|
||||
memset(sectorbuf, 0, 128 * SECTOR_SIZE);
|
||||
|
||||
/* Write 128 sectors at a time */
|
||||
while (count) {
|
||||
if (count >= 128)
|
||||
n = 128;
|
||||
else
|
||||
n = count;
|
||||
|
||||
if (storage_write_sectors(sector,n,sectorbuf) < 0) {
|
||||
printf("[ERR] Write failed in zero_sectors\n");
|
||||
return -1;
|
||||
}
|
||||
sector += n;
|
||||
count -= n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
28.2 CALCULATING THE VOLUME SERIAL NUMBER
|
||||
|
||||
For example, say a disk was formatted on 26 Dec 95 at 9:55 PM and 41.94
|
||||
seconds. DOS takes the date and time just before it writes it to the
|
||||
disk.
|
||||
|
||||
Low order word is calculated: Volume Serial Number is:
|
||||
Month & Day 12/26 0c1ah
|
||||
Sec & Hundrenths 41:94 295eh 3578:1d02
|
||||
-----
|
||||
3578h
|
||||
|
||||
High order word is calculated:
|
||||
Hours & Minutes 21:55 1537h
|
||||
Year 1995 07cbh
|
||||
-----
|
||||
1d02h
|
||||
*/
|
||||
static uint32_t get_volume_id ( void )
|
||||
{
|
||||
/* TODO */
|
||||
#if 0
|
||||
SYSTEMTIME s;
|
||||
uint32_t d;
|
||||
uint16_t lo,hi,tmp;
|
||||
|
||||
GetLocalTime( &s );
|
||||
|
||||
lo = s.wDay + ( s.wMonth << 8 );
|
||||
tmp = (s.wMilliseconds/10) + (s.wSecond << 8 );
|
||||
lo += tmp;
|
||||
|
||||
hi = s.wMinute + ( s.wHour << 8 );
|
||||
hi += s.wYear;
|
||||
|
||||
d = lo + (hi << 16);
|
||||
return(d);
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
This is the Microsoft calculation from FATGEN
|
||||
|
||||
uint32_t RootDirSectors = 0;
|
||||
uint32_t TmpVal1, TmpVal2, FATSz;
|
||||
|
||||
TmpVal1 = DskSize - ( ReservedSecCnt + RootDirSectors);
|
||||
TmpVal2 = (256 * SecPerClus) + NumFATs;
|
||||
TmpVal2 = TmpVal2 / 2;
|
||||
FATSz = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
|
||||
|
||||
return( FatSz );
|
||||
*/
|
||||
|
||||
|
||||
static uint32_t get_fat_size_sectors(uint32_t DskSize, uint32_t ReservedSecCnt,
|
||||
uint32_t SecPerClus, uint32_t NumFATs,
|
||||
uint32_t BytesPerSect)
|
||||
{
|
||||
uint32_t Numerator, Denominator;
|
||||
uint32_t FatElementSize = 4;
|
||||
uint32_t FatSz;
|
||||
|
||||
/* This is based on
|
||||
http://hjem.get2net.dk/rune_moeller_barnkob/filesystems/fat.html
|
||||
I've made the obvious changes for FAT32
|
||||
*/
|
||||
|
||||
Numerator = FatElementSize * ( DskSize - ReservedSecCnt );
|
||||
Denominator = ( SecPerClus * BytesPerSect ) + ( FatElementSize * NumFATs );
|
||||
FatSz = Numerator / Denominator;
|
||||
|
||||
/* round up */
|
||||
FatSz += 1;
|
||||
|
||||
return((uint32_t)FatSz);
|
||||
}
|
||||
|
||||
static uint8_t get_spc(uint32_t ClusterSizeKB, uint32_t BytesPerSect)
|
||||
{
|
||||
uint32_t spc = ( ClusterSizeKB * 1024 ) / BytesPerSect;
|
||||
return( (uint8_t) spc );
|
||||
}
|
||||
|
||||
static uint8_t get_sectors_per_cluster(uint32_t DiskSizeSectors,
|
||||
uint32_t BytesPerSect)
|
||||
{
|
||||
uint8_t ret = 0x01; /* 1 sector per cluster */
|
||||
int32_t DiskSizeMB = DiskSizeSectors / ( 1024*1024 / SECTOR_SIZE);
|
||||
|
||||
/* 512 MB to 8,191 MB 4 KB */
|
||||
if ( DiskSizeMB > 512 )
|
||||
ret = get_spc( 4, BytesPerSect ); /* ret = 0x8; */
|
||||
|
||||
/* 8,192 MB to 16,383 MB 8 KB */
|
||||
if ( DiskSizeMB > 8192 )
|
||||
ret = get_spc( 8, BytesPerSect ); /* ret = 0x10; */
|
||||
|
||||
/* 16,384 MB to 32,767 MB 16 KB */
|
||||
if ( DiskSizeMB > 16384 )
|
||||
ret = get_spc( 16, BytesPerSect ); /* ret = 0x20; */
|
||||
|
||||
/* Larger than 32,768 MB 32 KB */
|
||||
if ( DiskSizeMB > 32768 )
|
||||
ret = get_spc( 32, BytesPerSect ); /* ret = 0x40; */
|
||||
|
||||
return( ret );
|
||||
|
||||
}
|
||||
|
||||
static void create_boot_sector(unsigned char* buf)
|
||||
{
|
||||
struct FAT_BOOTSECTOR32* pFAT32BootSect = (struct FAT_BOOTSECTOR32*)buf;
|
||||
|
||||
/* fill out the boot sector and fs info */
|
||||
pFAT32BootSect->sJmpBoot[0]=0xEB;
|
||||
pFAT32BootSect->sJmpBoot[1]=0x5A;
|
||||
pFAT32BootSect->sJmpBoot[2]=0x90;
|
||||
memcpy(pFAT32BootSect->sOEMName, "MSWIN4.1", 8 );
|
||||
pFAT32BootSect->wBytsPerSec = rb_htole16(BytesPerSect);
|
||||
pFAT32BootSect->bSecPerClus = SectorsPerCluster ;
|
||||
pFAT32BootSect->wRsvdSecCnt = rb_htole16(ReservedSectCount);
|
||||
pFAT32BootSect->bNumFATs = NumFATs;
|
||||
pFAT32BootSect->wRootEntCnt = rb_htole16(0);
|
||||
pFAT32BootSect->wTotSec16 = rb_htole16(0);
|
||||
pFAT32BootSect->bMedia = 0xF8;
|
||||
pFAT32BootSect->wFATSz16 = rb_htole16(0);
|
||||
pFAT32BootSect->wSecPerTrk = 63;
|
||||
pFAT32BootSect->wNumHeads = 255;
|
||||
pFAT32BootSect->dHiddSec = 0;
|
||||
pFAT32BootSect->dTotSec32 = rb_htole32(TotalSectors);
|
||||
pFAT32BootSect->dFATSz32 = rb_htole32(FatSize);
|
||||
pFAT32BootSect->wExtFlags = rb_htole16(0);
|
||||
pFAT32BootSect->wFSVer = rb_htole16(0);
|
||||
pFAT32BootSect->dRootClus = rb_htole32(2);
|
||||
pFAT32BootSect->wFSInfo = rb_htole16(1);
|
||||
pFAT32BootSect->wBkBootSec = rb_htole16(BackupBootSect);
|
||||
pFAT32BootSect->bDrvNum = 0x80;
|
||||
pFAT32BootSect->Reserved1 = 0;
|
||||
pFAT32BootSect->bBootSig = 0x29;
|
||||
pFAT32BootSect->dBS_VolID = rb_htole32(VolumeId);
|
||||
memcpy(pFAT32BootSect->sVolLab, VolId, 11);
|
||||
memcpy(pFAT32BootSect->sBS_FilSysType, "FAT32 ", 8 );
|
||||
|
||||
buf[510] = 0x55;
|
||||
buf[511] = 0xaa;
|
||||
}
|
||||
|
||||
static void create_fsinfo(unsigned char* buf)
|
||||
{
|
||||
struct FAT_FSINFO* pFAT32FsInfo = (struct FAT_FSINFO*)buf;
|
||||
|
||||
/* FSInfo sect */
|
||||
pFAT32FsInfo->dLeadSig = rb_htole32(0x41615252);
|
||||
pFAT32FsInfo->dStrucSig = rb_htole32(0x61417272);
|
||||
pFAT32FsInfo->dFree_Count = rb_htole32((uint32_t) -1);
|
||||
pFAT32FsInfo->dNxt_Free = rb_htole32((uint32_t) -1);
|
||||
pFAT32FsInfo->dTrailSig = rb_htole32(0xaa550000);
|
||||
pFAT32FsInfo->dFree_Count = rb_htole32((UserAreaSize/SectorsPerCluster)-1);
|
||||
|
||||
/* clusters 0-1 reserved, we used cluster 2 for the root dir */
|
||||
pFAT32FsInfo->dNxt_Free = rb_htole32(3);
|
||||
}
|
||||
|
||||
static void create_firstfatsector(unsigned char* buf)
|
||||
{
|
||||
uint32_t* p = (uint32_t*)buf; /* We know the buffer is aligned */
|
||||
|
||||
/* First FAT Sector */
|
||||
p[0] = rb_htole32(0x0ffffff8); /* Reserved cluster 1 media id in low byte */
|
||||
p[1] = rb_htole32(0x0fffffff); /* Reserved cluster 2 EOC */
|
||||
p[2] = rb_htole32(0x0fffffff); /* end of cluster chain for root dir */
|
||||
}
|
||||
|
||||
int format_partition(int start, int size)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t qTotalSectors=0;
|
||||
uint32_t FatNeeded;
|
||||
|
||||
VolumeId = get_volume_id( );
|
||||
|
||||
/* Only support hard disks at the moment */
|
||||
if ( SECTOR_SIZE != 512 )
|
||||
{
|
||||
printf("[ERR] Only disks with 512 bytes per sector are supported.\n");
|
||||
return -1;
|
||||
}
|
||||
BytesPerSect = SECTOR_SIZE;
|
||||
|
||||
/* Checks on Disk Size */
|
||||
qTotalSectors = size;
|
||||
|
||||
/* low end limit - 65536 sectors */
|
||||
if ( qTotalSectors < 65536 )
|
||||
{
|
||||
/* I suspect that most FAT32 implementations would mount this
|
||||
volume just fine, but the spec says that we shouldn't do
|
||||
this, so we won't */
|
||||
|
||||
printf("[ERR] This drive is too small for FAT32 - there must be at least 64K clusters\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( qTotalSectors >= 0xffffffff )
|
||||
{
|
||||
/* This is a more fundamental limitation on FAT32 - the total
|
||||
sector count in the root dir is 32bit. With a bit of
|
||||
creativity, FAT32 could be extended to handle at least 2^28
|
||||
clusters There would need to be an extra field in the
|
||||
FSInfo sector, and the old sector count could be set to
|
||||
0xffffffff. This is non standard though, the Windows FAT
|
||||
driver FASTFAT.SYS won't understand this. Perhaps a future
|
||||
version of FAT32 and FASTFAT will handle this. */
|
||||
|
||||
printf("[ERR] This drive is too big for FAT32 - max 2TB supported\n");
|
||||
}
|
||||
|
||||
if ( sectors_per_cluster ) {
|
||||
SectorsPerCluster = sectors_per_cluster;
|
||||
} else {
|
||||
SectorsPerCluster = get_sectors_per_cluster(size,
|
||||
BytesPerSect );
|
||||
}
|
||||
|
||||
TotalSectors = (uint32_t) qTotalSectors;
|
||||
|
||||
FatSize = get_fat_size_sectors(TotalSectors, ReservedSectCount,
|
||||
SectorsPerCluster, NumFATs, BytesPerSect );
|
||||
|
||||
UserAreaSize = TotalSectors - ReservedSectCount - (NumFATs*FatSize);
|
||||
|
||||
/* First zero out ReservedSect + FatSize * NumFats + SectorsPerCluster */
|
||||
SystemAreaSize = (ReservedSectCount+(NumFATs*FatSize) + SectorsPerCluster);
|
||||
|
||||
/* Work out the Cluster count */
|
||||
FatNeeded = UserAreaSize/SectorsPerCluster;
|
||||
|
||||
/* check for a cluster count of >2^28, since the upper 4 bits of
|
||||
the cluster values in the FAT are reserved. */
|
||||
if (FatNeeded > 0x0FFFFFFF) {
|
||||
printf("[ERR] This drive has more than 2^28 clusters, try to specify a larger cluster size\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Sanity check, make sure the fat is big enough.
|
||||
Convert the cluster count into a Fat sector count, and check
|
||||
the fat size value we calculated earlier is OK. */
|
||||
|
||||
FatNeeded *=4;
|
||||
FatNeeded += (BytesPerSect-1);
|
||||
FatNeeded /= BytesPerSect;
|
||||
|
||||
if ( FatNeeded > FatSize ) {
|
||||
printf("[ERR] Drive too big to format\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
Write boot sector, fats
|
||||
Sector 0 Boot Sector
|
||||
Sector 1 FSInfo
|
||||
Sector 2 More boot code - we write zeros here
|
||||
Sector 3 unused
|
||||
Sector 4 unused
|
||||
Sector 5 unused
|
||||
Sector 6 Backup boot sector
|
||||
Sector 7 Backup FSInfo sector
|
||||
Sector 8 Backup 'more boot code'
|
||||
zero'd sectors upto ReservedSectCount
|
||||
FAT1 ReservedSectCount to ReservedSectCount + FatSize
|
||||
...
|
||||
FATn ReservedSectCount to ReservedSectCount + FatSize
|
||||
RootDir - allocated to cluster2
|
||||
*/
|
||||
|
||||
|
||||
printf("[INFO] Formatting partition:...");
|
||||
|
||||
/* Once zero_sectors has run, any data on the drive is basically lost... */
|
||||
printf("[INFO] Clearing out %d sectors for Reserved sectors, fats and root cluster...\n", SystemAreaSize );
|
||||
|
||||
zero_sectors(start, SystemAreaSize);
|
||||
|
||||
printf("[INFO] Initialising reserved sectors and FATs...\n" );
|
||||
|
||||
/* Create the boot sector structure */
|
||||
create_boot_sector(sectorbuf);
|
||||
create_fsinfo(sectorbuf + 512);
|
||||
|
||||
if (storage_write_sectors(start,2,sectorbuf)) {
|
||||
printf("[ERR] Write failed (first copy of bootsect/fsinfo)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (storage_write_sectors(start + BackupBootSect,2,sectorbuf)) {
|
||||
printf("[ERR] Write failed (first copy of bootsect/fsinfo)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create the first FAT sector */
|
||||
create_firstfatsector(sectorbuf);
|
||||
|
||||
/* Write the first fat sector in the right places */
|
||||
for ( i=0; i<NumFATs; i++ ) {
|
||||
int SectorStart = ReservedSectCount + (i * FatSize );
|
||||
|
||||
if (storage_write_sectors(start + SectorStart,1,sectorbuf)) {
|
||||
printf("[ERR] Write failed (first copy of bootsect/fsinfo)\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("[INFO] Format successful\n");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: main-e200r-installer.c 15599 2007-11-12 18:49:53Z amiconn $
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
||||
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
#include "cpu.h"
|
||||
#include "file.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "storage.h"
|
||||
#include "button.h"
|
||||
#include "disk.h"
|
||||
#include "crc32-mi4.h"
|
||||
#include <string.h>
|
||||
#include "i2c.h"
|
||||
#include "backlight-target.h"
|
||||
#include "power.h"
|
||||
|
||||
|
||||
unsigned char mbr[] = {
|
||||
0x33, 0xc0, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0xfb, 0x50, 0x07, 0x50, 0x1f, 0xfc, 0xbe, 0x1b, 0x7c,
|
||||
0xbf, 0x1b, 0x06, 0x50, 0x57, 0xb9, 0xe5, 0x01, 0xf3, 0xa4, 0xcb, 0xbe, 0xbe, 0x07, 0xb1, 0x04,
|
||||
0x38, 0x2c, 0x7c, 0x09, 0x75, 0x15, 0x83, 0xc6, 0x10, 0xe2, 0xf5, 0xcd, 0x18, 0x8b, 0x14, 0x8b,
|
||||
0xee, 0x83, 0xc6, 0x10, 0x49, 0x74, 0x16, 0x38, 0x2c, 0x74, 0xf6, 0xbe, 0x10, 0x07, 0x4e, 0xac,
|
||||
0x3c, 0x00, 0x74, 0xfa, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0xeb, 0xf2, 0x89, 0x46, 0x25,
|
||||
0x96, 0x8a, 0x46, 0x04, 0xb4, 0x06, 0x3c, 0x0e, 0x74, 0x11, 0xb4, 0x0b, 0x3c, 0x0c, 0x74, 0x05,
|
||||
0x3a, 0xc4, 0x75, 0x2b, 0x40, 0xc6, 0x46, 0x25, 0x06, 0x75, 0x24, 0xbb, 0xaa, 0x55, 0x50, 0xb4,
|
||||
0x41, 0xcd, 0x13, 0x58, 0x72, 0x16, 0x81, 0xfb, 0x55, 0xaa, 0x75, 0x10, 0xf6, 0xc1, 0x01, 0x74,
|
||||
0x0b, 0x8a, 0xe0, 0x88, 0x56, 0x24, 0xc7, 0x06, 0xa1, 0x06, 0xeb, 0x1e, 0x88, 0x66, 0x04, 0xbf,
|
||||
0x0a, 0x00, 0xb8, 0x01, 0x02, 0x8b, 0xdc, 0x33, 0xc9, 0x83, 0xff, 0x05, 0x7f, 0x03, 0x8b, 0x4e,
|
||||
0x25, 0x03, 0x4e, 0x02, 0xcd, 0x13, 0x72, 0x29, 0xbe, 0x75, 0x07, 0x81, 0x3e, 0xfe, 0x7d, 0x55,
|
||||
0xaa, 0x74, 0x5a, 0x83, 0xef, 0x05, 0x7f, 0xda, 0x85, 0xf6, 0x75, 0x83, 0xbe, 0x3f, 0x07, 0xeb,
|
||||
0x8a, 0x98, 0x91, 0x52, 0x99, 0x03, 0x46, 0x08, 0x13, 0x56, 0x0a, 0xe8, 0x12, 0x00, 0x5a, 0xeb,
|
||||
0xd5, 0x4f, 0x74, 0xe4, 0x33, 0xc0, 0xcd, 0x13, 0xeb, 0xb8, 0x00, 0x00, 0x80, 0x32, 0x22, 0x16,
|
||||
0x56, 0x33, 0xf6, 0x56, 0x56, 0x52, 0x50, 0x06, 0x53, 0x51, 0xbe, 0x10, 0x00, 0x56, 0x8b, 0xf4,
|
||||
0x50, 0x52, 0xb8, 0x00, 0x42, 0x8a, 0x56, 0x24, 0xcd, 0x13, 0x5a, 0x58, 0x8d, 0x64, 0x10, 0x72,
|
||||
0x0a, 0x40, 0x75, 0x01, 0x42, 0x80, 0xc7, 0x02, 0xe2, 0xf7, 0xf8, 0x5e, 0xc3, 0xeb, 0x74, 0x49,
|
||||
0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x20, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x20, 0x53, 0x65, 0x74, 0x75, 0x70, 0x20, 0x63, 0x61,
|
||||
0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x65, 0x2e, 0x00, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x70, 0x65,
|
||||
0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x20, 0x53,
|
||||
0x65, 0x74, 0x75, 0x70, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x69, 0x6e, 0x75, 0x65, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x8b, 0xfc, 0x1e, 0x57, 0x8b, 0xf5, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x10,
|
||||
0x10, 0x00, 0x06, 0x59, 0x1f, 0x7a, 0xff, 0x03, 0x00, 0x00, 0x01, 0xfa, 0x1d, 0x00, 0x00, 0x59,
|
||||
0x20, 0x7a, 0x84, 0xe5, 0x29, 0x7c, 0x00, 0xfe, 0x1d, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
|
||||
};
|
||||
|
||||
unsigned char fat[]={
|
||||
0xeb,0x3c,0x90,0x6d,0x6b,0x64,0x6f,0x73,0x66,0x73,0x00,0x00,0x02,0x20,0x01,0x00,
|
||||
0x02,0x00,0x02,0x00,0x00,0xf8,0xf0,0x00,0x20,0x00,0x40,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xfa,0x1d,0x00,0x00,0x00,0x29,0x3d,0xa7,0x07,0x48,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x46,0x41,0x54,0x31,0x36,0x20,0x20,0x20,0x0e,0x1f,
|
||||
0xbe,0x5b,0x7c,0xac,0x22,0xc0,0x74,0x0b,0x56,0xb4,0x0e,0xbb,0x07,0x00,0xcd,0x10,
|
||||
0x5e,0xeb,0xf0,0x32,0xe4,0xcd,0x16,0xcd,0x19,0xeb,0xfe,0x54,0x68,0x69,0x73,0x20,
|
||||
0x69,0x73,0x20,0x6e,0x6f,0x74,0x20,0x61,0x20,0x62,0x6f,0x6f,0x74,0x61,0x62,0x6c,
|
||||
0x65,0x20,0x64,0x69,0x73,0x6b,0x2e,0x20,0x20,0x50,0x6c,0x65,0x61,0x73,0x65,0x20,
|
||||
0x69,0x6e,0x73,0x65,0x72,0x74,0x20,0x61,0x20,0x62,0x6f,0x6f,0x74,0x61,0x62,0x6c,
|
||||
0x65,0x20,0x66,0x6c,0x6f,0x70,0x70,0x79,0x20,0x61,0x6e,0x64,0x0d,0x0a,0x70,0x72,
|
||||
0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,0x20,0x74,0x6f,0x20,0x74,
|
||||
0x72,0x79,0x20,0x61,0x67,0x61,0x69,0x6e,0x20,0x2e,0x2e,0x2e,0x20,0x0d,0x0a,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xaa,
|
||||
};
|
||||
|
||||
|
||||
unsigned char backupfat[] = {
|
||||
0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
#define NUM_E200_CRCS ((int)((sizeof(e200_crcs) / sizeof(uint32_t))))
|
||||
|
||||
#define REG_USBCMD (*(volatile unsigned int *)(USB_BASE+0x140))
|
||||
#define REG_USBSTS (*(volatile unsigned int *)(USB_BASE+0x144))
|
||||
#define REG_CONFIGFLAG (*(volatile unsigned int *)(USB_BASE+0x180))
|
||||
#define REG_PORTSC1 (*(volatile unsigned int *)(USB_BASE+0x184))
|
||||
#define REG_OTGSC (*(volatile unsigned int *)(USB_BASE+0x1a4))
|
||||
#define REG_USBMODE (*(volatile unsigned int *)(USB_BASE+0x1a8))
|
||||
|
||||
unsigned char zero[1024*16];
|
||||
|
||||
|
||||
|
||||
void* main(void)
|
||||
{
|
||||
int i;
|
||||
int btn;
|
||||
|
||||
chksum_crc32gentab ();
|
||||
|
||||
system_init();
|
||||
kernel_init();
|
||||
lcd_init();
|
||||
font_init();
|
||||
button_init();
|
||||
i2c_init();
|
||||
_backlight_on();
|
||||
|
||||
lcd_set_foreground(LCD_WHITE);
|
||||
lcd_set_background(LCD_BLACK);
|
||||
lcd_clear_display();
|
||||
|
||||
btn = button_read_device();
|
||||
verbose = true;
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
printf("Rockbox c240 initializer");
|
||||
printf("");
|
||||
|
||||
|
||||
i=storage_init();
|
||||
disk_init(IF_MV(0));
|
||||
|
||||
memset(zero,0,16*1024);
|
||||
printf("Zeroing flash");
|
||||
for(i=0;i<250816;i++)
|
||||
{
|
||||
storage_write_sectors(i*32,32,zero);
|
||||
if(i%64 == 0)
|
||||
{
|
||||
printf("%d kB left",(250816-i)/2);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Writing MBR");
|
||||
storage_write_sectors(0,1,mbr);
|
||||
printf("Writing FAT bootsector");
|
||||
storage_write_sectors(1023,1,fat);
|
||||
printf("Writing more FAT");
|
||||
storage_write_sectors(1024,1,backupfat);
|
||||
printf("Writing more FAT");
|
||||
storage_write_sectors(1264,1,backupfat);
|
||||
if (button_hold())
|
||||
printf("Release Hold and");
|
||||
|
||||
printf("Press any key to shutdown");
|
||||
|
||||
while(button_read_device() == BUTTON_NONE);
|
||||
|
||||
power_off();
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -1,287 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: main-e200r-installer.c 15599 2007-11-12 18:49:53Z amiconn $
|
||||
*
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
||||
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
#include "cpu.h"
|
||||
#include "file.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "storage.h"
|
||||
#include "button.h"
|
||||
#include "disk.h"
|
||||
#include "crc32-mi4.h"
|
||||
#include <string.h>
|
||||
#include "i2c.h"
|
||||
#include "backlight-target.h"
|
||||
#include "power.h"
|
||||
|
||||
unsigned char mbr[] = {
|
||||
0x33, 0xc0, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0xfb, 0x50, 0x07, 0x50, 0x1f, 0xfc, 0xbe, 0x1b, 0x7c,
|
||||
0xbf, 0x1b, 0x06, 0x50, 0x57, 0xb9, 0xe5, 0x01, 0xf3, 0xa4, 0xcb, 0xbe, 0xbe, 0x07, 0xb1, 0x04,
|
||||
0x38, 0x2c, 0x7c, 0x09, 0x75, 0x15, 0x83, 0xc6, 0x10, 0xe2, 0xf5, 0xcd, 0x18, 0x8b, 0x14, 0x8b,
|
||||
0xee, 0x83, 0xc6, 0x10, 0x49, 0x74, 0x16, 0x38, 0x2c, 0x74, 0xf6, 0xbe, 0x10, 0x07, 0x4e, 0xac,
|
||||
0x3c, 0x00, 0x74, 0xfa, 0xbb, 0x07, 0x00, 0xb4, 0x0e, 0xcd, 0x10, 0xeb, 0xf2, 0x89, 0x46, 0x25,
|
||||
0x96, 0x8a, 0x46, 0x04, 0xb4, 0x06, 0x3c, 0x0e, 0x74, 0x11, 0xb4, 0x0b, 0x3c, 0x0c, 0x74, 0x05,
|
||||
0x3a, 0xc4, 0x75, 0x2b, 0x40, 0xc6, 0x46, 0x25, 0x06, 0x75, 0x24, 0xbb, 0xaa, 0x55, 0x50, 0xb4,
|
||||
0x41, 0xcd, 0x13, 0x58, 0x72, 0x16, 0x81, 0xfb, 0x55, 0xaa, 0x75, 0x10, 0xf6, 0xc1, 0x01, 0x74,
|
||||
0x0b, 0x8a, 0xe0, 0x88, 0x56, 0x24, 0xc7, 0x06, 0xa1, 0x06, 0xeb, 0x1e, 0x88, 0x66, 0x04, 0xbf,
|
||||
0x0a, 0x00, 0xb8, 0x01, 0x02, 0x8b, 0xdc, 0x33, 0xc9, 0x83, 0xff, 0x05, 0x7f, 0x03, 0x8b, 0x4e,
|
||||
0x25, 0x03, 0x4e, 0x02, 0xcd, 0x13, 0x72, 0x29, 0xbe, 0x75, 0x07, 0x81, 0x3e, 0xfe, 0x7d, 0x55,
|
||||
0xaa, 0x74, 0x5a, 0x83, 0xef, 0x05, 0x7f, 0xda, 0x85, 0xf6, 0x75, 0x83, 0xbe, 0x3f, 0x07, 0xeb,
|
||||
0x8a, 0x98, 0x91, 0x52, 0x99, 0x03, 0x46, 0x08, 0x13, 0x56, 0x0a, 0xe8, 0x12, 0x00, 0x5a, 0xeb,
|
||||
0xd5, 0x4f, 0x74, 0xe4, 0x33, 0xc0, 0xcd, 0x13, 0xeb, 0xb8, 0x00, 0x00, 0x80, 0x32, 0x22, 0x16,
|
||||
0x56, 0x33, 0xf6, 0x56, 0x56, 0x52, 0x50, 0x06, 0x53, 0x51, 0xbe, 0x10, 0x00, 0x56, 0x8b, 0xf4,
|
||||
0x50, 0x52, 0xb8, 0x00, 0x42, 0x8a, 0x56, 0x24, 0xcd, 0x13, 0x5a, 0x58, 0x8d, 0x64, 0x10, 0x72,
|
||||
0x0a, 0x40, 0x75, 0x01, 0x42, 0x80, 0xc7, 0x02, 0xe2, 0xf7, 0xf8, 0x5e, 0xc3, 0xeb, 0x74, 0x49,
|
||||
0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x20, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x20, 0x53, 0x65, 0x74, 0x75, 0x70, 0x20, 0x63, 0x61,
|
||||
0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x65, 0x2e, 0x00, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x70, 0x65,
|
||||
0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x20, 0x53,
|
||||
0x65, 0x74, 0x75, 0x70, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x69, 0x6e, 0x75, 0x65, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x8b, 0xfc, 0x1e, 0x57, 0x8b, 0xf5, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x10,
|
||||
0x0a, 0x00, 0x06, 0x40, 0x09, 0xf7, 0xf9, 0x03, 0x00, 0x00, 0x07, 0x98, 0x3c, 0x00, 0x00, 0x40,
|
||||
0x0a, 0xf7, 0x84, 0xcc, 0x13, 0xf9, 0x00, 0x9c, 0x3c, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
|
||||
};
|
||||
|
||||
unsigned char bootsector[]={
|
||||
0xeb,0x58,0x90,0x6d,0x6b,0x64,0x6f,0x73,0x66,0x73,0x00,0x00,0x02,0x08,0x20,0x00,
|
||||
0x02,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x20,0x00,0x40,0x00,0x00,0x00,0x00,0x00,
|
||||
0x06,0x98,0x3c,0x00,0x1f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
|
||||
0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x29,0xe5,0xbf,0xac,0x47,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x46,0x41,0x54,0x33,0x32,0x20,0x20,0x20,0x0e,0x1f,0xbe,0x77,0x7c,0xac,
|
||||
0x22,0xc0,0x74,0x0b,0x56,0xb4,0x0e,0xbb,0x07,0x00,0xcd,0x10,0x5e,0xeb,0xf0,0x32,
|
||||
0xe4,0xcd,0x16,0xcd,0x19,0xeb,0xfe,0x54,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x6e,
|
||||
0x6f,0x74,0x20,0x61,0x20,0x62,0x6f,0x6f,0x74,0x61,0x62,0x6c,0x65,0x20,0x64,0x69,
|
||||
0x73,0x6b,0x2e,0x20,0x20,0x50,0x6c,0x65,0x61,0x73,0x65,0x20,0x69,0x6e,0x73,0x65,
|
||||
0x72,0x74,0x20,0x61,0x20,0x62,0x6f,0x6f,0x74,0x61,0x62,0x6c,0x65,0x20,0x66,0x6c,
|
||||
0x6f,0x70,0x70,0x79,0x20,0x61,0x6e,0x64,0x0d,0x0a,0x70,0x72,0x65,0x73,0x73,0x20,
|
||||
0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,0x20,0x74,0x6f,0x20,0x74,0x72,0x79,0x20,0x61,
|
||||
0x67,0x61,0x69,0x6e,0x20,0x2e,0x2e,0x2e,0x20,0x0d,0x0a,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xaa,
|
||||
0x52,0x52,0x61,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x72,0x72,0x41,0x61,0x34,0x8f,0x07,0x00,0x02,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xaa,
|
||||
};
|
||||
|
||||
unsigned char fat[]={
|
||||
0xeb,0x58,0x90,0x6d,0x6b,0x64,0x6f,0x73,0x66,0x73,0x00,0x00,0x02,0x08,0x20,0x00,
|
||||
0x02,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x20,0x00,0x40,0x00,0x00,0x00,0x00,0x00,
|
||||
0x06,0x98,0x3c,0x00,0x1f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
|
||||
0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x29,0xe5,0xbf,0xac,0x47,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x46,0x41,0x54,0x33,0x32,0x20,0x20,0x20,0x0e,0x1f,0xbe,0x77,0x7c,0xac,
|
||||
0x22,0xc0,0x74,0x0b,0x56,0xb4,0x0e,0xbb,0x07,0x00,0xcd,0x10,0x5e,0xeb,0xf0,0x32,
|
||||
0xe4,0xcd,0x16,0xcd,0x19,0xeb,0xfe,0x54,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x6e,
|
||||
0x6f,0x74,0x20,0x61,0x20,0x62,0x6f,0x6f,0x74,0x61,0x62,0x6c,0x65,0x20,0x64,0x69,
|
||||
0x73,0x6b,0x2e,0x20,0x20,0x50,0x6c,0x65,0x61,0x73,0x65,0x20,0x69,0x6e,0x73,0x65,
|
||||
0x72,0x74,0x20,0x61,0x20,0x62,0x6f,0x6f,0x74,0x61,0x62,0x6c,0x65,0x20,0x66,0x6c,
|
||||
0x6f,0x70,0x70,0x79,0x20,0x61,0x6e,0x64,0x0d,0x0a,0x70,0x72,0x65,0x73,0x73,0x20,
|
||||
0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,0x20,0x74,0x6f,0x20,0x74,0x72,0x79,0x20,0x61,
|
||||
0x67,0x61,0x69,0x6e,0x20,0x2e,0x2e,0x2e,0x20,0x0d,0x0a,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xaa
|
||||
};
|
||||
|
||||
unsigned char backupfat[]={
|
||||
0xf8,0xff,0xff,0x0f,0xff,0xff,0xff,0x0f,0xf8,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
#define NUM_E200_CRCS ((int)((sizeof(e200_crcs) / sizeof(uint32_t))))
|
||||
|
||||
#define REG_USBCMD (*(volatile unsigned int *)(USB_BASE+0x140))
|
||||
#define REG_USBSTS (*(volatile unsigned int *)(USB_BASE+0x144))
|
||||
#define REG_CONFIGFLAG (*(volatile unsigned int *)(USB_BASE+0x180))
|
||||
#define REG_PORTSC1 (*(volatile unsigned int *)(USB_BASE+0x184))
|
||||
#define REG_OTGSC (*(volatile unsigned int *)(USB_BASE+0x1a4))
|
||||
#define REG_USBMODE (*(volatile unsigned int *)(USB_BASE+0x1a8))
|
||||
|
||||
unsigned char zero[1024*16];
|
||||
|
||||
|
||||
|
||||
void* main(void)
|
||||
{
|
||||
int i;
|
||||
int btn;
|
||||
|
||||
chksum_crc32gentab ();
|
||||
|
||||
system_init();
|
||||
kernel_init();
|
||||
lcd_init();
|
||||
font_init();
|
||||
button_init();
|
||||
i2c_init();
|
||||
_backlight_on();
|
||||
|
||||
lcd_set_foreground(LCD_WHITE);
|
||||
lcd_set_background(LCD_BLACK);
|
||||
lcd_clear_display();
|
||||
|
||||
btn = button_read_device();
|
||||
verbose = true;
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
printf("Rockbox c250 initializer");
|
||||
printf("");
|
||||
|
||||
|
||||
i=storage_init();
|
||||
disk_init(IF_MV(0));
|
||||
|
||||
memset(zero,0,16*1024);
|
||||
printf("Zeroing flash");
|
||||
for(i=0;i<250816;i++)
|
||||
{
|
||||
storage_write_sectors(i*32,32,zero);
|
||||
if(i%64 == 0)
|
||||
{
|
||||
printf("%d kB left",(250816-i)/2);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Writing MBR");
|
||||
storage_write_sectors(0,1,mbr);
|
||||
printf("Writing FAT bootsector");
|
||||
storage_write_sectors(1017,2,bootsector);
|
||||
printf("Writing more FAT");
|
||||
storage_write_sectors(1023,1,fat);
|
||||
printf("Writing more FAT");
|
||||
storage_write_sectors(1049,1,backupfat);
|
||||
printf("Writing more FAT");
|
||||
storage_write_sectors(4920,1,backupfat);
|
||||
if (button_hold())
|
||||
printf("Release Hold and");
|
||||
|
||||
printf("Press any key to shutdown");
|
||||
|
||||
while(button_read_device() == BUTTON_NONE);
|
||||
|
||||
power_off();
|
||||
|
||||
return NULL;
|
||||
}
|
250
bootloader/main-ppsansawipe.c
Normal file
250
bootloader/main-ppsansawipe.c
Normal file
|
@ -0,0 +1,250 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: main-e200r-installer.c 15599 2007-11-12 18:49:53Z amiconn $
|
||||
*
|
||||
* Copyright (C) 2011 by Frank Gevaerts
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
#include "cpu.h"
|
||||
#include "file.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "storage.h"
|
||||
#include "button.h"
|
||||
#include "disk.h"
|
||||
#include "crc32-mi4.h"
|
||||
#include <string.h>
|
||||
#include "i2c.h"
|
||||
#include "backlight-target.h"
|
||||
#include "power.h"
|
||||
|
||||
unsigned char zero[1024*64];
|
||||
unsigned char nonzero[1024*64];
|
||||
unsigned char scratch[1024*64];
|
||||
struct storage_info info;
|
||||
|
||||
int format_partition(int start, int size);
|
||||
|
||||
#define SPT 63
|
||||
#define HPC 255
|
||||
|
||||
int c(int lba)
|
||||
{
|
||||
return lba/(SPT * HPC);
|
||||
}
|
||||
int h(int lba)
|
||||
{
|
||||
return (lba/SPT)%HPC;
|
||||
}
|
||||
int s(int lba)
|
||||
{
|
||||
return (lba%SPT) + 1;
|
||||
}
|
||||
|
||||
int write_mbr(int datastart,int datasize, int firmwarestart, int firmwaresize)
|
||||
{
|
||||
unsigned char mbr[512];
|
||||
memset(mbr,0,512);
|
||||
mbr[446]=0x80; /* flags */
|
||||
mbr[447]=h(datastart); /* chs1[0] (h) */
|
||||
mbr[448]=s(datastart); /* chs1[1] (s) */
|
||||
mbr[449]=c(datastart); /* chs1[2] (c) */
|
||||
mbr[450]=0x0b; /* type */
|
||||
mbr[451]=h(datastart+datasize-1); /* chs2[0] (h) */
|
||||
mbr[452]=s(datastart+datasize-1); /* chs2[1] (s) */
|
||||
mbr[453]=c(datastart+datasize-1); /* chs2[2] (c) */
|
||||
mbr[454]=(datastart&0x000000ff); /* lba[0] */
|
||||
mbr[455]=(datastart&0x0000ff00) >>8; /* lba[1] */
|
||||
mbr[456]=(datastart&0x00ff0000) >>16; /* lba[2] */
|
||||
mbr[457]=(datastart&0xff000000) >>24; /* lba[3] */
|
||||
mbr[458]=(datasize&0x000000ff); /* size[0] */
|
||||
mbr[459]=(datasize&0x0000ff00) >>8; /* size[1] */
|
||||
mbr[460]=(datasize&0x00ff0000) >>16; /* size[2] */
|
||||
mbr[461]=(datasize&0xff000000) >>24; /* size[3] */
|
||||
|
||||
mbr[462]=0; /* flags */
|
||||
mbr[463]=h(firmwarestart); /* chs1[0] (h) */
|
||||
mbr[464]=s(firmwarestart); /* chs1[1] (s) */
|
||||
mbr[465]=c(firmwarestart); /* chs1[2] (c) */
|
||||
mbr[466]=0x84; /* type */
|
||||
mbr[467]=h(firmwarestart+firmwaresize-1); /* chs2[0] (h) */
|
||||
mbr[468]=s(firmwarestart+firmwaresize-1); /* chs2[1] (s) */
|
||||
mbr[469]=c(firmwarestart+firmwaresize-1); /* chs2[2] (c) */
|
||||
mbr[470]=(firmwarestart&0x000000ffu); /* lba[0] */
|
||||
mbr[471]=(firmwarestart&0x0000ff00u) >>8; /* lba[1] */
|
||||
mbr[472]=(firmwarestart&0x00ff0000u) >>16; /* lba[2] */
|
||||
mbr[473]=(firmwarestart&0xff000000u) >>24; /* lba[3] */
|
||||
mbr[474]=(firmwaresize&0x000000ffu); /* size[0] */
|
||||
mbr[475]=(firmwaresize&0x0000ff00u) >>8; /* size[1] */
|
||||
mbr[476]=(firmwaresize&0x00ff0000u) >>16; /* size[2] */
|
||||
mbr[477]=(firmwaresize&0xff000000u) >>24; /* size[3] */
|
||||
|
||||
mbr[510]=0x55;
|
||||
mbr[511]=0xaa;
|
||||
|
||||
int res = storage_write_sectors(0,1,mbr);
|
||||
if(res != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Hack. We "steal" line from common.c to reset the line number
|
||||
* so we can overwrite the previous line for nicer progress info
|
||||
*/
|
||||
extern int line;
|
||||
int wipe(int size, int verify)
|
||||
{
|
||||
int i;
|
||||
int res;
|
||||
int sectors = sizeof(nonzero)/512;
|
||||
for(i=0;i<size;i+=sectors)
|
||||
{
|
||||
if(verify)
|
||||
{
|
||||
res = storage_write_sectors(i,sectors,nonzero);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("write error (1) on sector %d (of %d)!",i,size);
|
||||
return -1;
|
||||
}
|
||||
res = storage_read_sectors(i,sectors,scratch);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("read error (1) on sector %d (of %d)!",i,size);
|
||||
return -1;
|
||||
}
|
||||
res = memcmp(nonzero, scratch, sizeof(nonzero));
|
||||
if(res != 0)
|
||||
{
|
||||
printf("compare error (1) on sector %d (of %d)!",i,size);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
res = storage_write_sectors(i,sectors,zero);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("write error (2) on sector %d (of %d)!",i,size);
|
||||
return -1;
|
||||
}
|
||||
if(verify)
|
||||
{
|
||||
res = storage_read_sectors(i,sectors,scratch);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("read error (2) on sector %d (of %d)!",i,size);
|
||||
return -1;
|
||||
}
|
||||
res = memcmp(zero, scratch, sizeof(nonzero));
|
||||
if(res != 0)
|
||||
{
|
||||
printf("compare error (2) on sector %d (of %d)!",i,size);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(i%2048 == 0)
|
||||
{
|
||||
printf("%d of %d MB done",i/2048, size/2048);
|
||||
/* Hack to overwrite the previous line */
|
||||
line--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* main(void)
|
||||
{
|
||||
int i;
|
||||
int btn;
|
||||
|
||||
chksum_crc32gentab ();
|
||||
|
||||
system_init();
|
||||
kernel_init();
|
||||
lcd_init();
|
||||
font_init();
|
||||
button_init();
|
||||
i2c_init();
|
||||
_backlight_on();
|
||||
|
||||
lcd_set_foreground(LCD_WHITE);
|
||||
lcd_set_background(LCD_BLACK);
|
||||
lcd_clear_display();
|
||||
|
||||
btn = button_read_device();
|
||||
verbose = true;
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
printf("Sansa initialiser");
|
||||
printf("");
|
||||
|
||||
|
||||
i=storage_init();
|
||||
disk_init(IF_MD(0));
|
||||
|
||||
storage_get_info(0,&info);
|
||||
int size = info.num_sectors;
|
||||
memset(zero,0,sizeof(zero));
|
||||
memset(nonzero,0xff,sizeof(nonzero));
|
||||
printf("Zeroing flash");
|
||||
int res;
|
||||
|
||||
res = wipe(size, 0);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("error wiping flash");
|
||||
}
|
||||
|
||||
int firmwaresize = 0xa000;
|
||||
int firmwarestart = size - firmwaresize;
|
||||
int datastart = 600;
|
||||
int datasize = firmwarestart - datastart;
|
||||
|
||||
res = write_mbr(datastart,datasize,firmwarestart,firmwaresize);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("error writing mbr");
|
||||
}
|
||||
res = format_partition(datastart, datasize);
|
||||
if(res != 0)
|
||||
{
|
||||
printf("error formatting");
|
||||
}
|
||||
|
||||
printf("Wipe done.");
|
||||
if (button_hold())
|
||||
printf("Release Hold and");
|
||||
printf("press any key to");
|
||||
printf("shutdown.");
|
||||
|
||||
printf("Remember to use");
|
||||
printf("manufacturing");
|
||||
printf("mode to recover");
|
||||
printf("further");
|
||||
|
||||
while(button_read_device() == BUTTON_NONE);
|
||||
|
||||
power_off();
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -33,7 +33,7 @@ MEMORY
|
|||
|
||||
SECTIONS
|
||||
{
|
||||
#ifdef C200_ERASE
|
||||
#ifdef SANSA_PP_ERASE
|
||||
. = IRAMORIG+0x4000;
|
||||
#else
|
||||
. = IRAMORIG;
|
||||
|
|
18
tools/configure
vendored
18
tools/configure
vendored
|
@ -3232,6 +3232,9 @@ case $modelname in
|
|||
sansac200)
|
||||
gdbstub=", (E)raser"
|
||||
;;
|
||||
sansae200)
|
||||
gdbstub=", (E)raser"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
@ -3253,20 +3256,9 @@ fi
|
|||
[Ee])
|
||||
appsdir='$(ROOTDIR)/bootloader'
|
||||
apps="bootloader"
|
||||
echo "C2(4)0 or C2(5)0"
|
||||
variant=`input`
|
||||
case $variant in
|
||||
4)
|
||||
extradefines="$extradefines -DBOOTLOADER -DC200_ERASE -DC240_ERASE -ffunction-sections -fdata-sections"
|
||||
echo "c240 eraser build selected"
|
||||
;;
|
||||
5)
|
||||
extradefines="$extradefines -DBOOTLOADER -DC200_ERASE -DC250_ERASE -ffunction-sections -fdata-sections"
|
||||
echo "c240 eraser build selected"
|
||||
;;
|
||||
esac
|
||||
extradefines="$extradefines -DBOOTLOADER -DSANSA_PP_ERASE -ffunction-sections -fdata-sections"
|
||||
bootloader="1"
|
||||
echo "c200 eraser build selected"
|
||||
echo "sansa eraser build selected"
|
||||
;;
|
||||
[Bb])
|
||||
if test $t_manufacturer = "archos"; then
|
||||
|
|
Loading…
Reference in a new issue