-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from PW-Sat2/safe-mode-crc
Safe mode & bootloader padding
- Loading branch information
Showing
7 changed files
with
72 additions
and
15 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
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
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
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,33 @@ | ||
import argparse | ||
|
||
import sys | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
|
||
def int_dec_or_hex(v): | ||
if v[0:2] == '0x': | ||
return int(v, 16) | ||
|
||
return int(v) | ||
|
||
|
||
parser.add_argument("file", help="File that will be padded") | ||
parser.add_argument("size", help="Size of the file with padding", type=int_dec_or_hex) | ||
parser.add_argument("pad", help="Byte used as padding", type=int_dec_or_hex, default=0) | ||
|
||
args = parser.parse_args() | ||
|
||
with file(args.file, 'r+b') as f: | ||
f.seek(0, 2) | ||
|
||
pos = f.tell() | ||
|
||
if pos > args.size: | ||
sys.stderr.write("Unable to pad to size {} bytes as file is already bigger ({} bytes)".format(pos, args.size)) | ||
exit(-1) | ||
|
||
padding_size = args.size - pos | ||
padding = chr(args.pad) * padding_size | ||
|
||
f.write(padding) |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ si 1 | |
speed auto | ||
r | ||
halt | ||
loadbin "${HEX_FILE}", ${BASE_ADDRESS} | ||
loadbin "${FLASH_FILE}", ${BASE_ADDRESS} | ||
r | ||
g | ||
exit |
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
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