Skip to content

Commit

Permalink
add support for small-sized PDDB images plus some debugging info
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnie committed Nov 3, 2022
1 parent 5c624e7 commit 6c2e86d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
31 changes: 31 additions & 0 deletions tools/cycle.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
target\debug\create-image.exe `
target\riscv32imac-unknown-xous-elf\release\xous_presign.img `
--kernel target/riscv32imac-unknown-xous-elf/release/xous-kernel `
--init target/riscv32imac-unknown-xous-elf/release/xous-ticktimer `
--init target/riscv32imac-unknown-xous-elf/release/xous-log `
--init fake-root-keys\target\riscv32imac-unknown-xous-elf\debug\fake-root-keys `
--init pddb-raw\target\riscv32imac-unknown-xous-elf\debug\pddb-raw `
--init target/riscv32imac-unknown-xous-elf/release/xous-names `
--init target/riscv32imac-unknown-xous-elf/release/xous-susres `
--init target\riscv32imac-unknown-xous-elf\release\pddb `
--init target\riscv32imac-unknown-xous-elf\release\trng `
--init target\riscv32imac-unknown-xous-elf\release\llio `
--init target\riscv32imac-unknown-xous-elf\release\spinor `
--svd utralib/renode/renode.svd

target\debug\copy-object.exe `
target/riscv32imac-unknown-xous-elf/release/loader `
target/riscv32imac-unknown-xous-elf/release\loader_presign.bin

target\debug\sign-image.exe `
--loader-image target/riscv32imac-unknown-xous-elf/release\loader_presign.bin `
--loader-key devkey/dev.key `
--loader-output target/riscv32imac-unknown-xous-elf/release\loader.bin `
--min-xous-ver v0.9.8-791

target\debug\sign-image.exe `
--kernel-image target/riscv32imac-unknown-xous-elf/release\xous_presign.img `
--kernel-key devkey/dev.key `
--kernel-output target/riscv32imac-unknown-xous-elf/release\xous.img `
--min-xous-ver v0.9.8-791

4 changes: 2 additions & 2 deletions tools/pddbcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ def __init__(self, index, v2p, disk, key, name, dna=DNA):
except ValueError:
logging.error("\n") # make some whitespace so this stands out in the logs
logging.error("**** basisdicts: encountered an invalid dict root record. Data loss may have occurred!")
logging.error("**** couldn't decrypt vpage @ {:x} ppage @ {:x} in basis {}, dna {}".format(dict_header_vaddr, v2p[dict_header_vaddr], name, dna))
logging.error("****** partial dump: {}\n".format(disk[pp:pp + 64].hex()))
logging.error("**** couldn't decrypt vpage @ {:x} ppage @ {:x} in basis {}, aad {}".format(dict_header_vaddr, v2p[dict_header_vaddr], name, basis_aad(name, dna=dna).hex()))
logging.error("****** partial dump: {}...{} len {}\n".format(disk[pp:pp + 48].hex(), disk[pp + 4048:pp + 4096].hex(), len(disk[pp:pp + 4096])))
self.valid = False

if self.num_keys > 0:
Expand Down
13 changes: 11 additions & 2 deletions tools/pddbdbg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def main():
parser.add_argument(
"--renode", required=False, help="Override flex-size settings and read a Renode bin file", action="store_true"
)
parser.add_argument(
"--smalldb", required=False, help="Override default size of PDDB and set it to 4MiB (for images built to that size only)", action="store_true"
)
parser.add_argument(
"--basis", type=str, help="Extra Bases to unlock, as `name:pass`. Each additional basis requires another --basis separator. Note that : is not legal to use in a Basis name.", action="append", nargs="+"
)
Expand Down Expand Up @@ -57,7 +60,10 @@ def main():
keyrom = key_f.read()
with open(imagefile, 'rb') as img_f:
raw_img = img_f.read()
raw_img = raw_img[0x01D80000:0x07F80000]
if args.smalldb:
raw_img = raw_img[0x01D80000:0x1D8_0000 + 1024 * 1024 * 4]
else:
raw_img = raw_img[0x01D80000:0x07F80000]
keys = extract_keys(keyrom, raw_img, args.pin, basis_credentials)
else:
if args.name == None:
Expand Down Expand Up @@ -102,7 +108,10 @@ def main():
with open(imagefile, 'rb') as img_f:
raw_img = img_f.read()
if args.renode:
raw_img = raw_img[0x01D80000:0x07F80000]
if args.smalldb:
raw_img = raw_img[0x01D80000:0x1D8_0000 + 1024 * 1024 * 4]
else:
raw_img = raw_img[0x01D80000:0x07F80000]
pddb_len = len(raw_img)
pddb_size_pages = pddb_len // PAGE_SIZE
logging.info("Disk size: 0x{:x}".format(pddb_len))
Expand Down

0 comments on commit 6c2e86d

Please sign in to comment.