litex_term/SFL: remove flashing capability.

It's probably better not mixing uploading/flashing utilities. Flashing should be
done with the proper bootloader (as we are doing on Fomu/OrangeCrab for example).
This commit is contained in:
Florent Kermarrec 2021-01-18 16:47:47 +01:00
parent a0bcbeb68b
commit 41964f945c
3 changed files with 7 additions and 53 deletions

View file

@ -26,7 +26,6 @@
#include "jsmn.h"
#include <progress.h>
#include <spiflash.h>
#include <libliteeth/udp.h>
#include <libliteeth/tftp.h>
@ -229,31 +228,6 @@ int serialboot(void)
boot(0, 0, 0, addr);
break;
}
case SFL_CMD_FLASH: {
#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE)
uint32_t addr;
failed = 0;
addr = get_uint32(&frame.payload[0]);
for (i = 4; i < frame.payload_length; i++) {
/* Erase page at sector boundaries before writing */
if ((addr & (SPIFLASH_SECTOR_SIZE - 1)) == 0) {
erase_flash_sector(addr);
}
write_to_flash(addr, &frame.payload[i], 1);
addr++;
}
uart_write(SFL_ACK_SUCCESS);
#endif
break;
}
case SFL_CMD_REBOOT:
#ifdef CSR_CTRL_RESET_ADDR
uart_write(SFL_ACK_SUCCESS);
ctrl_reset_write(1);
#endif
break;
default:
failed++;
if(failed == MAX_FAILED) {

View file

@ -19,8 +19,6 @@ struct sfl_frame {
#define SFL_CMD_ABORT 0x00
#define SFL_CMD_LOAD 0x01
#define SFL_CMD_JUMP 0x02
#define SFL_CMD_FLASH 0x04
#define SFL_CMD_REBOOT 0x05
/* Replies */
#define SFL_ACK_SUCCESS 'K'

View file

@ -178,8 +178,6 @@ sfl_outstanding = 128
sfl_cmd_abort = b"\x00"
sfl_cmd_load = b"\x01"
sfl_cmd_jump = b"\x02"
sfl_cmd_flash = b"\x04"
sfl_cmd_reboot = b"\x05"
# Replies
sfl_ack_success = b"K"
@ -250,7 +248,7 @@ def crc16(l):
# LiteXTerm ----------------------------------------------------------------------------------------
class LiteXTerm:
def __init__(self, serial_boot, kernel_image, kernel_address, json_images, flash):
def __init__(self, serial_boot, kernel_image, kernel_address, json_images):
self.serial_boot = serial_boot
assert not (kernel_image is not None and json_images is not None)
self.mem_regions = {}
@ -264,7 +262,6 @@ class LiteXTerm:
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
self.reader_alive = False
self.writer_alive = False
@ -338,8 +335,7 @@ class LiteXTerm:
length = f.tell()
f.seek(0, 0)
action = "Flashing" if self.flash else "Uploading"
print(f"[LXTERM] {action} {filename} to 0x{address:08x} ({length} bytes)...")
print(f"[LXTERM] Uploading {filename} to 0x{address:08x} ({length} bytes)...")
# Prepare parameters
current_address = address
@ -359,11 +355,8 @@ class LiteXTerm:
if outstanding <= sfl_outstanding:
# Prepare frame.
frame = SFLFrame()
frame_data = f.read(min(remaining, self.payload_length-4))
if self.flash:
frame.cmd = sfl_cmd_flash
else:
frame.cmd = sfl_cmd_load
frame_data = f.read(min(remaining, self.payload_length-4))
frame.payload = current_address.to_bytes(4, "big")
frame.payload += frame_data
@ -402,12 +395,6 @@ class LiteXTerm:
frame.payload = int(self.boot_address, 16).to_bytes(4, "big")
self.send_frame(frame)
def reboot(self):
print("[LXTERM] Rebooting the device.")
frame = SFLFrame()
frame.cmd = sfl_cmd_reboot
self.send_frame(frame)
def detect_prompt(self, data):
if len(data):
self.prompt_detect_buffer = self.prompt_detect_buffer[1:] + data
@ -432,10 +419,6 @@ class LiteXTerm:
self.port.write(sfl_magic_ack)
for filename, base in self.mem_regions.items():
self.upload(filename, int(base, 16))
if self.flash:
# clear mem_regions to avoid re-flashing on next reboot(s)
self.mem_regions = {}
else:
self.boot()
print("[LXTERM] Done.");
@ -516,14 +499,13 @@ def _get_args():
parser.add_argument("--speed", default=115200, help="Serial baudrate")
parser.add_argument("--serial-boot", default=False, action='store_true', help="Automatically initiate serial boot")
parser.add_argument("--kernel", default=None, help="Kernel image")
parser.add_argument("--kernel-adr", default="0x40000000", help="Kernel address (or flash offset with --flash)")
parser.add_argument("--kernel-adr", default="0x40000000", help="Kernel address")
parser.add_argument("--images", default=None, help="JSON description of the images to load to memory")
parser.add_argument("--flash", default=False, action='store_true', help="Flash data with serialboot command")
return parser.parse_args()
def main():
args = _get_args()
term = LiteXTerm(args.serial_boot, args.kernel, args.kernel_adr, args.images, args.flash)
term = LiteXTerm(args.serial_boot, args.kernel, args.kernel_adr, args.images)
if sys.platform == "win32":
if args.port in ["crossover", "jtag_uart"]: