diff options
| author | Dave Chapman <dave@dchapman.com> | 2007-10-28 11:08:10 +0000 |
|---|---|---|
| committer | Dave Chapman <dave@dchapman.com> | 2007-10-28 11:08:10 +0000 |
| commit | 28f6ae49ec1b1d3464add2941eb015bab56f8016 (patch) | |
| tree | 6d4cddba129663340cf2f30212a516acdd16a4eb /tools | |
| parent | d3e101bd1184e5c1f474ff0978f65ac7e8e2dbfb (diff) | |
| download | rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.zip rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.tar.gz rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.tar.bz2 rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.tar.xz | |
Initial work on a port to the Logik DAX 1GB MP3/DAB player. The bootloader build compiles and runs (but only displays some debugging info), and the LCD and ADC drivers are working. Two different bootloader builds are possible: 1) The default build is just a test application for uploading to the device via tcctool; 2) Adding -DTCCBOOT to EXTRA_DEFINES in the build directory Makefile will compile the bootloader so that it can be appended to the end of the original firmware and installed on the device, dual-booting. This commit also includes some work by Hein-Pieter van Braam on a port to the iAudio 7, but that doesn't build yet. A large part of these ports will be generic to all TCC77x devices - see the TelechipsInfo wiki page for some other devices with this CPU. NOTE: Compiling these builds requires an arm-elf-gcc with armv5 support - the current version of rockboxdev.sh compiles such a gcc.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15339 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/Makefile | 5 | ||||
| -rwxr-xr-x | tools/configure | 66 | ||||
| -rw-r--r-- | tools/mktccboot.c | 184 |
3 files changed, 251 insertions, 4 deletions
diff --git a/tools/Makefile b/tools/Makefile index 347b113..f45c5df 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -11,7 +11,7 @@ LDFLAGS := -g CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \ generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat database \ - lngdump telechips gigabeats + lngdump telechips gigabeats mktccboot all: @echo "Run make in your build directory!" @@ -38,6 +38,9 @@ rdf2binary: rdf2binary.c mkboot: mkboot.c $(SILENT)$(CC) -g $+ -o $@ +mktccboot: mktccboot.c telechips.o + $(SILENT)$(CC) -g $+ -o $@ + lngdump: lngdump.c $(SILENT)$(CC) -g $+ -o $@ diff --git a/tools/configure b/tools/configure index 1cc7e62..3971bcb 100755 --- a/tools/configure +++ b/tools/configure @@ -212,6 +212,13 @@ arm9tdmicc () { endian="little" } +arm946cc () { + prefixtools arm-elf- + GCCOPTS="$CCOPTS -mcpu=arm9e -mlong-calls" + GCCOPTIMIZE="-fomit-frame-pointer" + endian="little" +} + whichadvanced () { ################################################################## # Prompt for specific developer options @@ -619,10 +626,10 @@ cat <<EOF ==iAudio== ==Toshiba== ==SanDisk== 30) X5/X5V/X5L 40) Gigabeat F 50) Sansa e200 31) M5/M5L 41) Gigabeat S 51) Sansa e200R - 52) Sansa c200 + 32) 7 52) Sansa c200 - ==Tatung== ==Olympus== - 60) Elio TPJ-1022 70) M:Robe 500 + ==Tatung== ==Olympus== ==Logik== + 60) Elio TPJ-1022 70) M:Robe 500 80) DAX 1GB MP3/DAB EOF buildfor=`input`; @@ -636,6 +643,7 @@ EOF iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb" ipodbitmaptools="$toolset scramble ipod_fw bmp2rb" gigabeatbitmaptools="$toolset scramble descramble bmp2rb" + tccbitmaptools="$toolset scramble mktccboot bmp2rb" # generic is used by IFP, H10, Sansa-e200 genericbitmaptools="$toolset bmp2rb" @@ -1310,6 +1318,32 @@ EOF t_model="mrobe-500" ;; + 80|logikdax) + target_id=31 + archos="logikdax" + target="-DLOGIK_DAX" + memory=2 # always + arm946cc + tool="$rootdir/tools/scramble -add=ldax" + boottool="$rootdir/tools/scramble -tcc=crc" + bootoutput="player.rom" + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" + bmp2rb_native="$rootdir/tools/bmp2rb -f 0" + output="rockbox.logik" + appextra="recorder:gui" + archosrom="" + flash="" + plugins="no" + swcodec="yes" + # toolset is the tools within the tools directory that we build for + # this particular target. + toolset=$tccbitmaptools + # architecture, manufacturer and model for the target-tree build + t_cpu="arm" + t_manufacturer="tcc77x" + t_model="logikdax" + ;; + 50|e200) target_id=23 archos="e200" @@ -1416,6 +1450,32 @@ EOF t_manufacturer="tatung" t_model="tpj1022" ;; + + 32|iaudio7) + target_id=32 + archos="iaudio7" + target="-DIAUDIO_7" + memory=16 # always + arm946cc + tool="$rootdir/tools/scramble -add i7" + boottool="$rootdir/tools/scramble -tcc=crc" + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" + bmp2rb_native="$rootdir/tools/bmp2rb -f 5" + output="rockbox.iaudio" + appextra="recorder:gui" + archosrom="" + flash="" + plugins="yes" + swcodec="yes" + bootoutput="I7_FW.BIN" + # toolset is the tools within the tools directory that we build for + # this particular target. + toolset="$tccbitmaptools" + # architecture, manufacturer and model for the target-tree build + t_cpu="arm" + t_manufacturer="tcc77x" + t_model="iaudio7" + ;; *) echo "Please select a supported target platform!" diff --git a/tools/mktccboot.c b/tools/mktccboot.c new file mode 100644 index 0000000..90b85e8 --- /dev/null +++ b/tools/mktccboot.c @@ -0,0 +1,184 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Dave Chapman + * + * Based on mkboot, Copyright (C) 2005 by Linus Nielsen Feltzing + * + * 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. + * + ****************************************************************************/ +#include <stdio.h> +#include <stdlib.h> +#include <string.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, fdboot,fdout; + int i,n; + int inlength,bootlength; + uint32_t ldr; + unsigned char* image; + int origoffset; + + 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); + } + + fdboot = open(bootfile, O_RDONLY|O_BINARY); + if (fdboot < 0) + { + perror(bootfile); + } + + inlength = filesize(fdin); + bootlength = filesize(fdboot); + + image = malloc(inlength + bootlength); + + if (image==NULL) + { + printf("[ERR] Could not allocate memory, aborting\n"); + return 1; + } + + n = read(fdin, image, inlength); + if (n != inlength) + { + printf("[ERR] Could not read from %s\n",infile); + return 2; + } + + n = read(fdboot, image + inlength, bootlength); + if (n != bootlength) + { + printf("[ERR] Could not read from %s\n",bootfile); + return 3; + } + + ldr = get_uint32le(image); + + /* TODO: Verify it's a LDR instruction */ + origoffset = (ldr&0xfff) + 8; + + printf("original firmware entry point: 0x%08x\n",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); + } + + n = write(fdout, image, inlength + bootlength); + if (n != inlength + bootlength) + { + printf("[ERR] Could not write output file %s\n",outfile); + return 3; + } + + close(fdin); + close(fdboot); + close(fdout); + + return 0; +} |