Browse Source

Fix USB serial number generation

H. Peter Anvin 3 years ago
parent
commit
4b07e7703d
11 changed files with 1438 additions and 1434 deletions
  1. 2 2
      fpga/max80.qpf
  2. 1073 1073
      fpga/output/sram.mif
  3. BIN
      fpga/output/v1.jic
  4. BIN
      fpga/output/v1.sof
  5. BIN
      fpga/output/v2.jic
  6. BIN
      fpga/output/v2.sof
  7. 1 1
      fpga/usb/usb_desc.conf
  8. 334 326
      fpga/usb/usb_desc.v
  9. 1 1
      rv32/checksum.h
  10. 0 1
      rv32/fw.h
  11. 27 30
      rv32/romcopy.c

+ 2 - 2
fpga/max80.qpf

@@ -19,12 +19,12 @@
 #
 # Quartus Prime
 # Version 21.1.0 Build 842 10/21/2021 SJ Lite Edition
-# Date created = 05:12:58  February 02, 2022
+# Date created = 05:45:18  February 02, 2022
 #
 # -------------------------------------------------------------------------- #
 
 QUARTUS_VERSION = "21.1"
-DATE = "05:12:58  February 02, 2022"
+DATE = "05:45:18  February 02, 2022"
 
 # Revisions
 

File diff suppressed because it is too large
+ 1073 - 1073
fpga/output/sram.mif


BIN
fpga/output/v1.jic


BIN
fpga/output/v1.sof


BIN
fpga/output/v2.jic


BIN
fpga/output/v2.sof


+ 1 - 1
fpga/usb/usb_desc.conf

@@ -11,7 +11,7 @@ my $vendor_id    = word(0x1d50);
 my $device_id    = word(0x6149);
 my $version_id   = word(0x0100);
 
-my $serial       = usb_serial('_Serial_???_');
+my $serial       = usb_serial('SerialNumberHere'); # 16 characters
 my $manufacturer = usb_string(''   => 'Peter & Per');
 my $product      = usb_string(''   => 'MAX80 I/O card for ABC');
 

+ 334 - 326
fpga/usb/usb_desc.v

@@ -18,408 +18,416 @@ module usb_desc_rom (
 	reg [7:0] rom [0:511];
 
 	initial begin
-		rom[9'h000] = 8'h1a;
+		rom[9'h000] = 8'h22;
 		rom[9'h001] = 8'h03;
-		rom[9'h002] = 8'h5f;
+		rom[9'h002] = 8'h53;
 		rom[9'h003] = 8'h00;
-		rom[9'h004] = 8'h53;
+		rom[9'h004] = 8'h65;
 		rom[9'h005] = 8'h00;
-		rom[9'h006] = 8'h65;
+		rom[9'h006] = 8'h72;
 		rom[9'h007] = 8'h00;
-		rom[9'h008] = 8'h72;
+		rom[9'h008] = 8'h69;
 		rom[9'h009] = 8'h00;
-		rom[9'h00a] = 8'h69;
+		rom[9'h00a] = 8'h61;
 		rom[9'h00b] = 8'h00;
-		rom[9'h00c] = 8'h61;
+		rom[9'h00c] = 8'h6c;
 		rom[9'h00d] = 8'h00;
-		rom[9'h00e] = 8'h6c;
+		rom[9'h00e] = 8'h4e;
 		rom[9'h00f] = 8'h00;
-		rom[9'h010] = 8'h5f;
+		rom[9'h010] = 8'h75;
 		rom[9'h011] = 8'h00;
-		rom[9'h012] = 8'h3f;
+		rom[9'h012] = 8'h6d;
 		rom[9'h013] = 8'h00;
-		rom[9'h014] = 8'h3f;
+		rom[9'h014] = 8'h62;
 		rom[9'h015] = 8'h00;
-		rom[9'h016] = 8'h3f;
+		rom[9'h016] = 8'h65;
 		rom[9'h017] = 8'h00;
-		rom[9'h018] = 8'h5f;
+		rom[9'h018] = 8'h72;
 		rom[9'h019] = 8'h00;
-		rom[9'h01a] = 8'h12;
-		rom[9'h01b] = 8'h01;
-		rom[9'h01c] = 8'h01;
-		rom[9'h01d] = 8'h01;
-		rom[9'h01e] = 8'h00;
+		rom[9'h01a] = 8'h48;
+		rom[9'h01b] = 8'h00;
+		rom[9'h01c] = 8'h65;
+		rom[9'h01d] = 8'h00;
+		rom[9'h01e] = 8'h72;
 		rom[9'h01f] = 8'h00;
-		rom[9'h020] = 8'h00;
-		rom[9'h021] = 8'h08;
-		rom[9'h022] = 8'h50;
-		rom[9'h023] = 8'h1d;
-		rom[9'h024] = 8'h49;
-		rom[9'h025] = 8'h61;
+		rom[9'h020] = 8'h65;
+		rom[9'h021] = 8'h00;
+		rom[9'h022] = 8'h12;
+		rom[9'h023] = 8'h01;
+		rom[9'h024] = 8'h01;
+		rom[9'h025] = 8'h01;
 		rom[9'h026] = 8'h00;
-		rom[9'h027] = 8'h01;
-		rom[9'h028] = 8'h02;
-		rom[9'h029] = 8'h03;
-		rom[9'h02a] = 8'h01;
-		rom[9'h02b] = 8'h01;
-		rom[9'h02c] = 8'h09;
-		rom[9'h02d] = 8'h02;
-		rom[9'h02e] = 8'h11;
+		rom[9'h027] = 8'h00;
+		rom[9'h028] = 8'h00;
+		rom[9'h029] = 8'h08;
+		rom[9'h02a] = 8'h50;
+		rom[9'h02b] = 8'h1d;
+		rom[9'h02c] = 8'h49;
+		rom[9'h02d] = 8'h61;
+		rom[9'h02e] = 8'h00;
 		rom[9'h02f] = 8'h01;
-		rom[9'h030] = 8'h08;
-		rom[9'h031] = 8'h01;
-		rom[9'h032] = 8'h04;
-		rom[9'h033] = 8'hc0;
-		rom[9'h034] = 8'hfa;
-		rom[9'h035] = 8'h08;
-		rom[9'h036] = 8'h0b;
-		rom[9'h037] = 8'h00;
-		rom[9'h038] = 8'h02;
-		rom[9'h039] = 8'h02;
-		rom[9'h03a] = 8'h02;
-		rom[9'h03b] = 8'h01;
-		rom[9'h03c] = 8'h04;
-		rom[9'h03d] = 8'h09;
-		rom[9'h03e] = 8'h04;
+		rom[9'h030] = 8'h02;
+		rom[9'h031] = 8'h03;
+		rom[9'h032] = 8'h01;
+		rom[9'h033] = 8'h01;
+		rom[9'h034] = 8'h09;
+		rom[9'h035] = 8'h02;
+		rom[9'h036] = 8'h11;
+		rom[9'h037] = 8'h01;
+		rom[9'h038] = 8'h08;
+		rom[9'h039] = 8'h01;
+		rom[9'h03a] = 8'h04;
+		rom[9'h03b] = 8'hc0;
+		rom[9'h03c] = 8'hfa;
+		rom[9'h03d] = 8'h08;
+		rom[9'h03e] = 8'h0b;
 		rom[9'h03f] = 8'h00;
-		rom[9'h040] = 8'h00;
-		rom[9'h041] = 8'h01;
+		rom[9'h040] = 8'h02;
+		rom[9'h041] = 8'h02;
 		rom[9'h042] = 8'h02;
-		rom[9'h043] = 8'h02;
-		rom[9'h044] = 8'h01;
-		rom[9'h045] = 8'h04;
-		rom[9'h046] = 8'h05;
-		rom[9'h047] = 8'h24;
+		rom[9'h043] = 8'h01;
+		rom[9'h044] = 8'h04;
+		rom[9'h045] = 8'h09;
+		rom[9'h046] = 8'h04;
+		rom[9'h047] = 8'h00;
 		rom[9'h048] = 8'h00;
-		rom[9'h049] = 8'h20;
-		rom[9'h04a] = 8'h01;
-		rom[9'h04b] = 8'h05;
-		rom[9'h04c] = 8'h24;
-		rom[9'h04d] = 8'h01;
-		rom[9'h04e] = 8'h03;
-		rom[9'h04f] = 8'h01;
-		rom[9'h050] = 8'h04;
-		rom[9'h051] = 8'h24;
-		rom[9'h052] = 8'h02;
-		rom[9'h053] = 8'h06;
-		rom[9'h054] = 8'h05;
-		rom[9'h055] = 8'h24;
-		rom[9'h056] = 8'h06;
-		rom[9'h057] = 8'h00;
-		rom[9'h058] = 8'h01;
-		rom[9'h059] = 8'h07;
-		rom[9'h05a] = 8'h05;
-		rom[9'h05b] = 8'h82;
-		rom[9'h05c] = 8'h03;
-		rom[9'h05d] = 8'h40;
-		rom[9'h05e] = 8'h00;
-		rom[9'h05f] = 8'h02;
-		rom[9'h060] = 8'h09;
-		rom[9'h061] = 8'h04;
-		rom[9'h062] = 8'h01;
-		rom[9'h063] = 8'h00;
-		rom[9'h064] = 8'h02;
-		rom[9'h065] = 8'h0a;
+		rom[9'h049] = 8'h01;
+		rom[9'h04a] = 8'h02;
+		rom[9'h04b] = 8'h02;
+		rom[9'h04c] = 8'h01;
+		rom[9'h04d] = 8'h04;
+		rom[9'h04e] = 8'h05;
+		rom[9'h04f] = 8'h24;
+		rom[9'h050] = 8'h00;
+		rom[9'h051] = 8'h20;
+		rom[9'h052] = 8'h01;
+		rom[9'h053] = 8'h05;
+		rom[9'h054] = 8'h24;
+		rom[9'h055] = 8'h01;
+		rom[9'h056] = 8'h03;
+		rom[9'h057] = 8'h01;
+		rom[9'h058] = 8'h04;
+		rom[9'h059] = 8'h24;
+		rom[9'h05a] = 8'h02;
+		rom[9'h05b] = 8'h06;
+		rom[9'h05c] = 8'h05;
+		rom[9'h05d] = 8'h24;
+		rom[9'h05e] = 8'h06;
+		rom[9'h05f] = 8'h00;
+		rom[9'h060] = 8'h01;
+		rom[9'h061] = 8'h07;
+		rom[9'h062] = 8'h05;
+		rom[9'h063] = 8'h82;
+		rom[9'h064] = 8'h03;
+		rom[9'h065] = 8'h40;
 		rom[9'h066] = 8'h00;
-		rom[9'h067] = 8'h00;
-		rom[9'h068] = 8'h04;
-		rom[9'h069] = 8'h07;
-		rom[9'h06a] = 8'h05;
-		rom[9'h06b] = 8'h81;
+		rom[9'h067] = 8'h02;
+		rom[9'h068] = 8'h09;
+		rom[9'h069] = 8'h04;
+		rom[9'h06a] = 8'h01;
+		rom[9'h06b] = 8'h00;
 		rom[9'h06c] = 8'h02;
-		rom[9'h06d] = 8'h40;
+		rom[9'h06d] = 8'h0a;
 		rom[9'h06e] = 8'h00;
 		rom[9'h06f] = 8'h00;
-		rom[9'h070] = 8'h07;
-		rom[9'h071] = 8'h05;
-		rom[9'h072] = 8'h01;
-		rom[9'h073] = 8'h02;
-		rom[9'h074] = 8'h40;
-		rom[9'h075] = 8'h00;
+		rom[9'h070] = 8'h04;
+		rom[9'h071] = 8'h07;
+		rom[9'h072] = 8'h05;
+		rom[9'h073] = 8'h81;
+		rom[9'h074] = 8'h02;
+		rom[9'h075] = 8'h40;
 		rom[9'h076] = 8'h00;
-		rom[9'h077] = 8'h08;
-		rom[9'h078] = 8'h0b;
-		rom[9'h079] = 8'h02;
-		rom[9'h07a] = 8'h02;
+		rom[9'h077] = 8'h00;
+		rom[9'h078] = 8'h07;
+		rom[9'h079] = 8'h05;
+		rom[9'h07a] = 8'h01;
 		rom[9'h07b] = 8'h02;
-		rom[9'h07c] = 8'h02;
-		rom[9'h07d] = 8'h01;
-		rom[9'h07e] = 8'h04;
-		rom[9'h07f] = 8'h09;
-		rom[9'h080] = 8'h04;
+		rom[9'h07c] = 8'h40;
+		rom[9'h07d] = 8'h00;
+		rom[9'h07e] = 8'h00;
+		rom[9'h07f] = 8'h08;
+		rom[9'h080] = 8'h0b;
 		rom[9'h081] = 8'h02;
-		rom[9'h082] = 8'h00;
-		rom[9'h083] = 8'h01;
+		rom[9'h082] = 8'h02;
+		rom[9'h083] = 8'h02;
 		rom[9'h084] = 8'h02;
-		rom[9'h085] = 8'h02;
-		rom[9'h086] = 8'h01;
-		rom[9'h087] = 8'h04;
-		rom[9'h088] = 8'h05;
-		rom[9'h089] = 8'h24;
+		rom[9'h085] = 8'h01;
+		rom[9'h086] = 8'h04;
+		rom[9'h087] = 8'h09;
+		rom[9'h088] = 8'h04;
+		rom[9'h089] = 8'h02;
 		rom[9'h08a] = 8'h00;
-		rom[9'h08b] = 8'h20;
-		rom[9'h08c] = 8'h01;
-		rom[9'h08d] = 8'h05;
-		rom[9'h08e] = 8'h24;
-		rom[9'h08f] = 8'h01;
-		rom[9'h090] = 8'h03;
-		rom[9'h091] = 8'h03;
-		rom[9'h092] = 8'h04;
-		rom[9'h093] = 8'h24;
-		rom[9'h094] = 8'h02;
-		rom[9'h095] = 8'h06;
-		rom[9'h096] = 8'h05;
-		rom[9'h097] = 8'h24;
-		rom[9'h098] = 8'h06;
-		rom[9'h099] = 8'h02;
-		rom[9'h09a] = 8'h03;
-		rom[9'h09b] = 8'h07;
-		rom[9'h09c] = 8'h05;
-		rom[9'h09d] = 8'h84;
-		rom[9'h09e] = 8'h03;
-		rom[9'h09f] = 8'h40;
-		rom[9'h0a0] = 8'h00;
+		rom[9'h08b] = 8'h01;
+		rom[9'h08c] = 8'h02;
+		rom[9'h08d] = 8'h02;
+		rom[9'h08e] = 8'h01;
+		rom[9'h08f] = 8'h04;
+		rom[9'h090] = 8'h05;
+		rom[9'h091] = 8'h24;
+		rom[9'h092] = 8'h00;
+		rom[9'h093] = 8'h20;
+		rom[9'h094] = 8'h01;
+		rom[9'h095] = 8'h05;
+		rom[9'h096] = 8'h24;
+		rom[9'h097] = 8'h01;
+		rom[9'h098] = 8'h03;
+		rom[9'h099] = 8'h03;
+		rom[9'h09a] = 8'h04;
+		rom[9'h09b] = 8'h24;
+		rom[9'h09c] = 8'h02;
+		rom[9'h09d] = 8'h06;
+		rom[9'h09e] = 8'h05;
+		rom[9'h09f] = 8'h24;
+		rom[9'h0a0] = 8'h06;
 		rom[9'h0a1] = 8'h02;
-		rom[9'h0a2] = 8'h09;
-		rom[9'h0a3] = 8'h04;
-		rom[9'h0a4] = 8'h03;
-		rom[9'h0a5] = 8'h00;
-		rom[9'h0a6] = 8'h02;
-		rom[9'h0a7] = 8'h0a;
+		rom[9'h0a2] = 8'h03;
+		rom[9'h0a3] = 8'h07;
+		rom[9'h0a4] = 8'h05;
+		rom[9'h0a5] = 8'h84;
+		rom[9'h0a6] = 8'h03;
+		rom[9'h0a7] = 8'h40;
 		rom[9'h0a8] = 8'h00;
-		rom[9'h0a9] = 8'h00;
-		rom[9'h0aa] = 8'h04;
-		rom[9'h0ab] = 8'h07;
-		rom[9'h0ac] = 8'h05;
-		rom[9'h0ad] = 8'h83;
+		rom[9'h0a9] = 8'h02;
+		rom[9'h0aa] = 8'h09;
+		rom[9'h0ab] = 8'h04;
+		rom[9'h0ac] = 8'h03;
+		rom[9'h0ad] = 8'h00;
 		rom[9'h0ae] = 8'h02;
-		rom[9'h0af] = 8'h40;
+		rom[9'h0af] = 8'h0a;
 		rom[9'h0b0] = 8'h00;
 		rom[9'h0b1] = 8'h00;
-		rom[9'h0b2] = 8'h07;
-		rom[9'h0b3] = 8'h05;
-		rom[9'h0b4] = 8'h03;
-		rom[9'h0b5] = 8'h02;
-		rom[9'h0b6] = 8'h40;
-		rom[9'h0b7] = 8'h00;
+		rom[9'h0b2] = 8'h04;
+		rom[9'h0b3] = 8'h07;
+		rom[9'h0b4] = 8'h05;
+		rom[9'h0b5] = 8'h83;
+		rom[9'h0b6] = 8'h02;
+		rom[9'h0b7] = 8'h40;
 		rom[9'h0b8] = 8'h00;
-		rom[9'h0b9] = 8'h08;
-		rom[9'h0ba] = 8'h0b;
-		rom[9'h0bb] = 8'h04;
-		rom[9'h0bc] = 8'h02;
+		rom[9'h0b9] = 8'h00;
+		rom[9'h0ba] = 8'h07;
+		rom[9'h0bb] = 8'h05;
+		rom[9'h0bc] = 8'h03;
 		rom[9'h0bd] = 8'h02;
-		rom[9'h0be] = 8'h02;
-		rom[9'h0bf] = 8'h01;
-		rom[9'h0c0] = 8'h04;
-		rom[9'h0c1] = 8'h09;
-		rom[9'h0c2] = 8'h04;
+		rom[9'h0be] = 8'h40;
+		rom[9'h0bf] = 8'h00;
+		rom[9'h0c0] = 8'h00;
+		rom[9'h0c1] = 8'h08;
+		rom[9'h0c2] = 8'h0b;
 		rom[9'h0c3] = 8'h04;
-		rom[9'h0c4] = 8'h00;
-		rom[9'h0c5] = 8'h01;
+		rom[9'h0c4] = 8'h02;
+		rom[9'h0c5] = 8'h02;
 		rom[9'h0c6] = 8'h02;
-		rom[9'h0c7] = 8'h02;
-		rom[9'h0c8] = 8'h01;
-		rom[9'h0c9] = 8'h04;
-		rom[9'h0ca] = 8'h05;
-		rom[9'h0cb] = 8'h24;
+		rom[9'h0c7] = 8'h01;
+		rom[9'h0c8] = 8'h04;
+		rom[9'h0c9] = 8'h09;
+		rom[9'h0ca] = 8'h04;
+		rom[9'h0cb] = 8'h04;
 		rom[9'h0cc] = 8'h00;
-		rom[9'h0cd] = 8'h20;
-		rom[9'h0ce] = 8'h01;
-		rom[9'h0cf] = 8'h05;
-		rom[9'h0d0] = 8'h24;
-		rom[9'h0d1] = 8'h01;
-		rom[9'h0d2] = 8'h03;
-		rom[9'h0d3] = 8'h05;
-		rom[9'h0d4] = 8'h04;
-		rom[9'h0d5] = 8'h24;
-		rom[9'h0d6] = 8'h02;
-		rom[9'h0d7] = 8'h06;
-		rom[9'h0d8] = 8'h05;
-		rom[9'h0d9] = 8'h24;
-		rom[9'h0da] = 8'h06;
-		rom[9'h0db] = 8'h04;
-		rom[9'h0dc] = 8'h05;
-		rom[9'h0dd] = 8'h07;
-		rom[9'h0de] = 8'h05;
-		rom[9'h0df] = 8'h86;
-		rom[9'h0e0] = 8'h03;
-		rom[9'h0e1] = 8'h40;
-		rom[9'h0e2] = 8'h00;
-		rom[9'h0e3] = 8'h02;
-		rom[9'h0e4] = 8'h09;
-		rom[9'h0e5] = 8'h04;
+		rom[9'h0cd] = 8'h01;
+		rom[9'h0ce] = 8'h02;
+		rom[9'h0cf] = 8'h02;
+		rom[9'h0d0] = 8'h01;
+		rom[9'h0d1] = 8'h04;
+		rom[9'h0d2] = 8'h05;
+		rom[9'h0d3] = 8'h24;
+		rom[9'h0d4] = 8'h00;
+		rom[9'h0d5] = 8'h20;
+		rom[9'h0d6] = 8'h01;
+		rom[9'h0d7] = 8'h05;
+		rom[9'h0d8] = 8'h24;
+		rom[9'h0d9] = 8'h01;
+		rom[9'h0da] = 8'h03;
+		rom[9'h0db] = 8'h05;
+		rom[9'h0dc] = 8'h04;
+		rom[9'h0dd] = 8'h24;
+		rom[9'h0de] = 8'h02;
+		rom[9'h0df] = 8'h06;
+		rom[9'h0e0] = 8'h05;
+		rom[9'h0e1] = 8'h24;
+		rom[9'h0e2] = 8'h06;
+		rom[9'h0e3] = 8'h04;
+		rom[9'h0e4] = 8'h05;
+		rom[9'h0e5] = 8'h07;
 		rom[9'h0e6] = 8'h05;
-		rom[9'h0e7] = 8'h00;
-		rom[9'h0e8] = 8'h02;
-		rom[9'h0e9] = 8'h0a;
+		rom[9'h0e7] = 8'h86;
+		rom[9'h0e8] = 8'h03;
+		rom[9'h0e9] = 8'h40;
 		rom[9'h0ea] = 8'h00;
-		rom[9'h0eb] = 8'h00;
-		rom[9'h0ec] = 8'h04;
-		rom[9'h0ed] = 8'h07;
+		rom[9'h0eb] = 8'h02;
+		rom[9'h0ec] = 8'h09;
+		rom[9'h0ed] = 8'h04;
 		rom[9'h0ee] = 8'h05;
-		rom[9'h0ef] = 8'h85;
+		rom[9'h0ef] = 8'h00;
 		rom[9'h0f0] = 8'h02;
-		rom[9'h0f1] = 8'h40;
+		rom[9'h0f1] = 8'h0a;
 		rom[9'h0f2] = 8'h00;
 		rom[9'h0f3] = 8'h00;
-		rom[9'h0f4] = 8'h07;
-		rom[9'h0f5] = 8'h05;
+		rom[9'h0f4] = 8'h04;
+		rom[9'h0f5] = 8'h07;
 		rom[9'h0f6] = 8'h05;
-		rom[9'h0f7] = 8'h02;
-		rom[9'h0f8] = 8'h40;
-		rom[9'h0f9] = 8'h00;
+		rom[9'h0f7] = 8'h85;
+		rom[9'h0f8] = 8'h02;
+		rom[9'h0f9] = 8'h40;
 		rom[9'h0fa] = 8'h00;
-		rom[9'h0fb] = 8'h08;
-		rom[9'h0fc] = 8'h0b;
-		rom[9'h0fd] = 8'h06;
-		rom[9'h0fe] = 8'h02;
+		rom[9'h0fb] = 8'h00;
+		rom[9'h0fc] = 8'h07;
+		rom[9'h0fd] = 8'h05;
+		rom[9'h0fe] = 8'h05;
 		rom[9'h0ff] = 8'h02;
-		rom[9'h100] = 8'h02;
-		rom[9'h101] = 8'h01;
-		rom[9'h102] = 8'h04;
-		rom[9'h103] = 8'h09;
-		rom[9'h104] = 8'h04;
+		rom[9'h100] = 8'h40;
+		rom[9'h101] = 8'h00;
+		rom[9'h102] = 8'h00;
+		rom[9'h103] = 8'h08;
+		rom[9'h104] = 8'h0b;
 		rom[9'h105] = 8'h06;
-		rom[9'h106] = 8'h00;
-		rom[9'h107] = 8'h01;
+		rom[9'h106] = 8'h02;
+		rom[9'h107] = 8'h02;
 		rom[9'h108] = 8'h02;
-		rom[9'h109] = 8'h02;
-		rom[9'h10a] = 8'h01;
-		rom[9'h10b] = 8'h04;
-		rom[9'h10c] = 8'h05;
-		rom[9'h10d] = 8'h24;
+		rom[9'h109] = 8'h01;
+		rom[9'h10a] = 8'h04;
+		rom[9'h10b] = 8'h09;
+		rom[9'h10c] = 8'h04;
+		rom[9'h10d] = 8'h06;
 		rom[9'h10e] = 8'h00;
-		rom[9'h10f] = 8'h20;
-		rom[9'h110] = 8'h01;
-		rom[9'h111] = 8'h05;
-		rom[9'h112] = 8'h24;
-		rom[9'h113] = 8'h01;
-		rom[9'h114] = 8'h03;
-		rom[9'h115] = 8'h07;
-		rom[9'h116] = 8'h04;
-		rom[9'h117] = 8'h24;
-		rom[9'h118] = 8'h02;
-		rom[9'h119] = 8'h06;
-		rom[9'h11a] = 8'h05;
-		rom[9'h11b] = 8'h24;
-		rom[9'h11c] = 8'h06;
-		rom[9'h11d] = 8'h06;
-		rom[9'h11e] = 8'h07;
-		rom[9'h11f] = 8'h07;
-		rom[9'h120] = 8'h05;
-		rom[9'h121] = 8'h88;
-		rom[9'h122] = 8'h03;
-		rom[9'h123] = 8'h40;
-		rom[9'h124] = 8'h00;
-		rom[9'h125] = 8'h02;
-		rom[9'h126] = 8'h09;
-		rom[9'h127] = 8'h04;
-		rom[9'h128] = 8'h07;
-		rom[9'h129] = 8'h00;
-		rom[9'h12a] = 8'h02;
-		rom[9'h12b] = 8'h0a;
+		rom[9'h10f] = 8'h01;
+		rom[9'h110] = 8'h02;
+		rom[9'h111] = 8'h02;
+		rom[9'h112] = 8'h01;
+		rom[9'h113] = 8'h04;
+		rom[9'h114] = 8'h05;
+		rom[9'h115] = 8'h24;
+		rom[9'h116] = 8'h00;
+		rom[9'h117] = 8'h20;
+		rom[9'h118] = 8'h01;
+		rom[9'h119] = 8'h05;
+		rom[9'h11a] = 8'h24;
+		rom[9'h11b] = 8'h01;
+		rom[9'h11c] = 8'h03;
+		rom[9'h11d] = 8'h07;
+		rom[9'h11e] = 8'h04;
+		rom[9'h11f] = 8'h24;
+		rom[9'h120] = 8'h02;
+		rom[9'h121] = 8'h06;
+		rom[9'h122] = 8'h05;
+		rom[9'h123] = 8'h24;
+		rom[9'h124] = 8'h06;
+		rom[9'h125] = 8'h06;
+		rom[9'h126] = 8'h07;
+		rom[9'h127] = 8'h07;
+		rom[9'h128] = 8'h05;
+		rom[9'h129] = 8'h88;
+		rom[9'h12a] = 8'h03;
+		rom[9'h12b] = 8'h40;
 		rom[9'h12c] = 8'h00;
-		rom[9'h12d] = 8'h00;
-		rom[9'h12e] = 8'h04;
-		rom[9'h12f] = 8'h07;
-		rom[9'h130] = 8'h05;
-		rom[9'h131] = 8'h87;
+		rom[9'h12d] = 8'h02;
+		rom[9'h12e] = 8'h09;
+		rom[9'h12f] = 8'h04;
+		rom[9'h130] = 8'h07;
+		rom[9'h131] = 8'h00;
 		rom[9'h132] = 8'h02;
-		rom[9'h133] = 8'h40;
+		rom[9'h133] = 8'h0a;
 		rom[9'h134] = 8'h00;
 		rom[9'h135] = 8'h00;
-		rom[9'h136] = 8'h07;
-		rom[9'h137] = 8'h05;
-		rom[9'h138] = 8'h07;
-		rom[9'h139] = 8'h02;
-		rom[9'h13a] = 8'h40;
-		rom[9'h13b] = 8'h00;
+		rom[9'h136] = 8'h04;
+		rom[9'h137] = 8'h07;
+		rom[9'h138] = 8'h05;
+		rom[9'h139] = 8'h87;
+		rom[9'h13a] = 8'h02;
+		rom[9'h13b] = 8'h40;
 		rom[9'h13c] = 8'h00;
-		rom[9'h13d] = 8'h06;
-		rom[9'h13e] = 8'h03;
-		rom[9'h13f] = 8'h09;
-		rom[9'h140] = 8'h04;
-		rom[9'h141] = 8'h1d;
-		rom[9'h142] = 8'h04;
-		rom[9'h143] = 8'h18;
-		rom[9'h144] = 8'h03;
-		rom[9'h145] = 8'h50;
-		rom[9'h146] = 8'h00;
-		rom[9'h147] = 8'h65;
-		rom[9'h148] = 8'h00;
-		rom[9'h149] = 8'h74;
-		rom[9'h14a] = 8'h00;
-		rom[9'h14b] = 8'h65;
-		rom[9'h14c] = 8'h00;
-		rom[9'h14d] = 8'h72;
+		rom[9'h13d] = 8'h00;
+		rom[9'h13e] = 8'h07;
+		rom[9'h13f] = 8'h05;
+		rom[9'h140] = 8'h07;
+		rom[9'h141] = 8'h02;
+		rom[9'h142] = 8'h40;
+		rom[9'h143] = 8'h00;
+		rom[9'h144] = 8'h00;
+		rom[9'h145] = 8'h06;
+		rom[9'h146] = 8'h03;
+		rom[9'h147] = 8'h09;
+		rom[9'h148] = 8'h04;
+		rom[9'h149] = 8'h1d;
+		rom[9'h14a] = 8'h04;
+		rom[9'h14b] = 8'h18;
+		rom[9'h14c] = 8'h03;
+		rom[9'h14d] = 8'h50;
 		rom[9'h14e] = 8'h00;
-		rom[9'h14f] = 8'h20;
+		rom[9'h14f] = 8'h65;
 		rom[9'h150] = 8'h00;
-		rom[9'h151] = 8'h26;
+		rom[9'h151] = 8'h74;
 		rom[9'h152] = 8'h00;
-		rom[9'h153] = 8'h20;
+		rom[9'h153] = 8'h65;
 		rom[9'h154] = 8'h00;
-		rom[9'h155] = 8'h50;
+		rom[9'h155] = 8'h72;
 		rom[9'h156] = 8'h00;
-		rom[9'h157] = 8'h65;
+		rom[9'h157] = 8'h20;
 		rom[9'h158] = 8'h00;
-		rom[9'h159] = 8'h72;
+		rom[9'h159] = 8'h26;
 		rom[9'h15a] = 8'h00;
-		rom[9'h15b] = 8'h2e;
-		rom[9'h15c] = 8'h03;
-		rom[9'h15d] = 8'h4d;
+		rom[9'h15b] = 8'h20;
+		rom[9'h15c] = 8'h00;
+		rom[9'h15d] = 8'h50;
 		rom[9'h15e] = 8'h00;
-		rom[9'h15f] = 8'h41;
+		rom[9'h15f] = 8'h65;
 		rom[9'h160] = 8'h00;
-		rom[9'h161] = 8'h58;
+		rom[9'h161] = 8'h72;
 		rom[9'h162] = 8'h00;
-		rom[9'h163] = 8'h38;
-		rom[9'h164] = 8'h00;
-		rom[9'h165] = 8'h30;
+		rom[9'h163] = 8'h2e;
+		rom[9'h164] = 8'h03;
+		rom[9'h165] = 8'h4d;
 		rom[9'h166] = 8'h00;
-		rom[9'h167] = 8'h20;
+		rom[9'h167] = 8'h41;
 		rom[9'h168] = 8'h00;
-		rom[9'h169] = 8'h49;
+		rom[9'h169] = 8'h58;
 		rom[9'h16a] = 8'h00;
-		rom[9'h16b] = 8'h2f;
+		rom[9'h16b] = 8'h38;
 		rom[9'h16c] = 8'h00;
-		rom[9'h16d] = 8'h4f;
+		rom[9'h16d] = 8'h30;
 		rom[9'h16e] = 8'h00;
 		rom[9'h16f] = 8'h20;
 		rom[9'h170] = 8'h00;
-		rom[9'h171] = 8'h63;
+		rom[9'h171] = 8'h49;
 		rom[9'h172] = 8'h00;
-		rom[9'h173] = 8'h61;
+		rom[9'h173] = 8'h2f;
 		rom[9'h174] = 8'h00;
-		rom[9'h175] = 8'h72;
+		rom[9'h175] = 8'h4f;
 		rom[9'h176] = 8'h00;
-		rom[9'h177] = 8'h64;
+		rom[9'h177] = 8'h20;
 		rom[9'h178] = 8'h00;
-		rom[9'h179] = 8'h20;
+		rom[9'h179] = 8'h63;
 		rom[9'h17a] = 8'h00;
-		rom[9'h17b] = 8'h66;
+		rom[9'h17b] = 8'h61;
 		rom[9'h17c] = 8'h00;
-		rom[9'h17d] = 8'h6f;
+		rom[9'h17d] = 8'h72;
 		rom[9'h17e] = 8'h00;
-		rom[9'h17f] = 8'h72;
+		rom[9'h17f] = 8'h64;
 		rom[9'h180] = 8'h00;
 		rom[9'h181] = 8'h20;
 		rom[9'h182] = 8'h00;
-		rom[9'h183] = 8'h41;
+		rom[9'h183] = 8'h66;
 		rom[9'h184] = 8'h00;
-		rom[9'h185] = 8'h42;
+		rom[9'h185] = 8'h6f;
 		rom[9'h186] = 8'h00;
-		rom[9'h187] = 8'h43;
+		rom[9'h187] = 8'h72;
 		rom[9'h188] = 8'h00;
-		rom[9'h189] = 8'h02;
-		rom[9'h18a] = 8'h03;
-		rom[9'h18b] = 8'h00;
-		rom[9'h18c] = 8'h96;
-		rom[9'h18d] = 8'h00;
+		rom[9'h189] = 8'h20;
+		rom[9'h18a] = 8'h00;
+		rom[9'h18b] = 8'h41;
+		rom[9'h18c] = 8'h00;
+		rom[9'h18d] = 8'h42;
 		rom[9'h18e] = 8'h00;
-		rom[9'h18f] = 8'h00;
+		rom[9'h18f] = 8'h43;
 		rom[9'h190] = 8'h00;
-		rom[9'h191] = 8'h08;
+		rom[9'h191] = 8'h02;
+		rom[9'h192] = 8'h03;
+		rom[9'h193] = 8'h00;
+		rom[9'h194] = 8'h96;
+		rom[9'h195] = 8'h00;
+		rom[9'h196] = 8'h00;
+		rom[9'h197] = 8'h00;
+		rom[9'h198] = 8'h00;
+		rom[9'h199] = 8'h08;
 	end
 
 	always @(posedge clk) begin
@@ -445,18 +453,18 @@ module usb_desc_index (
 
 	always @(*)
        	if (additional)
-		{addr,len} = {9'h18b,9'h007};
+		{addr,len} = {9'h193,9'h007};
 	else priority casez ({windex,dindex,dtype})
-		32'b??????00_00011101_00000010_00000011: {addr,len} = {9'h143,9'h018};
-		32'b??????00_00011101_00000011_00000011: {addr,len} = {9'h15b,9'h02e};
-		32'b??????00_00011101_00000100_00000011: {addr,len} = {9'h189,9'h002};
-		32'b????????_????????_00000000_00000010: {addr,len} = {9'h02c,9'h111};
-		32'b????????_????????_00000000_00000011: {addr,len} = {9'h13d,9'h006};
-		32'b????????_????????_00000001_00000011: {addr,len} = {9'h000,9'h01a};
-		32'b????????_????????_00000010_00000011: {addr,len} = {9'h143,9'h018};
-		32'b????????_????????_00000011_00000011: {addr,len} = {9'h15b,9'h02e};
-		32'b????????_????????_00000100_00000011: {addr,len} = {9'h189,9'h002};
-		32'b????????_????????_????????_00000001: {addr,len} = {9'h01a,9'h012};
+		32'b??????00_00011101_00000010_00000011: {addr,len} = {9'h14b,9'h018};
+		32'b??????00_00011101_00000011_00000011: {addr,len} = {9'h163,9'h02e};
+		32'b??????00_00011101_00000100_00000011: {addr,len} = {9'h191,9'h002};
+		32'b????????_????????_00000000_00000010: {addr,len} = {9'h034,9'h111};
+		32'b????????_????????_00000000_00000011: {addr,len} = {9'h145,9'h006};
+		32'b????????_????????_00000001_00000011: {addr,len} = {9'h000,9'h022};
+		32'b????????_????????_00000010_00000011: {addr,len} = {9'h14b,9'h018};
+		32'b????????_????????_00000011_00000011: {addr,len} = {9'h163,9'h02e};
+		32'b????????_????????_00000100_00000011: {addr,len} = {9'h191,9'h002};
+		32'b????????_????????_????????_00000001: {addr,len} = {9'h022,9'h012};
 		32'b????????_????????_????????_????????: {addr,len} = {9'hxxx,9'h000};
 	endcase
 endmodule

+ 1 - 1
rv32/checksum.h

@@ -1,4 +1,4 @@
 #ifndef CHECKSUM_H
 #define CHECKSUM_H
-#define SDRAM_SUM 0xb09378de
+#define SDRAM_SUM 0x70614e7c
 #endif

+ 0 - 1
rv32/fw.h

@@ -64,7 +64,6 @@ extern void romcopy_download(void *, size_t, size_t);
 extern void romcopy_bzero(void *, size_t);
 extern void rom_print_serial(void);
 extern qword_t rom_serial;
-extern char rom_serial_str[];
 
 extern void run_test_image(void);
 

+ 27 - 30
rv32/romcopy.c

@@ -70,17 +70,8 @@ void __hot romcopy_bzero(void *dst, size_t len)
 }
 
 /*
- * Read unique serial number programmed into ROM. Convert the serial
- * number to 12 characters in base32; we lose four bits but that is never
- * going to matter. It's more fun than plain hex... :)
+ * Read unique serial number programmed into ROM
  *
- * This is run before the 64-bit division routines are available in SDRAM,
- * so it needs to be an encoding that can be generated with only plain
- * 32-bit instructions.
- *
- * Doing this as early as possible means a much better chance to see
- * the proper serial number during USB enumeration, so doing it
- * immediately after SPI ROM conditioning is a great time.
  */
 char __bss_hot rom_serial_str[16];
 qword_t __bss_hot rom_serial;
@@ -101,38 +92,46 @@ static __must_inline void rom_read_serial(void)
     rom_serial.l[0] = ROMCOPY_INPUT;
 }
 
+/*
+ * Convert the ROM serial number to a hex string and poke it into the
+ * USB descriptor "ROM". Used to use base36, but this has to be done
+ * very early, and it has turned out that making it consistent with
+ * what one can easily get out of a debugger is really useful.
+ *
+ * Doing this as early as possible means a much better chance to see
+ * the proper serial number during USB enumeration, so doing it
+ * immediately after SPI ROM conditioning is a great time.
+ */
 static __must_inline void rom_mangle_serial(void)
 {
-    rom_serial_str[12] = '\0';
-    uint64_t v = rom_serial.q;
+    volatile uint32_t *udp = &usbdesc_rom[2];
+    
+    for (int i = 7; i >= 0; i--) {
+	unsigned int v = rom_serial.b[i];
+	unsigned int c;
 
-    for (int i = 11; i >= 0; i--) {
-	unsigned char c;
-	unsigned int d = v & 31;
-	v >>= 5;
+	c = (v >> 4)+'0';
+	if (c > '9')
+	    c += 'A'-'9'-1;
+
+	udp[0] = c;
 
-	c = d + '0';
+	c = (v & 15)+'0';
 	if (c > '9')
 	    c += 'A'-'9'-1;
-	if (c >= 'I')
-	    c++;
-	if (c >= 'O')
-	    c++;
-	if (c >= 'S')
-	    c++;
 
-	/* IOSZ not used to avoid confusion with 1052 */
+	udp[2] = c;
 
-	rom_serial_str[i] = c;
-	usbdesc_rom[2+2*i] = c;
+	udp += 4;
     }
 }
 
 void rom_print_serial(void)
 {
     /* Print the ROM serial when we actually can */
-    con_printf("ROM serial: %08x-%08x (%s)\n",
-	       rom_serial.l[1], rom_serial.l[0], rom_serial_str);
+    con_printf("ROM serial: %08X%08X (%08x-%08x)\n",
+	       rom_serial.l[1], rom_serial.l[0],
+	       rom_serial.l[1], rom_serial.l[0]);
 }
 
 static __must_inline void romcopy_config_flash(void)
@@ -146,8 +145,6 @@ static __must_inline void romcopy_config_flash(void)
     ROMCOPY_ROMCMD = ROM_WRITE_SR3 << 24;
     ROMCOPY_DATALEN = ROMCOPY_SPI_CMDLEN(2);
     waitfor(ROMCOPY_IRQ);
-
-    asm volatile("nop; nop");	/* Make extra sure tSHSL2 is OK */
 }
 
 IRQHANDLER(romcopy,0)

Some files were not shown because too many files changed in this diff