From bd8d1da000db1c705581670c5307219e46f3f3fc Mon Sep 17 00:00:00 2001 From: Romain Dolbeau Date: Sat, 14 Oct 2023 10:35:49 +0200 Subject: [PATCH] minor fixes to flashsend, resetFpga seems needed between plugin the board & using the flash --- flashsend/FlashSend.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flashsend/FlashSend.java b/flashsend/FlashSend.java index c7c5999..e76c01d 100644 --- a/flashsend/FlashSend.java +++ b/flashsend/FlashSend.java @@ -224,6 +224,7 @@ class FlashSend extends Ztex1v1 { System.out.println("Primary Flash enabled: " + ztex.flashEnabled()); System.out.println("Primary Flash sector size: " + ztex.toHumanStr(ztex.flashSectorSize())+" Bytes"); System.out.println("Primary Flash size: " + ztex.toHumanStr(ztex.flashSize())+" Bytes"); + System.out.println("Primary Flash first free sector: " + ztex.flashFirstFreeSector()); } else { throw new ParameterException("Currently write only to Primary Flash, which is not available."); } @@ -237,11 +238,16 @@ class FlashSend extends Ztex1v1 { if (sector < 0) { throw new ParameterException("Sector to start must be specified as a positive integer, it is recommened to be higher than the reserved area."); } + if (doWrite & (sector < ztex.flashFirstFreeSector())) { + throw new ParameterException("Sector to start writing at should be higher than the reserved area, probably (" + ztex.flashFirstFreeSector() + ")"); + } if (filename == null) { throw new ParameterException("Non-existent filename: " + (filename == null ? "(null)": "filename" )); } + ztex.resetFpga(); + if (doWrite) { File f = new File(filename); if (!f.exists() || !f.isFile() || !f.canRead() || f.length() == 0) {