Prepare Creative bootloader compilation for future dual boot integration

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18187 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2008-08-03 19:32:14 +00:00
parent 7a4c333581
commit 06e3c660cc
5 changed files with 55 additions and 25 deletions

View file

@ -98,7 +98,7 @@ $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAP
$(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 $(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
$(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf $(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
$(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@ $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
$(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
$(TOOLSDIR)/sh2d -sh1 $< > $@ $(TOOLSDIR)/sh2d -sh1 $< > $@

6
tools/configure vendored
View file

@ -1489,7 +1489,7 @@ fi
plugins="" plugins=""
swcodec="yes" swcodec="yes"
toolset=$ipodbitmaptools toolset=$ipodbitmaptools
boottool="$rootdir/tools/scramble -creative=zvm" boottool="$rootdir/tools/scramble -creative=zvm -no-ciff"
bootoutput="rockbox.zvmboot" bootoutput="rockbox.zvmboot"
# architecture, manufacturer and model for the target-tree build # architecture, manufacturer and model for the target-tree build
t_cpu="arm" t_cpu="arm"
@ -1507,7 +1507,7 @@ fi
bmp2rb_native="$rootdir/tools/bmp2rb -f 4" bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0"
tool="$rootdir/tools/scramble -creative=zvm60" tool="$rootdir/tools/scramble -creative=zvm60 -no-ciff"
USE_ELF="yes" USE_ELF="yes"
output="rockbox.zvm60" output="rockbox.zvm60"
appextra="recorder:gui" appextra="recorder:gui"
@ -1532,7 +1532,7 @@ fi
bmp2rb_native="$rootdir/tools/bmp2rb -f 4" bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0"
tool="$rootdir/tools/scramble -creative=zenvision" tool="$rootdir/tools/scramble -creative=zenvision -no-ciff"
USE_ELF="yes" USE_ELF="yes"
output="rockbox.zv" output="rockbox.zv"
appextra="recorder:gui" appextra="recorder:gui"

View file

@ -155,7 +155,7 @@ static int make_jrm_file(const unsigned char *inbuf, unsigned char *outbuf)
return 0xC+length; return 0xC+length;
} }
int zvm_encode(const char *iname, const char *oname, int device) int zvm_encode(const char *iname, const char *oname, int device, bool enable_ciff)
{ {
size_t len; size_t len;
int length; int length;
@ -164,7 +164,8 @@ int zvm_encode(const char *iname, const char *oname, int device)
unsigned char *buf; unsigned char *buf;
file = fopen(iname, "rb"); file = fopen(iname, "rb");
if (!file) { if (!file)
{
perror(iname); perror(iname);
return -1; return -1;
} }
@ -174,20 +175,23 @@ int zvm_encode(const char *iname, const char *oname, int device)
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
buf = (unsigned char*)malloc(length); buf = (unsigned char*)malloc(length);
if ( !buf ) { if ( !buf )
{
printf("Out of memory!\n"); printf("Out of memory!\n");
return -1; return -1;
} }
len = fread(buf, 1, length, file); len = fread(buf, 1, length, file);
if(len < (size_t)length) { if(len < (size_t)length)
{
perror(iname); perror(iname);
return -2; return -2;
} }
fclose(file); fclose(file);
outbuf = (unsigned char*)malloc(length+0x300); outbuf = (unsigned char*)malloc(length+0x300);
if ( !outbuf ) { if ( !outbuf )
{
free(buf); free(buf);
printf("Out of memory!\n"); printf("Out of memory!\n");
return -1; return -1;
@ -200,20 +204,33 @@ int zvm_encode(const char *iname, const char *oname, int device)
printf("Error in making JRM file!\n"); printf("Error in making JRM file!\n");
return -1; return -1;
} }
if(enable_ciff)
{
buf = (unsigned char*)malloc(length+0x200); buf = (unsigned char*)malloc(length+0x200);
if ( !buf )
{
free(outbuf);
printf("Out of memory!\n");
return -1;
}
memset(buf, 0, length+0x200); memset(buf, 0, length+0x200);
length = make_ciff_file(outbuf, length, buf, device); length = make_ciff_file(outbuf, length, buf, device);
free(outbuf); free(outbuf);
}
else
buf = outbuf;
file = fopen(oname, "wb"); file = fopen(oname, "wb");
if (!file) { if (!file)
{
free(buf); free(buf);
perror(oname); perror(oname);
return -3; return -3;
} }
len = fwrite(buf, 1, length, file); len = fwrite(buf, 1, length, file);
if(len < (size_t)length) { if(len < (size_t)length)
{
free(buf); free(buf);
perror(oname); perror(oname);
return -4; return -4;

View file

@ -38,6 +38,6 @@ struct device_info
const char* null; const char* null;
}; };
int zvm_encode(const char *iname, const char *oname, int device); int zvm_encode(const char *iname, const char *oname, int device, bool enable_ciff);
#endif /*CREATIVE_H_*/ #endif /*CREATIVE_H_*/

View file

@ -145,6 +145,7 @@ int main (int argc, char** argv)
char modelname[5]; char modelname[5];
int model_id; int model_id;
enum { none, scramble, xor, tcc_sum, tcc_crc, add } method = scramble; enum { none, scramble, xor, tcc_sum, tcc_crc, add } method = scramble;
bool creative_enable_ciff;
model_id = ARCHOS_PLAYER; model_id = ARCHOS_PLAYER;
@ -341,20 +342,32 @@ int main (int argc, char** argv)
oname = argv[3]; oname = argv[3];
return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */ return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */
} }
else if(!strncmp(argv[1], "-creative=", 10)) { else if(!strncmp(argv[1], "-creative=", 10))
{
if(!strcmp(argv[2], "-no-ciff"))
{
creative_enable_ciff = false;
iname = argv[3];
oname = argv[4];
}
else
{
creative_enable_ciff = true;
iname = argv[2]; iname = argv[2];
oname = argv[3]; oname = argv[3];
}
if(!strcmp(&argv[1][10], "zvm")) if(!strcmp(&argv[1][10], "zvm"))
return zvm_encode(iname, oname, ZENVISIONM); return zvm_encode(iname, oname, ZENVISIONM, creative_enable_ciff);
else if(!strcmp(&argv[1][10], "zvm60")) else if(!strcmp(&argv[1][10], "zvm60"))
return zvm_encode(iname, oname, ZENVISIONM60); return zvm_encode(iname, oname, ZENVISIONM60, creative_enable_ciff);
else if(!strcmp(&argv[1][10], "zenvision")) else if(!strcmp(&argv[1][10], "zenvision"))
return zvm_encode(iname, oname, ZENVISION); return zvm_encode(iname, oname, ZENVISION, creative_enable_ciff);
else if(!strcmp(&argv[1][10], "zenv")) else if(!strcmp(&argv[1][10], "zenv"))
return zvm_encode(iname, oname, ZENV); return zvm_encode(iname, oname, ZENV, creative_enable_ciff);
else if(!strcmp(&argv[1][10], "zen")) else if(!strcmp(&argv[1][10], "zen"))
return zvm_encode(iname, oname, ZEN); return zvm_encode(iname, oname, ZEN, creative_enable_ciff);
else { else
{
fprintf(stderr, "unsupported Creative device: %s\n", &argv[1][10]); fprintf(stderr, "unsupported Creative device: %s\n", &argv[1][10]);
return 2; return 2;
} }