1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * mkamsboot.h - a tool for merging bootloader code into an Sansa V2
13 * Copyright (C) 2008 Dave Chapman
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
29 #include <sys/types.h>
35 /* Supported models */
47 /* Holds info about the OF */
54 /* load_rockbox_file()
56 * Loads a rockbox bootloader file into memory
60 * filename : bootloader file to load
61 * model : a 4 characters string representing the Sansa model
62 * ("fuze", "clip", "e2v2", "m2v4", or "c2v2")
63 * bootloader_size : set to the uncompressed bootloader size
64 * rb_packed_size : set to the size of compressed bootloader
65 * errstr : provided buffer to store an eventual error
66 * errstrsize : size of provided error buffer
69 * pointer to allocated memory containing the content of compressed bootloader
70 * or NULL in case of error (errstr will hold a description of the error)
73 unsigned char* load_rockbox_file(
74 char* filename
, int model
, int* bootloader_size
, int* rb_packedsize
,
75 char* errstr
, int errstrsize
);
80 * Loads a Sansa AMS Original Firmware file into memory
84 * filename : firmware file to load
85 * bufsize : set to firmware file size
86 * md5sum : set to file md5sum, must be at least 33 bytes long
87 * model : set to firmware model (MODEL_XXX)
88 * fw_version : set to firmware format version (1 or 2)
89 * firmware_size : set to firmware block's size
90 * of_packed : pointer to allocated memory containing the compressed
91 * original firmware block
92 * of_packedsize : size of compressed original firmware block
93 * errstr : provided buffer to store an eventual error
94 * errstrsize : size of provided error buffer
97 * pointer to allocated memory containing the content of Original Firmware
98 * or NULL in case of error (errstr will hold a description of the error)
101 unsigned char* load_of_file(
102 char* filename
, off_t
* bufsize
, struct md5sums
*sum
,
103 int* firmware_size
, unsigned char** of_packed
,
104 int* of_packedsize
, char* errstr
, int errstrsize
);
109 * Patches a Sansa AMS Original Firmware file
113 * model : firmware model (MODEL_XXX)
114 * fw_version : firmware format version (1 or 2)
115 * firmware_size : size of uncompressed original firmware block
116 * buf : pointer to original firmware file
117 * len : size of original firmware file
118 * of_packed : pointer to compressed original firmware block
119 * of_packedsize : size of compressed original firmware block
120 * rb_packed : pointer to compressed rockbox bootloader
121 * rb_packed_size : size of compressed rockbox bootloader
125 int model
, int fw_version
, int firmware_size
, unsigned char* buf
,
126 int len
, unsigned char* of_packed
, int of_packedsize
,
127 unsigned char* rb_packed
, int rb_packedsize
);
132 * Calculates the size of the new firmware block
136 * model : firmware model (MODEL_XXX)
137 * rb_packed_size : size of compressed rockbox bootloader
138 * of_packedsize : size of compressed original firmware block
141 * Size of new firmware block
144 int total_size(int model
, int rb_packedsize
, int of_packedsize
);
146 /* firmware_revision()
148 * returns the firmware revision for a particular model
152 * model : firmware model (MODEL_XXX)
157 int firmware_revision(int model
);