summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-06-05 01:07:04 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2011-06-05 01:07:04 (GMT)
commit7978de7d92dc79887bda80c2aa9c1b12dbdf524d (patch)
treedf0501ec0a0d9a20172f2622867a7e44d8dedc88
parent27502ceb0e048b67f1b6f4b700fcfeb823672620 (diff)
downloadde1flash-7978de7d92dc79887bda80c2aa9c1b12dbdf524d.zip
de1flash-7978de7d92dc79887bda80c2aa9c1b12dbdf524d.tar.gz
de1flash-7978de7d92dc79887bda80c2aa9c1b12dbdf524d.tar.bz2
de1flash-7978de7d92dc79887bda80c2aa9c1b12dbdf524d.tar.xz
Fix data items lost during readback operations
Fix data items lost during readback operations. In order to make this easier to debug, add a 3-bit counter to the value returned, so that it is trivial to see if one has been lost or not.
-rw-r--r--de1flash.tcl22
-rw-r--r--de1flash.v26
-rw-r--r--protocol.txt3
3 files changed, 35 insertions, 16 deletions
diff --git a/de1flash.tcl b/de1flash.tcl
index 0480e82..1d8f4f3 100644
--- a/de1flash.tcl
+++ b/de1flash.tcl
@@ -145,9 +145,11 @@ proc fl_erase addr {
# Blank check the sector before erasing
fl_send [format "50%08X%08X" $secaddr $secsize]
set zc [fl_recv]
- set ze [format "85%08XFFFFFFFF" [expr $secaddr + $secsize]]
+ set ze [format "\[89ABCDEF\]5%08XFFFFFFFF" [expr $secaddr + $secsize]]
+
+ if { ![string match $ze $zc] } {
+ puts "\nNot blank, expected $ze got $zc"
- if { [string compare $zc $ze] } {
fl_send 81AAAAAAAAAAAAAAAA
fl_send 815555555555555555
fl_send 81AAAAAAAA80808080
@@ -160,7 +162,7 @@ proc fl_erase addr {
set ndone 1
while { $ndone } {
fl_send $read_cmd
- set ndone [string compare [fl_recv] 8DFFFFFFFFFFFFFFFF]
+ set ndone [string match [fl_recv] "\[89ABCDEF\]DFFFFFFFFFFFFFFFF"]
}
puts "done."
} else {
@@ -225,7 +227,7 @@ proc fl_write_file { file size } {
# Then, program
set left $size
- fl_send [format "D0%08X%08X" $size 0]
+ fl_send [format "C0%08X%08X" $addr 0]
while { $left > 0 } {
set blk [expr ($left < 8) ? $left : 8]
set d [read $f $blk]
@@ -236,8 +238,14 @@ proc fl_write_file { file size } {
}
# Synchronize
+ puts -nonewline "Sending sync... "
fl_send 6000000000AEAEAEAE
- fl_recv
+ set v [fl_recv]
+ if { [string match $v [format "\[89ABCDEF\]6%08XAEAEAEAE" [expr $addr + $size]]] } {
+ puts "error!"
+ } else {
+ puts "done."
+ }
close $f
}
@@ -263,7 +271,7 @@ foreach hardware_name [get_hardware_names] {
set usbblaster_name $hardware_name
}
}
-puts "\nUsing programming cable \"$usbblaster_name\".\n";
+puts "\nUsing programming cable \{$usbblaster_name\}.\n";
# List all devices on the chain, and select the first device on the
# chain.
@@ -274,7 +282,7 @@ foreach device_name [get_device_names -hardware_name $usbblaster_name] {
set test_device $device_name
}
}
-puts "\nSelecting device: $test_device.\n";
+puts "\nSelecting device: \{$test_device\}.\n";
# Open device
open_device -hardware_name $usbblaster_name -device_name $test_device
diff --git a/de1flash.v b/de1flash.v
index 082f96f..a1de450 100644
--- a/de1flash.v
+++ b/de1flash.v
@@ -168,9 +168,9 @@ module de1flash (
case (ir_in)
cmd_read_fifo:
begin
- if ( jtag_data_ctr == 7'd1 )
+ if ( jtag_data_ctr == 7'd2 )
begin
- jtag_rd_rrq <= jtag_rd_valid;
+ jtag_rd_rrq <= jtag_rd_valid;
jtag_rd_valid <= 1'b0;
end
@@ -402,6 +402,8 @@ module de1flash (
hexled hexled2 ( .value (fl_addr[19:16]), .s7 (s7_2_w) );
hexled hexled3 ( .value (fl_addr[23:20]), .s7 (s7_3_w) );
+ reg [2:0] rd_cnt;
+
always @(posedge fl_clk or negedge fl_reset_n)
if (~fl_reset_n)
begin
@@ -420,7 +422,13 @@ module de1flash (
assign prog_wr_rrq = ~prog_wr_empty & (prog_state == pst_idle);
assign prog_rd_wrq = rd_ack;
- assign prog_rd_data = { 4'b0, fl_rbcmd, fl_data };
+ assign prog_rd_data = { 1'b1, rd_cnt, fl_rbcmd, fl_data };
+
+ always @(negedge fl_reset_n or posedge fl_clk)
+ if (~fl_reset_n)
+ rd_cnt <= 3'b000;
+ else
+ rd_cnt <= rd_cnt + rd_ack;
wire bump_addr =
(prog_state == pst_read2) |
@@ -562,6 +570,7 @@ module de1flash (
pst_read2:
begin
+ fl_ce_q <= 1'b1;
fl_data <= { fl_dq, fl_data[63:8] };
rd_ack <= &fl_rbctr;
fl_bytectr <= fl_bytectr - 1'b1;
@@ -580,7 +589,7 @@ module de1flash (
pst_zchk0: // Zero check
begin
fl_a_q <= fl_addr;
- if ( &tst_data & |fl_bytectr )
+ if ( (&tst_data) & (|fl_bytectr) )
begin
fl_ce_q <= 1'b1;
fl_oe_q <= 1'b1;
@@ -605,6 +614,7 @@ module de1flash (
pst_zchk2:
begin
+ fl_ce_q <= 1'b1;
tst_data <= fl_dq;
fl_bytectr <= fl_bytectr - 1'b1;
prog_state <= pst_zchk0;
@@ -654,16 +664,16 @@ module de1flash (
pst_program3:
begin
+ fl_ce_q <= 1'b1;
pgm_data <= tst_data & fl_data[7:0];
fl_data <= { 8'hFF, fl_data[63:8] };
if ( |(tst_data & ~fl_data[7:0]) )
begin
- fl_ce_q <= 1'b1;
fl_we_q <= 1'b1;
fl_d_en <= 1'b1;
fl_d_q <= 8'hAA;
- fl_a_q <= 32'hAAAAAAAA;
+ fl_a_q <= 32'hAAAA_AAAA;
prog_state <= pst_program4;
end
else
@@ -688,7 +698,7 @@ module de1flash (
fl_we_q <= 1'b1;
fl_d_en <= 1'b1;
fl_d_q <= 8'h55;
- fl_a_q <= 32'h55555555;
+ fl_a_q <= 32'h5555_5555;
prog_state <= pst_program6;
end
@@ -705,7 +715,7 @@ module de1flash (
fl_we_q <= 1'b1;
fl_d_en <= 1'b1;
fl_d_q <= 8'hA0;
- fl_a_q <= 32'hAAAAAAAA;
+ fl_a_q <= 32'hAAAA_AAAA;
prog_state <= pst_program8;
end
diff --git a/protocol.txt b/protocol.txt
index c332f7c..892b21d 100644
--- a/protocol.txt
+++ b/protocol.txt
@@ -14,7 +14,8 @@ READ FIFO
72 bits:
-binary- -------hex-------
-V000CCCC DDDDDDD DDDDDDDDD - V = valid
+VNNNCCCC DDDDDDD DDDDDDDDD - V = valid
+ - N = sequence counter
- C = top 4 bits of command
Read transactions can be streamed by shifting out a multiple of 72 bits.