source: svn/trunk/newcon3bcm2_21bu/dta/src/bootloader/sign.sh @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#! /bin/bash
2# all offsets and numbers are for rsa2048
3
4eswap=../../tools/sswap32
5action="split"
6
7case $1 in
8    -s )
9        action="split" ;;
10    -i )
11        action="inject" ;;
12    * )
13        echo "Invalid parameter"
14        exit 1 ;;
15esac
16
17if [ ${action} == "split" ] ; then
18
19# separate stage 1
20dd if=bootloader12.bin bs=32K count=1 | ${eswap} > bootloader.s1.bin
21# remove the hole. numbers are for rsa2048 keys.
22dd if=bootloader.s1.bin of=bootloader.s11.bin bs=64 count=16
23dd if=bootloader.s1.bin of=bootloader.s12.bin bs=64 skip=33
24# combine both images to form stage 1
25cat bootloader.s11.bin bootloader.s12.bin > bootloader.s1.bin
26rm -f bootloader.s11.bin bootloader.s12.bin
27#extract stage 2
28stage2_address=`awk '/_stage2_start/ { print $1 ; }' bootloader12.map`
29stage2_off=$((($stage2_address & 0xffff)/0x40))
30dd if=bootloader12.bin bs=64 skip=${stage2_off} | ${eswap} > bootloader.s2.bin
31
32else
33
34# reverse endianness
35cat bootloader.s1.sig | ${eswap} > bootloader.s1s.sig
36cat bootloader.s2.sig | ${eswap} > bootloader.s2s.sig
37# inject signatures
38dd if=bootloader.s1s.sig of=bootloader12.bin bs=64 seek=29 conv=notrunc
39cat bootloader12.bin bootloader.s2s.sig > bootloader12.sbin
40
41fi
Note: See TracBrowser for help on using the repository browser.