tools/lxterm/json: json file provide relative path, add json file directory to image names.

Allow sharing same json file between serial boot and Ethernet/SDCard/SATAboot:

boot.json:
{
	"Image":        "0x40000000",
	"rv32.dtb":     "0x40ef0000",
	"rootfs.cpio":  "0x41000000",
	"opensbi.bin":  "0x40f00000"
}

If boot.json and images are located in images directory, using lxterm --images=images/boot.json
will now work.
This commit is contained in:
Florent Kermarrec 2020-12-17 16:06:26 +01:00
parent f777cddefe
commit 4092180662
1 changed files with 3 additions and 1 deletions

View File

@ -229,7 +229,9 @@ class LiteXTerm:
self.boot_address = kernel_address
if json_images is not None:
f = open(json_images, "r")
self.mem_regions.update(json.load(f))
json_dir = os.path.dirname(json_images)
for k, v in json.load(f).items():
self.mem_regions[os.path.join(json_dir, k)] = v
self.boot_address = self.mem_regions[list(self.mem_regions.keys())[-1]]
f.close()
self.flash = flash