2021-12-10 12:12:32 +01:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2021 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
|
|
|
|
* Copyright (C) 2021 Cologne Chip AG <support@colognechip.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef SRC_COLOGNECHIP_HPP_
|
|
|
|
|
#define SRC_COLOGNECHIP_HPP_
|
|
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <regex>
|
2021-12-12 11:55:10 +01:00
|
|
|
#include <string>
|
2021-12-10 12:12:32 +01:00
|
|
|
|
|
|
|
|
#include "device.hpp"
|
|
|
|
|
#include "jtag.hpp"
|
|
|
|
|
#include "ftdispi.hpp"
|
|
|
|
|
#include "ftdiJtagMPSSE.hpp"
|
|
|
|
|
#include "rawParser.hpp"
|
|
|
|
|
#include "colognechipCfgParser.hpp"
|
|
|
|
|
#include "spiFlash.hpp"
|
2021-12-11 16:36:29 +01:00
|
|
|
#include "progressBar.hpp"
|
2021-12-10 12:12:32 +01:00
|
|
|
|
|
|
|
|
class CologneChip: public Device, SPIInterface {
|
|
|
|
|
public:
|
|
|
|
|
CologneChip(FtdiSpi *spi, const std::string &filename,
|
|
|
|
|
const std::string &file_type, Device::prog_type_t prg_type,
|
2022-04-09 13:08:57 +02:00
|
|
|
uint16_t rstn_pin, uint16_t done_pin, uint16_t fail_pin, uint16_t oen_pin,
|
2021-12-10 12:12:32 +01:00
|
|
|
bool verify, int8_t verbose);
|
|
|
|
|
CologneChip(Jtag* jtag, const std::string &filename,
|
|
|
|
|
const std::string &file_type, Device::prog_type_t prg_type,
|
|
|
|
|
const std::string &board_name, const std::string &cable_name,
|
|
|
|
|
bool verify, int8_t verbose);
|
|
|
|
|
~CologneChip() {}
|
|
|
|
|
|
2021-12-12 15:34:25 +01:00
|
|
|
bool cfgDone();
|
|
|
|
|
void waitCfgDone();
|
2022-03-20 08:25:51 +01:00
|
|
|
bool dumpFlash(uint32_t base_addr, uint32_t len) override;
|
2021-12-22 19:11:35 +01:00
|
|
|
virtual bool protect_flash(uint32_t len) override {
|
|
|
|
|
(void) len;
|
|
|
|
|
printError("protect flash not supported"); return false;}
|
|
|
|
|
virtual bool unprotect_flash() override {
|
|
|
|
|
printError("unprotect flash not supported"); return false;}
|
2022-03-10 08:51:54 +01:00
|
|
|
virtual bool bulk_erase_flash() override {
|
|
|
|
|
printError("bulk erase flash not supported"); return false;}
|
2021-12-22 19:11:35 +01:00
|
|
|
void program(unsigned int offset, bool unprotect_flash) override;
|
2021-12-10 12:12:32 +01:00
|
|
|
|
|
|
|
|
int idCode() override {return 0;}
|
|
|
|
|
void reset() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void programSPI_sram(uint8_t *data, int length);
|
2021-12-22 19:11:35 +01:00
|
|
|
void programSPI_flash(unsigned int offset, uint8_t *data, int length,
|
|
|
|
|
bool unprotect_flash);
|
2021-12-10 12:12:32 +01:00
|
|
|
void programJTAG_sram(uint8_t *data, int length);
|
2021-12-22 19:11:35 +01:00
|
|
|
void programJTAG_flash(unsigned int offset, uint8_t *data, int length,
|
|
|
|
|
bool unprotect_flash);
|
2021-12-10 12:12:32 +01:00
|
|
|
|
|
|
|
|
/* spi interface via jtag */
|
|
|
|
|
int spi_put(uint8_t cmd, uint8_t *tx, uint8_t *rx,
|
|
|
|
|
uint32_t len) override;
|
|
|
|
|
int spi_put(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,
|
|
|
|
|
bool verbose=false) override;
|
|
|
|
|
|
|
|
|
|
FtdiSpi *_spi = NULL;
|
|
|
|
|
FtdiJtagMPSSE *_ftdi_jtag = NULL;
|
|
|
|
|
uint16_t _rstn_pin;
|
|
|
|
|
uint16_t _done_pin;
|
2022-04-09 13:08:57 +02:00
|
|
|
uint16_t _fail_pin;
|
2021-12-10 12:12:32 +01:00
|
|
|
uint16_t _oen_pin;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SRC_COLOGNECHIP_HPP_
|