@@ -46,6 +46,12 @@ CologneChip::CologneChip(Jtag* jtag, const std::string &filename,
4646 ftdi_board_name = std::regex_replace (board_name, std::regex (" jtag" ), " spi" );
4747 } else if (cable_name == " gatemate_pgm" ) {
4848 ftdi_board_name = " gatemate_pgm_spi" ;
49+ } else if (cable_name == " dirtyJtag" ) {
50+ _dirtyjtag = reinterpret_cast <DirtyJtag *>(_jtag->_jtag );
51+ _rstn_pin = (1 << 6 );
52+ _done_pin = 0 ;
53+ _fail_pin = 0 ;
54+ _oen_pin = 0 ;
4955 }
5056
5157 if (ftdi_board_name != " " ) {
@@ -84,6 +90,10 @@ void CologneChip::reset()
8490 _ftdi_jtag->gpio_clear (_rstn_pin | _oen_pin);
8591 usleep (SLEEP_US);
8692 _ftdi_jtag->gpio_set (_rstn_pin);
93+ } else if (_dirtyjtag) {
94+ _dirtyjtag->gpio_clear (_rstn_pin);
95+ _dirtyjtag->gpio_set (_rstn_pin);
96+ usleep (SLEEP_US);
8797 }
8898}
8999
@@ -123,10 +133,7 @@ void CologneChip::waitCfgDone()
123133 }
124134}
125135
126- /* *
127- * Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
128- */
129- bool CologneChip::detect_flash ()
136+ bool CologneChip::prepare_flash_access ()
130137{
131138 if (_spi) {
132139 /* enable output and hold reset */
@@ -135,9 +142,37 @@ bool CologneChip::detect_flash()
135142 /* enable output and disable reset */
136143 _ftdi_jtag->gpio_clear (_oen_pin);
137144 _ftdi_jtag->gpio_set (_rstn_pin);
145+ } else if (_dirtyjtag) {
146+ _dirtyjtag->gpio_clear (_rstn_pin);
147+ _dirtyjtag->gpio_set (_rstn_pin);
148+ usleep (SLEEP_US);
138149 }
139150
151+ return true ;
152+ }
153+
154+ bool CologneChip::post_flash_access ()
155+ {
156+ if (_spi) {
157+ /* disable output and release reset */
158+ _spi->gpio_set (_rstn_pin | _oen_pin);
159+ } else if (_ftdi_jtag) {
160+ /* disable output */
161+ _ftdi_jtag->gpio_set (_oen_pin);
162+ }
163+ usleep (SLEEP_US);
164+
165+ return true ;
166+ }
167+
168+ /* *
169+ * Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
170+ */
171+ bool CologneChip::detect_flash ()
172+ {
140173 /* prepare SPI access */
174+ prepare_flash_access ();
175+
141176 printInfo (" Read Flash " , false );
142177 try {
143178 std::unique_ptr<SPIFlash> flash (_spi ?
@@ -151,33 +186,17 @@ bool CologneChip::detect_flash()
151186 return false ;
152187 }
153188
154- if (_spi) {
155- /* disable output and release reset */
156- _spi->gpio_set (_rstn_pin | _oen_pin);
157- } else if (_ftdi_jtag) {
158- /* disable output */
159- _ftdi_jtag->gpio_set (_oen_pin);
160- }
161- usleep (SLEEP_US);
162-
163- return true ;
189+ return post_flash_access ();
164190}
165191
166192/* *
167193 * Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
168194 */
169195bool CologneChip::dumpFlash (uint32_t base_addr, uint32_t len)
170196{
171- if (_spi) {
172- /* enable output and hold reset */
173- _spi->gpio_clear (_rstn_pin | _oen_pin);
174- } else if (_ftdi_jtag) {
175- /* enable output and disable reset */
176- _ftdi_jtag->gpio_clear (_oen_pin);
177- _ftdi_jtag->gpio_set (_rstn_pin);
178- }
179-
180197 /* prepare SPI access */
198+ prepare_flash_access ();
199+
181200 printInfo (" Read Flash " , false );
182201 try {
183202 std::unique_ptr<SPIFlash> flash (_spi ?
@@ -190,16 +209,7 @@ bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
190209 return false ;
191210 }
192211
193- if (_spi) {
194- /* disable output and release reset */
195- _spi->gpio_set (_rstn_pin | _oen_pin);
196- } else if (_ftdi_jtag) {
197- /* disable output */
198- _ftdi_jtag->gpio_set (_oen_pin);
199- }
200- usleep (SLEEP_US);
201-
202- return true ;
212+ return post_flash_access ();
203213}
204214
205215/* *
0 commit comments