summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-03 19:32:14 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-03 19:32:14 +0000
commit06e3c660ccc09a5161bd600bf0ee5d5d7a59c589 (patch)
tree2d9015af877f4a4a1113abfbdc2f4c6944817a27
parent7a4c33358122e73afc06ea1d417365f06445aefb (diff)
downloadrockbox-06e3c660ccc09a5161bd600bf0ee5d5d7a59c589.tar.gz
rockbox-06e3c660ccc09a5161bd600bf0ee5d5d7a59c589.zip
Prepare Creative bootloader compilation for future dual boot integration
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18187 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/Makefile2
-rwxr-xr-xtools/configure6
-rw-r--r--tools/creative.c39
-rw-r--r--tools/creative.h2
-rw-r--r--tools/scramble.c31
5 files changed, 55 insertions, 25 deletions
diff --git a/bootloader/Makefile b/bootloader/Makefile
index 796cd9ae2c..3272510051 100644
--- a/bootloader/Makefile
+++ b/bootloader/Makefile
@@ -98,7 +98,7 @@ $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAP
98 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootloader.map 98 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootloader.map
99 99
100$(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf 100$(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
101 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@ 101 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
102 102
103$(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin 103$(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
104 $(TOOLSDIR)/sh2d -sh1 $< > $@ 104 $(TOOLSDIR)/sh2d -sh1 $< > $@
diff --git a/tools/configure b/tools/configure
index 2267489997..e709bff62d 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1489,7 +1489,7 @@ fi
1489 plugins="" 1489 plugins=""
1490 swcodec="yes" 1490 swcodec="yes"
1491 toolset=$ipodbitmaptools 1491 toolset=$ipodbitmaptools
1492 boottool="$rootdir/tools/scramble -creative=zvm" 1492 boottool="$rootdir/tools/scramble -creative=zvm -no-ciff"
1493 bootoutput="rockbox.zvmboot" 1493 bootoutput="rockbox.zvmboot"
1494 # architecture, manufacturer and model for the target-tree build 1494 # architecture, manufacturer and model for the target-tree build
1495 t_cpu="arm" 1495 t_cpu="arm"
@@ -1507,7 +1507,7 @@ fi
1507 bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 1507 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
1508 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" 1508 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0"
1509 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" 1509 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0"
1510 tool="$rootdir/tools/scramble -creative=zvm60" 1510 tool="$rootdir/tools/scramble -creative=zvm60 -no-ciff"
1511 USE_ELF="yes" 1511 USE_ELF="yes"
1512 output="rockbox.zvm60" 1512 output="rockbox.zvm60"
1513 appextra="recorder:gui" 1513 appextra="recorder:gui"
@@ -1532,7 +1532,7 @@ fi
1532 bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 1532 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
1533 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" 1533 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0"
1534 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" 1534 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0"
1535 tool="$rootdir/tools/scramble -creative=zenvision" 1535 tool="$rootdir/tools/scramble -creative=zenvision -no-ciff"
1536 USE_ELF="yes" 1536 USE_ELF="yes"
1537 output="rockbox.zv" 1537 output="rockbox.zv"
1538 appextra="recorder:gui" 1538 appextra="recorder:gui"
diff --git a/tools/creative.c b/tools/creative.c
index 43fdbbc917..1698f58930 100644
--- a/tools/creative.c
+++ b/tools/creative.c
@@ -155,7 +155,7 @@ static int make_jrm_file(const unsigned char *inbuf, unsigned char *outbuf)
155 return 0xC+length; 155 return 0xC+length;
156} 156}
157 157
158int zvm_encode(const char *iname, const char *oname, int device) 158int zvm_encode(const char *iname, const char *oname, int device, bool enable_ciff)
159{ 159{
160 size_t len; 160 size_t len;
161 int length; 161 int length;
@@ -164,7 +164,8 @@ int zvm_encode(const char *iname, const char *oname, int device)
164 unsigned char *buf; 164 unsigned char *buf;
165 165
166 file = fopen(iname, "rb"); 166 file = fopen(iname, "rb");
167 if (!file) { 167 if (!file)
168 {
168 perror(iname); 169 perror(iname);
169 return -1; 170 return -1;
170 } 171 }
@@ -174,20 +175,23 @@ int zvm_encode(const char *iname, const char *oname, int device)
174 fseek(file, 0, SEEK_SET); 175 fseek(file, 0, SEEK_SET);
175 176
176 buf = (unsigned char*)malloc(length); 177 buf = (unsigned char*)malloc(length);
177 if ( !buf ) { 178 if ( !buf )
179 {
178 printf("Out of memory!\n"); 180 printf("Out of memory!\n");
179 return -1; 181 return -1;
180 } 182 }
181 183
182 len = fread(buf, 1, length, file); 184 len = fread(buf, 1, length, file);
183 if(len < (size_t)length) { 185 if(len < (size_t)length)
186 {
184 perror(iname); 187 perror(iname);
185 return -2; 188 return -2;
186 } 189 }
187 fclose(file); 190 fclose(file);
188 191
189 outbuf = (unsigned char*)malloc(length+0x300); 192 outbuf = (unsigned char*)malloc(length+0x300);
190 if ( !outbuf ) { 193 if ( !outbuf )
194 {
191 free(buf); 195 free(buf);
192 printf("Out of memory!\n"); 196 printf("Out of memory!\n");
193 return -1; 197 return -1;
@@ -200,20 +204,33 @@ int zvm_encode(const char *iname, const char *oname, int device)
200 printf("Error in making JRM file!\n"); 204 printf("Error in making JRM file!\n");
201 return -1; 205 return -1;
202 } 206 }
203 buf = (unsigned char*)malloc(length+0x200); 207 if(enable_ciff)
204 memset(buf, 0, length+0x200); 208 {
205 length = make_ciff_file(outbuf, length, buf, device); 209 buf = (unsigned char*)malloc(length+0x200);
206 free(outbuf); 210 if ( !buf )
211 {
212 free(outbuf);
213 printf("Out of memory!\n");
214 return -1;
215 }
216 memset(buf, 0, length+0x200);
217 length = make_ciff_file(outbuf, length, buf, device);
218 free(outbuf);
219 }
220 else
221 buf = outbuf;
207 222
208 file = fopen(oname, "wb"); 223 file = fopen(oname, "wb");
209 if (!file) { 224 if (!file)
225 {
210 free(buf); 226 free(buf);
211 perror(oname); 227 perror(oname);
212 return -3; 228 return -3;
213 } 229 }
214 230
215 len = fwrite(buf, 1, length, file); 231 len = fwrite(buf, 1, length, file);
216 if(len < (size_t)length) { 232 if(len < (size_t)length)
233 {
217 free(buf); 234 free(buf);
218 perror(oname); 235 perror(oname);
219 return -4; 236 return -4;
diff --git a/tools/creative.h b/tools/creative.h
index a634e439c6..ee2cf90582 100644
--- a/tools/creative.h
+++ b/tools/creative.h
@@ -38,6 +38,6 @@ struct device_info
38 const char* null; 38 const char* null;
39}; 39};
40 40
41int zvm_encode(const char *iname, const char *oname, int device); 41int zvm_encode(const char *iname, const char *oname, int device, bool enable_ciff);
42 42
43#endif /*CREATIVE_H_*/ 43#endif /*CREATIVE_H_*/
diff --git a/tools/scramble.c b/tools/scramble.c
index ace8337a1b..5dff4f4086 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -145,6 +145,7 @@ int main (int argc, char** argv)
145 char modelname[5]; 145 char modelname[5];
146 int model_id; 146 int model_id;
147 enum { none, scramble, xor, tcc_sum, tcc_crc, add } method = scramble; 147 enum { none, scramble, xor, tcc_sum, tcc_crc, add } method = scramble;
148 bool creative_enable_ciff;
148 149
149 model_id = ARCHOS_PLAYER; 150 model_id = ARCHOS_PLAYER;
150 151
@@ -341,20 +342,32 @@ int main (int argc, char** argv)
341 oname = argv[3]; 342 oname = argv[3];
342 return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */ 343 return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */
343 } 344 }
344 else if(!strncmp(argv[1], "-creative=", 10)) { 345 else if(!strncmp(argv[1], "-creative=", 10))
345 iname = argv[2]; 346 {
346 oname = argv[3]; 347 if(!strcmp(argv[2], "-no-ciff"))
348 {
349 creative_enable_ciff = false;
350 iname = argv[3];
351 oname = argv[4];
352 }
353 else
354 {
355 creative_enable_ciff = true;
356 iname = argv[2];
357 oname = argv[3];
358 }
347 if(!strcmp(&argv[1][10], "zvm")) 359 if(!strcmp(&argv[1][10], "zvm"))
348 return zvm_encode(iname, oname, ZENVISIONM); 360 return zvm_encode(iname, oname, ZENVISIONM, creative_enable_ciff);
349 else if(!strcmp(&argv[1][10], "zvm60")) 361 else if(!strcmp(&argv[1][10], "zvm60"))
350 return zvm_encode(iname, oname, ZENVISIONM60); 362 return zvm_encode(iname, oname, ZENVISIONM60, creative_enable_ciff);
351 else if(!strcmp(&argv[1][10], "zenvision")) 363 else if(!strcmp(&argv[1][10], "zenvision"))
352 return zvm_encode(iname, oname, ZENVISION); 364 return zvm_encode(iname, oname, ZENVISION, creative_enable_ciff);
353 else if(!strcmp(&argv[1][10], "zenv")) 365 else if(!strcmp(&argv[1][10], "zenv"))
354 return zvm_encode(iname, oname, ZENV); 366 return zvm_encode(iname, oname, ZENV, creative_enable_ciff);
355 else if(!strcmp(&argv[1][10], "zen")) 367 else if(!strcmp(&argv[1][10], "zen"))
356 return zvm_encode(iname, oname, ZEN); 368 return zvm_encode(iname, oname, ZEN, creative_enable_ciff);
357 else { 369 else
370 {
358 fprintf(stderr, "unsupported Creative device: %s\n", &argv[1][10]); 371 fprintf(stderr, "unsupported Creative device: %s\n", &argv[1][10]);
359 return 2; 372 return 2;
360 } 373 }