forked from len0rd/rockbox
FS#10728 - Cowon D2: Add support for D2 in rbutil
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23410 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0f90f0b423
commit
ad78551811
9 changed files with 522 additions and 71 deletions
|
@ -6,16 +6,112 @@
|
||||||
# \/ \/ \/ \/ \/
|
# \/ \/ \/ \/ \/
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# We use the Telechips code available in the Rockbox tools/ directory
|
||||||
TOOLSDIR=../../tools
|
TOOLSDIR=../../tools
|
||||||
CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR)
|
CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR)
|
||||||
|
|
||||||
all: mktccboot
|
PLAT=tcc
|
||||||
|
|
||||||
telechips.o: $(TOOLSDIR)/telechips.c $(TOOLSDIR)/telechips.h
|
CC = gcc
|
||||||
$(SILENT)$(CC) $(CFLAGS) $(TOOLSDIR)/telechips.c -c -o $@
|
MKPLATBOOT=mk$(PLAT)boot
|
||||||
|
LIB_MKPLATBOOT=lib$(MKPLATBOOT)
|
||||||
|
|
||||||
mktccboot: mktccboot.c telechips.o
|
#change for releases
|
||||||
$(SILENT)$(CC) $(CFLAGS) $+ -o $@
|
ifndef APPVERSION
|
||||||
|
APPVERSION=`$(TOOLSDIR)/version.sh`
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef V
|
||||||
|
SILENT = @
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
|
||||||
|
OUTPUT=$(MKPLATBOOT).exe
|
||||||
|
CFLAGS+=-mno-cygwin
|
||||||
|
else
|
||||||
|
ifeq ($(findstring MINGW,$(shell uname)),MINGW)
|
||||||
|
OUTPUT=$(MKPLATBOOT).exe
|
||||||
|
else
|
||||||
|
ifeq ($(findstring mingw,$(CC)),mingw)
|
||||||
|
OUTPUT=$(MKPLATBOOT).exe
|
||||||
|
else
|
||||||
|
OUTPUT=$(MKPLATBOOT)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef RBARCH
|
||||||
|
CFLAGS += -arch $(RBARCH)
|
||||||
|
endif
|
||||||
|
|
||||||
|
OUT = $(TARGET_DIR)build$(RBARCH)
|
||||||
|
|
||||||
|
MKPLATBOOT_OBJ=$(OUT)/$(MKPLATBOOT).o
|
||||||
|
LIBMKPLATBOOT_OBJ=$(OUT)/$(LIB_MKPLATBOOT).o
|
||||||
|
|
||||||
|
all: $(OUTPUT)
|
||||||
|
|
||||||
|
# Dependant modules
|
||||||
|
TELECHIPS=$(TOOLSDIR)/telechips
|
||||||
|
TELECHIPS_OBJ=$(TELECHIPS).o
|
||||||
|
|
||||||
|
$(TELECHIPS_OBJ): $(TELECHIPS).[ch]
|
||||||
|
make -C $(TOOLSDIR) $(TARGET_DIR)telechips.o
|
||||||
|
|
||||||
|
DEPENDANT_OBJS=$(TELECHIPS_OBJ)
|
||||||
|
|
||||||
|
$(MKPLATBOOT_OBJ): $(MKPLATBOOT).[ch] $(DEPENDANT_OBJS)
|
||||||
|
@echo CC $<
|
||||||
|
$(SILENT)$(CC) $(CFLAGS) -c -o $(MKPLATBOOT_OBJ) -W -Wall $(MKPLATBOOT).c -DVERSION=\"$(APPVERSION)\"
|
||||||
|
|
||||||
|
$(OUTPUT): $(OUT) $(MKPLATBOOT_OBJ)
|
||||||
|
@echo CC $<
|
||||||
|
$(SILENT)$(CC) $(CFLAGS) -o $(OUTPUT) $(MKPLATBOOT_OBJ) $(DEPENDANT_OBJS)
|
||||||
|
|
||||||
|
$(LIBMKPLATBOOT_OBJ): $(MKPLATBOOT_OBJ)
|
||||||
|
@echo CC $<
|
||||||
|
$(SILENT)$(CC) $(CFLAGS) -DLIB -c -o $(LIBMKPLATBOOT_OBJ) -W -Wall $(MKPLATBOOT).c
|
||||||
|
|
||||||
|
$(LIB_MKPLATBOOT)$(RBARCH).a: $(OUT) $(LIBMKPLATBOOT_OBJ)
|
||||||
|
@echo AR $@
|
||||||
|
$(SILENT)$(AR) ruc $(TARGET_DIR)$(LIB_MKPLATBOOT)$(RBARCH).a $(LIBMKPLATBOOT_OBJ)
|
||||||
|
|
||||||
|
# some trickery to build ppc and i386 from a single call
|
||||||
|
ifeq ($(RBARCH),)
|
||||||
|
$(LIB_MKPLATBOOT)i386.a:
|
||||||
|
make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) $(LIB_MKPLATBOOT)i386.a
|
||||||
|
|
||||||
|
$(LIB_MKPLATBOOT)ppc.a:
|
||||||
|
make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) $(LIB_MKPLATBOOT)ppc.a
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(LIB_MKPLATBOOT)-universal: $(LIB_MKPLATBOOT)i386.a $(LIB_MKPLATBOOT)ppc.a
|
||||||
|
@echo lipo $(TARGET_DIR)$(LIB_MKPLATBOOT).a
|
||||||
|
$(SILENT) rm -f $(TARGET_DIR)$(LIB_MKPLATBOOT).a
|
||||||
|
lipo -create $(TARGET_DIR)$(LIB_MKPLATBOOT)ppc.a $(TARGET_DIR)$(LIB_MKPLATBOOT)i386.a -output $(TARGET_DIR)$(LIB_MKPLATBOOT).a
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f telechips.o mktccboot
|
rm -f $(OUTPUT) $(LIB_MKPLATBOOT).o $(TARGET_DIR)$(LIB_MKPLATBOOT)*.a $(MKPLATBOOT).dmg
|
||||||
|
rm -f $(DEPENDANT_OBJS)
|
||||||
|
rm -rf build* $(MKPLATBOOT)-*
|
||||||
|
|
||||||
|
$(MKPLATBOOT)-i386:
|
||||||
|
$(MAKE) RBARCH=i386
|
||||||
|
mv $(MKPLATBOOT) $(MKPLATBOOT)-i386
|
||||||
|
|
||||||
|
$(MKPLATBOOT)-ppc:
|
||||||
|
make RBARCH=ppc
|
||||||
|
mv $(MKPLATBOOT) $(MKPLATBOOT)-ppc
|
||||||
|
|
||||||
|
$(MKPLATBOOT)-mac: $(MKPLATBOOT)-i386 $(MKPLATBOOT)-ppc
|
||||||
|
lipo -create $(MKPLATBOOT)-ppc $(MKPLATBOOT)-i386 -output $(MKPLATBOOT)-mac
|
||||||
|
|
||||||
|
$(MKPLATBOOT).dmg: $(MKPLATBOOT)-mac
|
||||||
|
mkdir -p $(MKPLATBOOT)-dmg
|
||||||
|
cp -p $(MKPLATBOOT)-mac $(MKPLATBOOT)-dmg
|
||||||
|
hdiutil create -srcfolder $(MKPLATBOOT)-dmg $(MKPLATBOOT).dmg
|
||||||
|
|
||||||
|
$(OUT):
|
||||||
|
@echo MKDIR $(OUT)
|
||||||
|
$(SILENT)mkdir $(OUT)
|
||||||
|
|
35
rbutil/mktccboot/README
Normal file
35
rbutil/mktccboot/README
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
mktccboot
|
||||||
|
---------
|
||||||
|
|
||||||
|
A tool to inject a bootloader into a Telechips 77X/78X firmware file.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
|
mktccboot <firmware file> <boot file> <output file>
|
||||||
|
|
||||||
|
<firmware file> is an original Telechips firmware file.
|
||||||
|
|
||||||
|
<boot file> is the code you want to execute (a rockbox bootloader), previously
|
||||||
|
scrambled with tools/scramble utility.
|
||||||
|
|
||||||
|
<output file> is the resulting firmware file which you'll have to copy on your
|
||||||
|
player. See "Firmware filenames".
|
||||||
|
|
||||||
|
Dual-Boot
|
||||||
|
---------
|
||||||
|
|
||||||
|
The purpose of this program is to provide dual-boot between the original
|
||||||
|
firmware and the new (rockbox) firmware.
|
||||||
|
|
||||||
|
By default the player will boot into the new firmware.
|
||||||
|
|
||||||
|
To boot into the Original Firmware, you need to press the <???> key.
|
||||||
|
|
||||||
|
The player will boot into the Original Firmware as well if it is powered up by
|
||||||
|
inserting an usb cable.
|
||||||
|
|
||||||
|
Hacking
|
||||||
|
-------
|
||||||
|
|
||||||
|
See comments in mktccboot.c for more information.
|
|
@ -81,7 +81,7 @@ void usage(void)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t filesize(int fd) {
|
static off_t filesize(int fd) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if (fstat(fd,&buf) < 0) {
|
if (fstat(fd,&buf) < 0) {
|
||||||
|
@ -92,16 +92,97 @@ off_t filesize(int fd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DRAMORIG 0x20000000
|
||||||
|
/* Injects a bootloader into a Telechips 77X/78X firmware file */
|
||||||
|
unsigned char *patch_firmware_tcc(unsigned char *of_buf, int of_size,
|
||||||
|
unsigned char *boot_buf, int boot_size, int *patched_size)
|
||||||
|
{
|
||||||
|
unsigned char *patched_buf;
|
||||||
|
uint32_t ldr, old_ep_offset, new_ep_offset;
|
||||||
|
int of_offset;
|
||||||
|
|
||||||
|
patched_buf = malloc(of_size + boot_size);
|
||||||
|
if (!patched_buf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
memcpy(patched_buf, of_buf, of_size);
|
||||||
|
memcpy(patched_buf + of_size, boot_buf, boot_size);
|
||||||
|
|
||||||
|
ldr = get_uint32le(patched_buf);
|
||||||
|
|
||||||
|
/* TODO: Verify it's a LDR instruction */
|
||||||
|
of_offset = (ldr & 0xfff) + 8;
|
||||||
|
old_ep_offset = get_uint32le(patched_buf + of_offset);
|
||||||
|
new_ep_offset = DRAMORIG + of_size;
|
||||||
|
|
||||||
|
printf("OF entry point: 0x%08x\n", old_ep_offset);
|
||||||
|
printf("New entry point: 0x%08x\n", new_ep_offset + 8);
|
||||||
|
|
||||||
|
/* Save the OF entry point at the start of the bootloader image */
|
||||||
|
put_uint32le(old_ep_offset, patched_buf + of_size);
|
||||||
|
put_uint32le(new_ep_offset, patched_buf + of_size + 4);
|
||||||
|
|
||||||
|
/* Change the OF entry point to the third word in our bootloader */
|
||||||
|
put_uint32le(new_ep_offset + 8, patched_buf + of_offset);
|
||||||
|
|
||||||
|
telechips_encode_crc(patched_buf, of_size + boot_size);
|
||||||
|
*patched_size = of_size + boot_size;
|
||||||
|
|
||||||
|
return patched_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char *file_read(char *filename, int *size)
|
||||||
|
{
|
||||||
|
unsigned char *buf = NULL;
|
||||||
|
int n, fd = -1;
|
||||||
|
|
||||||
|
/* Open file for reading */
|
||||||
|
fd = open(filename, O_RDONLY|O_BINARY);
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
printf("[ERR] Could open file for reading, aborting\n");
|
||||||
|
perror(filename);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get file size, and allocate a buffer of that size */
|
||||||
|
*size = filesize(fd);
|
||||||
|
buf = malloc(*size);
|
||||||
|
if (buf == NULL)
|
||||||
|
{
|
||||||
|
printf("[ERR] Could not allocate memory, aborting\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the file's content to the buffer */
|
||||||
|
n = read(fd, buf, *size);
|
||||||
|
if (n != *size)
|
||||||
|
{
|
||||||
|
printf("[ERR] Could not read from %s\n", filename);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (fd >= 0)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
if (buf)
|
||||||
|
free(buf);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef LIB
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *infile, *bootfile, *outfile;
|
char *infile, *bootfile, *outfile;
|
||||||
int fdin = -1, fdboot = -1, fdout = -1;
|
int fdout = -1;
|
||||||
int n;
|
int n, of_size, boot_size, patched_size;
|
||||||
int inlength,bootlength;
|
unsigned char *of_buf;
|
||||||
uint32_t ldr;
|
unsigned char *boot_buf = NULL;
|
||||||
unsigned char* image;
|
unsigned char* image = NULL;
|
||||||
int origoffset;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(argc < 3) {
|
if(argc < 3) {
|
||||||
|
@ -112,79 +193,50 @@ int main(int argc, char *argv[])
|
||||||
bootfile = argv[2];
|
bootfile = argv[2];
|
||||||
outfile = argv[3];
|
outfile = argv[3];
|
||||||
|
|
||||||
fdin = open(infile, O_RDONLY|O_BINARY);
|
/* Read OF and boot files */
|
||||||
if (fdin < 0)
|
of_buf = file_read(infile, &of_size);
|
||||||
|
if (!of_buf)
|
||||||
{
|
{
|
||||||
perror(infile);
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdboot = open(bootfile, O_RDONLY|O_BINARY);
|
boot_buf = file_read(bootfile, &boot_size);
|
||||||
if (fdboot < 0)
|
if (!boot_buf)
|
||||||
{
|
{
|
||||||
perror(bootfile);
|
|
||||||
ret = 2;
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
inlength = filesize(fdin);
|
|
||||||
bootlength = filesize(fdboot);
|
|
||||||
|
|
||||||
image = malloc(inlength + bootlength);
|
|
||||||
|
|
||||||
if (image==NULL)
|
|
||||||
{
|
|
||||||
printf("[ERR] Could not allocate memory, aborting\n");
|
|
||||||
ret = 3;
|
ret = 3;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = read(fdin, image, inlength);
|
/* Allocate buffer for patched firmware */
|
||||||
if (n != inlength)
|
image = malloc(of_size + boot_size);
|
||||||
|
if (image == NULL)
|
||||||
{
|
{
|
||||||
printf("[ERR] Could not read from %s\n",infile);
|
printf("[ERR] Could not allocate memory, aborting\n");
|
||||||
ret = 4;
|
ret = 4;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = read(fdboot, image + inlength, bootlength);
|
/* Create the patched firmware */
|
||||||
if (n != bootlength)
|
image = patch_firmware_tcc(of_buf, of_size, boot_buf, boot_size,
|
||||||
|
&patched_size);
|
||||||
|
if (!image)
|
||||||
{
|
{
|
||||||
printf("[ERR] Could not read from %s\n",bootfile);
|
printf("[ERR] Error creating patched firmware, aborting\n");
|
||||||
ret = 5;
|
ret = 5;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldr = get_uint32le(image);
|
|
||||||
|
|
||||||
/* TODO: Verify it's a LDR instruction */
|
|
||||||
origoffset = (ldr&0xfff) + 8;
|
|
||||||
|
|
||||||
printf("original firmware entry point: 0x%08x\n",
|
|
||||||
(unsigned int) get_uint32le(image + origoffset));
|
|
||||||
printf("New entry point: 0x%08x\n",0x20000000 + inlength + 8);
|
|
||||||
|
|
||||||
/* Save the original firmware entry point at the start of the bootloader image */
|
|
||||||
put_uint32le(get_uint32le(image + origoffset),image+inlength);
|
|
||||||
put_uint32le(0x20000000 + inlength,image + inlength + 4);
|
|
||||||
|
|
||||||
/* Change the original firmware entry point to the third word in our bootloader */
|
|
||||||
put_uint32le(0x20000000 + inlength + 8,image+origoffset);
|
|
||||||
|
|
||||||
|
|
||||||
telechips_encode_crc(image, inlength + bootlength);
|
|
||||||
|
|
||||||
fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
|
fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
|
||||||
if (fdout < 0)
|
if (fdout < 0)
|
||||||
{
|
{
|
||||||
perror(bootfile);
|
perror(outfile);
|
||||||
ret = 6;
|
ret = 6;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = write(fdout, image, inlength + bootlength);
|
n = write(fdout, image, patched_size);
|
||||||
if (n != inlength + bootlength)
|
if (n != patched_size)
|
||||||
{
|
{
|
||||||
printf("[ERR] Could not write output file %s\n",outfile);
|
printf("[ERR] Could not write output file %s\n",outfile);
|
||||||
ret = 7;
|
ret = 7;
|
||||||
|
@ -193,14 +245,18 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
|
|
||||||
if (fdin >= 0)
|
|
||||||
close(fdin);
|
|
||||||
|
|
||||||
if (fdboot >= 0)
|
|
||||||
close(fdboot);
|
|
||||||
|
|
||||||
if (fdout >= 0)
|
if (fdout >= 0)
|
||||||
close(fdout);
|
close(fdout);
|
||||||
|
|
||||||
|
if (of_buf)
|
||||||
|
free(of_buf);
|
||||||
|
|
||||||
|
if (boot_buf)
|
||||||
|
free(boot_buf);
|
||||||
|
|
||||||
|
if (image)
|
||||||
|
free(image);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
42
rbutil/mktccboot/mktccboot.h
Normal file
42
rbutil/mktccboot/mktccboot.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* mktccboot.h - a tool to inject a bootloader into a Telechips 77X/78X firmware
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Tomer Shalev
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _MKTCCBOOT_H_
|
||||||
|
#define _MKTCCBOOT_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Injects a bootloader into a Telechips 77X/78X firmware file */
|
||||||
|
unsigned char *patch_firmware_tcc(unsigned char *of_buf, int of_size,
|
||||||
|
unsigned char *boot_buf, int boot_size, int *patched_size);
|
||||||
|
|
||||||
|
unsigned char *file_read(char *filename, int *size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
154
rbutil/rbutilqt/base/bootloaderinstalltcc.cpp
Normal file
154
rbutil/rbutilqt/base/bootloaderinstalltcc.cpp
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 by Tomer Shalev
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* This file is a modified version of the AMS installer by Dominik Wenger
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
#include "bootloaderinstallbase.h"
|
||||||
|
#include "bootloaderinstalltcc.h"
|
||||||
|
#include "../mktccboot/mktccboot.h"
|
||||||
|
|
||||||
|
BootloaderInstallTcc::BootloaderInstallTcc(QObject *parent)
|
||||||
|
: BootloaderInstallBase(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BootloaderInstallTcc::ofHint()
|
||||||
|
{
|
||||||
|
return tr("Bootloader installation requires you to provide "
|
||||||
|
"a firmware file of the original firmware (bin file). "
|
||||||
|
"You need to download this file yourself due to legal "
|
||||||
|
"reasons."
|
||||||
|
"Press Ok to continue and browse your computer for the firmware "
|
||||||
|
"file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BootloaderInstallTcc::install(void)
|
||||||
|
{
|
||||||
|
if(m_offile.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Download firmware from server
|
||||||
|
emit logItem(tr("Downloading bootloader file"), LOGINFO);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
|
||||||
|
downloadBlStart(m_blurl);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BootloaderInstallTcc::installStage2(void)
|
||||||
|
{
|
||||||
|
unsigned char *of_buf, *boot_buf = NULL, *patched_buf = NULL;
|
||||||
|
int n, of_size, boot_size, patched_size;
|
||||||
|
char errstr[200];
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
m_tempfile.open();
|
||||||
|
QString bootfile = m_tempfile.fileName();
|
||||||
|
m_tempfile.close();
|
||||||
|
|
||||||
|
/* Construct path for write out.
|
||||||
|
* Combine path of m_blfile with filename from OF */
|
||||||
|
QString outfilename = QFileInfo(m_blfile).absolutePath() + "/" +
|
||||||
|
QFileInfo(m_offile).fileName();
|
||||||
|
|
||||||
|
/* Write out file */
|
||||||
|
QFile out(outfilename);
|
||||||
|
|
||||||
|
/* Load original firmware file */
|
||||||
|
of_buf = file_read(m_offile.toLocal8Bit().data(), &of_size);
|
||||||
|
if (of_buf == NULL)
|
||||||
|
{
|
||||||
|
emit logItem(errstr, LOGERROR);
|
||||||
|
emit logItem(tr("Could not load %1").arg(m_offile), LOGERROR);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load bootloader file */
|
||||||
|
boot_buf = file_read(bootfile.toLocal8Bit().data(), &boot_size);
|
||||||
|
if (boot_buf == NULL)
|
||||||
|
{
|
||||||
|
emit logItem(errstr, LOGERROR);
|
||||||
|
emit logItem(tr("Could not load %1").arg(bootfile), LOGERROR);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Patch the firmware */
|
||||||
|
emit logItem(tr("Patching Firmware..."), LOGINFO);
|
||||||
|
|
||||||
|
patched_buf = patch_firmware_tcc(of_buf, of_size, boot_buf, boot_size,
|
||||||
|
&patched_size);
|
||||||
|
if (patched_buf == NULL)
|
||||||
|
{
|
||||||
|
emit logItem(errstr, LOGERROR);
|
||||||
|
emit logItem(tr("Could patch firmware"), LOGERROR);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!out.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
|
{
|
||||||
|
emit logItem(tr("Could not open %1 for writing").arg(m_blfile),
|
||||||
|
LOGERROR);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = out.write((char*)patched_buf, patched_size);
|
||||||
|
out.close();
|
||||||
|
if (n != patched_size)
|
||||||
|
{
|
||||||
|
emit logItem(tr("Could not write firmware file"), LOGERROR);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of install */
|
||||||
|
emit logItem(tr("Success: modified firmware file created"), LOGINFO);
|
||||||
|
logInstall(LogAdd);
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
if (of_buf)
|
||||||
|
free(of_buf);
|
||||||
|
|
||||||
|
if (boot_buf)
|
||||||
|
free(boot_buf);
|
||||||
|
|
||||||
|
if (patched_buf)
|
||||||
|
free(patched_buf);
|
||||||
|
|
||||||
|
emit done(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BootloaderInstallTcc::uninstall(void)
|
||||||
|
{
|
||||||
|
emit logItem("To uninstall, perform a normal upgrade with an unmodified original firmware", LOGINFO);
|
||||||
|
logInstall(LogRemove);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BootloaderInstallBase::BootloaderType BootloaderInstallTcc::installed(void)
|
||||||
|
{
|
||||||
|
return BootloaderUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
BootloaderInstallBase::Capabilities BootloaderInstallTcc::capabilities(void)
|
||||||
|
{
|
||||||
|
return (Install | NeedsOf);
|
||||||
|
}
|
45
rbutil/rbutilqt/base/bootloaderinstalltcc.h
Normal file
45
rbutil/rbutilqt/base/bootloaderinstalltcc.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 by Tomer Shalev
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* This file is a modified version of the AMS installer by Dominik Wenger
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef BOOTLOADERINSTALLTCC_H
|
||||||
|
#define BOOTLOADERINSTALLTCC_H
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
#include "bootloaderinstallbase.h"
|
||||||
|
|
||||||
|
//! bootloader installation derivate based on mktccboot
|
||||||
|
class BootloaderInstallTcc : public BootloaderInstallBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
BootloaderInstallTcc(QObject *parent);
|
||||||
|
bool install(void);
|
||||||
|
bool uninstall(void);
|
||||||
|
BootloaderInstallBase::BootloaderType installed(void);
|
||||||
|
Capabilities capabilities(void);
|
||||||
|
QString ofHint();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void installStage2(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -58,7 +58,7 @@ platform60=mrobe100
|
||||||
platform70=smsgyh820
|
platform70=smsgyh820
|
||||||
platform71=smsgyh920
|
platform71=smsgyh920
|
||||||
platform72=smsgyh925
|
platform72=smsgyh925
|
||||||
|
platform73=cowond2
|
||||||
|
|
||||||
[player]
|
[player]
|
||||||
name="Jukebox Player 6000 / Jukebox Studio 5 / 10 / 20"
|
name="Jukebox Player 6000 / Jukebox Studio 5 / 10 / 20"
|
||||||
|
@ -537,6 +537,19 @@ usbid=0x04e85024
|
||||||
configure_modelname=yh925
|
configure_modelname=yh925
|
||||||
encoder=rbspeex
|
encoder=rbspeex
|
||||||
|
|
||||||
|
[cowond2]
|
||||||
|
name="D2 (Unstable)"
|
||||||
|
buildserver_modelname=cowond2
|
||||||
|
bootloadermethod=tcc
|
||||||
|
bootloadername=/cowon/d2.bin
|
||||||
|
bootloaderfile=d2n.bin
|
||||||
|
manualname=
|
||||||
|
brand=Cowon
|
||||||
|
usbid=0x0e210800, 0x0e210860, 0x0e210870, 0x0e210880, 0x0e210890
|
||||||
|
usberror=0x0e210801, 0x0e210861, 0x0e210871, 0x0e210881, 0x0e210891
|
||||||
|
configure_modelname=cowond2
|
||||||
|
encoder=rbspeex
|
||||||
|
|
||||||
[05ac1240]
|
[05ac1240]
|
||||||
name="Apple Ipod Nano (Second Generation, DFU Mode)"
|
name="Apple Ipod Nano (Second Generation, DFU Mode)"
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "bootloaderinstallfile.h"
|
#include "bootloaderinstallfile.h"
|
||||||
#include "bootloaderinstallchinachip.h"
|
#include "bootloaderinstallchinachip.h"
|
||||||
#include "bootloaderinstallams.h"
|
#include "bootloaderinstallams.h"
|
||||||
|
#include "bootloaderinstalltcc.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
|
@ -673,6 +674,9 @@ void RbUtilQt::installBootloader()
|
||||||
else if(type == "ams") {
|
else if(type == "ams") {
|
||||||
bl = new BootloaderInstallAms(this);
|
bl = new BootloaderInstallAms(this);
|
||||||
}
|
}
|
||||||
|
else if(type == "tcc") {
|
||||||
|
bl = new BootloaderInstallTcc(this);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
logger->addItem(tr("No install method known."), LOGERROR);
|
logger->addItem(tr("No install method known."), LOGERROR);
|
||||||
logger->setFinished();
|
logger->setFinished();
|
||||||
|
|
|
@ -42,14 +42,16 @@ LIBSPEEX = $$system(pkg-config --silence-errors --libs speex)
|
||||||
rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex.a
|
rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex.a
|
||||||
libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl.a
|
libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl.a
|
||||||
libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot.a
|
libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot.a
|
||||||
|
libmktccboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mktccboot libmktccboot.a
|
||||||
}
|
}
|
||||||
mac {
|
mac {
|
||||||
rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex-universal
|
rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex-universal
|
||||||
libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl-universal
|
libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl-universal
|
||||||
libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot-universal
|
libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot-universal
|
||||||
|
libmktccboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mktccboot libmktccboot-universal
|
||||||
}
|
}
|
||||||
QMAKE_EXTRA_TARGETS += rbspeex libucl libmkamsboot
|
QMAKE_EXTRA_TARGETS += rbspeex libucl libmkamsboot libmktccboot
|
||||||
PRE_TARGETDEPS += rbspeex libucl libmkamsboot
|
PRE_TARGETDEPS += rbspeex libucl libmkamsboot libmktccboot
|
||||||
|
|
||||||
# rule for creating ctags file
|
# rule for creating ctags file
|
||||||
tags.commands = ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(SOURCES)
|
tags.commands = ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(SOURCES)
|
||||||
|
@ -110,8 +112,10 @@ SOURCES += rbutilqt.cpp \
|
||||||
base/bootloaderinstallfile.cpp \
|
base/bootloaderinstallfile.cpp \
|
||||||
base/bootloaderinstallchinachip.cpp \
|
base/bootloaderinstallchinachip.cpp \
|
||||||
base/bootloaderinstallams.cpp \
|
base/bootloaderinstallams.cpp \
|
||||||
|
base/bootloaderinstalltcc.cpp \
|
||||||
../../tools/mkboot.c \
|
../../tools/mkboot.c \
|
||||||
../../tools/iriver.c
|
../../tools/iriver.c \
|
||||||
|
../../tools/telechips.c \
|
||||||
|
|
||||||
HEADERS += rbutilqt.h \
|
HEADERS += rbutilqt.h \
|
||||||
install.h \
|
install.h \
|
||||||
|
@ -170,8 +174,10 @@ HEADERS += rbutilqt.h \
|
||||||
base/bootloaderinstallfile.h \
|
base/bootloaderinstallfile.h \
|
||||||
base/bootloaderinstallchinachip.h \
|
base/bootloaderinstallchinachip.h \
|
||||||
base/bootloaderinstallams.h \
|
base/bootloaderinstallams.h \
|
||||||
|
base/bootloaderinstalltcc.h \
|
||||||
../../tools/mkboot.h \
|
../../tools/mkboot.h \
|
||||||
../../tools/iriver.h
|
../../tools/iriver.h \
|
||||||
|
../../tools/telechips.h \
|
||||||
|
|
||||||
# Needed by QT on Win
|
# Needed by QT on Win
|
||||||
INCLUDEPATH = $$_PRO_FILE_PWD_ $$_PRO_FILE_PWD_/irivertools $$_PRO_FILE_PWD_/zip $$_PRO_FILE_PWD_/zlib $$_PRO_FILE_PWD_/base
|
INCLUDEPATH = $$_PRO_FILE_PWD_ $$_PRO_FILE_PWD_/irivertools $$_PRO_FILE_PWD_/zip $$_PRO_FILE_PWD_/zlib $$_PRO_FILE_PWD_/base
|
||||||
|
@ -179,7 +185,7 @@ INCLUDEPATH += $$RBBASE_DIR/rbutil/ipodpatcher $$RBBASE_DIR/rbutil/sansapatcher
|
||||||
|
|
||||||
DEPENDPATH = $$INCLUDEPATH
|
DEPENDPATH = $$INCLUDEPATH
|
||||||
|
|
||||||
LIBS += -L$$OUT_PWD -L$$MYBUILDDIR -lrbspeex -lmkamsboot -lucl
|
LIBS += -L$$OUT_PWD -L$$MYBUILDDIR -lrbspeex -lmkamsboot -lmktccboot -lucl
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
dbg {
|
dbg {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue