Compare commits
No commits in common. "3cf558ebe2f878bd598e883d2f7783363efdb172" and "ab8d8fc0d34374d551774eee0d455fe014d259dd" have entirely different histories.
3cf558ebe2
...
ab8d8fc0d3
|
|
@ -46,12 +46,6 @@ CologneChip::CologneChip(Jtag* jtag, const std::string &filename,
|
|||
ftdi_board_name = std::regex_replace(board_name, std::regex("jtag"), "spi");
|
||||
} else if (cable_name == "gatemate_pgm") {
|
||||
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 != "") {
|
||||
|
|
@ -90,10 +84,6 @@ void CologneChip::reset()
|
|||
_ftdi_jtag->gpio_clear(_rstn_pin | _oen_pin);
|
||||
usleep(SLEEP_US);
|
||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||
} else if (_dirtyjtag) {
|
||||
_dirtyjtag->gpio_clear(_rstn_pin);
|
||||
_dirtyjtag->gpio_set(_rstn_pin);
|
||||
usleep(SLEEP_US);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +123,10 @@ 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) {
|
||||
/* enable output and hold reset */
|
||||
|
|
@ -142,17 +135,22 @@ bool CologneChip::prepare_flash_access()
|
|||
/* enable output and disable reset */
|
||||
_ftdi_jtag->gpio_clear(_oen_pin);
|
||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||
} else if (_dirtyjtag) {
|
||||
_dirtyjtag->gpio_clear(_rstn_pin);
|
||||
_dirtyjtag->gpio_set(_rstn_pin);
|
||||
usleep(SLEEP_US);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/* prepare SPI access */
|
||||
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) {
|
||||
/* disable output and release reset */
|
||||
_spi->gpio_set(_rstn_pin | _oen_pin);
|
||||
|
|
@ -165,38 +163,21 @@ bool CologneChip::post_flash_access()
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump flash contents to file. Works in both SPI and JTAG-SPI-bypass mode.
|
||||
*/
|
||||
bool CologneChip::detect_flash()
|
||||
{
|
||||
/* prepare SPI access */
|
||||
prepare_flash_access();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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_flash_access();
|
||||
if (_spi) {
|
||||
/* enable output and hold reset */
|
||||
_spi->gpio_clear(_rstn_pin | _oen_pin);
|
||||
} else if (_ftdi_jtag) {
|
||||
/* enable output and disable reset */
|
||||
_ftdi_jtag->gpio_clear(_oen_pin);
|
||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||
}
|
||||
|
||||
/* prepare SPI access */
|
||||
printInfo("Read Flash ", false);
|
||||
try {
|
||||
std::unique_ptr<SPIFlash> flash(_spi ?
|
||||
|
|
@ -209,7 +190,16 @@ bool CologneChip::dumpFlash(uint32_t base_addr, uint32_t len)
|
|||
return false;
|
||||
}
|
||||
|
||||
return post_flash_access();
|
||||
if (_spi) {
|
||||
/* 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,7 +12,6 @@
|
|||
#include <string>
|
||||
|
||||
#include "device.hpp"
|
||||
#include "dirtyJtag.hpp"
|
||||
#include "jtag.hpp"
|
||||
#include "ftdispi.hpp"
|
||||
#include "ftdiJtagMPSSE.hpp"
|
||||
|
|
@ -49,10 +48,6 @@ class CologneChip: public Device, SPIInterface {
|
|||
uint32_t idCode() override {return 0;}
|
||||
void reset() override;
|
||||
|
||||
protected:
|
||||
bool prepare_flash_access() override;
|
||||
bool post_flash_access() override;
|
||||
|
||||
private:
|
||||
void programSPI_sram(const uint8_t *data, int length);
|
||||
void programSPI_flash(unsigned int offset, const uint8_t *data, int length,
|
||||
|
|
@ -70,7 +65,6 @@ class CologneChip: public Device, SPIInterface {
|
|||
|
||||
FtdiSpi *_spi = NULL;
|
||||
FtdiJtagMPSSE *_ftdi_jtag = NULL;
|
||||
DirtyJtag *_dirtyjtag = NULL;
|
||||
uint16_t _rstn_pin;
|
||||
uint16_t _done_pin;
|
||||
uint16_t _fail_pin;
|
||||
|
|
|
|||
|
|
@ -54,12 +54,10 @@ static version_specific v_options[4] ={{0, 240}, {0, 240}, {NO_READ, 496},
|
|||
|
||||
|
||||
enum dirtyJtagSig {
|
||||
SIG_TCK = (1 << 1),
|
||||
SIG_TDI = (1 << 2),
|
||||
SIG_TDO = (1 << 3),
|
||||
SIG_TMS = (1 << 4),
|
||||
SIG_TRST = (1 << 5),
|
||||
SIG_SRST = (1 << 6)
|
||||
SIG_TCK = (1 << 1),
|
||||
SIG_TDI = (1 << 2),
|
||||
SIG_TDO = (1 << 3),
|
||||
SIG_TMS = (1 << 4)
|
||||
};
|
||||
|
||||
DirtyJtag::DirtyJtag(uint32_t clkHZ, int8_t verbose):
|
||||
|
|
@ -386,56 +384,3 @@ int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
|||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* GPIOs */
|
||||
/* Read GPIOs */
|
||||
uint8_t DirtyJtag::gpio_get()
|
||||
{
|
||||
int actual_length;
|
||||
uint8_t sig;
|
||||
uint8_t buf[] = {CMD_GETSIG, CMD_STOP};
|
||||
if (libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP, buf, sizeof(buf),
|
||||
&actual_length, DIRTYJTAG_TIMEOUT) < 0) {
|
||||
printError("writeTDI: last bit error: usb bulk write failed 1");
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
|
||||
do {
|
||||
if (libusb_bulk_transfer(dev_handle, DIRTYJTAG_READ_EP, &sig, 1,
|
||||
&actual_length, DIRTYJTAG_TIMEOUT) < 0) {
|
||||
printError("writeTDI: last bit error: usb bulk read failed");
|
||||
return -EXIT_FAILURE;
|
||||
}
|
||||
} while (actual_length == 0);
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
bool DirtyJtag::_set_gpio_level(uint8_t gpio, uint8_t val)
|
||||
{
|
||||
int actual_length;
|
||||
uint8_t buf[] = {
|
||||
CMD_SETSIG,
|
||||
static_cast<uint8_t>(gpio), // mask
|
||||
static_cast<uint8_t>(val), // bit set
|
||||
CMD_STOP,
|
||||
};
|
||||
if (libusb_bulk_transfer(dev_handle, DIRTYJTAG_WRITE_EP, buf, 4,
|
||||
&actual_length, DIRTYJTAG_TIMEOUT) < 0) {
|
||||
printError("GPIO set: usb bulk write failed 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* update selected gpio */
|
||||
bool DirtyJtag::gpio_set(uint8_t gpio)
|
||||
{
|
||||
return _set_gpio_level(gpio, gpio);
|
||||
}
|
||||
|
||||
bool DirtyJtag::gpio_clear(uint8_t gpio)
|
||||
{
|
||||
return _set_gpio_level(gpio, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,21 +42,12 @@ class DirtyJtag : public JtagInterface {
|
|||
|
||||
int flush() override;
|
||||
|
||||
/* access gpio */
|
||||
/* read gpio */
|
||||
uint8_t gpio_get();
|
||||
/* update selected gpio */
|
||||
bool gpio_set(uint8_t gpio);
|
||||
bool gpio_clear(uint8_t gpio);
|
||||
|
||||
private:
|
||||
int8_t _verbose;
|
||||
|
||||
int sendBitBang(uint8_t mask, uint8_t val, uint8_t *read, bool last);
|
||||
bool getVersion();
|
||||
|
||||
bool _set_gpio_level(uint8_t gpio, uint8_t val);
|
||||
|
||||
libusb_device_handle *dev_handle;
|
||||
libusb_context *usb_ctx;
|
||||
uint8_t _tdi;
|
||||
|
|
|
|||
Loading…
Reference in New Issue