Skip to content

Instantly share code, notes, and snippets.

View sthornington's full-sized avatar

Simon Thornington sthornington

  • New York
View GitHub Profile
// SUPPORT CRAP
#[link(name = "c")]
extern {
fn mmap(addr: *mut u8, len: usize, prot: i32, flags: i32, fd: i32, offset: i64) -> *mut u8;
fn madvise(addr: *mut u8, length: usize, advice: i32) -> i32;
fn lseek(fd: i32, offset: i64, whence: i32) -> i64;
fn ftruncate(fd: i32, offset: i64) -> i32;
fn open(path: *const c_char, oflag: i32) -> i32;
fn fcntl(fd: i32, cmd: i32, ...) -> i32;
#[cfg(target_os = "macos")]
fn get_stdout_path(path_buf: &mut [u8; 4096]) {
unsafe {
let f_getpath = 50;
let stdout = 1;
let result = fcntl(stdout, f_getpath, path_buf.as_mut_ptr());
if result == -1 {
panic!("fcntl failed, errno {}", std::io::Error::last_os_error().raw_os_error().unwrap());
}
let path = CStr::from_ptr(path_buf.as_ptr() as *const c_char);
@sthornington
sthornington / ft2232_to_digilent_jtag.md
Created April 2, 2021 15:05 — forked from rikka0w0/ft2232_to_digilent_jtag.md
FT2232 to Digilent JTag for Xilinx FPGAs (ISE/Vivado)

The Digilent JTag uses FT2232, but its configuration EEPROM contains secrete data needed to be recoginzed by Xilinx ISE/Vivado. The following method only works on linux (tested on Ubuntu16.04), but the patched FT2232 doggle also works on Windows. Since WSL1 does not provide USB device access, the following method will not work for WSL1.

DONT use FT_Prog on offical Digilent cable, as it can trash the firmware! The offical eeprom contains secrete data that cannot be handled correctly by FT_Prog.

Here are steps to create a Digilent-like Jtag that can be used in Xilinx ISE and Vivado

  1. Install softwares: sudo apt-get install libftdi1 ftdi-eeprom
  2. Create a file "flash_digilent.conf" with the following content: