Flash file system for BASIC, with bitstream write protection
BASIC gets SAVE, LOAD, RUN "NAME", DIR and DEL, storing program listings in the configuration flash from 240000h (448 x 4 KB blocks, 64 files, 32 KB each). The directory is kept in two alternating blocks with a sequence number and checksum, new data is written before the directory switches to it, and every page is verified after programming. rtl/flash_spi.v drives the flash through STARTUPE2 on ports 40h/41h. It only passes read, status, WREN/WRDI, RDID, page program and 4 KB erase, and abandons any program or erase below 240000h before the address reaches the chip. Tested on the board: an erase at 0 and a write at 200000h were refused and left the flash unchanged. With SW14 up, the Z-80's output is also copied to the PC's serial port, and tools/get-bas.py uses that to LIST a program into a file or run commands and print the replies. Also fixes port 10h returning the previous millisecond latch (the first read after reset was undefined). Simulation adds a model flash and a save/load/run/protection test. Manual and README updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dc7c7c22c5
commit
29a15bf7c7
15 files changed
+6907
-6056
No files matched your search
+24
-1
@@ -14,13 +14,18 @@ module tb_terminal;
|
||||
wire rstx, hs, vs;
|
||||
wire [3:0] r, g, b;
|
||||
wire [15:0] led;
|
||||
wire qcs;
|
||||
wire [3:0] qdb;
|
||||
|
||||
basys3_terminal #(.FONT_FILE(`FONT_FILE), .MEM_FILE(`MEM_FILE)) dut (
|
||||
.clk(clk), .btnC(btnC), .btnU(btnU), .btnD(btnD), .sw(sw), .led(led), .seg(), .dp(), .an(),
|
||||
.vgaRed(r), .vgaGreen(g), .vgaBlue(b), .Hsync(hs), .Vsync(vs),
|
||||
.RsRx(rsrx), .RsTx(rstx), .PS2Clk(ps2c), .PS2Data(ps2d)
|
||||
.RsRx(rsrx), .RsTx(rstx), .PS2Clk(ps2c), .PS2Data(ps2d),
|
||||
.QspiCSn(qcs), .QspiDB(qdb)
|
||||
);
|
||||
|
||||
spiflash_model flash (.cs_n(qcs), .sck(dut.fl_sck), .mosi(qdb[0]), .miso(qdb[1]));
|
||||
|
||||
localparam BIT_NS = 1_000_000_000 / 115200;
|
||||
integer errors = 0;
|
||||
|
||||
@@ -280,6 +285,24 @@ module tb_terminal;
|
||||
end
|
||||
capture_frame("frame_3.ppm");
|
||||
|
||||
// ---- files in the flash, and the bitstream protection
|
||||
uart_str({"CLS:NEW\01510 PRINT \"SAVED\";6*7\015SAVE \"TEST1\"\015NEW\015",
|
||||
"LOAD \"TEST1\"\015RUN\015DIR\015"});
|
||||
#20_000_000;
|
||||
expect_row(13, "SAVED 42");
|
||||
expect_row(17, "TEST1 21");
|
||||
expect_row(18, "1 FILE, 1780K FREE");
|
||||
uart_str("OUT 64,1:OUT 65,6:OUT 64,0:OUT 64,1:OUT 65,32:OUT 65,0:OUT 65,0:OUT 65,0:OUT 64,0\015");
|
||||
#3_000_000;
|
||||
if (flash.programs > 0 && flash.erases > 0 && flash.violations == 0)
|
||||
$display("PASS flash: %0d programs, %0d erases, bitstream untouched",
|
||||
flash.programs, flash.erases);
|
||||
else begin
|
||||
$display("FAIL flash: %0d programs, %0d erases, %0d violations",
|
||||
flash.programs, flash.erases, flash.violations);
|
||||
errors = errors + 1;
|
||||
end
|
||||
|
||||
dump_screen;
|
||||
if (errors == 0) $display("ALL TESTS PASSED");
|
||||
else $display("%0d TESTS FAILED", errors);
|
||||
|
||||
Reference in new issue
Block a user