From 41964f945cee71337e8e0998d597086b2ef94f77 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 Jan 2021 16:47:47 +0100 Subject: [PATCH] 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). --- litex/soc/software/bios/boot.c | 26 -------------------------- litex/soc/software/bios/sfl.h | 2 -- litex/tools/litex_term.py | 32 +++++++------------------------- 3 files changed, 7 insertions(+), 53 deletions(-) diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index ed2174f44..7516c0dd6 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -26,7 +26,6 @@ #include "jsmn.h" #include -#include #include #include @@ -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) { diff --git a/litex/soc/software/bios/sfl.h b/litex/soc/software/bios/sfl.h index 6079b07a8..cd2cae1f5 100644 --- a/litex/soc/software/bios/sfl.h +++ b/litex/soc/software/bios/sfl.h @@ -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' diff --git a/litex/tools/litex_term.py b/litex/tools/litex_term.py index a526ca3d2..923d4c2a2 100755 --- a/litex/tools/litex_term.py +++ b/litex/tools/litex_term.py @@ -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 @@ -358,12 +354,9 @@ class LiteXTerm: # Send frame if max outstanding not reached. if outstanding <= sfl_outstanding: # Prepare frame. - frame = SFLFrame() + frame = SFLFrame() + frame.cmd = sfl_cmd_load 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.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,11 +419,7 @@ 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() + self.boot() print("[LXTERM] Done."); def reader(self): @@ -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"]: