Make IDCODE unsigned

This commit is contained in:
Alexey Starikovskiy 2023-08-10 13:50:26 +03:00
parent 8976404b78
commit 0f3afbcaea
19 changed files with 34 additions and 34 deletions

View File

@ -250,7 +250,7 @@ void Altera::program(unsigned int offset, bool unprotect_flash)
}
}
int Altera::idCode()
uint32_t Altera::idCode()
{
unsigned char tx_data[4] = {IDCODE};
unsigned char rx_data[4];

View File

@ -39,7 +39,7 @@ class Altera: public Device, SPIInterface {
return SPIInterface::dump(base_addr, len);
}
int idCode() override;
uint32_t idCode() override;
void reset() override;
/*************************/

View File

@ -113,11 +113,7 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
const uint8_t *ptr = data;
while (len > 0) {
int xfer_len = (len > 512)?512:len;
Jtag::tapState_t tx_end;
if (len - xfer_len == 0)
tx_end = Jtag::RUN_TEST_IDLE;
else
tx_end = Jtag::SHIFT_DR;
Jtag::tapState_t tx_end = (len - xfer_len) ? Jtag::SHIFT_DR : Jtag::RUN_TEST_IDLE;
_jtag->shiftDR(ptr, NULL, xfer_len * 8, tx_end);
len -= xfer_len;
progress.display(pos);
@ -143,7 +139,7 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
}
}
int Anlogic::idCode()
uint32_t Anlogic::idCode()
{
unsigned char tx_data[4];
unsigned char rx_data[4];

View File

@ -22,7 +22,7 @@ class Anlogic: public Device, SPIInterface {
~Anlogic();
void program(unsigned int offset, bool unprotect_flash) override;
int idCode() override;
uint32_t idCode() override;
void reset() override;
/* spi interface */

View File

@ -44,7 +44,7 @@ class CologneChip: public Device, SPIInterface {
printError("bulk erase flash not supported"); return false;}
void program(unsigned int offset, bool unprotect_flash) override;
int idCode() override {return 0;}
uint32_t idCode() override {return 0;}
void reset() override;
private:

View File

@ -50,7 +50,7 @@ class Device {
virtual bool unprotect_flash() = 0;
virtual bool bulk_erase_flash() = 0;
virtual int idCode() = 0;
virtual uint32_t idCode() = 0;
virtual void reset();
virtual bool connectJtagToMCU() {return false;}

View File

@ -37,7 +37,7 @@ class Efinix: public Device, SPIInterface {
bool bulk_erase_flash() override {
printError("bulk erase flash not supported"); return false;}
/* not supported in SPI Active mode */
int idCode() override {return 0;}
uint32_t idCode() override {return 0;}
void reset() override;
/* spi interface */

View File

@ -400,7 +400,7 @@ bool Gowin::DisableCfg()
return pollFlag(STATUS_SYSTEM_EDIT_MODE, 0);
}
int Gowin::idCode()
uint32_t Gowin::idCode()
{
uint8_t device_id[4];
wr_rd(READ_IDCODE, NULL, 0, device_id, 4);

View File

@ -22,7 +22,7 @@ class Gowin: public Device, SPIInterface {
Device::prog_type_t prg_type, bool external_flash,
bool verify, int8_t verbose);
~Gowin();
int idCode() override;
uint32_t idCode() override;
void reset() override;
void program(unsigned int offset, bool unprotect_flash) override;
void programFlash();

View File

@ -28,7 +28,7 @@ class Ice40: public Device, SPIInterface {
bool unprotect_flash() override;
bool bulk_erase_flash() override;
/* not supported in SPI Active mode */
int idCode() override {return 0;}
uint32_t idCode() override {return 0;}
void reset() override;
int spi_put(uint8_t cmd, const uint8_t *tx, uint8_t *rx,

View File

@ -440,7 +440,7 @@ int Jtag::shiftIR(unsigned char *tdi, unsigned char *tdo, int irlen, tapState_t
return 0;
}
void Jtag::set_state(int newState)
void Jtag::set_state(tapState_t newState)
{
unsigned char tms = 0;
while (newState != _state) {
@ -621,6 +621,9 @@ void Jtag::set_state(int newState)
_state = SELECT_DR_SCAN;
}
break;
case UNKNOWN:;
// UNKNOWN should not be valid...
throw std::exception();
}
setTMS(tms);

View File

@ -67,6 +67,7 @@ class Jtag {
* \return a pointer instance of JtagInterface
*/
JtagInterface *get_ll_class() {return _jtag;}
enum tapState_t {
TEST_LOGIC_RESET = 0,
RUN_TEST_IDLE = 1,
@ -88,16 +89,16 @@ class Jtag {
};
int shiftIR(unsigned char *tdi, unsigned char *tdo, int irlen,
Jtag::tapState_t end_state = RUN_TEST_IDLE);
tapState_t end_state = RUN_TEST_IDLE);
int shiftIR(unsigned char tdi, int irlen,
Jtag::tapState_t end_state = RUN_TEST_IDLE);
tapState_t end_state = RUN_TEST_IDLE);
int shiftDR(const uint8_t *tdi, unsigned char *tdo, int drlen,
Jtag::tapState_t end_state = RUN_TEST_IDLE);
tapState_t end_state = RUN_TEST_IDLE);
int read_write(const uint8_t *tdi, unsigned char *tdo, int len, char last);
void toggleClk(int nb);
void go_test_logic_reset();
void set_state(int newState);
void set_state(tapState_t newState);
int flushTMS(bool flush_buffer = false);
void flush() {flushTMS(); _jtag->flush();}
void setTMS(unsigned char tms);
@ -119,7 +120,7 @@ class Jtag {
*/
bool search_and_insert_device_with_idcode(uint32_t idcode);
bool _verbose;
int _state;
tapState_t _state;
int _tms_buffer_size;
int _num_tms;
unsigned char *_tms_buffer;

View File

@ -843,7 +843,7 @@ bool Lattice::DisableCfg()
return true;
}
int Lattice::idCode()
uint32_t Lattice::idCode()
{
uint8_t device_id[4];
wr_rd(READ_DEVICE_ID_CODE, NULL, 0, device_id, 4);
@ -1308,7 +1308,7 @@ uint16_t Lattice::getUFMStartPageFromJEDEC(JedParser *_jed, int id)
addres.
TODO: In any case, JEDEC files don't carry part information. Verify against
IDCODE read previously? */
if(raw_page_offset > 9211) {
return raw_page_offset - 9211 - 1; // 7000
} else if(raw_page_offset > 5758) {

View File

@ -23,7 +23,7 @@ class Lattice: public Device, SPIInterface {
Lattice(Jtag *jtag, std::string filename, const std::string &file_type,
Device::prog_type_t prg_type, std::string flash_sector, bool verify,
int8_t verbose);
int idCode() override;
uint32_t idCode() override;
int userCode();
void reset() override {}
void program(unsigned int offset, bool unprotect_flash) override;

View File

@ -115,7 +115,7 @@ int main(int argc, char **argv)
/* index_chain file_size target_flash external_flash altsetting */
-1, 0, "primary", false, -1,
/* vid, pid, index bus_addr, device_addr */
0, 0, -1, 0, 0,
0, 0, -1, 0, 0,
"127.0.0.1", 0, false, false, "", false, false,
/* xvc server */
false, 3721, "-",
@ -533,7 +533,7 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
}
/* check if selected device is supported
/* check if selected device is supported
* mainly used in conjunction with --index-chain
*/
if (fpga_list.find(idcode) == fpga_list.end()) {

View File

@ -217,12 +217,12 @@ void SVF_jtag::parse_runtest(vector<string> const &vstr)
end_state = fsm_state[*res];
}
if (run_state != -1) {
_run_state = run_state;
_run_state = (Jtag::tapState_t)run_state;
}
if (end_state != -1) {
_end_state = end_state;
_end_state = (Jtag::tapState_t)end_state;
} else if (run_state != -1) {
_end_state = run_state;
_end_state = (Jtag::tapState_t)run_state;
}
_jtag->set_state(_run_state);
_jtag->toggleClk(nb_iter);
@ -336,7 +336,7 @@ void SVF_jtag::handle_instruction(vector<string> const &vstr)
SVF_jtag::SVF_jtag(Jtag *jtag, bool verbose):_verbose(verbose), _freq_hz(0),
_enddr((Jtag::tapState_t)fsm_state["IDLE"]), _endir((Jtag::tapState_t)fsm_state["IDLE"]),
_run_state(fsm_state["IDLE"]), _end_state(fsm_state["IDLE"])
_run_state((Jtag::tapState_t)fsm_state["IDLE"]), _end_state((Jtag::tapState_t)fsm_state["IDLE"])
{
_jtag = jtag;

View File

@ -60,8 +60,8 @@ class SVF_jtag {
uint32_t _freq_hz;
Jtag::tapState_t _enddr;
Jtag::tapState_t _endir;
int _run_state;
int _end_state;
Jtag::tapState_t _run_state;
Jtag::tapState_t _end_state;
svf_XYR hdr;
svf_XYR hir;
svf_XYR sdr;

View File

@ -330,7 +330,7 @@ void Xilinx::reset()
_jtag->toggleClk(2000);
}
int Xilinx::idCode()
uint32_t Xilinx::idCode()
{
int id = 0;
unsigned char tx_data[4]= {0x00, 0x00, 0x00, 0x00};

View File

@ -46,7 +46,7 @@ class Xilinx: public Device, SPIInterface {
*/
bool bulk_erase_flash() override;
int idCode() override;
uint32_t idCode() override;
void reset() override;
/* -------------- */