Merge pull request #269 from phdussud/master
Removed the svf programming code from devices and added device independent svf programming
This commit is contained in:
commit
abf6fe35c1
|
|
@ -31,7 +31,7 @@ Altera::Altera(Jtag *jtag, const std::string &filename,
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
|
SPIInterface(filename, verbose, 256, verify, skip_load_bridge,
|
||||||
skip_reset),
|
skip_reset),
|
||||||
_svf(_jtag, _verbose), _device_package(device_package),
|
_device_package(device_package),
|
||||||
_vir_addr(0x1000), _vir_length(14)
|
_vir_addr(0x1000), _vir_length(14)
|
||||||
{
|
{
|
||||||
if (prg_type == Device::RD_FLASH) {
|
if (prg_type == Device::RD_FLASH) {
|
||||||
|
|
@ -216,13 +216,9 @@ void Altera::program(unsigned int offset, bool unprotect_flash)
|
||||||
*/
|
*/
|
||||||
/* mem mode -> svf */
|
/* mem mode -> svf */
|
||||||
if (_mode == Device::MEM_MODE) {
|
if (_mode == Device::MEM_MODE) {
|
||||||
if (_file_extension == "svf") {
|
|
||||||
_svf.parse(_filename);
|
|
||||||
} else {
|
|
||||||
RawParser _bit(_filename, false);
|
RawParser _bit(_filename, false);
|
||||||
_bit.parse();
|
_bit.parse();
|
||||||
programMem(_bit);
|
programMem(_bit);
|
||||||
}
|
|
||||||
} else if (_mode == Device::SPI_MODE) {
|
} else if (_mode == Device::SPI_MODE) {
|
||||||
// reverse only bitstream raw binaries data no
|
// reverse only bitstream raw binaries data no
|
||||||
bool reverseOrder = false;
|
bool reverseOrder = false;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,6 @@ class Altera: public Device, SPIInterface {
|
||||||
void shiftVDR(uint8_t * tx, uint8_t * rx, uint32_t len,
|
void shiftVDR(uint8_t * tx, uint8_t * rx, uint32_t len,
|
||||||
int end_state = Jtag::UPDATE_DR, bool debug = false);
|
int end_state = Jtag::UPDATE_DR, bool debug = false);
|
||||||
|
|
||||||
SVF_jtag _svf;
|
|
||||||
std::string _device_package;
|
std::string _device_package;
|
||||||
uint32_t _vir_addr; /**< addr affected to virtual jtag */
|
uint32_t _vir_addr; /**< addr affected to virtual jtag */
|
||||||
uint32_t _vir_length; /**< length of virtual jtag IR */
|
uint32_t _vir_length; /**< length of virtual jtag IR */
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ Anlogic::Anlogic(Jtag *jtag, const std::string &filename,
|
||||||
const std::string &file_type,
|
const std::string &file_type,
|
||||||
Device::prog_type_t prg_type, bool verify, int8_t verbose):
|
Device::prog_type_t prg_type, bool verify, int8_t verbose):
|
||||||
Device(jtag, filename, file_type, verify, verbose),
|
Device(jtag, filename, file_type, verify, verbose),
|
||||||
SPIInterface(filename, verbose, 0, verify), _svf(_jtag, _verbose)
|
SPIInterface(filename, verbose, 0, verify)
|
||||||
{
|
{
|
||||||
if (prg_type == Device::RD_FLASH) {
|
if (prg_type == Device::RD_FLASH) {
|
||||||
_mode = Device::READ_MODE;
|
_mode = Device::READ_MODE;
|
||||||
|
|
@ -64,11 +64,6 @@ void Anlogic::program(unsigned int offset, bool unprotect_flash)
|
||||||
if (_mode == Device::NONE_MODE)
|
if (_mode == Device::NONE_MODE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_file_extension == "svf") {
|
|
||||||
_svf.parse(_filename);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnlogicBitParser bit(_filename, (_mode == Device::MEM_MODE), _verbose);
|
AnlogicBitParser bit(_filename, (_mode == Device::MEM_MODE), _verbose);
|
||||||
|
|
||||||
printInfo("Parse file ", false);
|
printInfo("Parse file ", false);
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,6 @@ class Anlogic: public Device, SPIInterface {
|
||||||
*/
|
*/
|
||||||
virtual bool post_flash_access() override {reset(); return true;}
|
virtual bool post_flash_access() override {reset(); return true;}
|
||||||
|
|
||||||
private:
|
|
||||||
SVF_jtag _svf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SRC_ANLOGIC_HPP_
|
#endif // SRC_ANLOGIC_HPP_
|
||||||
|
|
|
||||||
14
src/main.cpp
14
src/main.cpp
|
|
@ -31,6 +31,7 @@
|
||||||
#include "spiFlash.hpp"
|
#include "spiFlash.hpp"
|
||||||
#include "rawParser.hpp"
|
#include "rawParser.hpp"
|
||||||
#include "xilinx.hpp"
|
#include "xilinx.hpp"
|
||||||
|
#include "svf_jtag.hpp"
|
||||||
#ifdef ENABLE_XVC
|
#ifdef ENABLE_XVC
|
||||||
#include "xvc_server.hpp"
|
#include "xvc_server.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -496,6 +497,19 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
jtag->device_select(index);
|
jtag->device_select(index);
|
||||||
|
|
||||||
|
/* detect svf file and program the device */
|
||||||
|
if (!args.bit_file.empty() &&
|
||||||
|
((!args.file_type.empty() && args.file_type == "svf") ||
|
||||||
|
(args.bit_file.substr(args.bit_file.find_last_of(".") + 1) == "svf"))) {
|
||||||
|
SVF_jtag *svf = new SVF_jtag(jtag, args.verbose);
|
||||||
|
try {
|
||||||
|
svf->parse(args.bit_file);
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if selected device is supported
|
/* check if selected device is supported
|
||||||
* mainly used in conjunction with --index-chain
|
* mainly used in conjunction with --index-chain
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ static unsigned char *parse_hex(string const &in, size_t byte_length,
|
||||||
{
|
{
|
||||||
unsigned char *txbuf = new unsigned char[byte_length];
|
unsigned char *txbuf = new unsigned char[byte_length];
|
||||||
char c;
|
char c;
|
||||||
size_t last_iter = in.size() - (2 * byte_length);
|
ssize_t last_iter = in.size() - (2 * byte_length);
|
||||||
for (size_t i = (in.size() - 1), pos = 0; i >= last_iter; i--, pos++) {
|
for (ssize_t i = (in.size() - 1), pos = 0; i >= last_iter; i--, pos++) {
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
c = default_value ? 0x0f : 0x00;
|
c = default_value ? 0x0f : 0x00;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue