loader: update to remote 9a16c25
This commit is contained in:
parent
de7ae71455
commit
e955ad7b91
1
alchitry-loader/.gitignore
vendored
Normal file
1
alchitry-loader/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
alchitry_loader
|
28
alchitry-loader/CMakeLists.txt
Normal file
28
alchitry-loader/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(alchitry_loader)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
include_directories(src)
|
||||
|
||||
add_executable(alchitry_loader
|
||||
src/Alchitry_Loader.cpp
|
||||
src/config_type.cpp
|
||||
src/config_type.h
|
||||
src/ftd2xx.h
|
||||
src/jtag.cpp
|
||||
src/jtag.h
|
||||
src/jtag_fsm.cpp
|
||||
src/jtag_fsm.h
|
||||
src/loader.cpp
|
||||
src/loader.h
|
||||
src/mingw.thread.h
|
||||
src/spi.cpp
|
||||
src/spi.h
|
||||
src/WinTypes.h)
|
||||
|
||||
|
||||
target_link_libraries(alchitry_loader
|
||||
${CMAKE_SOURCE_DIR}/lib/linux/libftd2xx.a
|
||||
${CMAKE_SOURCE_DIR}/lib/windows/ftd2xx.lib
|
||||
pthread)
|
@ -1,16 +1,18 @@
|
||||
FROM debian:bookworm AS deps
|
||||
|
||||
RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends build-essential
|
||||
RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends build-essential cmake
|
||||
|
||||
|
||||
|
||||
FROM deps AS build
|
||||
|
||||
ADD . /workspace
|
||||
ADD src /workspace/src
|
||||
ADD lib /workspace/lib
|
||||
ADD CMakeLists.txt /workspace/
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN make loader
|
||||
RUN mkdir build && cd build && cmake .. && make
|
||||
|
||||
|
||||
FROM scratch AS export
|
||||
COPY --from=build /workspace/loader /
|
||||
COPY --from=build /workspace/build/alchitry_loader /
|
||||
|
@ -1,24 +1,6 @@
|
||||
sources = $(wildcard src/*.cpp)
|
||||
objects = $(sources:.cpp=.o)
|
||||
os = $(shell uname -s)
|
||||
static_libs = lib/$(os)/libftd2xx.a
|
||||
libs = -lpthread
|
||||
|
||||
CXXFLAGS = -std=c++11
|
||||
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
# Assume target is Mac OS if build host is Mac OS; any other host targets Linux
|
||||
ifeq ($(os), Darwin)
|
||||
libs += -lobjc -framework IOKit -framework CoreFoundation
|
||||
else
|
||||
libs += -lrt
|
||||
endif
|
||||
|
||||
loader: $(objects) ## build the loader executable
|
||||
$(CXX) $(LDFLAGS) -o $@ $^ $(static_libs) $(libs)
|
||||
|
||||
build: ## build the loader in docker (linux)
|
||||
loader: ## build the loader in docker (linux)
|
||||
docker build -o . .
|
||||
|
||||
.PHONY: clean
|
||||
|
63
alchitry-loader/README.md
Normal file
63
alchitry-loader/README.md
Normal file
@ -0,0 +1,63 @@
|
||||
# Alchitry Loader (based on D2XX)
|
||||
This project was originally used as a tool by Alchitry Labs to program the Alchitry boards using the
|
||||
official D2XX library from FTDI. You can find D2XX here https://ftdichip.com/drivers/d2xx-drivers/
|
||||
|
||||
It has been updated to include the Alchitry Au+ and can be used as a stand-alone command line tool for
|
||||
loading the Alchitry boards without using Alchitry Labs.
|
||||
|
||||
Alchitry Labs no longer relies on this loader and instead has a fully Java loader built in.
|
||||
|
||||
## Building
|
||||
Clone the repository
|
||||
|
||||
`git clone https://github.com/alchitry/alchitry-loader.git`
|
||||
|
||||
Enter the project files
|
||||
|
||||
`cd alchitry-loader`
|
||||
|
||||
Create the Makefile
|
||||
|
||||
`cmake CMakeLists.txt`
|
||||
|
||||
Build the project
|
||||
|
||||
`make`
|
||||
|
||||
Test it out
|
||||
|
||||
`./alchitry_loader`
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
Usage: "loader arguments"
|
||||
|
||||
Arguments:
|
||||
-e : erase FPGA flash
|
||||
-l : list detected boards
|
||||
-h : print this help message
|
||||
-f config.bin : write FPGA flash
|
||||
-r config.bin : write FPGA RAM
|
||||
-u config.data : write FTDI eeprom
|
||||
-b n : select board "n" (defaults to 0)
|
||||
-p loader.bin : Au bridge bin
|
||||
-t TYPE : TYPE can be au, au+, or cu (defaults to au)
|
||||
```
|
||||
|
||||
### Examples
|
||||
Load a .bin onto an Au's RAM (lost on power cycle)
|
||||
|
||||
`./alchitry_loader -t au -r au_config.bin`
|
||||
|
||||
Load a .bin onto an Au+'s flash (persistent config)
|
||||
|
||||
`./alchitry_loader -t "au+" -f au_config.bin -p ./bridge/au_plus_loader.bin`
|
||||
|
||||
Note that to load to the Au or Au+ flash memory you need to specify a bridge bin file. These can be found
|
||||
in the bridge folder of this repo. This file is loaded onto the Au and allows this loader to program the
|
||||
flash memory. It acts as a bridge from the JTAG port to the SPI of the flash memory.
|
||||
|
||||
The source for the bridge files can be found here https://github.com/alchitry/au-bridge
|
||||
|
||||
This isn't needed for the Cu which has direct access to the flash over the SPI protocol.
|
Binary file not shown.
Binary file not shown.
BIN
alchitry-loader/lib/linux/libftd2xx.a
Normal file
BIN
alchitry-loader/lib/linux/libftd2xx.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
alchitry-loader/lib/windows/ftd2xx64.dll
Normal file
BIN
alchitry-loader/lib/windows/ftd2xx64.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,18 +14,23 @@
|
||||
#include <iterator>
|
||||
#include "loader.h"
|
||||
#include <chrono>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "mingw.thread.h"
|
||||
#else
|
||||
|
||||
#include <thread>
|
||||
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include "config_type.h"
|
||||
|
||||
#define BOARD_ERROR -2
|
||||
#define BOARD_UNKNOWN -1
|
||||
#define BOARD_AU 0
|
||||
#define BOARD_CU 1
|
||||
#define BOARD_AU_PLUS 1
|
||||
#define BOARD_CU 2
|
||||
|
||||
using namespace std;
|
||||
using get_time = chrono::steady_clock;
|
||||
@ -35,7 +40,7 @@ char ManufacturerIdBuf[16];
|
||||
char DescriptionBuf[64];
|
||||
char SerialNumberBuf[16];
|
||||
|
||||
string getErrorName(int error) {
|
||||
string getErrorName(unsigned int error) {
|
||||
switch (error) {
|
||||
case FT_OK:
|
||||
return "FT_OK";
|
||||
@ -78,11 +83,12 @@ string getErrorName(int error) {
|
||||
return "FT_OTHER_ERROR";
|
||||
case FT_DEVICE_LIST_NOT_READY:
|
||||
return "FT_DEVICE_LIST_NOT_READY";
|
||||
}
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void write_to_file(string file, PFT_PROGRAM_DATA ftData) {
|
||||
void write_to_file(const string& file, PFT_PROGRAM_DATA ftData) {
|
||||
ofstream output_file(file, ios::binary);
|
||||
CONFIG_DATA config;
|
||||
ft_to_config(&config, ftData);
|
||||
@ -94,7 +100,7 @@ void write_to_file(string file, PFT_PROGRAM_DATA ftData) {
|
||||
output_file.close();
|
||||
}
|
||||
|
||||
bool read_from_file(string file, PFT_PROGRAM_DATA ftData) {
|
||||
bool read_from_file(const string& file, PFT_PROGRAM_DATA ftData) {
|
||||
cout << "Reading " << file << endl;
|
||||
try {
|
||||
ifstream input_file(file, ios::in | ios::binary);
|
||||
@ -153,7 +159,7 @@ void erase(FT_HANDLE ftHandle) {
|
||||
cout << "Done." << endl;
|
||||
}
|
||||
|
||||
bool programDevice(unsigned int devNumber, string file) {
|
||||
bool programDevice(int devNumber, const string& file) {
|
||||
FT_HANDLE ftHandle;
|
||||
|
||||
cout << "Opening device... ";
|
||||
@ -207,26 +213,43 @@ bool programDevice(unsigned int devNumber, string file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
string descriptionToName(string des) {
|
||||
string descriptionToName(const string &des) {
|
||||
if (des == "Alchitry Cu A") {
|
||||
return "Alchitry Cu";
|
||||
} else if (des == "Alchitry Au A") {
|
||||
return "Alchitry Au";
|
||||
} else if (des == "Alchitry Au+ A") {
|
||||
return "Alchitry Au+";
|
||||
} else {
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
int desciptionToType(string des) {
|
||||
int descriptionToType(const string &des) {
|
||||
if (des == "Alchitry Cu A") {
|
||||
return BOARD_CU;
|
||||
} else if (des == "Alchitry Au A") {
|
||||
return BOARD_AU;
|
||||
} else if (des == "Alchitry Au+ A") {
|
||||
return BOARD_AU_PLUS;
|
||||
} else {
|
||||
return BOARD_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
string boardToName(int board) {
|
||||
switch (board) {
|
||||
case BOARD_AU:
|
||||
return "Alchitry Au";
|
||||
case BOARD_AU_PLUS:
|
||||
return "Alchitry Au+";
|
||||
case BOARD_CU:
|
||||
return "Alchitry Cu";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void printDeviceList() {
|
||||
FT_STATUS ftStatus;
|
||||
FT_DEVICE_LIST_INFO_NODE *devInfo;
|
||||
@ -287,6 +310,8 @@ int getDeviceType(unsigned int devNumber) {
|
||||
board = BOARD_CU;
|
||||
} else if (boardDescription == "Alchitry Au A") {
|
||||
board = BOARD_AU;
|
||||
} else if (boardDescription == "Alchitry Au+ A") {
|
||||
board = BOARD_AU_PLUS;
|
||||
} else {
|
||||
board = BOARD_UNKNOWN;
|
||||
}
|
||||
@ -324,7 +349,7 @@ int getFirstDeviceOfType(int board) {
|
||||
if (ftStatus == FT_OK) {
|
||||
for (int devNumber = 0; devNumber < numDevs; devNumber++) {
|
||||
string boardDescription = devInfo[devNumber].Description;
|
||||
int type = desciptionToType(boardDescription);
|
||||
int type = descriptionToType(boardDescription);
|
||||
if (type == board) {
|
||||
free(devInfo);
|
||||
return devNumber;
|
||||
@ -337,7 +362,7 @@ int getFirstDeviceOfType(int board) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool readAndSaveFTDI(string file) {
|
||||
bool readAndSaveFTDI(const string& file) {
|
||||
FT_HANDLE ftHandle;
|
||||
|
||||
cout << "Opening device... ";
|
||||
@ -392,7 +417,7 @@ void printUsage() {
|
||||
cout << " -u config.data : write FTDI eeprom" << endl;
|
||||
cout << " -b n : select board \"n\" (defaults to 0)" << endl;
|
||||
cout << " -p loader.bin : Au bridge bin" << endl;
|
||||
cout << " -t TYPE : TYPE can be au or cu (defaults to au)" << endl;
|
||||
cout << " -t TYPE : TYPE can be au, au+, or cu (defaults to au)" << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -413,7 +438,7 @@ int main(int argc, char *argv[]) {
|
||||
int deviceNumber = -1;
|
||||
bool bridgeProvided = false;
|
||||
string auBridgeBin;
|
||||
bool isAu = true;
|
||||
int board = BOARD_AU;
|
||||
|
||||
for (int i = 1; i < argc;) {
|
||||
string arg = argv[i];
|
||||
@ -488,9 +513,11 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(argv[i + 1], "au") == 0) {
|
||||
isAu = true;
|
||||
board = BOARD_AU;
|
||||
} else if (strcmp(argv[i + 1], "au+") == 0) {
|
||||
board = BOARD_AU_PLUS;
|
||||
} else if (strcmp(argv[i + 1], "cu") == 0) {
|
||||
isAu = false;
|
||||
board = BOARD_CU;
|
||||
} else {
|
||||
cerr << "Invalid board type: " << argv[i + 1] << endl;
|
||||
printUsage();
|
||||
@ -512,14 +539,14 @@ int main(int argc, char *argv[]) {
|
||||
printDeviceList();
|
||||
|
||||
if (deviceNumber < 0)
|
||||
deviceNumber = getFirstDeviceOfType(isAu ? BOARD_AU : BOARD_CU);
|
||||
deviceNumber = getFirstDeviceOfType(board);
|
||||
|
||||
if (deviceNumber < 0) {
|
||||
cerr << "Couldn't find device!" << endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
cout << "Found " << (isAu ? "Au" : "Cu") << " as device " << deviceNumber
|
||||
cout << "Found " << boardToName(board) << " as device " << deviceNumber
|
||||
<< "." << endl;
|
||||
|
||||
if (eeprom)
|
||||
@ -527,15 +554,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (erase || fpgaFlash || fpgaRam) {
|
||||
int boardType = getDeviceType(deviceNumber);
|
||||
if ((isAu && boardType != BOARD_AU)
|
||||
|| (!isAu && boardType != BOARD_CU)) {
|
||||
if (board != boardType) {
|
||||
cerr << "Invalid board type detected!" << endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (boardType == BOARD_AU) {
|
||||
if (bridgeProvided == false && (erase || fpgaFlash)) {
|
||||
cerr << "No Au bridge bin provided!" << endl;
|
||||
if (boardType == BOARD_AU || boardType == BOARD_AU_PLUS) {
|
||||
if (!bridgeProvided && (erase || fpgaFlash)) {
|
||||
cerr << "No bridge bin provided!" << endl;
|
||||
return 2;
|
||||
}
|
||||
Jtag jtag;
|
||||
@ -543,7 +569,7 @@ int main(int argc, char *argv[]) {
|
||||
cerr << "Failed to connect to JTAG!" << endl;
|
||||
return 2;
|
||||
}
|
||||
if (jtag.initialize() == false) {
|
||||
if (!jtag.initialize()) {
|
||||
cerr << "Failed to initialize JTAG!" << endl;
|
||||
return 2;
|
||||
}
|
||||
@ -576,7 +602,7 @@ int main(int argc, char *argv[]) {
|
||||
cerr << "Failed to connect to SPI!" << endl;
|
||||
return 2;
|
||||
}
|
||||
if (spi.initialize() == false) {
|
||||
if (!spi.initialize()) {
|
||||
cerr << "Failed to initialize SPI!" << endl;
|
||||
return 2;
|
||||
}
|
||||
|
0
alchitry-loader/src/WinTypes.h
Normal file → Executable file
0
alchitry-loader/src/WinTypes.h
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright © 2001-2011 Future Technology Devices International Limited
|
||||
Copyright © 2001-2021 Future Technology Devices International Limited
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
@ -27,7 +27,7 @@ ftd2xx.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Native USB device driver for FTDI FT232x, FT245x, FT2232x and FT4232x devices
|
||||
Native USB device driver for FTDI FT232x, FT245x, FT2232x, FT4232x, FT2233H and FT4233H devices
|
||||
FTD2XX library definitions
|
||||
|
||||
Environment:
|
||||
@ -225,6 +225,18 @@ enum {
|
||||
FT_DEVICE_4222H_1_2,
|
||||
FT_DEVICE_4222H_3,
|
||||
FT_DEVICE_4222_PROG,
|
||||
FT_DEVICE_900,
|
||||
FT_DEVICE_930,
|
||||
FT_DEVICE_UMFTPD3A,
|
||||
FT_DEVICE_2233HP,
|
||||
FT_DEVICE_4233HP,
|
||||
FT_DEVICE_2232HP,
|
||||
FT_DEVICE_4232HP,
|
||||
FT_DEVICE_233HP,
|
||||
FT_DEVICE_232HP,
|
||||
FT_DEVICE_2232HA,
|
||||
FT_DEVICE_4232HA,
|
||||
FT_DEVICE_232RN,
|
||||
};
|
||||
|
||||
//
|
||||
@ -784,8 +796,8 @@ extern "C" {
|
||||
UCHAR BIsFifoTar; // non-zero if interface is 245 FIFO CPU target
|
||||
UCHAR BIsFastSer; // non-zero if interface is Fast serial
|
||||
// Driver option
|
||||
UCHAR ADriverType; //
|
||||
UCHAR BDriverType; //
|
||||
UCHAR ADriverType; // non-zero if interface is to use VCP drivers
|
||||
UCHAR BDriverType; // non-zero if interface is to use VCP drivers
|
||||
} FT_EEPROM_2232, *PFT_EEPROM_2232;
|
||||
|
||||
|
||||
@ -811,7 +823,7 @@ extern "C" {
|
||||
UCHAR Cbus3; // Cbus Mux control
|
||||
UCHAR Cbus4; // Cbus Mux control
|
||||
// Driver option
|
||||
UCHAR DriverType; //
|
||||
UCHAR DriverType; // non-zero if using D2XX driver
|
||||
} FT_EEPROM_232R, *PFT_EEPROM_232R;
|
||||
|
||||
|
||||
@ -841,8 +853,8 @@ extern "C" {
|
||||
UCHAR BIsFastSer; // non-zero if interface is Fast serial
|
||||
UCHAR PowerSaveEnable; // non-zero if using BCBUS7 to save power for self-powered designs
|
||||
// Driver option
|
||||
UCHAR ADriverType; //
|
||||
UCHAR BDriverType; //
|
||||
UCHAR ADriverType; // non-zero if interface is to use VCP drivers
|
||||
UCHAR BDriverType; // non-zero if interface is to use VCP drivers
|
||||
} FT_EEPROM_2232H, *PFT_EEPROM_2232H;
|
||||
|
||||
|
||||
@ -869,10 +881,10 @@ extern "C" {
|
||||
UCHAR CRIIsTXDEN; // non-zero if port C uses RI as RS485 TXDEN
|
||||
UCHAR DRIIsTXDEN; // non-zero if port D uses RI as RS485 TXDEN
|
||||
// Driver option
|
||||
UCHAR ADriverType; //
|
||||
UCHAR BDriverType; //
|
||||
UCHAR CDriverType; //
|
||||
UCHAR DDriverType; //
|
||||
UCHAR ADriverType; // non-zero if interface is to use VCP drivers
|
||||
UCHAR BDriverType; // non-zero if interface is to use VCP drivers
|
||||
UCHAR CDriverType; // non-zero if interface is to use VCP drivers
|
||||
UCHAR DDriverType; // non-zero if interface is to use VCP drivers
|
||||
} FT_EEPROM_4232H, *PFT_EEPROM_4232H;
|
||||
|
||||
|
||||
@ -909,7 +921,7 @@ extern "C" {
|
||||
UCHAR IsFT1248; // non-zero if interface is FT1248
|
||||
UCHAR PowerSaveEnable; //
|
||||
// Driver option
|
||||
UCHAR DriverType; //
|
||||
UCHAR DriverType; // non-zero if interface is to use VCP drivers
|
||||
} FT_EEPROM_232H, *PFT_EEPROM_232H;
|
||||
|
||||
|
||||
@ -957,10 +969,223 @@ extern "C" {
|
||||
UCHAR RS485EchoSuppress; //
|
||||
UCHAR PowerSaveEnable; //
|
||||
// Driver option
|
||||
UCHAR DriverType; //
|
||||
UCHAR DriverType; // non-zero if interface is to use VCP drivers
|
||||
} FT_EEPROM_X_SERIES, *PFT_EEPROM_X_SERIES;
|
||||
|
||||
|
||||
// FT4222H EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
typedef struct ft_eeprom_4222h {
|
||||
// Common header
|
||||
FT_EEPROM_HEADER common; // common elements for all device EEPROMs
|
||||
CHAR Revision; // 'A', 'B', 'C', or 'D'.
|
||||
UCHAR I2C_Slave_Address;
|
||||
// Suspend
|
||||
UCHAR SPISuspend; // 0 for "Disable SPI, tristate pins", 2 for "Keep SPI pin status", 3 for "Enable SPI pin control"
|
||||
UCHAR SuspendOutPol; // 0 for negative, 1 for positive (not implemented on Rev A)
|
||||
UCHAR EnableSuspendOut; // non-zero to enable (not implemented on Rev A)
|
||||
// QSPI
|
||||
UCHAR Clock_SlowSlew; // non-zero if clock pin has slow slew
|
||||
UCHAR Clock_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR IO0_SlowSlew; // non-zero if IO0 pin has slow slew
|
||||
UCHAR IO1_SlowSlew; // non-zero if IO1 pin has slow slew
|
||||
UCHAR IO2_SlowSlew; // non-zero if IO2 pin has slow slew
|
||||
UCHAR IO3_SlowSlew; // non-zero if IO3 pin has slow slew
|
||||
UCHAR IO_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR SlaveSelect_PullUp; // non-zero to enable pull up
|
||||
UCHAR SlaveSelect_PullDown; // non-zero to enable pull down
|
||||
UCHAR SlaveSelect_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR SlaveSelect_SlowSlew; // non-zero if slave select pin has slow slew
|
||||
UCHAR MISO_Suspend; // 2 for push-low, 3 for push high, 0 and 1 reserved
|
||||
UCHAR SIMO_Suspend; // 2 for push-low, 3 for push high, 0 and 1 reserved
|
||||
UCHAR IO2_IO3_Suspend; // 2 for push-low, 3 for push high, 0 and 1 reserved
|
||||
UCHAR SlaveSelect_Suspend; // 0 for no-change (not implemented on Rev A), 2 for push-low, 3 for push high, 1 reserved
|
||||
// GPIO
|
||||
UCHAR GPIO0_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR GPIO1_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR GPIO2_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR GPIO3_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
UCHAR GPIO0_SlowSlew; // non-zero if IO0 pin has slow slew
|
||||
UCHAR GPIO1_SlowSlew; // non-zero if IO0 pin has slow slew
|
||||
UCHAR GPIO2_SlowSlew; // non-zero if IO0 pin has slow slew
|
||||
UCHAR GPIO3_SlowSlew; // non-zero if IO0 pin has slow slew
|
||||
UCHAR GPIO0_PullDown; // non-zero to enable pull down
|
||||
UCHAR GPIO1_PullDown; // non-zero to enable pull down
|
||||
UCHAR GPIO2_PullDown; // non-zero to enable pull down
|
||||
UCHAR GPIO3_PullDown; // non-zero to enable pull down
|
||||
UCHAR GPIO0_PullUp; // non-zero to enable pull up
|
||||
UCHAR GPIO1_PullUp; // non-zero to enable pull up
|
||||
UCHAR GPIO2_PullUp; // non-zero to enable pull up
|
||||
UCHAR GPIO3_PullUp; // non-zero to enable pull up
|
||||
UCHAR GPIO0_OpenDrain; // non-zero to enable open drain
|
||||
UCHAR GPIO1_OpenDrain; // non-zero to enable open drain
|
||||
UCHAR GPIO2_OpenDrain; // non-zero to enable open drain
|
||||
UCHAR GPIO3_OpenDrain; // non-zero to enable open drain
|
||||
UCHAR GPIO0_Suspend; // 0 for no-change, 1 for input (not implemented on Rev A), 2 for push-low, 3 for push high
|
||||
UCHAR GPIO1_Suspend; // 0 for no-change, 1 for input (not implemented on Rev A), 2 for push-low, 3 for push high
|
||||
UCHAR GPIO2_Suspend; // 0 for no-change, 1 for input (not implemented on Rev A), 2 for push-low, 3 for push high
|
||||
UCHAR GPIO3_Suspend; // 0 for no-change, 1 for input (not implemented on Rev A), 2 for push-low, 3 for push high
|
||||
UCHAR FallingEdge; // non-zero to change GPIO on falling edge
|
||||
// BCD
|
||||
UCHAR BCD_Disable; // non-zero to disable BCD
|
||||
UCHAR BCD_OutputActiveLow; // non-zero to set BCD output active low
|
||||
UCHAR BCD_Drive; // valid values are 4mA, 8mA, 12mA, 16mA
|
||||
} FT_EEPROM_4222H, *PFT_EEPROM_4222H;
|
||||
|
||||
|
||||
// Power Delivery structures for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// PDO Configuration structure, mA supported values 0 to 10230mA, mV supported values 0 to 51100mV
|
||||
// This is part of the FT_EEPROM_PD structure.
|
||||
typedef struct ft_eeprom_PD_PDO_mv_ma {
|
||||
USHORT PDO1ma; // PDO1 mA
|
||||
USHORT PDO1mv; // PDO1 mV
|
||||
USHORT PDO2ma; // PDO2 mA
|
||||
USHORT PDO2mv; // PDO2 mV
|
||||
USHORT PDO3ma; // PDO3 mA
|
||||
USHORT PDO3mv; // PDO3 mV
|
||||
USHORT PDO4ma; // PDO4 mA
|
||||
USHORT PDO4mv; // PDO4 mV
|
||||
USHORT PDO5ma; // PDO5 mA (FTx233HP only)
|
||||
USHORT PDO5mv; // PDO5 mV (FTx233HP only)
|
||||
USHORT PDO6ma; // PDO6 mA (FTx233HP only)
|
||||
USHORT PDO6mv; // PDO6 mV (FTx233HP only)
|
||||
USHORT PDO7ma; // PDO7 mA (FTx233HP only)
|
||||
USHORT PDO7mv; // PDO7 mV (FTx233HP only)
|
||||
} FT_EEPROM_PD_PDO_mv_ma;
|
||||
|
||||
// PD EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// This is appended to the end of the base device structure. e_g.
|
||||
// struct {
|
||||
// FT_EEPROM_xxx base;
|
||||
// FT_EEPROM_PD pd;
|
||||
// };
|
||||
// Device GPIO values are:
|
||||
// FTx233HP - 0 to 7, 15 for N/A
|
||||
// FTx232HP - 0 to 3, 15 for N/A
|
||||
typedef struct ft_eeprom_pd {
|
||||
// Configuration
|
||||
UCHAR srprs; // non-zero to enable Sink Request Power Role Swap
|
||||
UCHAR sraprs; // non-zero to enable Sink Accept PR Swap
|
||||
UCHAR srrprs; // non-zero to enable Source Request PR SWAP
|
||||
UCHAR saprs; // non-zero to enable Source Accept PR SWAP
|
||||
UCHAR vconns; // non-zero to enable vConn Swap
|
||||
UCHAR passthru; // non-zero to enable Pass Through (FTx233HP only)
|
||||
UCHAR extmcu; // non-zero to enable External MCU
|
||||
UCHAR pd2en; // non-zero to enable PD2 (FTx233HP only)
|
||||
UCHAR pd1autoclk; // non-zero to enable PD1 Auto Clock
|
||||
UCHAR pd2autoclk; // non-zero to enable PD2 Auto Clock (FTx233HP only)
|
||||
UCHAR useefuse; // non-zero to Use EFUSE
|
||||
UCHAR extvconn; // non-zero to enable External vConn
|
||||
|
||||
// GPIO Configuration
|
||||
UCHAR count; // GPIO Count, supported values are 0 to 7
|
||||
UCHAR gpio1; // GPIO Number 1, supports device GPIO values
|
||||
UCHAR gpio2; // GPIO Number 2, supports device GPIO values
|
||||
UCHAR gpio3; // GPIO Number 3, supports device GPIO values
|
||||
UCHAR gpio4; // GPIO Number 4, supports device GPIO values
|
||||
UCHAR gpio5; // GPIO Number 5, supports device GPIO values (FTx233HP only)
|
||||
UCHAR gpio6; // GPIO Number 6, supports device GPIO values (FTx233HP only)
|
||||
UCHAR gpio7; // GPIO Number 7, supports device GPIO values (FTx233HP only)
|
||||
UCHAR pd1lden; // PD1 Load Enable, supports device GPIO values
|
||||
UCHAR pd2lden; // PD2 Load Enable, supports device GPIO values (FTx233HP only)
|
||||
UCHAR dispin; // Discharge Pin, supports device GPIO values
|
||||
UCHAR disenbm; // Discharge Enable BM, 0 for "Drive Hi", 1 for "Drive Low", 2 for "Input Mode", 3 for "Don't Care"
|
||||
UCHAR disdisbm; // Discharge Disable BM, 0 for "Drive Hi", 1 for "Drive Low", 2 for "Input Mode", 3 for "Don't Care"
|
||||
UCHAR ccselect; // CC Select Indicator, supports device GPIO values
|
||||
|
||||
// ISET Configuration
|
||||
UCHAR iset1; // ISET1, supports device GPIO values
|
||||
UCHAR iset2; // ISET2, supports device GPIO values
|
||||
UCHAR iset3; // ISET3, supports device GPIO values
|
||||
UCHAR extiset; // non-zero to enable EXTEND_ISET
|
||||
UCHAR isetpd2; // non-zero to enable ISET_PD2
|
||||
UCHAR iseten; // non-zero to set ISET_ENABLED
|
||||
|
||||
// BM Configuration, 0 for "Drive Hi", 1 for "Drive Low", 2 for "Input Mode", 3 for "Don't Care"
|
||||
UCHAR PDO1_GPIO[7]; // PDO1 GPIO1 to GPIO7
|
||||
UCHAR PDO2_GPIO[7]; // PDO2 GPIO1 to GPIO7
|
||||
UCHAR PDO3_GPIO[7]; // PDO3 GPIO1 to GPIO7
|
||||
UCHAR PDO4_GPIO[7]; // PDO4 GPIO1 to GPIO7
|
||||
UCHAR PDO5_GPIO[7]; // PDO5 GPIO1 to GPIO7 (FTx233HP only)
|
||||
UCHAR PDO6_GPIO[7]; // PDO6 GPIO1 to GPIO7 (FTx233HP only)
|
||||
UCHAR PDO7_GPIO[7]; // PDO7 GPIO1 to GPIO7 (FTx233HP only)
|
||||
UCHAR VSET0V_GPIO[7]; // PDO7 GPIO1 to GPIO7
|
||||
UCHAR VSAFE5V_GPIO[7]; // PDO7 GPIO1 to GPIO7
|
||||
|
||||
FT_EEPROM_PD_PDO_mv_ma BM_PDO_Sink;
|
||||
FT_EEPROM_PD_PDO_mv_ma BM_PDO_Source;
|
||||
FT_EEPROM_PD_PDO_mv_ma BM_PDO_Sink_2; // (FTx233HP only)
|
||||
|
||||
// PD Timers
|
||||
UCHAR srt; // Sender Response Timer
|
||||
UCHAR hrt; // Hard Reset Timer
|
||||
UCHAR sct; // Source Capability Timer
|
||||
UCHAR dit; // Discover Identity Timer
|
||||
USHORT srcrt; // Source Recover Timer
|
||||
USHORT trt; // Transition Timer
|
||||
USHORT sofft; // Source off timer
|
||||
USHORT nrt; // No Response Timer
|
||||
USHORT swct; // Sink Wait Capability Timer
|
||||
USHORT snkrt; // Sink Request Timer
|
||||
UCHAR dt; // Discharge Timer
|
||||
UCHAR cnst; // Chunk not supported timer
|
||||
USHORT it; // Idle Timer
|
||||
|
||||
// PD Control
|
||||
UCHAR i2caddr; // I2C Address (hex)
|
||||
UINT prou; // Power Reserved for OWN use
|
||||
UINT trim1; // TRIM1
|
||||
UINT trim2; // TRIM2
|
||||
UCHAR extdc; // non-zero to enable ETERNAL_DC_POWER
|
||||
} FT_EEPROM_PD, *PFT_EEPROM_PD;
|
||||
|
||||
// FT2233HP EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// FT2232H with power delivery
|
||||
typedef struct _ft_eeprom_2233hp
|
||||
{
|
||||
FT_EEPROM_2232H ft2232h;
|
||||
FT_EEPROM_PD pd;
|
||||
} FT_EEPROM_2233HP, *PFT_EEPROM_2233HP;
|
||||
|
||||
// FT4233HP EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// FT4232H with power delivery
|
||||
typedef struct _ft_eeprom_4233hp
|
||||
{
|
||||
FT_EEPROM_4232H ft4232h;
|
||||
FT_EEPROM_PD pd;
|
||||
} FT_EEPROM_4233HP, *PFT_EEPROM_4233HP;
|
||||
|
||||
// FT2232HP EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// FT2232H with power delivery
|
||||
typedef struct _ft_eeprom_2232hp
|
||||
{
|
||||
FT_EEPROM_2232H ft2232h;
|
||||
FT_EEPROM_PD pd;
|
||||
} FT_EEPROM_2232HP, *PFT_EEPROM_2232HP;
|
||||
|
||||
// FT4232HP EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// FT4232H with power delivery
|
||||
typedef struct _ft_eeprom_4232hp
|
||||
{
|
||||
FT_EEPROM_4232H ft4232h;
|
||||
FT_EEPROM_PD pd;
|
||||
} FT_EEPROM_4232HP, *PFT_EEPROM_4232HP;
|
||||
|
||||
// FT233HP EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// FT233H with power delivery
|
||||
typedef struct _ft_eeprom_233hp
|
||||
{
|
||||
FT_EEPROM_232H ft232h;
|
||||
FT_EEPROM_PD pd;
|
||||
} FT_EEPROM_233HP, *PFT_EEPROM_233HP;
|
||||
|
||||
// FT232HP EEPROM structure for use with FT_EEPROM_Read and FT_EEPROM_Program
|
||||
// FT232H with power delivery
|
||||
typedef struct _ft_eeprom_232hp
|
||||
{
|
||||
FT_EEPROM_232H ft232h;
|
||||
FT_EEPROM_PD pd;
|
||||
} FT_EEPROM_232HP, *PFT_EEPROM_232HP;
|
||||
|
||||
FTD2XX_API
|
||||
FT_STATUS WINAPI FT_EEPROM_Read(
|
||||
FT_HANDLE ftHandle,
|
||||
@ -1440,4 +1665,3 @@ extern "C" {
|
||||
|
||||
|
||||
#endif /* FTD2XX_H */
|
||||
|
||||
|
0
alchitry-loader/src/jtag.cpp
Normal file → Executable file
0
alchitry-loader/src/jtag.cpp
Normal file → Executable file
0
alchitry-loader/src/jtag.h
Normal file → Executable file
0
alchitry-loader/src/jtag.h
Normal file → Executable file
0
alchitry-loader/src/jtag_fsm.cpp
Normal file → Executable file
0
alchitry-loader/src/jtag_fsm.cpp
Normal file → Executable file
0
alchitry-loader/src/jtag_fsm.h
Normal file → Executable file
0
alchitry-loader/src/jtag_fsm.h
Normal file → Executable file
5
alchitry-loader/src/loader.cpp
Normal file → Executable file
5
alchitry-loader/src/loader.cpp
Normal file → Executable file
@ -134,6 +134,11 @@ string Loader::shiftDR(int bits, string write) {
|
||||
bool Loader::loadBin(string file) {
|
||||
string binStr = fileToBinStr(file);
|
||||
|
||||
if (binStr.empty()) {
|
||||
cerr << "Failed to read bin file: "+ file << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
string reversedBinStr = reverseBytes(binStr);
|
||||
|
||||
if (!device->setFreq(10000000)) {
|
||||
|
0
alchitry-loader/src/loader.h
Normal file → Executable file
0
alchitry-loader/src/loader.h
Normal file → Executable file
@ -9,9 +9,9 @@
|
||||
#define SPI_H_
|
||||
|
||||
#include "ftd2xx.h"
|
||||
#include <cstdint>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user