-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
481e179
commit 340bddb
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
all: flash-mon.bin flash-ecos-mon.bin flash-ecos-mon-double.bin | ||
|
||
../monitor/monitor.bin: | ||
+$(MAKE) -C ../monitor | ||
|
||
monitor.bin: ../monitor/monitor.bin | ||
cp ../monitor/monitor.bin . | ||
|
||
boot2-ecos.bin: flash-dump.bin | ||
../tools/extract-boot2.py $< $@ | ||
|
||
boot2-ecos-mon.bin: boot2-ecos.bin monitor.bin | ||
cp $< $@ | ||
../tools/patch-ecos.py $@ monitor.bin | ||
|
||
flash-mon.bin: flash-dump.bin monitor.bin | ||
cp $< $@ | ||
@chmod +w $@ | ||
../tools/inject-boot2.py $@ monitor.bin | ||
|
||
flash-ecos-mon.bin: flash-dump.bin boot2-ecos-mon.bin | ||
cp $< $@ | ||
@chmod +w $@ | ||
../tools/inject-boot2.py $@ boot2-ecos-mon.bin | ||
|
||
flash-ecos-mon-double.bin: flash-dump.bin boot2-ecos-mon.bin | ||
cp $< $@ | ||
@chmod +w $@ | ||
../tools/inject-boot2.py $@ boot2-ecos-mon.bin boot2-ecos-mon.bin | ||
|
||
clean: | ||
rm -f monitor.bin boot2-ecos.bin boot2-ecos-mon.bin flash-mon.bin flash-ecos-mon.bin | ||
|
||
.PHONY: clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Flash modification recipes | ||
|
||
Place your flash dump at `flash-dump.bin` and then just type `make` :-) | ||
|
||
``` | ||
flash-dump.bin original flash dump | ||
| | ../monitor/monitor.bin monitor program | ||
| | v | | ||
| `---> flash-mon.bin | flash image with monitor as boot2 | ||
| | | ||
|----> boot2-ecos.bin v original eCos-based boot2 | ||
| `----> boot2-ecos-mon.bin eCos patched to jump into monitor instead of app | ||
v | | ||
flash-ecos-mon.bin <-' flash image with patched eCos | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: MIT | ||
import argparse, lzma | ||
|
||
def extract(args): | ||
with open(args.image, 'rb') as f: | ||
data = f.read() | ||
a = lzma.decompress(data[0x20100:]) | ||
b = lzma.decompress(data[0x720100:]) | ||
|
||
if not args.recovery and a != b: | ||
print('Warning: main and recovery copies of boot2 are different! Extracting main only.') | ||
|
||
with open(args.main, 'wb') as f: | ||
f.write(a) | ||
f.close() | ||
|
||
if args.recovery: | ||
with open(args.recovery, 'wb') as f: | ||
f.write(b) | ||
f.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Extract boot2') | ||
parser.add_argument('image', help='flash image') | ||
parser.add_argument('main', help='filename of resulting program (main @ 0x20100)') | ||
parser.add_argument('recovery', help='filename of resulting program (recovery @ 0x720100)', nargs='?') | ||
args = parser.parse_args() | ||
extract(args) |