<div dir="ltr">Thanks for the feedback Stefan, Trying again :)<div><br></div><div><span style="color:rgb(80,0,80);font-size:12.8000001907349px">Signed-off-by: Reggie McMurtrey <</span><a href="mailto:reggie.mcmurtrey@gmail.com" style="font-size:12.8000001907349px">reggie.mcmurtrey@gmail.com</a><span style="color:rgb(80,0,80);font-size:12.8000001907349px">></span><br></div><div><span style="color:rgb(80,0,80);font-size:12.8000001907349px"><br></span></div><div><div style><font color="#500050"><span style="font-size:12.8000001907349px">---</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> flashrom.8.tmpl | 17 ++++++++++++</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> ft2232_spi.c    | 81 ++++++++++++++++++++++++++++++++++++++++++++-------------</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> 2 files changed, 80 insertions(+), 18 deletions(-)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"><br></span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">index 8b5f98c..40d8d84 100644</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">--- a/flashrom.8.tmpl</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+++ b/flashrom.8.tmpl</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -681,6 +681,23 @@ parameter with the</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> .B "  flashrom \-p ft2232_spi:divisor=div"</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> .sp</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> syntax.</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.sp</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+If the ft2232_spi device has been integrated into a custom board, or you are using a breakout cable</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+like the C232HM cable from FTDI you can control the upper bits of the port ( bits 7-4  ) via the</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.sp</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.B "  flashrom \-p ft2232_spi:gpio_dir=dir,gpio_value=value"</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.sp</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+syntax where</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.B dir</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+is a mask defining the directions of the port's upper bits.  </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.B value</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+is the value of the bits for the port. Only bits defined as outputs with the</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.B dir</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+argument are affected. For example</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+.B gpio_dir=0xf0,gpio_value=0x80 </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+would set the four upper bits of the port as outputs with bit 7 as high, and bits 6 through 4 as </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+low. This could be useful for controlling write protects, muxing options, or other in </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+circuit programming related features.</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> .SS</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> .BR "serprog " programmer</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> A mandatory parameter specifies either a serial</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">diff --git a/ft2232_spi.c b/ft2232_spi.c</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">index 4e23797..75cb772 100644</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">--- a/ft2232_spi.c</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+++ b/ft2232_spi.c</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -93,6 +93,9 @@ const struct dev_entry devs_ft2232spi[] = {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">  */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> static uint8_t cs_bits = 0x08;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> static uint8_t pindir = 0x0b;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+static uint8_t gpio_dir = 0x00;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+static uint8_t gpio_value = 0x00;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+static uint8_t adapter_mask = 0x00;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> static struct ftdi_context ftdic_context;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> static const char *get_ft2232_devicename(int ft2232_vid, int ft2232_type)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -204,10 +207,11 @@ int ft2232_spi_init(void)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                 </span>ft2232_type = AMONTEC_JTAGKEY_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                      </span>channel_count = 2;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                      </span>/* JTAGkey(2) needs to enable its output via Bit4 / GPIOL0</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                       </span>*  value: 0x18  OE=high, CS=high, DI=low, DO=low, SK=low</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                       </span>*    dir: 0x1b  OE=output, CS=output, DI=input, DO=output, SK=output */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                       </span>cs_bits = 0x18;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                  </span>pindir = 0x1b;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                   </span>*  value: 0x10  OE=high, Reserved (CS), Reserved (DI), Reserved (DO), Reserved (SK)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                    </span>*    dir: 0x10  OE=output, Reserved (CS), Reserved (DI), Reserved (DO), Reserved (SK) */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                      </span>gpio_dir = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>gpio_value = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                       </span>adapter_mask = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">            </span>} else if (!strcasecmp(arg, "picotap")) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                     </span>ft2232_vid = GOEPEL_VID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                        </span>ft2232_type = GOEPEL_PICOTAP_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -224,8 +228,9 @@ int ft2232_spi_init(void)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                  </span>/* In its default configuration it is a jtagkey clone */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                        </span>ft2232_type = FTDI_FT2232H_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                 </span>channel_count = 2;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                       </span>cs_bits = 0x18;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                  </span>pindir = 0x1b;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                   </span>gpio_dir = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>gpio_value = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                       </span>adapter_mask = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">            </span>} else if (!strcasecmp(arg, "openmoko")) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                    </span>ft2232_vid = FIC_VID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                   </span>ft2232_type = OPENMOKO_DBGBOARD_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -235,10 +240,11 @@ int ft2232_spi_init(void)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                     </span>ft2232_type = OLIMEX_ARM_OCD_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                       </span>channel_count = 2;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                      </span>/* arm-usb-ocd(-h) has an output buffer that needs to be enabled by pulling ADBUS4 low.</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                  </span>*  value: 0x08  #OE=low, CS=high, DI=low, DO=low, SK=low</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                       </span>*    dir: 0x1b  #OE=output, CS=output, DI=input, DO=output, SK=output */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                      </span>cs_bits = 0x08;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                  </span>pindir = 0x1b;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                   </span>*  value: 0x00  #OE=low, Reserved (CS), Reserved (DI), Reserved (DO), Reserved (SK)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                    </span>*    dir: 0x10  #OE=output, Reserved (CS), Reserved (DI), Reserved (DO), Reserved (SK) */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                     </span>gpio_dir = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>gpio_value = 0x00;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                       </span>adapter_mask = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">            </span>} else if (!strcasecmp(arg, "arm-usb-tiny")) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                        </span>ft2232_vid = OLIMEX_VID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                        </span>ft2232_type = OLIMEX_ARM_TINY_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -248,8 +254,9 @@ int ft2232_spi_init(void)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                 </span>ft2232_type = OLIMEX_ARM_OCD_H_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                     </span>channel_count = 2;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                      </span>/* See arm-usb-ocd */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                    </span>cs_bits = 0x08;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">                  </span>pindir = 0x1b;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                   </span>gpio_dir = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>gpio_value = 0x00;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                       </span>adapter_mask = 0x10;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">            </span>} else if (!strcasecmp(arg, "arm-usb-tiny-h")) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                      </span>ft2232_vid = OLIMEX_VID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">                        </span>ft2232_type = OLIMEX_ARM_TINY_H_PID;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -262,6 +269,38 @@ int ft2232_spi_init(void)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">      </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">       </span>free(arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">     </span>arg = extract_programmer_param("gpio_dir");</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">    </span>if (arg && strlen(arg)) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                </span>unsigned int temp = 0;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">           </span>char *endptr;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">            </span>temp = strtoul(arg, &endptr, 16);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">            </span>if (*endptr || temp > 0xFF) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>msg_perr("Error: Invalid GPIO direction mask \"%s\".\n"</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                              </span> "Valid values are between 0x0 and 0xff (the lower four bits are ignored).\n", arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                   </span>free(arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                       </span>return -2;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">               </span>} else {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>gpio_dir = ((uint32_t) temp & (0xf0 & ~adapter_mask)) | gpio_dir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">        </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">        </span>free(arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">      </span>arg = extract_programmer_param("gpio_value");</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">  </span>if (arg && strlen(arg)) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                </span>unsigned int temp = 0;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">           </span>char *endptr;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">            </span>temp = strtoul(arg, &endptr, 16);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">            </span>if (*endptr || temp > 0xFF) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>msg_perr("Error: Invalid GPIO value mask \"%s\".\n"</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                          </span> "Valid values are between 0x0 and 0xff (the lower four bits are ignored).\n", arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                   </span>free(arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                       </span>return -2;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">               </span>} else {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">                 </span>gpio_value = ((uint32_t) temp & (0xf0 & ~adapter_mask)) | gpio_value;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">            </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">        </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">        </span>free(arg);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">     </span>arg = extract_programmer_param("port");</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">       </span>if (arg) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">              </span>switch (toupper((unsigned char)*arg)) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -391,9 +430,11 @@ int ft2232_spi_init(void)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">   </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">     </span>msg_pdbg("Set data bits\n");</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">   </span>msg_pspew("Value: 0x%02x\n", cs_bits | gpio_value);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">    </span>msg_pspew("Dir: 0x%02x\n", pindir | gpio_dir);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">        </span>buf[0] = SET_BITS_LOW;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">   </span>buf[1] = cs_bits;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">        </span>buf[2] = pindir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre"> </span>buf[1] = cs_bits | gpio_value;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">   </span>buf[2] = pindir | gpio_dir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">     </span>if (send_buf(ftdic, buf, 3)) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">          </span>ret = -8;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">               </span>goto ftdi_err;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -446,9 +487,11 @@ static int ft2232_spi_send_command(struct flashctx *flash,</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">   </span> * operations.</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">  </span> */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">     </span>msg_pspew("Assert CS#\n");</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">     </span>msg_pspew("Value: 0x%02x\n", ~cs_bits & gpio_value);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">       </span>msg_pspew("Dir: 0x%02x\n", pindir | gpio_dir);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">        </span>buf[i++] = SET_BITS_LOW;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre"> </span>buf[i++] = 0 & ~cs_bits; /* assertive */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">     </span>buf[i++] = pindir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">       </span>buf[i++] = ~cs_bits & gpio_value; /* assertive */</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">    </span>buf[i++] = pindir | gpio_dir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre"> </span>if (writecnt) {</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">         </span>buf[i++] = MPSSE_DO_WRITE | MPSSE_WRITE_NEG;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">@@ -487,9 +530,11 @@ static int ft2232_spi_send_command(struct flashctx *flash,</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">     </span>}</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">     </span>msg_pspew("De-assert CS#\n");</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">  </span>msg_pspew("Value: 0x%02x\n", cs_bits | gpio_value);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">    </span>msg_pspew("Dir: 0x%02x\n", pindir | gpio_dir);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">        </span>buf[i++] = SET_BITS_LOW;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre"> </span>buf[i++] = cs_bits;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-<span class="" style="white-space:pre">      </span>buf[i++] = pindir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre">       </span>buf[i++] = cs_bits | gpio_value;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">+<span class="" style="white-space:pre"> </span>buf[i++] = pindir | gpio_dir;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">   </span>ret = send_buf(ftdic, buf, i);</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">  </span>failed |= ret;</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px"> <span class="" style="white-space:pre">  </span>if (ret)</span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">-- </span></font></div><div style><font color="#500050"><span style="font-size:12.8000001907349px">1.9.1</span></font></div><div style="color:rgb(80,0,80);font-size:12.8000001907349px"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 21, 2015 at 4:20 AM, Stefan Tauner <span dir="ltr"><<a href="mailto:stefan.tauner@alumni.tuwien.ac.at" target="_blank">stefan.tauner@alumni.tuwien.ac.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, 20 Feb 2015 18:21:09 -0600<br>
Reggie McMurtrey <<a href="mailto:reggie.mcmurtrey@gmail.com">reggie.mcmurtrey@gmail.com</a>> wrote:<br>
<br>
> This is my first time submitting a patch to a project, so let me know<br>
> if I have done something wrong here.<br>
><br>
><br>
> I commonly use the C232HM cable from FTDI to program various parts of<br>
> boards I design.  This one cable allows me to program SPI, I2C, and<br>
> JTAG parts.  Simply adding some muxes to the design I have a single<br>
> header to attach this cable to.  The patch below allows control of the<br>
> muxes from the GPIOL3-GPIOL0 signals on the cable and disable write<br>
> protection.  I figured other people may like this capability if they<br>
> are using a similar breakout cable of have designed the ft2232 chip<br>
> into their design.<br>
><br>
> Signed-off-by: Reggie McMurtrey <<a href="mailto:reggie.mcmurtrey@gmail.com">reggie.mcmurtrey@gmail.com</a>><br>
><br>
</span><span class="">> @@ -262,6 +269,18 @@ int ft2232_spi_init(void)<br>
>       }<br>
>       free(arg);<br>
><br>
> +     arg = extract_programmer_param("gpio_dir");<br>
> +     if (arg) {<br>
> +             gpio_dir = (strtoul(arg, 0, 16) & (0xf0 & ~adapter_mask)) | gpio_dir;<br>
> +     }<br>
> +     free(arg);<br>
> +<br>
> +     arg = extract_programmer_param("gpio_value");<br>
> +     if (arg) {<br>
> +             gpio_value = (strtoul(arg, 0, 16) & (0xf0 & ~adapter_mask)) | gpio_value;<br>
> +     }<br>
> +     free(arg);<br>
> +<br>
>       arg = extract_programmer_param("port");<br>
>       if (arg) {<br>
>               switch (toupper((unsigned char)*arg)) {<br>
<br>
</span>Hello Reggie,<br>
<br>
thanks for your patch! I had no time to review it in detail but we<br>
definitely want some error/wrong input handling for the parameter<br>
parsing above. There are various similar checks throughout the code<br>
base that you may wanna look at... not all are perfect yet though. If<br>
you have any doubts then please refer to the strtol(3) manpage.<br>
<br>
A more detailed review will follow when that's fixed.<br>
<span class="HOEnZb"><font color="#888888">--<br>
Kind regards/Mit freundlichen Grüßen, Stefan Tauner<br>
</font></span></blockquote></div><br></div>