From patchwork Tue Aug 3 00:51:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis 'GNUtoo' Carikli X-Patchwork-Id: 1512634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.helo=coreboot.org (client-ip=78.46.105.101; helo=coreboot.org; envelope-from=flashrom-bounces@flashrom.org; receiver=) Received: from coreboot.org (coreboot.org [78.46.105.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GdxBj4Jgrz9sS8 for ; Tue, 3 Aug 2021 10:51:08 +1000 (AEST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id B26A310619F3; Tue, 3 Aug 2021 00:51:00 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id C30DA10619C2 for ; Tue, 3 Aug 2021 00:50:45 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by cyberdimension.org (OpenSMTPD) with ESMTP id 76245842 for ; Tue, 3 Aug 2021 00:44:25 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by gnutoo.cyberdimension.org (OpenSMTPD) with ESMTP id d475db09 for ; Tue, 3 Aug 2021 00:44:25 +0000 (UTC) Date: Tue, 3 Aug 2021 02:51:31 +0200 From: Denis 'GNUtoo' Carikli To: flashrom@flashrom.org Message-ID: <20210803025131.245dfba6@primarylaptop.localdomain> MIME-Version: 1.0 Message-ID-Hash: OR4BCDM3DD4TISZFSGYTK4622GP7AYAD X-Message-ID-Hash: OR4BCDM3DD4TISZFSGYTK4622GP7AYAD X-MailFrom: GNUtoo@cyberdimension.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-flashrom.flashrom.org-0; header-match-flashrom.flashrom.org-1; header-match-flashrom.flashrom.org-2; header-match-flashrom.flashrom.org-3; header-match-flashrom.flashrom.org-4; header-match-flashrom.flashrom.org-5; header-match-flashrom.flashrom.org-6; header-match-flashrom.flashrom.org-7; header-match-flashrom.flashrom.org-8; header-match-flashrom.flashrom.org-9; header-match-flashrom.flashrom.org-10; header-match-flashrom.flashrom.org-11; header-match-flashrom.flashrom.org-12; header-match-flashrom.flashrom.org-13; header-match-flashrom.flashrom.org-14; header-match-flashrom.flashrom.org-15; header-match-flashrom.flashrom.org-16; header-match-flashrom.flashrom.org-17; header-match-flashrom.flashrom.org-18; header-match-flashrom.flashrom.org-19; header-match-flashrom.flashrom.org-20; header-match-flashrom.flashrom.org-21; header-match-flashrom.flashrom.org- 22; header-match-flashrom.flashrom.org-23; header-match-flashrom.flashrom.org-24; header-match-flashrom.flashrom.org-25; header-match-flashrom.flashrom.org-26; header-match-flashrom.flashrom.org-27; header-match-flashrom.flashrom.org-28; header-match-flashrom.flashrom.org-29; header-match-flashrom.flashrom.org-30; header-match-flashrom.flashrom.org-31; header-match-flashrom.flashrom.org-32; header-match-flashrom.flashrom.org-33; header-match-flashrom.flashrom.org-34; header-match-flashrom.flashrom.org-35; header-match-flashrom.flashrom.org-36; header-match-flashrom.flashrom.org-37; header-match-flashrom.flashrom.org-38; header-match-flashrom.flashrom.org-39; header-match-flashrom.flashrom.org-40; header-match-flashrom.flashrom.org-41; header-match-flashrom.flashrom.org-42; header-match-flashrom.flashrom.org-43; header-match-flashrom.flashrom.org-44; header-match-flashrom.flashrom.org-45; header-match-flashrom.flashrom.org-46; header-match-flashrom.flashrom.org-47; header-match-flash rom.flashrom.org-48; header-match-flashrom.flashrom.org-49; header-match-flashrom.flashrom.org-50; header-match-flashrom.flashrom.org-51; header-match-flashrom.flashrom.org-52; header-match-flashrom.flashrom.org-53; header-match-flashrom.flashrom.org-54; header-match-flashrom.flashrom.org-55; header-match-flashrom.flashrom.org-56; header-match-flashrom.flashrom.org-57; header-match-flashrom.flashrom.org-58; header-match-flashrom.flashrom.org-59; header-match-flashrom.flashrom.org-60; header-match-flashrom.flashrom.org-61; header-match-flashrom.flashrom.org-62; header-match-flashrom.flashrom.org-63; header-match-flashrom.flashrom.org-64; header-match-flashrom.flashrom.org-65; header-match-flashrom.flashrom.org-66; header-match-flashrom.flashrom.org-67; header-match-flashrom.flashrom.org-68; header-match-flashrom.flashrom.org-69; header-match-flashrom.flashrom.org-70; header-match-flashrom.flashrom.org-71; header-match-flashrom.flashrom.org-72; header-match-flashrom.flashrom.org-73; h eader-match-flashrom.flashrom.org-74; header-match-flashrom.flashrom.org-75; header-match-flashrom.flashrom.org-76; header-match-flashrom.flashrom.org-77; header-match-flashrom.flashrom.org-78; header-match-flashrom.flashrom.org-79; header-match-flashrom.flashrom.org-80; header-match-flashrom.flashrom.org-81; header-match-flashrom.flashrom.org-82; header-match-flashrom.flashrom.org-83; header-match-flashrom.flashrom.org-84; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.4 Precedence: list Subject: [flashrom] More detailed tests with the JTAG-lock-pick Tiny 2 List-Id: flashrom discussion and development mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=flashrom-bounces@flashrom.org X-Spamd-Bar: -- Hi, I've tried to make the Distortec JTAG-lock-pick Tiny 2[1][2] work with flashrom and for some reason it always read the same thing. Back in April there was also a thread about it[0], but not much details were shared about the setup, so since I tried things, I also took the occasion to try to share them here. The JTAG-lock-pick Tiny 2 connector is similar to the one of the Olimex ARM-USB-TINY that is described in the wiki[3]. Even if the connector is the same, there are some differences between both hardware designs: - On the JTAG-lock-pick Tiny 2, VREF and VTARGET are connected together according to its schematics that are in its manual[4]. - Users are supposed to connect a reference voltage to any of these two pins (VREF and VTARGET). - The pins 17 and 19 are not connected (NC) at all. - The JTAG-lock-pick Tiny 2 uses an FTD232HL chip (among with other chips like a CPLD and some chips to isolate the target device from it). I've made the following patch to try to use it: I've connected it in the same way described in the wiki for the Olimex ARM-USB-TINY[3], with wires that are about 10 centimeters, and I've provided 3.3v on VREF/VTARGET. When doing that flashrom always reads 0xff: > ./flashrom -p ft2232_spi:type=JTAG-lock-pick,divisor=131072 --verbose > [...] > Probing for Sanyo unknown Sanyo SPI chip, 0 kB: RDID byte 0 > parity violation. compare_id: id1 0xff, id2 0xffff > Probing for Winbond unknown Winbond (ex Nexcom) SPI chip, 0 kB: RDID > byte 0 parity violation. compare_id: id1 0xff, id2 0xffff > Probing for Generic Variable Size SPI chip, 64 kB: Probing for Generic > unknown SPI chip (RDID), 0 kB: RDID byte 0 parity violation. > compare_id: id1 0xff, id2 0xffff > Probing for Generic unknown SPI chip (REMS), 0 kB: compare_id: > id1 0xff, id2 0xff > No EEPROM/flash device found. > Note: flashrom can never write if the flash chip isn't found > automatically. > Releasing I/Os If instead I remove the power source, flashrom always reads zeros (0x00) instead of ones (0xff). If I go to about 1volt, flashrom still reads 0xff. That device is also supported by openocd and there I managed to use it to reprogram a microcontroller through SWD. With the same connection, on an openmoko debug board (connecting the 3.3v source to VTARGET), I get the following result: > ./flashrom -p ft2232_spi:type=openmoko,divisor=131072 --verbose > Probing for Winbond unknown Winbond (ex Nexcom) SPI chip, 0 kB: > compare_id: id1 0xef, id2 0x4017 > Probing for Generic Variable Size SPI chip, 64 kB: > Probing for Generic unknown SPI chip (RDID), 0 kB: > compare_id: id1 0xef, id2 0x4017 > Probing for Generic unknown SPI chip (REMS), 0 kB: > compare_id: id1 0xef, id2 0x16 > Found Winbond flash chip "W25Q64.V" (8192 kB, SPI). > This chip may contain one-time programmable memory. flashrom cannot > read and may never be able to write it, hence it may not be able to > completely clone the contents of this chip (see man page for > details). > No operations were specified. > Releasing I/Os So something is probably wrong somewhere. Note that in the distribution I use (Parabola i686), the FT232H support seems to be supported in libftdi as when running make in the flashrom source directory I have: > Checking for FTDI support... found. > Checking for FT232H support in libftdi... found. I wonder if there is some easy way to make the JTAG-lock-pick Tiny 2 work, as it is quite small and it also does JTAG and SWD, and it'd probably be more reliable than the Arduino that I use at 3.3v (which also needs a 3.3v power source to run at 3.3v). References: ----------- [0]https://www.mail-archive.com/flashrom@flashrom.org/msg14801.html [1]https://distortec.com/jtag-lock-pick-tiny-2/ [2]https://shop.sysmocom.de/products/jtag-lock-pick-tiny-2 [3]https://www.flashrom.org/FT2232SPI_Programmer#Olimex_ARM-USB-TINY.2F-H_and_ARM-USB-OCD.2F-H [4]https://distortec.com/download/70/ [5]https://ftdichip.com/products/ft232hl/ [6]https://ftdichip.com/wp-content/uploads/2020/07/DS_FT232H.pdf [7]https://www.mail-archive.com/flashrom@flashrom.org/msg14801.html Denis. diff --git a/ft2232_spi.c b/ft2232_spi.c index e32d7f81..d986e0a2 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -38,6 +38,7 @@ #define FTDI_FT2232H_PID 0x6010 #define FTDI_FT4232H_PID 0x6011 #define FTDI_FT232H_PID 0x6014 +#define DISTORTEC_JTAG_LOCK_PICK_TINY_2_PID 0x8220 #define TIAO_TUMPA_PID 0x8a98 #define TIAO_TUMPA_LITE_PID 0x8a99 #define AMONTEC_JTAGKEY_PID 0xCFF8 @@ -66,6 +67,7 @@ static const struct dev_entry devs_ft2232spi[] = { {FTDI_VID, TIAO_TUMPA_PID, OK, "TIAO", "USB Multi-Protocol Adapter"}, {FTDI_VID, TIAO_TUMPA_LITE_PID, OK, "TIAO", "USB Multi-Protocol Adapter Lite"}, {FTDI_VID, AMONTEC_JTAGKEY_PID, OK, "Amontec", "JTAGkey"}, + {FTDI_VID, DISTORTEC_JTAG_LOCK_PICK_TINY_2_PID, OK, "Distortec", "JTAG-lock-pick"}, {GOEPEL_VID, GOEPEL_PICOTAP_PID, OK, "GOEPEL", "PicoTAP"}, {GOOGLE_VID, GOOGLE_SERVO_PID, OK, "Google", "Servo"}, {GOOGLE_VID, GOOGLE_SERVO_V2_PID0, OK, "Google", "Servo V2 Legacy"}, @@ -350,6 +352,13 @@ static int ft2232_spi_init(void) ft2232_vid = GOEPEL_VID; ft2232_type = GOEPEL_PICOTAP_PID; channel_count = 2; + } else if (!strcasecmp(arg, "JTAG-lock-pick")) { + ft2232_type = DISTORTEC_JTAG_LOCK_PICK_TINY_2_PID; + /* It contains an FTD232HL chip. Its datasheet has + * "FT232H SINGLE CHANNEL HI-SPEED USB TO MULTIPURPOSE + * UART/FIFO IC" + */ + channel_count = 1; } else if (!strcasecmp(arg, "tumpa")) { /* Interface A is SPI1, B is SPI2. */ ft2232_type = TIAO_TUMPA_PID;