|
Last change
on this file since 2 was
2,
checked in by phkim, 11 years ago
|
|
1.phkim
- 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 | |
|---|
| 4 | eswap=../../tools/sswap32 |
|---|
| 5 | action="split" |
|---|
| 6 | |
|---|
| 7 | case $1 in |
|---|
| 8 | -s ) |
|---|
| 9 | action="split" ;; |
|---|
| 10 | -i ) |
|---|
| 11 | action="inject" ;; |
|---|
| 12 | * ) |
|---|
| 13 | echo "Invalid parameter" |
|---|
| 14 | exit 1 ;; |
|---|
| 15 | esac |
|---|
| 16 | |
|---|
| 17 | if [ ${action} == "split" ] ; then |
|---|
| 18 | |
|---|
| 19 | # separate stage 1 |
|---|
| 20 | dd if=bootloader12.bin bs=32K count=1 | ${eswap} > bootloader.s1.bin |
|---|
| 21 | # remove the hole. numbers are for rsa2048 keys. |
|---|
| 22 | dd if=bootloader.s1.bin of=bootloader.s11.bin bs=64 count=16 |
|---|
| 23 | dd if=bootloader.s1.bin of=bootloader.s12.bin bs=64 skip=33 |
|---|
| 24 | # combine both images to form stage 1 |
|---|
| 25 | cat bootloader.s11.bin bootloader.s12.bin > bootloader.s1.bin |
|---|
| 26 | rm -f bootloader.s11.bin bootloader.s12.bin |
|---|
| 27 | #extract stage 2 |
|---|
| 28 | stage2_address=`awk '/_stage2_start/ { print $1 ; }' bootloader12.map` |
|---|
| 29 | stage2_off=$((($stage2_address & 0xffff)/0x40)) |
|---|
| 30 | dd if=bootloader12.bin bs=64 skip=${stage2_off} | ${eswap} > bootloader.s2.bin |
|---|
| 31 | |
|---|
| 32 | else |
|---|
| 33 | |
|---|
| 34 | # reverse endianness |
|---|
| 35 | cat bootloader.s1.sig | ${eswap} > bootloader.s1s.sig |
|---|
| 36 | cat bootloader.s2.sig | ${eswap} > bootloader.s2s.sig |
|---|
| 37 | # inject signatures |
|---|
| 38 | dd if=bootloader.s1s.sig of=bootloader12.bin bs=64 seek=29 conv=notrunc |
|---|
| 39 | cat bootloader12.bin bootloader.s2s.sig > bootloader12.sbin |
|---|
| 40 | |
|---|
| 41 | fi |
|---|
Note: See
TracBrowser
for help on using the repository browser.