summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/FILES1
-rwxr-xr-xtools/configure5
-rwxr-xr-xtools/mkmi4.sh97
3 files changed, 100 insertions, 3 deletions
diff --git a/tools/FILES b/tools/FILES
index 25cfb0e713..57a931473f 100644
--- a/tools/FILES
+++ b/tools/FILES
@@ -20,3 +20,4 @@ ucl/src/Makefile
20ucl/include/ucl/*.h 20ucl/include/ucl/*.h
21profile_reader/*.pl 21profile_reader/*.pl
22rockboxdev.sh 22rockboxdev.sh
23mkmi4.sh
diff --git a/tools/configure b/tools/configure
index aa9c421194..8a97ad85c6 100755
--- a/tools/configure
+++ b/tools/configure
@@ -921,11 +921,10 @@ toolsdir='\$(ROOTDIR)/tools'
921 target="-DSANSA_E200" 921 target="-DSANSA_E200"
922 memory=32 # supposedly 922 memory=32 # supposedly
923 arm7tdmicc 923 arm7tdmicc
924 #tool="$rootdir/tools/ -add=iax5" 924 tool="$rootdir/tools/mkmi4.sh e200"
925 tool="$rootdir/tools/mi4code build"
926 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 925 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
927 bmp2rb_native="$rootdir/tools/bmp2rb -f 5" 926 bmp2rb_native="$rootdir/tools/bmp2rb -f 5"
928 output="rockbox.sansa" 927 output="PP5022.mi4"
929 appextra="recorder:gui" 928 appextra="recorder:gui"
930 archosrom="" 929 archosrom=""
931 flash="" 930 flash=""
diff --git a/tools/mkmi4.sh b/tools/mkmi4.sh
new file mode 100755
index 0000000000..8dc90d886f
--- /dev/null
+++ b/tools/mkmi4.sh
@@ -0,0 +1,97 @@
1#!/bin/sh
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10# Purpose of this script:
11#
12# Inputs: music player model name and a file name
13#
14# Action: Build a valid mi4 file (prepending and appending magic)
15# Encrypt the file with TEA encryption so that the model's own
16# bootloader accepts this file.
17# Sign the file with a DSA signature the bootloader accepts
18#
19# Output: A built, encrypted and signed mi4 file image.
20#
21# Requirement:
22#
23# This script assumes that you have the mi4code tool in your path, that
24# you have the environment variable MI4CODE pointing to the tool or that you
25# have it in the same dir that you invoke this script with.
26#
27# mi4 info and tool are here: http://daniel.haxx.se/sansa/mi4.html
28#
29
30mkmi4=$0
31target=$1
32input=$2
33output=$3
34
35# scan the $PATH for the given command
36findtool(){
37 file="$1"
38
39 IFS=":"
40 for path in $PATH
41 do
42 # echo "checks for $file in $path" >&2
43 if test -f "$path/$file"; then
44 echo "$path/$file"
45 return
46 fi
47 done
48}
49
50help () {
51 echo "Usage: mi4fix.sh <e200/h10> <input> <output>"
52 exit
53}
54
55if test -z "$output"; then
56 help
57fi
58
59case $target in
60 e200)
61 tea=sansa
62 ;;
63 h10)
64 tea=20gc_eng
65 ;;
66 *)
67 echo "unsupported target"
68 help
69 ;;
70esac
71
72if test -z "$MI4CODE"; then
73 tool=`findtool mi4code`
74 if test -z "$tool"; then
75 # not in path
76 tool=`dirname $mkmi4`/mi4code
77 if ! test -f $tool; then
78 echo "Couldn't find mi4code"
79 exit
80 fi
81 fi
82else
83 tool=$MI4CODE
84fi
85
86
87
88
89# build a 010301 version
90echo "$tool build $input $output.raw"
91$tool build $input $output.raw
92# encrypt
93echo "$tool encrypt $output.raw $output.encrypt $tea"
94$tool encrypt $output.raw $output.encrypt $tea
95# sign
96echo "$tool sign $output.encrypt $output"
97$tool sign $output.encrypt $output