pubrom
4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
MKCMD=$ROOT/usr/sbin/mkCmd
GENDESC=$ROOT/usr/sbin/gen_desc.pl
HOST_DATA_DIR=$ROOT/usr/host_data
DEFAULT_THUMB=$HOST_DATA_DIR/rom_thumb.rgba
DEFAULT_TITLE_IMG=$HOST_DATA_DIR/rom_title.inta
DEFAULT_TITLE=$HOST_DATA_DIR/rom_title.txt
DEFAULT_ISBN=$HOST_DATA_DIR/isbn.txt
DEFAULT_CRID=$HOST_DATA_DIR/crid.txt
DEFAULT_OADID=$HOST_DATA_DIR/oadid.txt
AES_KEY="a81902767e25db170f3449c5d94b162f"
AES_IV="a438b3410298747b0c089d8f6d2991a8"
desc=/tmp/desc$$
tmp_title=/tmp/title$$
CID_LIST="sm 0x00000001 eeprom=4\n
sm_e 0x00001001 eeprom=4\n
wr 0x00000002 eeprom=4,cpak=1\n
wr_j 0x00001002 eeprom=4,cpak=1\n
mk 0x00000003 eeprom=4,cpak=2\n
mk_e 0x00001003 eeprom=4,cpak=2\n
sf 0x00000004 eeprom=4\n
sf_e 0x00001004 eeprom=4\n
f0x 0x00000005 sram=256\n
f0x_e 0x00001005 sram=256\n
zelda 0x00000006 sram=256\n
zelda_e 0x00001006 sram=256\n
dm 0x00000007 eeprom=4\n
dm_e 0x00001007 eeprom=4\n
usbmon 0x00000008 ''\n
batman 0x00000009 ''\n
hydro 0x0000000a cpak=4,errataSize=16384,errataAddress=0x807bc000\n
quake2 0x0000000b cpak=4\n
sfrush 0x0000000c cpak=4,errataSize=16384,errataAddress=0x807bc000\n
rogue 0x0000000d eeprom=4,errataSize=16384,errataAddress=0x807bc000\n
naboo 0x0000000e eeprom=4,errataSize=16384,errataAddress=0x807bc000\n
golden 0x0000000f eeprom=4,errataSize=16384,errataAddress=0x807bc000\n
iqueclub 0x0000ffff ''\n
end xxxxxxxx ''\n"
function find_cid {
echo -e $CID_LIST | while read name value meta; do
if [ $1 == $name ]; then
echo $value
return 1;
elif [ $name == end ]; then
echo $1;
return 1;
fi
done
}
function find_meta {
echo -e $CID_LIST | while read name value meta; do
if [ $1 == $name ]; then
echo $meta
return 1;
elif [ $name == end ]; then
echo "";
return 1;
fi
done
}
function usage {
echo "Usage: pubrom [-e] [-i image_file] [-T title_img_file] [-n title_file | -t title_string] [-s isbn_file] [-c crid_file] [-o oadid_file] [-r hw_rights] [-R sk_rights][-L caCrlVersion] [-l cpCrlVersion] [-m metadata] [-p prop_file_out] rom cid"
exit 1
}
recrypt="-e"
thumb_file= title_file= title_string= isbn_file= crid_file= oadid_file= signer_key= pub_prop_file=
keep_desc="n"
while getopts "i:T:n:eEt:s:c:o:r:R:m:S:dp:L:l:" a
do
case $a in
e) recrypt="-e";;
E) recrypt="";;
i) thumb_file=$OPTARG;;
T) title_img=$OPTARG;;
n) title_file=$OPTARG;;
t) title_string=$OPTARG;;
s) isbn_file=$OPTARG;;
c) crid_file=$OPTARG;;
o) oadid_file=$OPTARG;;
r) rights="-r $OPTARG";;
R) Rights="-R $OPTARG";;
L) caCrlVersion="-L $OPTARG";;
l) cpCrlVersion="-l $OPTARG";;
m) metadata="$OPTARG";;
S) signer_key="-S $OPTARG";;
d) keep_desc="y";;
p) pub_prop_file="-p $OPTARG";;
*) usage; exit;;
esac
done
shift `expr $OPTIND - 1`
[ $# != 2 ] && usage
cid=`find_cid $2`
[ "$metadata" != "" ] || metadata=`find_meta $2`
name=`perl -e 'printf "%08x\n", '$cid;`
rom=$1
# default usbmon to all rights and no re-encryption
if [ $name == 00000008 ]; then
rights="-r 0xffffffff"
recrypt=
fi
# default iqueclub to no re-encryption, with fs & sk rights
if [ $name == 0000ffff ]; then
rights="-r 0x00000013 -R 0x00006001"
recrypt=
fi
[ "$thumb_file" != "" ] || thumb_file=$DEFAULT_THUMB
[ "$title_img" != "" ] || title_img=$DEFAULT_TITLE_IMG
[ "$title_file" != "" ] || title_file=$DEFAULT_TITLE
[ "$isbn_file" != "" ] || isbn_file=$DEFAULT_ISBN
[ "$crid_file" != "" ] || crid_file=$DEFAULT_CRID
[ "$oadid_file" != "" ] || oadid_file=$DEFAULT_OADID
if [ -n "$title_string" ]; then
echo -n $title_string > $tmp_title
title_file=$tmp_title
fi
# force iqueclub title to be "iQue Club"
if [ $name == 0000ffff ]; then
echo -n "iQue Club" > $tmp_title
title_file=$tmp_title
fi
$GENDESC $thumb_file $title_img $title_file "$metadata" $isbn_file $crid_file $oadid_file $desc
$MKCMD $pub_prop_file $rights $Rights $cpCrlVersion $caCrlVersion $recrypt $signer_key -d $desc -c $cid $rom $AES_KEY $AES_IV $name.app $name.cmd
if [ "$keep_desc" == "y" ]; then
cp $desc $name.desc
rm -f $tmp_title
else
rm -f $desc $tmp_title
fi