colognechip: added a workaround to drive reset pin with DirtyJTAG cable
(requires a recent DirtyJTAG firmware)
This commit is contained in:
parent
3c7324d14d
commit
3cf558ebe2
|
|
@ -46,6 +46,12 @@ CologneChip::CologneChip(Jtag* jtag, const std::string &filename,
|
||||||
ftdi_board_name = std::regex_replace(board_name, std::regex("jtag"), "spi");
|
ftdi_board_name = std::regex_replace(board_name, std::regex("jtag"), "spi");
|
||||||
} else if (cable_name == "gatemate_pgm") {
|
} else if (cable_name == "gatemate_pgm") {
|
||||||
ftdi_board_name = "gatemate_pgm_spi";
|
ftdi_board_name = "gatemate_pgm_spi";
|
||||||
|
} else if (cable_name == "dirtyJtag") {
|
||||||
|
_dirtyjtag = reinterpret_cast<DirtyJtag *>(_jtag->_jtag);
|
||||||
|
_rstn_pin = (1 << 6);
|
||||||
|
_done_pin = 0;
|
||||||
|
_fail_pin = 0;
|
||||||
|
_oen_pin = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ftdi_board_name != "") {
|
if (ftdi_board_name != "") {
|
||||||
|
|
@ -84,6 +90,10 @@ void CologneChip::reset()
|
||||||
_ftdi_jtag->gpio_clear(_rstn_pin | _oen_pin);
|
_ftdi_jtag->gpio_clear(_rstn_pin | _oen_pin);
|
||||||
usleep(SLEEP_US);
|
usleep(SLEEP_US);
|
||||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||||
|
} else if (_dirtyjtag) {
|
||||||
|
_dirtyjtag->gpio_clear(_rstn_pin);
|
||||||
|
_dirtyjtag->gpio_set(_rstn_pin);
|
||||||
|
usleep(SLEEP_US);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,10 +133,7 @@ void CologneChip::waitCfgDone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
bool CologneChip::prepare_flash_access()
|
||||||
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
|
||||||
*/
|
|
||||||
bool CologneChip::detect_flash()
|
|
||||||
{
|
{
|
||||||
if (_spi) {
|
if (_spi) {
|
||||||
/* enable output and hold reset */
|
/* enable output and hold reset */
|
||||||
|
|
@ -135,22 +142,17 @@ bool CologneChip::detect_flash()
|
||||||
/* enable output and disable reset */
|
/* enable output and disable reset */
|
||||||
_ftdi_jtag->gpio_clear(_oen_pin);
|
_ftdi_jtag->gpio_clear(_oen_pin);
|
||||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||||
|
} else if (_dirtyjtag) {
|
||||||
|
_dirtyjtag->gpio_clear(_rstn_pin);
|
||||||
|
_dirtyjtag->gpio_set(_rstn_pin);
|
||||||
|
usleep(SLEEP_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prepare SPI access */
|
return true;
|
||||||
printInfo("Read Flash ", false);
|
}
|
||||||
try {
|
|
||||||
std::unique_ptr<SPIFlash> flash(_spi ?
|
|
||||||
new SPIFlash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose):
|
|
||||||
new SPIFlash(this, false, _verbose));
|
|
||||||
flash->read_id();
|
|
||||||
flash->display_status_reg();
|
|
||||||
} catch (std::exception &e) {
|
|
||||||
printError("Fail");
|
|
||||||
printError(std::string(e.what()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool CologneChip::post_flash_access()
|
||||||
|
{
|
||||||
if (_spi) {
|
if (_spi) {
|
||||||
/* disable output and release reset */
|
/* disable output and release reset */
|
||||||
_spi->gpio_set(_rstn_pin | _oen_pin);
|
_spi->gpio_set(_rstn_pin | _oen_pin);
|
||||||
|
|
@ -166,18 +168,35 @@ bool CologneChip::detect_flash()
|
||||||
/**
|
/**
|
||||||
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
||||||
*/
|
*/
|
||||||
bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
|
bool CologneChip::detect_flash()
|
||||||
{
|
{
|
||||||
if (_spi) {
|
/* prepare SPI access */
|
||||||
/* enable output and hold reset */
|
prepare_flash_access();
|
||||||
_spi->gpio_clear(_rstn_pin | _oen_pin);
|
|
||||||
} else if (_ftdi_jtag) {
|
printInfo("Read Flash ", false);
|
||||||
/* enable output and disable reset */
|
try {
|
||||||
_ftdi_jtag->gpio_clear(_oen_pin);
|
std::unique_ptr<SPIFlash> flash(_spi ?
|
||||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
new SPIFlash(reinterpret_cast<SPIInterface *>(_spi), false, _verbose):
|
||||||
|
new SPIFlash(this, false, _verbose));
|
||||||
|
flash->read_id();
|
||||||
|
flash->display_status_reg();
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
printError("Fail");
|
||||||
|
printError(std::string(e.what()));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return post_flash_access();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
||||||
|
*/
|
||||||
|
bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
|
{
|
||||||
/* prepare SPI access */
|
/* prepare SPI access */
|
||||||
|
prepare_flash_access();
|
||||||
|
|
||||||
printInfo("Read Flash ", false);
|
printInfo("Read Flash ", false);
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<SPIFlash> flash(_spi ?
|
std::unique_ptr<SPIFlash> flash(_spi ?
|
||||||
|
|
@ -190,16 +209,7 @@ bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_spi) {
|
return post_flash_access();
|
||||||
/* disable output and release reset */
|
|
||||||
_spi->gpio_set(_rstn_pin | _oen_pin);
|
|
||||||
} else if (_ftdi_jtag) {
|
|
||||||
/* disable output */
|
|
||||||
_ftdi_jtag->gpio_set(_oen_pin);
|
|
||||||
}
|
|
||||||
usleep(SLEEP_US);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
|
#include "dirtyJtag.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
#include "ftdispi.hpp"
|
#include "ftdispi.hpp"
|
||||||
#include "ftdiJtagMPSSE.hpp"
|
#include "ftdiJtagMPSSE.hpp"
|
||||||
|
|
@ -48,6 +49,10 @@ class CologneChip: public Device, SPIInterface {
|
||||||
uint32_t idCode() override {return 0;}
|
uint32_t idCode() override {return 0;}
|
||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool prepare_flash_access() override;
|
||||||
|
bool post_flash_access() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void programSPI_sram(const uint8_t *data, int length);
|
void programSPI_sram(const uint8_t *data, int length);
|
||||||
void programSPI_flash(unsigned int offset, const uint8_t *data, int length,
|
void programSPI_flash(unsigned int offset, const uint8_t *data, int length,
|
||||||
|
|
@ -65,6 +70,7 @@ class CologneChip: public Device, SPIInterface {
|
||||||
|
|
||||||
FtdiSpi *_spi = NULL;
|
FtdiSpi *_spi = NULL;
|
||||||
FtdiJtagMPSSE *_ftdi_jtag = NULL;
|
FtdiJtagMPSSE *_ftdi_jtag = NULL;
|
||||||
|
DirtyJtag *_dirtyjtag = NULL;
|
||||||
uint16_t _rstn_pin;
|
uint16_t _rstn_pin;
|
||||||
uint16_t _done_pin;
|
uint16_t _done_pin;
|
||||||
uint16_t _fail_pin;
|
uint16_t _fail_pin;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue