summaryrefslogtreecommitdiff
path: root/flash/extract
diff options
context:
space:
mode:
Diffstat (limited to 'flash/extract')
-rw-r--r--flash/extract/README5
-rw-r--r--flash/extract/extract.c147
-rw-r--r--flash/extract/extract.dsp100
3 files changed, 0 insertions, 252 deletions
diff --git a/flash/extract/README b/flash/extract/README
deleted file mode 100644
index 6f1934906e..0000000000
--- a/flash/extract/README
+++ /dev/null
@@ -1,5 +0,0 @@
1(c) 2003 by Jörg Hohensohn
2
3This tool extracts the firmware image out of an original Archos ROM dump,
4like created with the Rockbox debug->dump feature.
5The extracted image can then be used to compose a dual-boot firmware.
diff --git a/flash/extract/extract.c b/flash/extract/extract.c
deleted file mode 100644
index 2389f9290e..0000000000
--- a/flash/extract/extract.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2003 by Jörg Hohensohn
11 *
12 * Tool to extract the scrambled image out of an Archos flash ROM dump
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <inttypes.h>
27
28#define UINT8 unsigned char
29#define UINT16 unsigned short
30#define UINT32 unsigned long
31
32#define IMAGE_HEADER 0x6000 // a 32 byte header in front of the software image
33#define IMAGE_START 0x6020 // software image position in Flash
34
35
36// place a 32 bit value into memory, big endian
37void Write32(UINT8* pByte, UINT32 value)
38{
39 pByte[0] = (UINT8)(value >> 24);
40 pByte[1] = (UINT8)(value >> 16);
41 pByte[2] = (UINT8)(value >> 8);
42 pByte[3] = (UINT8)(value);
43}
44
45
46// read a 32 bit value from memory, big endian
47UINT32 Read32(UINT8* pByte)
48{
49 UINT32 value = 0;
50
51 value |= (UINT32)pByte[0] << 24;
52 value |= (UINT32)pByte[1] << 16;
53 value |= (UINT32)pByte[2] << 8;
54 value |= (UINT32)pByte[3];
55
56 return value;
57}
58
59
60// entry point
61int main(int argc, char* argv[])
62{
63 FILE* pInFile;
64 FILE* pOutFile;
65 UINT8 aHeader[6];
66 UINT8 aImage[256*1024];
67 UINT32 i;
68 UINT32 uiSize, uiStart;
69 UINT16 usChecksum = 0;
70
71 if (argc < 2)
72 {
73 printf("Extract the software image out of an original Archos Flash ROM dump.\n");
74 printf("Result is a scrambled file, use the descramble tool to get the binary,\n");
75 printf(" always without the -fm option, even if processing an FM software.\n\n");
76 printf("Usage: extract <flash dump file> <output file>\n");
77 printf("Example: extract internal_rom_2000000-203FFFF.bin archos.ajz\n");
78 exit(0);
79 }
80
81 pInFile = fopen(argv[1], "rb");
82 if (pInFile == NULL)
83 {
84 printf("Error opening input file %s\n", argv[1]);
85 exit(1);
86 }
87
88 if (fread(aImage, 1, sizeof(aImage), pInFile) != sizeof(aImage))
89 {
90 printf("Error reading input file %s, must be 256kB in size.\n", argv[1]);
91 fclose(pInFile);
92 exit(2);
93 }
94 fclose(pInFile);
95
96 // find out about the type
97 uiStart = Read32(aImage + 8);
98 uiSize = Read32(aImage + 12); // booted ROM image
99 if (uiStart == 0x02000100 && uiSize > 20000)
100 { // Player has no loader, starts directly with the image
101 uiStart = 0x0100;
102 }
103 else
104 { // Recorder / FM / V2 Recorder
105 uiStart = IMAGE_START;
106 uiSize = Read32(aImage + IMAGE_HEADER + 4); // size record of header
107 }
108
109 // sanity check
110 if (uiSize > sizeof(aImage) - uiStart || uiSize < 40000)
111 {
112 printf("Error: Impossible image size %d bytes.\n", uiSize);
113 exit(3);
114 }
115
116 // generate checksum
117 for (i=0; i<uiSize; i++)
118 {
119 UINT8 byte;
120 byte = aImage[uiStart + i];
121 byte = ~((byte >> 1) | ((byte << 7) & 0x80)); /* poor man's ROR */
122 usChecksum += byte;
123 }
124
125 // make header
126 Write32(aHeader + 2, usChecksum); // checksum in 5th and 6th byte
127 Write32(aHeader, uiSize); // size in first 4 bytes
128
129 pOutFile = fopen(argv[2], "wb");
130 if (pOutFile == NULL)
131 {
132 printf("Error opening output file %s\n", argv[2]);
133 exit(4);
134 }
135
136 if (fwrite(aHeader, 1, sizeof(aHeader), pOutFile) != sizeof(aHeader)
137 || fwrite(aImage + uiStart, 1, uiSize, pOutFile) != uiSize)
138 {
139 printf("Write error\n");
140 fclose(pOutFile);
141 exit(5);
142 }
143
144 fclose(pOutFile);
145
146 return 0;
147}
diff --git a/flash/extract/extract.dsp b/flash/extract/extract.dsp
deleted file mode 100644
index e10281a829..0000000000
--- a/flash/extract/extract.dsp
+++ /dev/null
@@ -1,100 +0,0 @@
1# Microsoft Developer Studio Project File - Name="extract" - Package Owner=<4>
2# Microsoft Developer Studio Generated Build File, Format Version 6.00
3# ** DO NOT EDIT **
4
5# TARGTYPE "Win32 (x86) Console Application" 0x0103
6
7CFG=extract - Win32 Debug
8!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9!MESSAGE use the Export Makefile command and run
10!MESSAGE
11!MESSAGE NMAKE /f "extract.mak".
12!MESSAGE
13!MESSAGE You can specify a configuration when running NMAKE
14!MESSAGE by defining the macro CFG on the command line. For example:
15!MESSAGE
16!MESSAGE NMAKE /f "extract.mak" CFG="extract - Win32 Debug"
17!MESSAGE
18!MESSAGE Possible choices for configuration are:
19!MESSAGE
20!MESSAGE "extract - Win32 Release" (based on "Win32 (x86) Console Application")
21!MESSAGE "extract - Win32 Debug" (based on "Win32 (x86) Console Application")
22!MESSAGE
23
24# Begin Project
25# PROP AllowPerConfigDependencies 0
26# PROP Scc_ProjName ""
27# PROP Scc_LocalPath ""
28CPP=cl.exe
29RSC=rc.exe
30
31!IF "$(CFG)" == "extract - Win32 Release"
32
33# PROP BASE Use_MFC 0
34# PROP BASE Use_Debug_Libraries 0
35# PROP BASE Output_Dir "Release"
36# PROP BASE Intermediate_Dir "Release"
37# PROP BASE Target_Dir ""
38# PROP Use_MFC 0
39# PROP Use_Debug_Libraries 0
40# PROP Output_Dir "Release"
41# PROP Intermediate_Dir "Release"
42# PROP Target_Dir ""
43# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
45# ADD BASE RSC /l 0x407 /d "NDEBUG"
46# ADD RSC /l 0x407 /d "NDEBUG"
47BSC32=bscmake.exe
48# ADD BASE BSC32 /nologo
49# ADD BSC32 /nologo
50LINK32=link.exe
51# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
52# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53
54!ELSEIF "$(CFG)" == "extract - Win32 Debug"
55
56# PROP BASE Use_MFC 0
57# PROP BASE Use_Debug_Libraries 1
58# PROP BASE Output_Dir "Debug"
59# PROP BASE Intermediate_Dir "Debug"
60# PROP BASE Target_Dir ""
61# PROP Use_MFC 0
62# PROP Use_Debug_Libraries 1
63# PROP Output_Dir "Debug"
64# PROP Intermediate_Dir "Debug"
65# PROP Target_Dir ""
66# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
67# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
68# ADD BASE RSC /l 0x407 /d "_DEBUG"
69# ADD RSC /l 0x407 /d "_DEBUG"
70BSC32=bscmake.exe
71# ADD BASE BSC32 /nologo
72# ADD BSC32 /nologo
73LINK32=link.exe
74# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
75# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
76
77!ENDIF
78
79# Begin Target
80
81# Name "extract - Win32 Release"
82# Name "extract - Win32 Debug"
83# Begin Group "Source Files"
84
85# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
86# Begin Source File
87
88SOURCE=.\extract.c
89# End Source File
90# End Group
91# Begin Group "Header Files"
92
93# PROP Default_Filter "h;hpp;hxx;hm;inl"
94# End Group
95# Begin Group "Resource Files"
96
97# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
98# End Group
99# End Target
100# End Project