Welcome, Guest

Author Topic: Can't Flash ice40HX8k-EVB with Raspberry Pi  (Read 1575 times)

Forty-Bot

  • Newbie
  • *
  • Posts: 4
  • Karma: +1/-0
Can't Flash ice40HX8k-EVB with Raspberry Pi
« on: September 20, 2018, 12:43:36 AM »
Previously posted on reddit

I'm trying to program my ice40 HX8K. I am using a pi B+ ver2, which is offered as an alternate programming method on the wiki page for this board. These instructions are for the HX1K, so my connections are different.

Code: [Select]
    GND | GND
    GPIO 25 | iCE40-CRESET
    CE0# | iCE40-SS_B
    MOSI | iCE40-SDO
    MISO | iCE40-SDI
    SCLK | iCE40-SCK

The setup looks like this. I can turn off/on the iCE40-CRESET LED using GPIO25, like in the guide. However, when I try to read the flash contents I get

Code: [Select]
    $ flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=20000 -r dump.bin
    flashrom v0.9.9-r1954 on Linux 4.9.41+ (armv6l)
    flashrom is free software, get the source code at https://flashrom.org
   
    Calibrating delay loop... OK.
    No EEPROM/flash device found.
    Note: flashrom can never write if the flash chip isn't found automatically.

I have checked all my connections, tried switching from CE0# to CE1#, tried switching MISO and MOSI, tried all /dev/spidev?.? devices, tried rewiring to use SPI1 (pins 36-40), tried different baud rates, tried building flashrom from source (instead of using the packaged version), and rebooted. I have also tried powering the board via the raspberry pi, and using a pi rev 3 B. The jumper cables have been checked. I have the spi interface enabled in /boot/config.txt. I first asked on #raspberrypi on freenode, and again on ##electronics, but they were out of ideas. Thanks in advance for any suggestions.
« Last Edit: September 20, 2018, 12:50:30 AM by Forty-Bot »

LubOlimex

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1913
  • Karma: +48/-3
Re: Can't Flash ice40HX8k-EVB with Raspberry Pi
« Reply #1 on: September 20, 2018, 10:23:25 AM »
> These instructions are for the HX1K, so my connections are different.

I don't think your hardware connections should be different. The 1K and 8K boards have nearly identical programming connectors. Compare the programming connector in these PDFs:

https://github.com/OLIMEX/iCE40HX1K-EVB/blob/master/iCE40HX1K-EVB_Rev_B.pdf

https://github.com/OLIMEX/iCE40HX8K-EVB/blob/master/HARDWARE/REV-B/iCE40HX8K-EVB_Rev_B.pdf

Also the original project can be found here: https://github.com/anse1/olimex-ice40-notes
Technical support and documentation manager at Olimex

Forty-Bot

  • Newbie
  • *
  • Posts: 4
  • Karma: +1/-0
Re: Can't Flash ice40HX8k-EVB with Raspberry Pi
« Reply #2 on: September 20, 2018, 08:41:35 PM »
> I don't think your hardware connections should be different. The 1K and 8K boards have nearly identical programming connectors. Compare the programming connector in these PDFs:

Well it's more that the original instructions were for using IDC connectors and I am making the connection with jumper cables, as seen in the picture. Again, I have listed out the connections I made in the code box in the original post. I have checked them against the schematic for the HX8K and the pi.

Forty-Bot

  • Newbie
  • *
  • Posts: 4
  • Karma: +1/-0
Re: Can't Flash ice40HX8k-EVB with Raspberry Pi
« Reply #3 on: January 26, 2019, 11:44:47 PM »
I made another try today and got it working (not sure what changed...)

On the wiki, it is much easier to pad firmware by doing

Code: [Select]
truncate -s 2M image

Instead of remembering those dd incantations

AjgGmd

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: Can't Flash ice40HX8k-EVB with Raspberry Pi
« Reply #4 on: March 13, 2019, 09:49:08 PM »
I gave up on using 32u4 board because my version was 'A'. Changing the port numbers to match did not work plus the port jumped between /dev/ACM0 and /dev/ACM1 on board reset.
I configured a cable and flashrom software for a Pi 3B per the notes at the end of the Linux setup.
The files were modified in the ice40hx1k-evb for the ice40hx8k.evb.

Create an ice40hx8k-evb.pcf with the proper pin numbers:
------------------------
set_io CLK J3
set_io BUT1 K11
set_io BUT2 P13
set_io LED1 M12
set_io LED2 R16

Modify the make file lines to target the 8k device:
PIN_DEF = ice40hx8k-evb.pcf
DEVICE = hx8k

perform the make, leaving you with an example.bin.
The .bin file generation is done my main Ubuntu system.
A Samba share on the Pi was used to transfer the bin to the Pi.

On the Pi side, a readflash and writeflash script were created and made executable with chmod +x <'readflash' | 'writeflash'>

readflash:
echo 24> /sys/class/gpio/export
echo out /sys/class/gpio/gpio24/direction
flashrom  -p linux_spi:dev=/dev/spidev0.0,spispeed=10000 -r f_dump.bin

writeflash <inputBinary outputImageFile>
dd if=/dev/zero ibs=1k count=2k | tr "\000" "\377" > $2
dd if=$1 of=$2 conv=notrunc
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=10000 -w $2
echo in >/sys/class/gpio/gpio24/direction

Note that readflash should be executed at least once before writeflash to setup gpio24.
Or, just copy the first two lines from readflash to writeflash.

I prefer this solution as it has been working reliably. Flashrom is well supported on linux.

AjG