make output buffer const
This commit is contained in:
parent
d5c72dcc58
commit
1908ccd83b
|
|
@ -78,7 +78,7 @@ void Altera::reset()
|
||||||
void Altera::programMem(RawParser &_bit)
|
void Altera::programMem(RawParser &_bit)
|
||||||
{
|
{
|
||||||
int byte_length = _bit.getLength()/8;
|
int byte_length = _bit.getLength()/8;
|
||||||
uint8_t *data = _bit.getData();
|
const uint8_t *data = _bit.getData();
|
||||||
|
|
||||||
uint32_t clk_period = 1e9/static_cast<float>(_jtag->getClkFreq());
|
uint32_t clk_period = 1e9/static_cast<float>(_jtag->getClkFreq());
|
||||||
|
|
||||||
|
|
@ -232,7 +232,7 @@ void Altera::program(unsigned int offset, bool unprotect_flash)
|
||||||
reverseOrder = true;
|
reverseOrder = true;
|
||||||
|
|
||||||
/* prepare data to write */
|
/* prepare data to write */
|
||||||
uint8_t *data = NULL;
|
const uint8_t *data = NULL;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
RawParser bit(_filename, reverseOrder);
|
RawParser bit(_filename, reverseOrder);
|
||||||
|
|
@ -266,7 +266,7 @@ int Altera::idCode()
|
||||||
|
|
||||||
/* SPI interface */
|
/* SPI interface */
|
||||||
|
|
||||||
int Altera::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Altera::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
/* +1 because send first cmd + len byte + 1 for rx due to a delay of
|
/* +1 because send first cmd + len byte + 1 for rx due to a delay of
|
||||||
* one bit
|
* one bit
|
||||||
|
|
@ -291,7 +291,7 @@ int Altera::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int Altera::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Altera::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
return spi_put(tx[0], &tx[1], rx, len-1);
|
return spi_put(tx[0], &tx[1], rx, len-1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ class Altera: public Device, SPIInterface {
|
||||||
return SPIInterface::bulk_erase_flash();
|
return SPIInterface::bulk_erase_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose = false) override;
|
uint32_t timeout, bool verbose = false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
|
||||||
if (_verbose)
|
if (_verbose)
|
||||||
bit.displayHeader();
|
bit.displayHeader();
|
||||||
|
|
||||||
uint8_t *data = bit.getData();
|
const uint8_t *data = bit.getData();
|
||||||
int len = bit.getLength() / 8;
|
int len = bit.getLength() / 8;
|
||||||
|
|
||||||
if (_mode == Device::SPI_MODE) {
|
if (_mode == Device::SPI_MODE) {
|
||||||
|
|
@ -110,7 +110,7 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
|
||||||
|
|
||||||
ProgressBar progress("Loading", len, 50, _quiet);
|
ProgressBar progress("Loading", len, 50, _quiet);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
uint8_t *ptr = data;
|
const uint8_t *ptr = data;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
int xfer_len = (len > 512)?512:len;
|
int xfer_len = (len > 512)?512:len;
|
||||||
int tx_end;
|
int tx_end;
|
||||||
|
|
@ -184,7 +184,7 @@ bool Anlogic::prepare_flash_access()
|
||||||
* In write only operations to care about this delay
|
* In write only operations to care about this delay
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Anlogic::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Anlogic::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len + 1;
|
int xfer_len = len + 1;
|
||||||
if (rx)
|
if (rx)
|
||||||
|
|
@ -210,7 +210,7 @@ int Anlogic::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int Anlogic::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Anlogic::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len;
|
int xfer_len = len;
|
||||||
if (rx)
|
if (rx)
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ class Anlogic: public Device, SPIInterface {
|
||||||
return SPIInterface::dump(base_addr, len);
|
return SPIInterface::dump(base_addr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose=false) override;
|
uint32_t timeout, bool verbose=false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,9 @@ int AnlogicBitParser::parse()
|
||||||
for (auto it = blocks.begin(); it != blocks.end(); it++) {
|
for (auto it = blocks.begin(); it != blocks.end(); it++) {
|
||||||
for (size_t xpos = 0; xpos < it->size(); xpos++) {
|
for (size_t xpos = 0; xpos < it->size(); xpos++) {
|
||||||
if (_reverseOrder == true)
|
if (_reverseOrder == true)
|
||||||
_bit_data += reverseByte(((*it)[xpos]));
|
_bit_data.push_back(reverseByte(((*it)[xpos])));
|
||||||
else
|
else
|
||||||
_bit_data += ((*it)[xpos]);
|
_bit_data.push_back((*it)[xpos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bit_length = _bit_data.size() * 8;
|
_bit_length = _bit_data.size() * 8;
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ int AnlogicCable::setClkFreq(uint32_t clkHZ)
|
||||||
return clkHZ;
|
return clkHZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnlogicCable::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int AnlogicCable::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
(void) flush_buffer;
|
(void) flush_buffer;
|
||||||
|
|
||||||
|
|
@ -148,7 +148,7 @@ int AnlogicCable::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
uint8_t mask = (ANLOGICCABLE_TCK_PIN << 4);
|
uint8_t mask = (ANLOGICCABLE_TCK_PIN << 4);
|
||||||
|
|
||||||
int full_len = len;
|
int full_len = len;
|
||||||
uint8_t *tx_ptr = tms;
|
const uint8_t *tx_ptr = tms;
|
||||||
|
|
||||||
while (full_len > 0) {
|
while (full_len > 0) {
|
||||||
/* when len > buffer capacity -> limit to capacity
|
/* when len > buffer capacity -> limit to capacity
|
||||||
|
|
@ -219,13 +219,13 @@ int AnlogicCable::flush()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnlogicCable::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int AnlogicCable::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
uint8_t buf[512];
|
uint8_t buf[512];
|
||||||
uint8_t mask = (ANLOGICCABLE_TCK_PIN << 4);
|
uint8_t mask = (ANLOGICCABLE_TCK_PIN << 4);
|
||||||
|
|
||||||
int full_len = len;
|
int full_len = len;
|
||||||
uint8_t *tx_ptr = tx;
|
const uint8_t *tx_ptr = tx;
|
||||||
uint8_t *rx_ptr = rx;
|
uint8_t *rx_ptr = rx;
|
||||||
|
|
||||||
while (full_len > 0) {
|
while (full_len > 0) {
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ class AnlogicCable : public JtagInterface {
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override;
|
||||||
|
|
||||||
/* TMS */
|
/* TMS */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
/* clk */
|
/* clk */
|
||||||
int toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ CH347Jtag::CH347Jtag(uint32_t clkHZ, int8_t verbose):
|
||||||
}
|
}
|
||||||
libusb_bulk_transfer(dev_handle, CH347JTAG_READ_EP, ibuf, 512,
|
libusb_bulk_transfer(dev_handle, CH347JTAG_READ_EP, ibuf, 512,
|
||||||
&actual_length, CH347JTAG_TIMEOUT);
|
&actual_length, CH347JTAG_TIMEOUT);
|
||||||
setClkFreq(clkHZ);
|
_setClkFreq(clkHZ);
|
||||||
return;
|
return;
|
||||||
usb_release:
|
usb_release:
|
||||||
libusb_release_interface(dev_handle, CH347JTAG_INTF);
|
libusb_release_interface(dev_handle, CH347JTAG_INTF);
|
||||||
|
|
@ -221,7 +221,7 @@ CH347Jtag::~CH347Jtag()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CH347Jtag::setClkFreq(uint32_t clkHZ)
|
int CH347Jtag::_setClkFreq(uint32_t clkHZ)
|
||||||
{
|
{
|
||||||
unsigned i = 0, sl = 2000000;
|
unsigned i = 0, sl = 2000000;
|
||||||
if (clkHZ <= 2000000) {
|
if (clkHZ <= 2000000) {
|
||||||
|
|
@ -244,7 +244,7 @@ int CH347Jtag::setClkFreq(uint32_t clkHZ)
|
||||||
return _clkHZ;
|
return _clkHZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CH347Jtag::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int CH347Jtag::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
(void) flush_buffer;
|
(void) flush_buffer;
|
||||||
|
|
||||||
|
|
@ -307,15 +307,15 @@ int CH347Jtag::toggleClk(uint8_t tms, uint8_t tdi, uint32_t len)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CH347Jtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int CH347Jtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
if (!tx || !len)
|
if (!tx || !len)
|
||||||
return 0;
|
return 0;
|
||||||
unsigned bytes = (len - ((end)?1:0)) / 8;
|
unsigned bytes = (len - ((end)?1:0)) / 8;
|
||||||
unsigned bits = len - bytes * 8;
|
unsigned bits = len - bytes * 8;
|
||||||
uint8_t *rptr = rx;
|
uint8_t *rptr = rx;
|
||||||
uint8_t *tptr = tx;
|
const uint8_t *tptr = tx;
|
||||||
uint8_t *txend = &tx[bytes];
|
const uint8_t *txend = tx + bytes;
|
||||||
uint8_t cmd = (rx) ? CMD_BYTES_WR : CMD_BYTES_WO;
|
uint8_t cmd = (rx) ? CMD_BYTES_WR : CMD_BYTES_WO;
|
||||||
while (tptr < txend) {
|
while (tptr < txend) {
|
||||||
unsigned avail = sizeof(obuf) - 3;
|
unsigned avail = sizeof(obuf) - 3;
|
||||||
|
|
@ -349,7 +349,7 @@ int CH347Jtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
cmd = (rx) ? CMD_BITS_WR : CMD_BITS_WO;
|
cmd = (rx) ? CMD_BITS_WR : CMD_BITS_WO;
|
||||||
uint8_t *ptr = &obuf[3];
|
uint8_t *ptr = &obuf[3];
|
||||||
uint8_t x = 0;
|
uint8_t x = 0;
|
||||||
uint8_t *bptr = &tx[bytes];
|
const uint8_t *bptr = &tx[bytes];
|
||||||
for (unsigned i = 0; i < bits; ++i) {
|
for (unsigned i = 0; i < bits; ++i) {
|
||||||
uint8_t txb = bptr[i >> 3];
|
uint8_t txb = bptr[i >> 3];
|
||||||
uint8_t _tdi = (txb & (1 << (i & 7))) ? SIG_TDI : 0;
|
uint8_t _tdi = (txb & (1 << (i & 7))) ? SIG_TDI : 0;
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ class CH347Jtag : public JtagInterface {
|
||||||
CH347Jtag(uint32_t clkHZ, int8_t verbose);
|
CH347Jtag(uint32_t clkHZ, int8_t verbose);
|
||||||
virtual ~CH347Jtag();
|
virtual ~CH347Jtag();
|
||||||
|
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override { return _setClkFreq(clkHZ); };
|
||||||
|
int _setClkFreq(uint32_t clkHZ);
|
||||||
/* TMS */
|
/* TMS */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
/* clk */
|
/* clk */
|
||||||
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ int CH552_jtag::setClkFreq(uint32_t clkHZ) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CH552_jtag::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int CH552_jtag::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
(void) flush_buffer;
|
(void) flush_buffer;
|
||||||
display("%s %d %d\n", __func__, len, (len/8)+1);
|
display("%s %d %d\n", __func__, len, (len/8)+1);
|
||||||
|
|
@ -172,7 +172,7 @@ int CH552_jtag::flush()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CH552_jtag::writeTDI(uint8_t *tdi, uint8_t *tdo, uint32_t len, bool last)
|
int CH552_jtag::writeTDI(const uint8_t *tdi, uint8_t *tdo, uint32_t len, bool last)
|
||||||
{
|
{
|
||||||
bool rd_mode = (tdo) ? true : false;
|
bool rd_mode = (tdo) ? true : false;
|
||||||
/* 3 possible case :
|
/* 3 possible case :
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ class CH552_jtag : public JtagInterface, private FTDIpp_MPSSE {
|
||||||
uint32_t getClkFreq() override {return FTDIpp_MPSSE::getClkFreq();}
|
uint32_t getClkFreq() override {return FTDIpp_MPSSE::getClkFreq();}
|
||||||
|
|
||||||
/* TMS */
|
/* TMS */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
/* clock */
|
/* clock */
|
||||||
int toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len) override;
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief return internal buffer size (in byte).
|
* \brief return internal buffer size (in byte).
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ int CmsisDAP::setClkFreq(uint32_t clkHZ)
|
||||||
* flush the buffer
|
* flush the buffer
|
||||||
* tms states are written only if max or if flush_buffer set
|
* tms states are written only if max or if flush_buffer set
|
||||||
*/
|
*/
|
||||||
int CmsisDAP::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int CmsisDAP::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
/* nothing to send
|
/* nothing to send
|
||||||
* check if the buffer must be flushed
|
* check if the buffer must be flushed
|
||||||
|
|
@ -349,12 +349,13 @@ int CmsisDAP::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
|
|
||||||
/* 0x14 + number of sequence + seq1 details + tdi + seq2 details + tdi + ...
|
/* 0x14 + number of sequence + seq1 details + tdi + seq2 details + tdi + ...
|
||||||
*/
|
*/
|
||||||
int CmsisDAP::writeJtagSequence(uint8_t tms, uint8_t *tx, uint8_t *rx,
|
int CmsisDAP::writeJtagSequence(uint8_t tms, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len, bool end)
|
uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int real_len = len - (end ? 1 : 0); // full xfer size according to end
|
int real_len = len - (end ? 1 : 0); // full xfer size according to end
|
||||||
uint8_t *rx_ptr = rx, *tx_ptr = tx; // rd & wr ptr
|
uint8_t *rx_ptr = rx;
|
||||||
|
const uint8_t *tx_ptr = tx; // rd & wr ptr
|
||||||
int xfer_byte_len, xfer_bit_len; // size of one sequence
|
int xfer_byte_len, xfer_bit_len; // size of one sequence
|
||||||
// in byte and bit
|
// in byte and bit
|
||||||
int byte_to_read = 0; // for rd operation number of read in one xfer
|
int byte_to_read = 0; // for rd operation number of read in one xfer
|
||||||
|
|
@ -462,7 +463,7 @@ int CmsisDAP::writeJtagSequence(uint8_t tms, uint8_t *tx, uint8_t *rx,
|
||||||
/* send TDI by filling jtag sequence
|
/* send TDI by filling jtag sequence
|
||||||
* tx buffer is considered to be correctly aligned (LSB first)
|
* tx buffer is considered to be correctly aligned (LSB first)
|
||||||
*/
|
*/
|
||||||
int CmsisDAP::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int CmsisDAP::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
return writeJtagSequence(0, tx, rx, len, end);
|
return writeJtagSequence(0, tx, rx, len, end);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class CmsisDAP: public JtagInterface {
|
||||||
* \param[in] flush_buffer: force buffer to be send or not
|
* \param[in] flush_buffer: force buffer to be send or not
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief write and read len bits with optional tms set to 1 if end
|
* \brief write and read len bits with optional tms set to 1 if end
|
||||||
|
|
@ -54,7 +54,7 @@ class CmsisDAP: public JtagInterface {
|
||||||
* \param[in] end: if true tms is set to one with the last tdi bit
|
* \param[in] end: if true tms is set to one with the last tdi bit
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief send a serie of clock cycle with constant TMS and TDI
|
* \brief send a serie of clock cycle with constant TMS and TDI
|
||||||
|
|
@ -95,7 +95,7 @@ class CmsisDAP: public JtagInterface {
|
||||||
uint8_t *rx_buff, int rx_len);
|
uint8_t *rx_buff, int rx_len);
|
||||||
|
|
||||||
void display_info(uint8_t info, uint8_t type);
|
void display_info(uint8_t info, uint8_t type);
|
||||||
int writeJtagSequence(uint8_t tms, uint8_t *tx, uint8_t *rx,
|
int writeJtagSequence(uint8_t tms, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len, bool end);
|
uint32_t len, bool end);
|
||||||
|
|
||||||
bool _verbose; /**< display more message */
|
bool _verbose; /**< display more message */
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ void CologneChip::program(unsigned int offset, bool unprotect_flash)
|
||||||
|
|
||||||
cfg->parse();
|
cfg->parse();
|
||||||
|
|
||||||
uint8_t *data = cfg->getData();
|
const uint8_t *data = cfg->getData();
|
||||||
int length = cfg->getLength() / 8;
|
int length = cfg->getLength() / 8;
|
||||||
|
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
|
|
@ -214,7 +214,7 @@ void CologneChip::program(unsigned int offset, bool unprotect_flash)
|
||||||
* Write configuration into FPGA latches via SPI after active reset.
|
* Write configuration into FPGA latches via SPI after active reset.
|
||||||
* CFG_MD[3:0] must be set to 0x40 (SPI passive).
|
* CFG_MD[3:0] must be set to 0x40 (SPI passive).
|
||||||
*/
|
*/
|
||||||
void CologneChip::programSPI_sram(uint8_t *data, int length)
|
void CologneChip::programSPI_sram(const uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
/* hold device in reset for a moment */
|
/* hold device in reset for a moment */
|
||||||
reset();
|
reset();
|
||||||
|
|
@ -234,7 +234,7 @@ void CologneChip::programSPI_sram(uint8_t *data, int length)
|
||||||
* done, release reset to start FPGA in active SPI mode (load from flash).
|
* done, release reset to start FPGA in active SPI mode (load from flash).
|
||||||
* CFG_MD[3:0] must be set to 0x00 (SPI active).
|
* CFG_MD[3:0] must be set to 0x00 (SPI active).
|
||||||
*/
|
*/
|
||||||
void CologneChip::programSPI_flash(unsigned int offset, uint8_t *data,
|
void CologneChip::programSPI_flash(unsigned int offset, const uint8_t *data,
|
||||||
int length, bool unprotect_flash)
|
int length, bool unprotect_flash)
|
||||||
{
|
{
|
||||||
/* hold device in reset during flash write access */
|
/* hold device in reset during flash write access */
|
||||||
|
|
@ -266,7 +266,7 @@ void CologneChip::programSPI_flash(unsigned int offset, uint8_t *data,
|
||||||
* Write configuration into FPGA latches via JTAG after active reset.
|
* Write configuration into FPGA latches via JTAG after active reset.
|
||||||
* CFG_MD[3:0] must be set to 0xF0 (JTAG).
|
* CFG_MD[3:0] must be set to 0xF0 (JTAG).
|
||||||
*/
|
*/
|
||||||
void CologneChip::programJTAG_sram(uint8_t *data, int length)
|
void CologneChip::programJTAG_sram(const uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
/* hold device in reset for a moment */
|
/* hold device in reset for a moment */
|
||||||
reset();
|
reset();
|
||||||
|
|
@ -303,7 +303,7 @@ void CologneChip::programJTAG_sram(uint8_t *data, int length)
|
||||||
* Write configuration to flash via JTAG-SPI-bypass. The FPGA will not start
|
* Write configuration to flash via JTAG-SPI-bypass. The FPGA will not start
|
||||||
* as it is in JTAG mode with CFG_MD[3:0] set to 0xF0 (JTAG).
|
* as it is in JTAG mode with CFG_MD[3:0] set to 0xF0 (JTAG).
|
||||||
*/
|
*/
|
||||||
void CologneChip::programJTAG_flash(unsigned int offset, uint8_t *data,
|
void CologneChip::programJTAG_flash(unsigned int offset, const uint8_t *data,
|
||||||
int length, bool unprotect_flash)
|
int length, bool unprotect_flash)
|
||||||
{
|
{
|
||||||
/* hold device in reset for a moment */
|
/* hold device in reset for a moment */
|
||||||
|
|
@ -327,7 +327,7 @@ void CologneChip::programJTAG_flash(unsigned int offset, uint8_t *data,
|
||||||
/**
|
/**
|
||||||
* Overrides spi_put() to access SPI components via JTAG-SPI-bypass.
|
* Overrides spi_put() to access SPI components via JTAG-SPI-bypass.
|
||||||
*/
|
*/
|
||||||
int CologneChip::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
int CologneChip::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len + 1;
|
int xfer_len = len + 1;
|
||||||
uint8_t jtx[xfer_len+2];
|
uint8_t jtx[xfer_len+2];
|
||||||
|
|
@ -358,7 +358,7 @@ int CologneChip::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
/**
|
/**
|
||||||
* Overrides spi_put() to access SPI components via JTAG-SPI-bypass.
|
* Overrides spi_put() to access SPI components via JTAG-SPI-bypass.
|
||||||
*/
|
*/
|
||||||
int CologneChip::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int CologneChip::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len;
|
int xfer_len = len;
|
||||||
uint8_t jtx[xfer_len+2];
|
uint8_t jtx[xfer_len+2];
|
||||||
|
|
|
||||||
|
|
@ -48,17 +48,17 @@ class CologneChip: public Device, SPIInterface {
|
||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void programSPI_sram(uint8_t *data, int length);
|
void programSPI_sram(const uint8_t *data, int length);
|
||||||
void programSPI_flash(unsigned int offset, uint8_t *data, int length,
|
void programSPI_flash(unsigned int offset, const uint8_t *data, int length,
|
||||||
bool unprotect_flash);
|
bool unprotect_flash);
|
||||||
void programJTAG_sram(uint8_t *data, int length);
|
void programJTAG_sram(const uint8_t *data, int length);
|
||||||
void programJTAG_flash(unsigned int offset, uint8_t *data, int length,
|
void programJTAG_flash(unsigned int offset, const uint8_t *data, int length,
|
||||||
bool unprotect_flash);
|
bool unprotect_flash);
|
||||||
|
|
||||||
/* spi interface via jtag */
|
/* spi interface via jtag */
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond, uint32_t timeout,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond, uint32_t timeout,
|
||||||
bool verbose=false) override;
|
bool verbose=false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ int CologneChipCfgParser::parse()
|
||||||
std::string val = buffer.substr(0, buffer.find("//"));
|
std::string val = buffer.substr(0, buffer.find("//"));
|
||||||
val.erase(std::remove_if(val.begin(), val.end(), ::isspace), val.end());
|
val.erase(std::remove_if(val.begin(), val.end(), ::isspace), val.end());
|
||||||
if (val != "") {
|
if (val != "") {
|
||||||
_bit_data += std::stol(val, nullptr, 16);
|
_bit_data.push_back(std::stol(val, nullptr, 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bit_length = _bit_data.size() * 8;
|
_bit_length = _bit_data.size() * 8;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class ConfigBitstreamParser {
|
class ConfigBitstreamParser {
|
||||||
|
|
@ -19,7 +20,7 @@ class ConfigBitstreamParser {
|
||||||
bool verbose = false);
|
bool verbose = false);
|
||||||
virtual ~ConfigBitstreamParser();
|
virtual ~ConfigBitstreamParser();
|
||||||
virtual int parse() = 0;
|
virtual int parse() = 0;
|
||||||
uint8_t *getData() {return (uint8_t*)_bit_data.c_str();}
|
const uint8_t *getData() const {return _bit_data.data();}
|
||||||
int getLength() {return _bit_length;}
|
int getLength() {return _bit_length;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,7 +63,7 @@ class ConfigBitstreamParser {
|
||||||
int _bit_length;
|
int _bit_length;
|
||||||
int _file_size;
|
int _file_size;
|
||||||
bool _verbose;
|
bool _verbose;
|
||||||
std::string _bit_data;
|
std::vector<uint8_t> _bit_data;
|
||||||
std::string _raw_data; /**< unprocessed file content */
|
std::string _raw_data; /**< unprocessed file content */
|
||||||
std::map<std::string, std::string> _hdr;
|
std::map<std::string, std::string> _hdr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -435,12 +435,12 @@ int DFU::parseDFUDescriptor(const struct libusb_interface_descriptor *intf,
|
||||||
|
|
||||||
/* abstraction to send/receive to control */
|
/* abstraction to send/receive to control */
|
||||||
int DFU::send(bool out, uint8_t brequest, uint16_t wvalue,
|
int DFU::send(bool out, uint8_t brequest, uint16_t wvalue,
|
||||||
unsigned char *data, uint16_t length)
|
const uint8_t *data, uint16_t length)
|
||||||
{
|
{
|
||||||
uint8_t type = out ? DFU_REQUEST_OUT : DFU_REQUEST_IN;
|
uint8_t type = out ? DFU_REQUEST_OUT : DFU_REQUEST_IN;
|
||||||
int ret = libusb_control_transfer(dev_handle, type,
|
int ret = libusb_control_transfer(dev_handle, type,
|
||||||
brequest, wvalue, curr_intf,
|
brequest, wvalue, curr_intf,
|
||||||
data, length, 5000);
|
const_cast<uint8_t *>(data), length, 5000);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (checkDevicePresent()) {
|
if (checkDevicePresent()) {
|
||||||
/* close device ? */
|
/* close device ? */
|
||||||
|
|
@ -690,7 +690,7 @@ int DFU::download()
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret, ret_val = EXIT_SUCCESS;
|
int ret, ret_val = EXIT_SUCCESS;
|
||||||
uint8_t *buffer, *ptr;
|
const uint8_t *buffer, *ptr;
|
||||||
int size, xfer_len;
|
int size, xfer_len;
|
||||||
int bMaxPacketSize0 = dfu_dev[dev_idx].bMaxPacketSize0;
|
int bMaxPacketSize0 = dfu_dev[dev_idx].bMaxPacketSize0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ class DFU {
|
||||||
* \brief send an IN/OUT request
|
* \brief send an IN/OUT request
|
||||||
*/
|
*/
|
||||||
int send(bool out, uint8_t brequest, uint16_t wvalue,
|
int send(bool out, uint8_t brequest, uint16_t wvalue,
|
||||||
unsigned char *data, uint16_t length);
|
const uint8_t *data, uint16_t length);
|
||||||
/*!
|
/*!
|
||||||
* \brief fill specific DFU structure with extra descriptor
|
* \brief fill specific DFU structure with extra descriptor
|
||||||
* \param[in] intf: interface descriptor with extra area
|
* \param[in] intf: interface descriptor with extra area
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ int DirtyJtag::setClkFreq(uint32_t clkHZ)
|
||||||
return clkHZ;
|
return clkHZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DirtyJtag::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int DirtyJtag::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
(void) flush_buffer;
|
(void) flush_buffer;
|
||||||
int actual_length;
|
int actual_length;
|
||||||
|
|
@ -241,7 +241,7 @@ int DirtyJtag::flush()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DirtyJtag::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int DirtyJtag::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
int actual_length;
|
int actual_length;
|
||||||
uint32_t real_bit_len = len - (end ? 1 : 0);
|
uint32_t real_bit_len = len - (end ? 1 : 0);
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ class DirtyJtag : public JtagInterface {
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override;
|
||||||
|
|
||||||
/* TMS */
|
/* TMS */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
/* clk */
|
/* clk */
|
||||||
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ bool Efinix::prepare_flash_access()
|
||||||
* so to send only a cmd set len to 0 (or omit this param)
|
* so to send only a cmd set len to 0 (or omit this param)
|
||||||
*/
|
*/
|
||||||
int Efinix::spi_put(uint8_t cmd,
|
int Efinix::spi_put(uint8_t cmd,
|
||||||
uint8_t *tx, uint8_t *rx, uint32_t len)
|
const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int kXferLen = len + 1 + ((rx == NULL) ? 0 : 1);
|
int kXferLen = len + 1 + ((rx == NULL) ? 0 : 1);
|
||||||
uint8_t jtx[kXferLen];
|
uint8_t jtx[kXferLen];
|
||||||
|
|
@ -440,7 +440,7 @@ int Efinix::spi_put(uint8_t cmd,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Efinix::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Efinix::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int kXferLen = len + ((rx == NULL) ? 0 : 1);
|
int kXferLen = len + ((rx == NULL) ? 0 : 1);
|
||||||
uint8_t jtx[kXferLen];
|
uint8_t jtx[kXferLen];
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ class Efinix: public Device, SPIInterface {
|
||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose = false) override;
|
uint32_t timeout, bool verbose = false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ int EfinixHexParser::parse()
|
||||||
istringstream lineStream(_raw_data);
|
istringstream lineStream(_raw_data);
|
||||||
|
|
||||||
while (std::getline(lineStream, buffer, '\n')) {
|
while (std::getline(lineStream, buffer, '\n')) {
|
||||||
_bit_data += std::stol(buffer, nullptr, 16);
|
_bit_data.push_back(std::stol(buffer, nullptr, 16));
|
||||||
}
|
}
|
||||||
_bit_length = _bit_data.size() * 8;
|
_bit_length = _bit_data.size() * 8;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ int FsParser::parse()
|
||||||
for (auto &&line : _lstRawData) {
|
for (auto &&line : _lstRawData) {
|
||||||
for (size_t i = 0; i < line.size(); i += 8) {
|
for (size_t i = 0; i < line.size(); i += 8) {
|
||||||
uint8_t data = bitToVal(&line[i], 8);
|
uint8_t data = bitToVal(&line[i], 8);
|
||||||
_bit_data += (_reverseByte) ? reverseByte(data) : data;
|
_bit_data.push_back((_reverseByte) ? reverseByte(data) : data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ int FtdiJtagBitBang::setBitmode(uint8_t mode)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FtdiJtagBitBang::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int FtdiJtagBitBang::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ int FtdiJtagBitBang::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FtdiJtagBitBang::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int FtdiJtagBitBang::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
uint32_t iter;
|
uint32_t iter;
|
||||||
uint32_t xfer_size = (rx) ? _rx_size : _buffer_size;
|
uint32_t xfer_size = (rx) ? _rx_size : _buffer_size;
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ class FtdiJtagBitBang : public JtagInterface, private FTDIpp_MPSSE {
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override;
|
||||||
|
|
||||||
/* TMS */
|
/* TMS */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
|
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ void FtdiJtagMPSSE::config_edge()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FtdiJtagMPSSE::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int FtdiJtagMPSSE::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
(void) flush_buffer;
|
(void) flush_buffer;
|
||||||
display("%s %d %d\n", __func__, len, (len/8)+1);
|
display("%s %d %d\n", __func__, len, (len/8)+1);
|
||||||
|
|
@ -208,7 +208,7 @@ int FtdiJtagMPSSE::flush()
|
||||||
return mpsse_write();
|
return mpsse_write();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FtdiJtagMPSSE::writeTDI(uint8_t *tdi, uint8_t *tdo, uint32_t len, bool last)
|
int FtdiJtagMPSSE::writeTDI(const uint8_t *tdi, uint8_t *tdo, uint32_t len, bool last)
|
||||||
{
|
{
|
||||||
/* 3 possible case :
|
/* 3 possible case :
|
||||||
* - n * 8bits to send -> use byte command
|
* - n * 8bits to send -> use byte command
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ class FtdiJtagMPSSE : public JtagInterface, public FTDIpp_MPSSE {
|
||||||
uint32_t getClkFreq() override {return FTDIpp_MPSSE::getClkFreq();}
|
uint32_t getClkFreq() override {return FTDIpp_MPSSE::getClkFreq();}
|
||||||
|
|
||||||
/* TMS */
|
/* TMS */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
/* clock */
|
/* clock */
|
||||||
int toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len) override;
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief send TMD and TDI and receive tdo bits;
|
* \brief send TMD and TDI and receive tdo bits;
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ int FtdiSpi::ft2232_spi_wr_and_rd(//struct ftdi_spi *spi,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* method spiInterface::spi_put */
|
/* method spiInterface::spi_put */
|
||||||
int FtdiSpi::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
int FtdiSpi::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t xfer_len = len + 1;
|
uint32_t xfer_len = len + 1;
|
||||||
uint8_t jtx[xfer_len];
|
uint8_t jtx[xfer_len];
|
||||||
|
|
@ -252,7 +252,7 @@ int FtdiSpi::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* method spiInterface::spi_put */
|
/* method spiInterface::spi_put */
|
||||||
int FtdiSpi::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int FtdiSpi::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
return ft2232_spi_wr_and_rd(len, tx, rx);
|
return ft2232_spi_wr_and_rd(len, tx, rx);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,9 @@ class FtdiSpi : public FTDIpp_MPSSE, SPIInterface {
|
||||||
const uint8_t *writearr, uint8_t *readarr);
|
const uint8_t *writearr, uint8_t *readarr);
|
||||||
|
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose=false) override;
|
uint32_t timeout, bool verbose=false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,10 +204,10 @@ void Gowin::reset()
|
||||||
|
|
||||||
void Gowin::programFlash()
|
void Gowin::programFlash()
|
||||||
{
|
{
|
||||||
uint8_t *data = _fs->getData();
|
const uint8_t *data = _fs->getData();
|
||||||
int length = _fs->getLength();
|
int length = _fs->getLength();
|
||||||
|
|
||||||
uint8_t *mcu_data = nullptr;
|
const uint8_t *mcu_data = nullptr;
|
||||||
int mcu_length = 0;
|
int mcu_length = 0;
|
||||||
|
|
||||||
if (_mcufw) {
|
if (_mcufw) {
|
||||||
|
|
@ -256,7 +256,7 @@ void Gowin::programFlash()
|
||||||
|
|
||||||
void Gowin::program(unsigned int offset, bool unprotect_flash)
|
void Gowin::program(unsigned int offset, bool unprotect_flash)
|
||||||
{
|
{
|
||||||
uint8_t *data;
|
const uint8_t *data;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (_mode == NONE_MODE || !_fs)
|
if (_mode == NONE_MODE || !_fs)
|
||||||
|
|
@ -518,7 +518,7 @@ bool Gowin::pollFlag(uint32_t mask, uint32_t value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TN653 p. 17-21 */
|
/* TN653 p. 17-21 */
|
||||||
bool Gowin::flashFLASH(uint32_t page, uint8_t *data, int length)
|
bool Gowin::flashFLASH(uint32_t page, const uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
uint8_t tx[4] = {0x4E, 0x31, 0x57, 0x47};
|
uint8_t tx[4] = {0x4E, 0x31, 0x57, 0x47};
|
||||||
uint8_t tmp[4];
|
uint8_t tmp[4];
|
||||||
|
|
@ -630,7 +630,7 @@ bool Gowin::connectJtagToMCU()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TN653 p. 9 */
|
/* TN653 p. 9 */
|
||||||
bool Gowin::flashSRAM(uint8_t *data, int length)
|
bool Gowin::flashSRAM(const uint8_t *data, int length)
|
||||||
{
|
{
|
||||||
int tx_len, tx_end;
|
int tx_len, tx_end;
|
||||||
int byte_length = length / 8;
|
int byte_length = length / 8;
|
||||||
|
|
@ -748,7 +748,7 @@ bool Gowin::eraseSRAM()
|
||||||
_jtag->shiftDR(_wr, _rd, _len); \
|
_jtag->shiftDR(_wr, _rd, _len); \
|
||||||
_jtag->toggleClk(6); } while (0)
|
_jtag->toggleClk(6); } while (0)
|
||||||
|
|
||||||
int Gowin::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Gowin::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
uint8_t jrx[len+1], jtx[len+1];
|
uint8_t jrx[len+1], jtx[len+1];
|
||||||
jtx[0] = cmd;
|
jtx[0] = cmd;
|
||||||
|
|
@ -762,7 +762,7 @@ int Gowin::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Gowin::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Gowin::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
if (is_gw2a) {
|
if (is_gw2a) {
|
||||||
uint8_t jtx[len];
|
uint8_t jtx[len];
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ class Gowin: public Device, SPIInterface {
|
||||||
printError("unprotect flash not supported"); return false;}
|
printError("unprotect flash not supported"); return false;}
|
||||||
virtual bool bulk_erase_flash() override {
|
virtual bool bulk_erase_flash() override {
|
||||||
printError("bulk erase flash not supported"); return false;}
|
printError("bulk erase flash not supported"); return false;}
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose) override;
|
uint32_t timeout, bool verbose) override;
|
||||||
|
|
||||||
|
|
@ -50,8 +50,8 @@ class Gowin: public Device, SPIInterface {
|
||||||
bool pollFlag(uint32_t mask, uint32_t value);
|
bool pollFlag(uint32_t mask, uint32_t value);
|
||||||
bool eraseSRAM();
|
bool eraseSRAM();
|
||||||
bool eraseFLASH();
|
bool eraseFLASH();
|
||||||
bool flashSRAM(uint8_t *data, int length);
|
bool flashSRAM(const uint8_t *data, int length);
|
||||||
bool flashFLASH(uint32_t page, uint8_t *data, int length);
|
bool flashFLASH(uint32_t page, const uint8_t *data, int length);
|
||||||
void displayReadReg(uint32_t dev);
|
void displayReadReg(uint32_t dev);
|
||||||
uint32_t readStatusReg();
|
uint32_t readStatusReg();
|
||||||
uint32_t readUserCode();
|
uint32_t readUserCode();
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ void Ice40::reset()
|
||||||
/* cf. TN1248 (iCE40 Programming and Configuration)
|
/* cf. TN1248 (iCE40 Programming and Configuration)
|
||||||
* Appendix A. SPI Slave Configuration Procedure
|
* Appendix A. SPI Slave Configuration Procedure
|
||||||
*/
|
*/
|
||||||
bool Ice40::program_cram(uint8_t *data, uint32_t length)
|
bool Ice40::program_cram(const uint8_t *data, uint32_t length)
|
||||||
{
|
{
|
||||||
uint32_t timeout = 1000;
|
uint32_t timeout = 1000;
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ bool Ice40::program_cram(uint8_t *data, uint32_t length)
|
||||||
/* load configuration data MSB first
|
/* load configuration data MSB first
|
||||||
*/
|
*/
|
||||||
ProgressBar progress("Loading to CRAM", length, 50, _verbose);
|
ProgressBar progress("Loading to CRAM", length, 50, _verbose);
|
||||||
uint8_t *ptr = data;
|
const uint8_t *ptr = data;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (uint32_t addr = 0; addr < length; addr += size, ptr+=size) {
|
for (uint32_t addr = 0; addr < length; addr += size, ptr+=size) {
|
||||||
size = (addr + 256 > length)?(length-addr) : 256;
|
size = (addr + 256 > length)?(length-addr) : 256;
|
||||||
|
|
@ -127,7 +127,7 @@ void Ice40::program(unsigned int offset, bool unprotect_flash)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *data = bit.getData();
|
const uint8_t *data = bit.getData();
|
||||||
int length = bit.getLength() / 8;
|
int length = bit.getLength() / 8;
|
||||||
|
|
||||||
if (_mode == Device::MEM_MODE) {
|
if (_mode == Device::MEM_MODE) {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class Ice40: public Device, SPIInterface {
|
||||||
~Ice40();
|
~Ice40();
|
||||||
|
|
||||||
void program(unsigned int offset, bool unprotect_flash) override;
|
void program(unsigned int offset, bool unprotect_flash) override;
|
||||||
bool program_cram(uint8_t *data, uint32_t length);
|
bool program_cram(const uint8_t *data, uint32_t length);
|
||||||
bool dumpFlash(uint32_t base_addr, uint32_t len) override;
|
bool dumpFlash(uint32_t base_addr, uint32_t len) override;
|
||||||
bool protect_flash(uint32_t len) override;
|
bool protect_flash(uint32_t len) override;
|
||||||
bool unprotect_flash() override;
|
bool unprotect_flash() override;
|
||||||
|
|
@ -31,12 +31,12 @@ class Ice40: public Device, SPIInterface {
|
||||||
int idCode() override {return 0;}
|
int idCode() override {return 0;}
|
||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override {
|
uint32_t len) override {
|
||||||
(void)cmd; (void)tx; (void)rx; (void)len;
|
(void)cmd; (void)tx; (void)rx; (void)len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override {
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override {
|
||||||
(void)tx; (void)rx; (void)len;
|
(void)tx; (void)rx; (void)len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ Jlink::~Jlink()
|
||||||
libusb_exit(jlink_ctx);
|
libusb_exit(jlink_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Jlink::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int Jlink::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
// empty buffer
|
// empty buffer
|
||||||
// if asked flush
|
// if asked flush
|
||||||
|
|
@ -123,7 +123,7 @@ int Jlink::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Jlink::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int Jlink::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
if (len == 0) // nothing to do
|
if (len == 0) // nothing to do
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -132,7 +132,8 @@ int Jlink::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
|
|
||||||
uint32_t xfer_len = BUF_SIZE * 8; // default to buffer capacity
|
uint32_t xfer_len = BUF_SIZE * 8; // default to buffer capacity
|
||||||
uint8_t tms = (_last_tms) ? 0xff : 0x00; // set tms byte
|
uint8_t tms = (_last_tms) ? 0xff : 0x00; // set tms byte
|
||||||
uint8_t *tx_ptr = tx, *rx_ptr = rx; // use pointer to simplify algo
|
const uint8_t *tx_ptr = tx;
|
||||||
|
uint8_t *rx_ptr = rx; // use pointer to simplify algo
|
||||||
|
|
||||||
/* write by burst */
|
/* write by burst */
|
||||||
for (uint32_t rest = 0; rest < len; rest += xfer_len) {
|
for (uint32_t rest = 0; rest < len; rest += xfer_len) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Jlink: public JtagInterface {
|
||||||
* \param[in] flush_buffer: force buffer to be send or not
|
* \param[in] flush_buffer: force buffer to be send or not
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief write and read len bits with optional tms set to 1 if end
|
* \brief write and read len bits with optional tms set to 1 if end
|
||||||
|
|
@ -54,7 +54,7 @@ class Jlink: public JtagInterface {
|
||||||
* \param[in] end: if true tms is set to one with the last tdi bit
|
* \param[in] end: if true tms is set to one with the last tdi bit
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief access ll_write outer this class / directly receives
|
* \brief access ll_write outer this class / directly receives
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ void Jtag::go_test_logic_reset()
|
||||||
_state = TEST_LOGIC_RESET;
|
_state = TEST_LOGIC_RESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Jtag::read_write(unsigned char *tdi, unsigned char *tdo, int len, char last)
|
int Jtag::read_write(const uint8_t *tdi, unsigned char *tdo, int len, char last)
|
||||||
{
|
{
|
||||||
flushTMS(false);
|
flushTMS(false);
|
||||||
_jtag->writeTDI(tdi, tdo, len, last);
|
_jtag->writeTDI(tdi, tdo, len, last);
|
||||||
|
|
@ -317,7 +317,7 @@ void Jtag::toggleClk(int nb)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Jtag::shiftDR(unsigned char *tdi, unsigned char *tdo, int drlen, int end_state)
|
int Jtag::shiftDR(const uint8_t *tdi, unsigned char *tdo, int drlen, int end_state)
|
||||||
{
|
{
|
||||||
/* get number of devices in the JTAG chain
|
/* get number of devices in the JTAG chain
|
||||||
* after the selected one
|
* after the selected one
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,9 @@ class Jtag {
|
||||||
int end_state = RUN_TEST_IDLE);
|
int end_state = RUN_TEST_IDLE);
|
||||||
int shiftIR(unsigned char tdi, int irlen,
|
int shiftIR(unsigned char tdi, int irlen,
|
||||||
int end_state = RUN_TEST_IDLE);
|
int end_state = RUN_TEST_IDLE);
|
||||||
int shiftDR(unsigned char *tdi, unsigned char *tdo, int drlen,
|
int shiftDR(const uint8_t *tdi, unsigned char *tdo, int drlen,
|
||||||
int end_state = RUN_TEST_IDLE);
|
int end_state = RUN_TEST_IDLE);
|
||||||
int read_write(unsigned char *tdi, unsigned char *tdo, int len, char last);
|
int read_write(const uint8_t *tdi, unsigned char *tdo, int len, char last);
|
||||||
|
|
||||||
void toggleClk(int nb);
|
void toggleClk(int nb);
|
||||||
void go_test_logic_reset();
|
void go_test_logic_reset();
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class JtagInterface {
|
||||||
* \param len: number of bit to send
|
* \param len: number of bit to send
|
||||||
* \return number of bit send/received
|
* \return number of bit send/received
|
||||||
*/
|
*/
|
||||||
virtual int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) = 0;
|
virtual int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief send TDI bits (mainly in shift DR/IR state)
|
* \brief send TDI bits (mainly in shift DR/IR state)
|
||||||
|
|
@ -41,7 +41,7 @@ class JtagInterface {
|
||||||
* but only in shift[i|d]r, if end is false tms remain the same.
|
* but only in shift[i|d]r, if end is false tms remain the same.
|
||||||
* \return number of bit written and/or read
|
* \return number of bit written and/or read
|
||||||
*/
|
*/
|
||||||
virtual int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) = 0;
|
virtual int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) = 0;
|
||||||
/*!
|
/*!
|
||||||
* \brief send TMD and TDI and receive tdo bits;
|
* \brief send TMD and TDI and receive tdo bits;
|
||||||
* \param tms: array of TMS values (used to write)
|
* \param tms: array of TMS values (used to write)
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ bool Lattice::program_mem()
|
||||||
_jtag->set_state(Jtag::RUN_TEST_IDLE);
|
_jtag->set_state(Jtag::RUN_TEST_IDLE);
|
||||||
_jtag->toggleClk(1000);
|
_jtag->toggleClk(1000);
|
||||||
|
|
||||||
uint8_t *data = _bit.getData();
|
const uint8_t *data = _bit.getData();
|
||||||
int length = _bit.getLength()/8;
|
int length = _bit.getLength()/8;
|
||||||
wr_rd(0x7A, NULL, 0, NULL, 0);
|
wr_rd(0x7A, NULL, 0, NULL, 0);
|
||||||
_jtag->set_state(Jtag::RUN_TEST_IDLE);
|
_jtag->set_state(Jtag::RUN_TEST_IDLE);
|
||||||
|
|
@ -1329,7 +1329,7 @@ uint16_t Lattice::getUFMStartPageFromJEDEC(JedParser *_jed, int id)
|
||||||
/* SPI implementation */
|
/* SPI implementation */
|
||||||
/* ------------------ */
|
/* ------------------ */
|
||||||
|
|
||||||
int Lattice::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Lattice::spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len + 1;
|
int xfer_len = len + 1;
|
||||||
uint8_t jtx[xfer_len];
|
uint8_t jtx[xfer_len];
|
||||||
|
|
@ -1355,7 +1355,7 @@ int Lattice::spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lattice::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Lattice::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len;
|
int xfer_len = len;
|
||||||
uint8_t jtx[xfer_len];
|
uint8_t jtx[xfer_len];
|
||||||
|
|
@ -2009,7 +2009,7 @@ bool Lattice::program_pubkey_MachXO3D()
|
||||||
printSuccess("DONE");
|
printSuccess("DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* data = _pk.getData();
|
const uint8_t* data = _pk.getData();
|
||||||
len = _pk.getLength()/8;
|
len = _pk.getLength()/8;
|
||||||
|
|
||||||
if (data[0] == 0x0f && data[1] == 0xf0) {
|
if (data[0] == 0x0f && data[1] == 0xf0) {
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,9 @@ class Lattice: public Device, SPIInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose = false) override;
|
uint32_t timeout, bool verbose = false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ int LibgpiodJtagBitbang::setClkFreq(__attribute__((unused)) uint32_t clkHZ)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LibgpiodJtagBitbang::writeTMS(uint8_t *tms_buf, uint32_t len,
|
int LibgpiodJtagBitbang::writeTMS(const uint8_t *tms_buf, uint32_t len,
|
||||||
__attribute__((unused)) bool flush_buffer)
|
__attribute__((unused)) bool flush_buffer)
|
||||||
{
|
{
|
||||||
int tms;
|
int tms;
|
||||||
|
|
@ -311,7 +311,7 @@ int LibgpiodJtagBitbang::writeTMS(uint8_t *tms_buf, uint32_t len,
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LibgpiodJtagBitbang::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int LibgpiodJtagBitbang::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
int tms = _curr_tms;
|
int tms = _curr_tms;
|
||||||
int tdi = _curr_tdi;
|
int tdi = _curr_tdi;
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ class LibgpiodJtagBitbang : public JtagInterface {
|
||||||
virtual ~LibgpiodJtagBitbang();
|
virtual ~LibgpiodJtagBitbang();
|
||||||
|
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override;
|
||||||
int writeTMS(uint8_t *tms_buf, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms_buf, uint32_t len, bool flush_buffer) override;
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
int toggleClk(uint8_t tms, uint8_t tdo, uint32_t clk_len) override;
|
||||||
|
|
||||||
int get_buffer_size() override { return 0; }
|
int get_buffer_size() override { return 0; }
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ RemoteBitbang_client::~RemoteBitbang_client()
|
||||||
close(_sock);
|
close(_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RemoteBitbang_client::writeTMS(uint8_t *tms, uint32_t len,
|
int RemoteBitbang_client::writeTMS(const uint8_t *tms, uint32_t len,
|
||||||
bool flush_buffer)
|
bool flush_buffer)
|
||||||
{
|
{
|
||||||
// empty buffer
|
// empty buffer
|
||||||
|
|
@ -100,7 +100,7 @@ int RemoteBitbang_client::writeTMS(uint8_t *tms, uint32_t len,
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RemoteBitbang_client::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len,
|
int RemoteBitbang_client::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len,
|
||||||
bool end)
|
bool end)
|
||||||
{
|
{
|
||||||
if (len == 0) // nothing to do
|
if (len == 0) // nothing to do
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class RemoteBitbang_client: public JtagInterface {
|
||||||
* \param[in] flush_buffer: force buffer to be send or not
|
* \param[in] flush_buffer: force buffer to be send or not
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief write and read len bits with optional tms set to 1 if end
|
* \brief write and read len bits with optional tms set to 1 if end
|
||||||
|
|
@ -53,7 +53,7 @@ class RemoteBitbang_client: public JtagInterface {
|
||||||
* \param[in] end: if true tms is set to one with the last tdi bit
|
* \param[in] end: if true tms is set to one with the last tdi bit
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief send a serie of clock cycle with constant TMS and TDI
|
* \brief send a serie of clock cycle with constant TMS and TDI
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ int SPIFlash::sectors_erase(int base_addr, int size)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SPIFlash::write_page(int addr, uint8_t *data, int len)
|
int SPIFlash::write_page(int addr, const uint8_t *data, int len)
|
||||||
{
|
{
|
||||||
uint32_t addr_len;
|
uint32_t addr_len;
|
||||||
uint8_t write_cmd;
|
uint8_t write_cmd;
|
||||||
|
|
@ -340,7 +340,7 @@ bool SPIFlash::dump(const std::string &filename, const int &base_addr,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SPIFlash::erase_and_prog(int base_addr, uint8_t *data, int len)
|
int SPIFlash::erase_and_prog(int base_addr, const uint8_t *data, int len)
|
||||||
{
|
{
|
||||||
if (_jedec_id == 0) {
|
if (_jedec_id == 0) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -435,7 +435,7 @@ int SPIFlash::erase_and_prog(int base_addr, uint8_t *data, int len)
|
||||||
if (sectors_erase(base_addr, len) == -1)
|
if (sectors_erase(base_addr, len) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
uint8_t *ptr = data;
|
const uint8_t *ptr = data;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (int addr = 0; addr < len; addr += size, ptr+=size) {
|
for (int addr = 0; addr < len; addr += size, ptr+=size) {
|
||||||
size = (addr + 256 > len)?(len-addr) : 256;
|
size = (addr + 256 > len)?(len-addr) : 256;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class SPIFlash {
|
||||||
*/
|
*/
|
||||||
int sectors_erase(int base_addr, int len);
|
int sectors_erase(int base_addr, int len);
|
||||||
/* write */
|
/* write */
|
||||||
int write_page(int addr, uint8_t *data, int len);
|
int write_page(int addr, const uint8_t *data, int len);
|
||||||
/* read */
|
/* read */
|
||||||
int read(int base_addr, uint8_t *data, int len);
|
int read(int base_addr, uint8_t *data, int len);
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -79,7 +79,7 @@ class SPIFlash {
|
||||||
bool dump(const std::string &filename, const int &base_addr,
|
bool dump(const std::string &filename, const int &base_addr,
|
||||||
const int &len, int rd_burst = 0);
|
const int &len, int rd_burst = 0);
|
||||||
/* combo flash + erase */
|
/* combo flash + erase */
|
||||||
int erase_and_prog(int base_addr, uint8_t *data, int len);
|
int erase_and_prog(int base_addr, const uint8_t *data, int len);
|
||||||
/*!
|
/*!
|
||||||
* \brief check if area base_addr to base_addr + len match
|
* \brief check if area base_addr to base_addr + len match
|
||||||
* data content
|
* data content
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ bool SPIInterface::bulk_erase_flash()
|
||||||
return post_flash_access() && ret;
|
return post_flash_access() && ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPIInterface::write(uint32_t offset, uint8_t *data, uint32_t len,
|
bool SPIInterface::write(uint32_t offset, const uint8_t *data, uint32_t len,
|
||||||
bool unprotect_flash)
|
bool unprotect_flash)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class SPIInterface {
|
||||||
* \param[in] verbose: verbose level
|
* \param[in] verbose: verbose level
|
||||||
* \return false when something fails
|
* \return false when something fails
|
||||||
*/
|
*/
|
||||||
bool write(uint32_t offset, uint8_t *data, uint32_t len,
|
bool write(uint32_t offset, const uint8_t *data, uint32_t len,
|
||||||
bool unprotect_flash);
|
bool unprotect_flash);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -78,7 +78,7 @@ class SPIInterface {
|
||||||
* to send only a cmd set len to 0
|
* to send only a cmd set len to 0
|
||||||
* \return 0 when success
|
* \return 0 when success
|
||||||
*/
|
*/
|
||||||
virtual int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
virtual int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) = 0;
|
uint32_t len) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -88,7 +88,7 @@ class SPIInterface {
|
||||||
* \param[in] len: number of byte to send/receive
|
* \param[in] len: number of byte to send/receive
|
||||||
* \return 0 when success
|
* \return 0 when success
|
||||||
*/
|
*/
|
||||||
virtual int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) = 0;
|
virtual int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief wait until register content and mask match cond, or timeout
|
* \brief wait until register content and mask match cond, or timeout
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ uint32_t UsbBlaster::getClkFreq()
|
||||||
return ll_driver->getClkFreq();
|
return ll_driver->getClkFreq();
|
||||||
}
|
}
|
||||||
|
|
||||||
int UsbBlaster::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int UsbBlaster::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
@ -138,14 +138,14 @@ int UsbBlaster::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
|
|
||||||
#include "configBitstreamParser.hpp"
|
#include "configBitstreamParser.hpp"
|
||||||
|
|
||||||
int UsbBlaster::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int UsbBlaster::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
uint32_t real_len = (end) ? len -1 : len;
|
uint32_t real_len = (end) ? len -1 : len;
|
||||||
uint32_t nb_byte = real_len >> 3;
|
uint32_t nb_byte = real_len >> 3;
|
||||||
uint32_t nb_bit = (real_len & 0x07);
|
uint32_t nb_bit = (real_len & 0x07);
|
||||||
uint8_t mode = (rx != NULL)? DO_RDWR : DO_WRITE;
|
uint8_t mode = (rx != NULL)? DO_RDWR : DO_WRITE;
|
||||||
|
|
||||||
uint8_t *tx_ptr = tx;
|
const uint8_t *tx_ptr = tx;
|
||||||
uint8_t *rx_ptr = rx;
|
uint8_t *rx_ptr = rx;
|
||||||
|
|
||||||
/* security: send residual
|
/* security: send residual
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,10 @@ class UsbBlaster : public JtagInterface {
|
||||||
* \param flush_buffer force flushing the buffer
|
* \param flush_buffer force flushing the buffer
|
||||||
* \return number of state written
|
* \return number of state written
|
||||||
* */
|
* */
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
|
|
||||||
/* TDI */
|
/* TDI */
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
/*!
|
/*!
|
||||||
* \brief toggle clock with static tms and tdi
|
* \brief toggle clock with static tms and tdi
|
||||||
* \param tms TMS state
|
* \param tms TMS state
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ bool Xilinx::load_bridge()
|
||||||
void Xilinx::program_spi(ConfigBitstreamParser * bit, unsigned int offset,
|
void Xilinx::program_spi(ConfigBitstreamParser * bit, unsigned int offset,
|
||||||
bool unprotect_flash)
|
bool unprotect_flash)
|
||||||
{
|
{
|
||||||
uint8_t *data = bit->getData();
|
const uint8_t *data = bit->getData();
|
||||||
int length = bit->getLength() / 8;
|
int length = bit->getLength() / 8;
|
||||||
SPIInterface::write(offset, data, length, unprotect_flash);
|
SPIInterface::write(offset, data, length, unprotect_flash);
|
||||||
}
|
}
|
||||||
|
|
@ -570,7 +570,7 @@ void Xilinx::program_mem(ConfigBitstreamParser *bitfile)
|
||||||
*/
|
*/
|
||||||
/* GGM: TODO */
|
/* GGM: TODO */
|
||||||
int byte_length = bitfile->getLength() / 8;
|
int byte_length = bitfile->getLength() / 8;
|
||||||
uint8_t *data = bitfile->getData();
|
const uint8_t *data = bitfile->getData();
|
||||||
int tx_len, tx_end;
|
int tx_len, tx_end;
|
||||||
int burst_len = byte_length / 100;
|
int burst_len = byte_length / 100;
|
||||||
|
|
||||||
|
|
@ -727,7 +727,7 @@ bool Xilinx::xc3s_flow_program(ConfigBitstreamParser *bit)
|
||||||
{
|
{
|
||||||
int byte_length = bit->getLength() / 8;
|
int byte_length = bit->getLength() / 8;
|
||||||
int burst_len = byte_length / 100;
|
int burst_len = byte_length / 100;
|
||||||
uint8_t *data = bit->getData();
|
const uint8_t *data = bit->getData();
|
||||||
int tx_len = burst_len * 8, tx_end = Jtag::SHIFT_DR;
|
int tx_len = burst_len * 8, tx_end = Jtag::SHIFT_DR;
|
||||||
ProgressBar progress("Flash SRAM", byte_length, 50, _quiet);
|
ProgressBar progress("Flash SRAM", byte_length, 50, _quiet);
|
||||||
|
|
||||||
|
|
@ -769,8 +769,9 @@ bool Xilinx::xc3s_flow_program(ConfigBitstreamParser *bit)
|
||||||
_jtag->toggleClk(32);
|
_jtag->toggleClk(32);
|
||||||
if (_jtag->shiftIR(BYPASS, _irlen) < 0)
|
if (_jtag->shiftIR(BYPASS, _irlen) < 0)
|
||||||
return false;
|
return false;
|
||||||
data[0] = 0x00;
|
//data[0] = 0x00;
|
||||||
if (_jtag->shiftDR(data, NULL, 1) < 0)
|
uint8_t d = 0;
|
||||||
|
if (_jtag->shiftDR(&d, NULL, 1) < 0)
|
||||||
return false;
|
return false;
|
||||||
_jtag->toggleClk(1);
|
_jtag->toggleClk(1);
|
||||||
|
|
||||||
|
|
@ -1076,7 +1077,7 @@ bool Xilinx::xcf_program(ConfigBitstreamParser *bitfile)
|
||||||
uint8_t tx_buf[4096 / 8];
|
uint8_t tx_buf[4096 / 8];
|
||||||
uint16_t pkt_len =
|
uint16_t pkt_len =
|
||||||
((_jtag->get_target_device_id() == 0x05044093) ? 2048 : 4096) / 8;
|
((_jtag->get_target_device_id() == 0x05044093) ? 2048 : 4096) / 8;
|
||||||
uint8_t *data = bitfile->getData();
|
const uint8_t *data = bitfile->getData();
|
||||||
uint32_t data_len = bitfile->getLength() / 8;
|
uint32_t data_len = bitfile->getLength() / 8;
|
||||||
uint32_t xfer_len, offset = 0;
|
uint32_t xfer_len, offset = 0;
|
||||||
uint32_t addr = 0;
|
uint32_t addr = 0;
|
||||||
|
|
@ -1520,7 +1521,7 @@ bool Xilinx::xc2c_flow_program(JedParser *jed)
|
||||||
* so to send only a cmd set len to 0 (or omit this param)
|
* so to send only a cmd set len to 0 (or omit this param)
|
||||||
*/
|
*/
|
||||||
int Xilinx::spi_put(uint8_t cmd,
|
int Xilinx::spi_put(uint8_t cmd,
|
||||||
uint8_t *tx, uint8_t *rx, uint32_t len)
|
const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len + 1 + ((rx == NULL) ? 0 : 1);
|
int xfer_len = len + 1 + ((rx == NULL) ? 0 : 1);
|
||||||
uint8_t jtx[xfer_len];
|
uint8_t jtx[xfer_len];
|
||||||
|
|
@ -1546,7 +1547,7 @@ int Xilinx::spi_put(uint8_t cmd,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Xilinx::spi_put(uint8_t *tx, uint8_t *rx, uint32_t len)
|
int Xilinx::spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len)
|
||||||
{
|
{
|
||||||
int xfer_len = len + ((rx == NULL) ? 0 : 1);
|
int xfer_len = len + ((rx == NULL) ? 0 : 1);
|
||||||
uint8_t jtx[xfer_len];
|
uint8_t jtx[xfer_len];
|
||||||
|
|
|
||||||
|
|
@ -134,9 +134,9 @@ class Xilinx: public Device, SPIInterface {
|
||||||
bool xc2c_flow_program(JedParser *jed);
|
bool xc2c_flow_program(JedParser *jed);
|
||||||
|
|
||||||
/* spi interface */
|
/* spi interface */
|
||||||
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,
|
||||||
uint32_t len) override;
|
uint32_t len) override;
|
||||||
int spi_put(uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
int spi_put(const uint8_t *tx, uint8_t *rx, uint32_t len) override;
|
||||||
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
int spi_wait(uint8_t cmd, uint8_t mask, uint8_t cond,
|
||||||
uint32_t timeout, bool verbose = false) override;
|
uint32_t timeout, bool verbose = false) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ XVC_client::~XVC_client()
|
||||||
close(_sock);
|
close(_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int XVC_client::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
int XVC_client::writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
{
|
{
|
||||||
// empty buffer
|
// empty buffer
|
||||||
// if asked flush
|
// if asked flush
|
||||||
|
|
@ -121,7 +121,7 @@ int XVC_client::writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int XVC_client::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
int XVC_client::writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
{
|
{
|
||||||
if (len == 0) // nothing to do
|
if (len == 0) // nothing to do
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -130,7 +130,8 @@ int XVC_client::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
|
|
||||||
uint32_t xfer_len = _buffer_size * 8; // default to buffer capacity
|
uint32_t xfer_len = _buffer_size * 8; // default to buffer capacity
|
||||||
uint8_t tms = (_last_tms) ? 0xff : 0x00; // set tms byte
|
uint8_t tms = (_last_tms) ? 0xff : 0x00; // set tms byte
|
||||||
uint8_t *tx_ptr = tx, *rx_ptr = rx; // use pointer to simplify algo
|
const uint8_t *tx_ptr = tx;
|
||||||
|
uint8_t *rx_ptr = rx; // use pointer to simplify algo
|
||||||
|
|
||||||
/* write by burst */
|
/* write by burst */
|
||||||
for (uint32_t rest = 0; rest < len; rest += xfer_len) {
|
for (uint32_t rest = 0; rest < len; rest += xfer_len) {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class XVC_client: public JtagInterface {
|
||||||
* \param[in] flush_buffer: force buffer to be send or not
|
* \param[in] flush_buffer: force buffer to be send or not
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTMS(uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
int writeTMS(const uint8_t *tms, uint32_t len, bool flush_buffer) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief write and read len bits with optional tms set to 1 if end
|
* \brief write and read len bits with optional tms set to 1 if end
|
||||||
|
|
@ -53,7 +53,7 @@ class XVC_client: public JtagInterface {
|
||||||
* \param[in] end: if true tms is set to one with the last tdi bit
|
* \param[in] end: if true tms is set to one with the last tdi bit
|
||||||
* \return <= 0 if something wrong, len otherwise
|
* \return <= 0 if something wrong, len otherwise
|
||||||
*/
|
*/
|
||||||
int writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
int writeTDI(const uint8_t *tx, uint8_t *rx, uint32_t len, bool end) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief send a serie of clock cycle with constant TMS and TDI
|
* \brief send a serie of clock cycle with constant TMS and TDI
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue