Xc3sprog

From Tech
Jump to navigationJump to search

Links

xc3sprog bscan 59a6 bug

Programming the flash happens by first programming the FPGA with the bscan utility. This utility then receives the to-be-programmed flash data, and forwards it to the flash memory. For SST this happens 2 bytes at a time. Each time a header is prepended to the data, consisting of 32 magic bits (59a659a6), and some more.

The bscan FPGA progam waits for the 32 magic bits, and then decodes the rest of the header and data, like this:

Computer indicates start of package (DRCK1, CAPTURE, RESET, UPDATE, SEL1, cannot tell)
  -> FPGA-bscan sets have_header<='0'
Computer sends package: 59 a6 59 a6  00 03  ad 12 34
  -> FPGA-bscan sees magic, reads next two bytes (length), and  reads the data (ad-code, 12+34, data for flash).

The problem arises when the last two bytes of the data (in the SST case, the only two bytes) are 59 a6. Then the following happens:

Computer sends package: 59 a6 59 a6  00 03  ad 59 a6
  -> FPGA-bscan sees magic, reads next two bytes (length), and  reads the data (ad-code, 59-a6, data for flash), all OK.
Computer indicates start of package (DRCK1, CAPTURE, RESET, UPDATE, SEL1, cannot tell)
  -> FPGA-bscan sets have_header<='0'
     Now the 'header' signal in bscan contains "a6  00 03  ad 59" (last 6 bytes)
Computer sends first 4 bytes of next package (header): 59 a6 59 a6
  -> FPGA-bscan continuously shifts the read data into its 'header' signal, and thus at some point will have:
   59 a6 59 a6 59 a6  (first two bytes are last two bytes of last package, rest is magic header)
  -> FPGA-bscan now interprets the first two databytes + first to magic bytes as the magic header, and the length becomes "59 a6".
-> Error.

xc3sprog & papilio

The original xc3sprog doesn't support the SST flash on the Papilio. So instead use the papilio xc3sprog fork. Another option is to apply this patch (backport of papilio SST flash changes). After applying that patch, the Papilio flash can be programmed as follows:

sudo ./xc3sprog -c papilio -I./bscan_spi/xc3s500e_godil.bit ~/VHDL/LED2/LEDtest.bit  -v -R