Programming an eeprom on the board - Page 1
Forum section: electronics / general

author: bentomo
author_rank: Contributor
timestamp: July 19, 2017, 02:12:02 pm
content: So I've been using a dev board up until now and I'm designing a standalone with a lattice ICE40HX4k.I've found plenty of documentation about how the fpga is programmed from the eeprom, compatibility, and all that jazz. Great!The problem is I haven't found anything on how to get the bitstream onto the eeprom. I'm guessing this is a more universal thing and I'm not googling the right thing. Mostly I just need to figure out how to wire the header as it seams diamond programmer does the heavy lifting for me.There are some SPI looking pins on my programmer but I'm not sure if these can just be hooked up and programmed from the diamond programmer interface. I have an ispDownload cable and I am using a supported eeprom from the list.

author: bentomo
author_rank: Contributor
timestamp: July 19, 2017, 03:59:34 pm
content: Ah yes, I meant to say flash, even the memory I have picked out is FLASHSo if I'm using thishttp://i.ebayimg.com/images/i/111284428437-0-1/s-l1000.jpgI should just be able to wire up sdo, sdi, and tck and be able to program the flash then?(assuming I have vcc, gnd, wp, hold, and cs configured correctly or course)

author: voltsandjolts
author_rank: Unknown
timestamp: July 20, 2017, 07:44:48 am
content: You could use an ICE40 dev board schematic for guidance e.g.http://www.latticesemi.com/view_document?document_id=50946

author: bentomo
author_rank: Contributor
timestamp: July 20, 2017, 12:59:26 pm
content: That's what I thought to do at first but my ICE40HX8K dev board wires them up to the FTDI chip, so I have no idea what it's doing there.However looking at the one you posted it looks like they're just broken out to a header. So it looks like all you have to do is wire up the pins. I'll probably have to control creset_b manually.What I can do though is break out the pins on my dev board and see if I can program the spi flash through my cable directly. I'll post back if that works.

author: andersm
author_rank: Super Contributor
timestamp: July 20, 2017, 01:38:28 pm
content: Quote from: bentomo on July 20, 2017, 12:59:26 pmAre you sure you're not looking at a configuration EEPROM for the FTDI chip?

author: bentomo
author_rank: Contributor
timestamp: July 26, 2017, 07:00:52 pm
content: No, the pins coming off the FTDI are GPIOs, the SPI flash is configured the same across lattice devices. I just don't want to have to include an FTDI chip and usb port on my pcbs to program the board. I've read through all of their programming cable documentation and I've wired up how they say to configure it and set up diamond correctly as far as I can tell. I've tried reinstalling the drivers and still nothing.The worst part is I get no support from lattice since I'm not a big company looking to buy a bunch of parts. They have an automated email server that tells you they're not going to answer if you email their tech support address.I've also been able to program a MACHX02 chip before just fine, so I know the programmer is good. The only reason I still feel like sticking with it is because a $7 FPGA with a PLL is a pretty good deal. But I'm getting very close to just switching over to xilinx.

author: joshtyler
author_rank: Contributor
timestamp: July 26, 2017, 07:55:37 pm
content: Are you using your own PCBs now or the dev board? If it's a dev board, which?What have you connected to what exactly?

author: bentomo
author_rank: Contributor
timestamp: July 27, 2017, 02:32:00 am
content: Ok, so I'm trying to program the flash on the devboard. My devboard is a Lattice ice40HX8K breakout board.http://www.latticesemi.com/Products/DevelopmentBoardsAndKits/iCE40HX8KBreakoutBoard.aspx1. I broke out the CRESET_B, CDONE, and SCK pins since they aren't broken out already.2. I did not remove the jumper resistors between these signals and the FTDI chip, I assumed this would be alright as I followed a schematic for the iceBlink dev board that has an ice40HX1K with all of the programming pins sharing the bus with the FTDI chip.3. I am powering the board through the USB port, just no D+ and D- on the usb connection.4. I left the jumpers for SPI configuration on and broke out the pins for TDI, TDO, and SS.These are the connections I've made from the HW-USBN-2ARequired for ICE40programmer <-> dev board-------------------------------TDI <-> flash mosiTDO <-> flash misoNOTE: Normally it's TDO Programmer to SDI flash but I verified that this is correct by pulling the TDO pin high and low and seeing the check ID function report 0xFF and 0x00 accordingly(I have also swapped them around during all of my testing just to be on the safe side)TCK <-> sck - I've tried multiple division levels by configuring this pin with diamondPROG <-> SS/CS pin - I also checked the PROGRAMN box in lattice DiamondTRST <-> CRESET_B - This is set to LOW in the custom IO configuration in order to hold the FPGA in reset so it doesn't generate it's own SCKINITN - CDONE - I checked the box in the custom IO for this pin as wellVCC - VCC - 3.3v generated by the dev board and hooked up to the programmers vref pinGND - GNDI came to this configuration by reading through the Lattice programming cable user guide UG48https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjs7bqxtKjVAhUqjlQKHVkWBqUQFggoMAA&url=http%3A%2F%2Fwww.latticesemi.com%2F~%2Fmedia%2FLatticeSemi%2FDocuments%2FUserManuals%2FMQ%2FProgrammingCableUsersGuide.pdf%3Fdocument_id%3D143&usg=AFQjCNEb6UEFHBtfwoe1NbPibiwHfM5rIQI did try a couple variations on these connections but I never got anything except Diamond reporting "CHECK_ID Failed, Expected h16, Actual hFF. Which doesn't exactly tell me what's wrong.I suppose 1 more thing I could try is holding the FTDI chip in RESET or disconnecting the jumper resistors, but I doubt that would do it.

author: joshtyler
author_rank: Contributor
timestamp: July 28, 2017, 02:46:22 pm
content: Excellent - thanks for the detailed information (and yes looking at the Lattice programming cable datasheet you have TDI and TDO the correct way around).It sounds like the most likely culprit is the FTDI chip.According tothis app note (page 9)when in suspend mode (which is what it will enter if nobody talks to it over USB), the "Pull down I/O Pins in USB Suspend" parameter will determine the state of the outputs. If enabled, the pins will be tri-stated with a weak pulldown (good), or disabled the chip will drive the outputs (bad).The datasheet (page 75), shows that the parameter is determined by an EEPROM flag, with the default being disabled.FTDI produce a Windows utility to check (and modify) the contents of the EEPROM, but if you have means to hold the FT2232H in suspend mode, that is an easy fix too, and this guarantees the pins will be tristated with a weak pulldown (as described in the app note linked above).Do you have access to an oscilloscope/logic analyser, as that would help you to figure out what is happening very quickly!

author: bentomo
author_rank: Contributor
timestamp: August 01, 2017, 01:37:27 pm
content: Looks like you were correct Josh, the culprit was indeed the FTDI chip. I pulled the 0 ohm resistors R1 - R6 off the dev board and it's programming just fine now with the clone cable. My connections are as followsRequired for ICE40Remove jumper resistors to tdi chipprogrammer side - board sideTDI - flash mosi (pin 3 of J6 on dev board)TDO - flash miso (pin 2 of J6 on dev board)TCK - sckPROG - SS/CS pin (pin 2 of J7 on dev board)TRST - CRESET_BVCC - VCCGND - GNDjumpers can stay onTRST and PROG must be disconnected when power cycling to program fpgaTDI and TDO are labeled as what to connect to on the clone programmingcable so TDI connects to MOSI and TDO connects to MISOINIT and TMS are not required to be connectedSo my workflow will still require moving a jumper and power cycling to program the board but that's ok with me. Thanks for doing the digging on that Josh.