Hi all.
These are the changes I had to do the flashrom to get my in circuit programer working. Not much as you can see.
Unfortunately it seems to have problems writing to the chip. The first time I tried it it worked well. Writing random data to the chip. But when I then tried to write the bios image. After several tries, adding more capacitors, increasing the bus speed (yes increasing not decreasing) and always erasing the chip before doing a write I got good write. There where a couple of write runs that seems to be get partial success, parts of the bios looked okay while parts where still all FF. Increasing the bus speed seemed to make it write more data.
I have some pictures of the programer here: http://irc.walkyrie.se/coreboot/pictures/
Signed-off-by: Jakob Bornecrantz wallbraker@gmail.com
Cheers Jakob.
Jakob Bornecrantz wrote:
Unfortunately it seems to have problems writing to the chip.
Hm. So would need a lot more debugging added for SPI in flashrom I guess.
I have some pictures of the programer here: http://irc.walkyrie.se/coreboot/pictures/
I suggest shortening all wires as much as possible, signal wires under 3cm, you could make it so that the blue/white deck is upside down when the connector is attached to the board. Ie build wires to the connector straight up, so the connector is above the FTDI chip with solder side towards the chip.
As for the speed, just check that the chip you're driving can go as fast as you want. It might also make sense to use the same speed as the SPI master on the EPIA board, because the EPIA PCB could be optimized for that speed, but all "lower" speeds should work OK, say 10MHz or below..
Keeping the wires short is always important. I had trouble with Macronix flash which was very sensitive to noise on some lines. Only worked properly once I got wire length down.
//Peter
On 27.06.2009 13:43, Jakob Bornecrantz wrote:
These are the changes I had to do the flashrom to get my in circuit programer working. Not much as you can see.
Alternative patch which allows runtime selection of FT2232H/FT4232H and interface A/B.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-ft2232_parameter/flashrom.8 =================================================================== --- flashrom-ft2232_parameter/flashrom.8 (Revision 636) +++ flashrom-ft2232_parameter/flashrom.8 (Arbeitskopie) @@ -183,6 +183,23 @@ Currently the following programmers support this mechanism: .BR nic3com , .BR satasii . +.sp +The ft2232spi has an optional parameter specifying the controller type and +interface/port it should support. For that you have to use the +.B "flashrom -p ft2232spi=model,port=interface" +syntax where +.B model +can be any of +.B 2232H 4232H +and +.B interface +can be any of +.B A +.BR B . +The default model is +.B 4232H +and the default interface is +.BR B . .TP .B "-h, --help" Show a help text and exit. Index: flashrom-ft2232_parameter/flash.h =================================================================== --- flashrom-ft2232_parameter/flash.h (Revision 636) +++ flashrom-ft2232_parameter/flash.h (Arbeitskopie) @@ -368,6 +368,9 @@ extern struct pcidev_status satas_sii[];
/* ft2232_spi.c */ +#define FTDI_FT2232H 0x6010 +#define FTDI_FT4232H 0x6011 +extern char *ft2232spi_param; int ft2232_spi_init(void); int ft2232_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); Index: flashrom-ft2232_parameter/ft2232_spi.c =================================================================== --- flashrom-ft2232_parameter/ft2232_spi.c (Revision 636) +++ flashrom-ft2232_parameter/ft2232_spi.c (Arbeitskopie) @@ -22,9 +22,12 @@ #include <stdint.h> #include <string.h> #include <stdlib.h> +#include <ctype.h> #include "flash.h" #include "spi.h"
+char *ft2232spi_param = NULL; + #if FT2232_SPI_SUPPORT == 1
#include <ftdi.h> @@ -71,24 +74,55 @@ struct ftdi_context *ftdic = &ftdic_context; unsigned char buf[512]; unsigned char port_val = 0; + char *portpos = NULL; + int ft2232_type = FTDI_FT4232H; + enum ftdi_interface ft2232_interface = INTERFACE_B;
- if (ftdi_init(ftdic) < 0) { fprintf(stderr, "ftdi_init failed\n"); return EXIT_FAILURE; }
- // f = ftdi_usb_open(ftdic, 0x0403, 0x6010); // FT2232 - f = ftdi_usb_open(ftdic, 0x0403, 0x6011); // FT4232 + if (ft2232spi_param && !strlen(ft2232spi_param)) { + free(ft2232spi_param); + ft2232spi_param = NULL; + } + if (ft2232spi_param) { + if (strstr(ft2232spi_param, "2232")) + ft2232_type = FTDI_FT2232H; + if (strstr(ft2232spi_param, "4232")) + ft2232_type = FTDI_FT4232H; + portpos = strstr(ft2232spi_param, "port="); + if (portpos) { + portpos += 5; + switch (toupper(*portpos)) { + case 'A': + ft2232_interface = INTERFACE_A; + break; + case 'B': + ft2232_interface = INTERFACE_B; + break; + default: + fprintf(stderr, "Invalid interface specified, " + "using default.\n"); + } + } + } + printf_debug("Using device type %s ", + (ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H"); + printf_debug("interface %s\n", + (ft2232_interface == INTERFACE_A) ? "A" : "B");
+ f = ftdi_usb_open(ftdic, 0x0403, ft2232_type); + if (f < 0 && f != -5) { fprintf(stderr, "Unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdic)); exit(-1); }
- if (ftdi_set_interface(ftdic, INTERFACE_B) < 0) { - fprintf(stderr, "Unable to select FT2232 channel B: %s\n", + if (ftdi_set_interface(ftdic, ft2232_interface) < 0) { + fprintf(stderr, "Unable to select interface: %s\n", ftdic->error_str); }
Index: flashrom-ft2232_parameter/flashrom.c =================================================================== --- flashrom-ft2232_parameter/flashrom.c (Revision 636) +++ flashrom-ft2232_parameter/flashrom.c (Arbeitskopie) @@ -649,6 +649,8 @@ programmer = PROGRAMMER_IT87SPI; } else if (strncmp(optarg, "ft2232spi", 9) == 0) { programmer = PROGRAMMER_FT2232SPI; + if (optarg[9] == '=') + ft2232spi_param = strdup(optarg + 10); } else if (strncmp(optarg, "serprog", 7) == 0) { programmer = PROGRAMMER_SERPROG; if (optarg[7] == '=')
On Mon, Jun 29, 2009 at 2:19 PM, Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net wrote:
On 27.06.2009 13:43, Jakob Bornecrantz wrote:
These are the changes I had to do the flashrom to get my in circuit programer working. Not much as you can see.
Alternative patch which allows runtime selection of FT2232H/FT4232H and interface A/B.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
[SNIP]
Tested it works well.
Acked-by: Jakob Bornecrantz wallbraker@gmail.com Tested-by: Jakob Bornecrantz wallbraker@gmail.com
Cheers Jakob.
On 01.07.2009 01:11, Jakob Bornecrantz wrote:
On Mon, Jun 29, 2009 at 2:19 PM, Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net wrote:
allows runtime selection of FT2232H/FT4232H and interface A/B.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Jakob Bornecrantz wallbraker@gmail.com Tested-by: Jakob Bornecrantz wallbraker@gmail.com
Thanks, committed in r638.
Regards, Carl-Daniel