diff options
| author | Dave Chapman <dave@dchapman.com> | 2009-10-28 21:11:43 +0000 |
|---|---|---|
| committer | Dave Chapman <dave@dchapman.com> | 2009-10-28 21:11:43 +0000 |
| commit | 48430bfabd5148bb3b27576f3e58b1b3350beac6 (patch) | |
| tree | 42d07f008efc0d2726f9788133a73284744a673d /tools | |
| parent | 1992c389ae9f7b351b32d717c07606c8662519e9 (diff) | |
| download | rockbox-48430bfabd5148bb3b27576f3e58b1b3350beac6.zip rockbox-48430bfabd5148bb3b27576f3e58b1b3350beac6.tar.gz rockbox-48430bfabd5148bb3b27576f3e58b1b3350beac6.tar.bz2 rockbox-48430bfabd5148bb3b27576f3e58b1b3350beac6.tar.xz | |
Move mktccboot from tools/ to rbutil/mktccboot/ - inspired by FS#10728 but with no functional changes to code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23382 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/Makefile | 7 | ||||
| -rwxr-xr-x | tools/configure | 2 | ||||
| -rw-r--r-- | tools/mktccboot.c | 206 | ||||
| -rw-r--r-- | tools/root.make | 2 | ||||
| -rw-r--r-- | tools/tools.make | 1 |
5 files changed, 4 insertions, 214 deletions
diff --git a/tools/Makefile b/tools/Makefile index 71fb6bf..853b567 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -13,10 +13,10 @@ LDFLAGS := -g CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \ generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat \ - lngdump telechips gigabeats creative hmac-sha1 mktccboot rbspeexenc \ + lngdump telechips gigabeats creative hmac-sha1 rbspeexenc \ mkzenboot mk500boot -all: scramble descramble sh2d rdf2binary mkboot mktccboot mkzenboot \ +all: scramble descramble sh2d rdf2binary mkboot mkzenboot \ convbdf codepages uclpack rbspeexenc voicefont mk500boot scramble: scramble.o iriver.o mi4.o gigabeat.o gigabeats.o telechips.o iaudio_bl_flash.o creative.o hmac-sha1.o @@ -46,9 +46,6 @@ rdf2binary: rdf2binary.c mkboot: mkboot.c $(SILENT)$(CC) $(CFLAGS) $+ -o $@ -mktccboot: mktccboot.c telechips.o - $(SILENT)$(CC) $(CFLAGS) $+ -o $@ - mk500boot: mk500boot.c mr500.c $(SILENT)$(CC) $(CFLAGS) $+ -o $@ diff --git a/tools/configure b/tools/configure index c79d695..5023b69 100755 --- a/tools/configure +++ b/tools/configure @@ -909,7 +909,7 @@ fi iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb" ipodbitmaptools="$toolset scramble bmp2rb" gigabeatbitmaptools="$toolset scramble descramble bmp2rb" - tccbitmaptools="$toolset scramble mktccboot bmp2rb" + tccbitmaptools="$toolset scramble bmp2rb" # generic is used by IFP, Meizu and Onda genericbitmaptools="$toolset bmp2rb" # scramble is used by all other targets diff --git a/tools/mktccboot.c b/tools/mktccboot.c deleted file mode 100644 index e135b7e..0000000 --- a/tools/mktccboot.c +++ /dev/null @@ -1,206 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 by Dave Chapman - * - * Based on mkboot, Copyright (C) 2005 by Linus Nielsen Feltzing - * - * 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. - * - ****************************************************************************/ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <inttypes.h> -#include "telechips.h" - -/* - -Append a Rockbox bootloader to a Telechips original firmware file. - -The first instruction in a TCC firmware file is always of the form: - - ldr pc, [pc, #xxx] - -where [pc, #xxx] is the entry point of the firmware - e.g. 0x20000020 - -mktccboot appends the Rockbox bootloader to the end of the original -firmware image and replaces the contents of [pc, #xxx] with the entry -point of our bootloader - i.e. the length of the original firmware plus -0x20000000. - -It then stores the original entry point from [pc, #xxx] in a fixed -offset in the Rockbox boootloader, which is used by the bootloader to -dual-boot. - -Finally, mktccboot corrects the length and CRCs in the main firmware -header, creating a new legal firmware file which can be installed on -the device. - -*/ - -/* win32 compatibility */ - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -static void put_uint32le(uint32_t x, unsigned char* p) -{ - p[0] = x & 0xff; - p[1] = (x >> 8) & 0xff; - p[2] = (x >> 16) & 0xff; - p[3] = (x >> 24) & 0xff; -} - -static uint32_t get_uint32le(unsigned char* p) -{ - return (p[3] << 24) | (p[2] << 16) | (p[1]<<8) | p[0]; -} - -void usage(void) -{ - printf("Usage: mktccboot <firmware file> <boot file> <output file>\n"); - - exit(1); -} - -off_t filesize(int fd) { - struct stat buf; - - if (fstat(fd,&buf) < 0) { - perror("[ERR] Checking filesize of input file"); - return -1; - } else { - return(buf.st_size); - } -} - - -int main(int argc, char *argv[]) -{ - char *infile, *bootfile, *outfile; - int fdin = -1, fdboot = -1, fdout = -1; - int n; - int inlength,bootlength; - uint32_t ldr; - unsigned char* image; - int origoffset; - int ret = 0; - - if(argc < 3) { - usage(); - } - - infile = argv[1]; - bootfile = argv[2]; - outfile = argv[3]; - - fdin = open(infile, O_RDONLY|O_BINARY); - if (fdin < 0) - { - perror(infile); - ret = 1; - goto error_exit; - } - - fdboot = open(bootfile, O_RDONLY|O_BINARY); - if (fdboot < 0) - { - 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; - goto error_exit; - } - - n = read(fdin, image, inlength); - if (n != inlength) - { - printf("[ERR] Could not read from %s\n",infile); - ret = 4; - goto error_exit; - } - - n = read(fdboot, image + inlength, bootlength); - if (n != bootlength) - { - printf("[ERR] Could not read from %s\n",bootfile); - ret = 5; - 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); - if (fdout < 0) - { - perror(bootfile); - ret = 6; - goto error_exit; - } - - n = write(fdout, image, inlength + bootlength); - if (n != inlength + bootlength) - { - printf("[ERR] Could not write output file %s\n",outfile); - ret = 7; - goto error_exit; - } - -error_exit: - - if (fdin >= 0) - close(fdin); - - if (fdboot >= 0) - close(fdboot); - - if (fdout >= 0) - close(fdout); - - return ret; -} diff --git a/tools/root.make b/tools/root.make index 13768dd..d68f36d 100644 --- a/tools/root.make +++ b/tools/root.make @@ -20,7 +20,7 @@ PPCFLAGS = $(filter-out -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \ $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \ - $(TOOLSDIR)/uclpack $(TOOLSDIR)/mktccboot $(TOOLSDIR)/mkboot + $(TOOLSDIR)/uclpack $(TOOLSDIR)/mkboot ifeq (,$(PREFIX)) diff --git a/tools/tools.make b/tools/tools.make index e033774..64a47c5 100644 --- a/tools/tools.make +++ b/tools/tools.make @@ -18,7 +18,6 @@ $(TOOLSDIR)/rdf2binary: $(TOOLSDIR)/rdf2binary.c $(TOOLSDIR)/convbdf: $(TOOLSDIR)/convbdf.c $(TOOLSDIR)/codepages: $(TOOLSDIR)/codepages.c $(TOOLSDIR)/codepage_tables.c $(TOOLSDIR)/mkboot: $(TOOLSDIR)/mkboot.c -$(TOOLSDIR)/mktccboot: $(TOOLSDIR)/mktccboot.c $(TOOLSDIR)/telechips.c $(TOOLSDIR)/wavtrim: $(TOOLSDIR)/wavtrim.c $(TOOLSDIR)/voicefont: $(TOOLSDIR)/voicefont.c |