bios/flash: minor cleanup on serialboot flashing, add flash address support

This commit is contained in:
Florent Kermarrec 2019-11-09 00:00:55 +01:00
parent 2d6100bdbe
commit a17e307acf
2 changed files with 7 additions and 11 deletions

View File

@ -103,9 +103,9 @@ static int check_ack(void)
static uint32_t get_uint32(unsigned char* data) static uint32_t get_uint32(unsigned char* data)
{ {
return ((uint32_t) data[0] << 24) | return ((uint32_t) data[0] << 24) |
((uint32_t) data[1] << 16) | ((uint32_t) data[1] << 16) |
((uint32_t) data[2] << 8) | ((uint32_t) data[2] << 8) |
(uint32_t) data[3]; (uint32_t) data[3];
} }
#define MAX_FAILED 5 #define MAX_FAILED 5
@ -200,7 +200,7 @@ int serialboot(void)
failed = 0; failed = 0;
addr = get_uint32(&frame.payload[0]); addr = get_uint32(&frame.payload[0]);
for (i = 4; i < frame.length; i++) { for (i = 4; i < frame.length; i++) {
// erase page at sector boundaries before writing // erase page at sector boundaries before writing
if ((addr & (SPIFLASH_SECTOR_SIZE - 1)) == 0) { if ((addr & (SPIFLASH_SECTOR_SIZE - 1)) == 0) {

View File

@ -201,12 +201,9 @@ class LiteXTerm:
f.seek(0, 2) f.seek(0, 2)
length = f.tell() length = f.tell()
f.seek(0, 0) f.seek(0, 0)
if self.flash: print("[LXTERM] {} {} to 0x{:08x} ({} bytes)...".format(
print("[LXTERM] Flashing {} ({} bytes)...".format(filename, length)) "Flashing" if self.flash else "Uploading", filename, address, length))
current_address = 0 current_address = address
else:
print("[LXTERM] Uploading {} to 0x{:08x} ({} bytes)...".format(filename, address, length))
current_address = address
position = 0 position = 0
start = time.time() start = time.time()
remaining = length remaining = length
@ -368,7 +365,6 @@ def main():
term = LiteXTerm(args.serial_boot, args.kernel, args.kernel_adr, args.images, args.no_crc, args.flash) term = LiteXTerm(args.serial_boot, args.kernel, args.kernel_adr, args.images, args.no_crc, args.flash)
term.open(args.port, int(float(args.speed))) term.open(args.port, int(float(args.speed)))
term.console.configure() term.console.configure()
term.start() term.start()
term.join(True) term.join(True)