2026/01/24(土)MACH XO2の書き込み
mach xo2 cpld config via ftdi usb d2xxYes — you can configure/program a Lattice MachXO2 CPLD via an FTDI USB interface using the D2XX drivers, but there are a few important pieces you need to know about how it works and what’s involved in practice: 
⸻
📌 Overview
🔌 What’s Possible
• The MachXO2 family of CPLDs (e.g., LCMXO2 devices) can be programmed via JTAG or synchronous serial interfaces such as SPI or I2C, not directly as a USB peripheral. 
• An FTDI FT2232 / FT2232H / similar chip on your PCB or development board provides the USB ⇄ JTAG/SPI/I²C bridge. 
• Lattice’s tools (e.g., Diamond Programmer) recognize such an FTDI interface as a programming cable (e.g., HW-USBN-2B) when the USB interface is correctly configured. 
⸻
🧰 How It Works: FTDI + D2XX + MachXO2
📌 FTDI and D2XX Drivers
• D2XX drivers (ftd2xx) give you direct access to an FTDI device via an API (FT_Open(), FT_Write(), etc.). 
• On chips with the MPSSE (Multi-Protocol Synchronous Serial Engine) — such as FT2232H — you can generate bit-banged JTAG, SPI or I²C signals over USB. 
👉 Using D2XX + MPSSE, you can drive the hardware layer for JTAG (TMS, TCK, TDI, TDO) that MachXO2 expects. There are examples in the FTDI MPSSE application notes for JTAG over FTDI + D2XX, which is exactly what a programming cable does internally. 
⸻
🔧 Practical Steps
➤ 1. Get the FTDI Chip Configured
• Your FTDI must be in a mode that allows low-level synchronous signaling (MPSSE) — not just USB UART/VCP.
• On many boards, this requires setting the EEPROM descriptor so that the host and tools see the device as a JTAG programmer (like HW-USBN-2B). 
Tools:
• FT_Prog (FTDI Utility) — program the FTDI EEPROM descriptor for MPSSE/JTAG mode.
• On some dev boards, the EEPROM is already set to present a JTAG programmer to Diamond.
⸻
➤ 2. Install Drivers
• Install D2XX drivers appropriate for your OS. 
• On Linux, you may need to prevent the default ftdi_sio/usbserial drivers from binding so Diamond / direct tools can access the chip directly.
⸻
➤ 3. Wiring & Interface
• Physically connect the FTDI’s synchronous pins to MachXO2’s JTAG or SPI/I²C config interface, as supported.
• JTAG is usually the simplest:
• TCK → TCK
• TMS → TMS
• TDI → TDI
• TDO → TDO
• GND, VCC for reference
⸻
➤ 4. Use Diamond / open-source tool
With Lattice Diamond:
• Diamond Programmer should detect your FTDI-based cable if the descriptor matches and the MPSSE is enabled.
• Choose the correct cable (e.g., HW-USBN-2B or equivalent) and target device.
• Diamond handles the upload of the JEDEC (.jed), or .xcf/.bit equivalent. 
Alternative / Open Tool:
• openFPGALoader supports FTDI JTAG (including MachXO2 in some forks — search docs), using the FTDI D2XX/MPSSE layer instead of proprietary libs.
⸻
🧠 Notes & Tips
✔ You don’t program MachXO2 directly over “USB as USB” — the FTDI chip bridges USB to synchronous signals that the CPLD expects (usually JTAG). 
✔ FTDI’s MPSSE engine is the key: it lets you bit-bang protocols over USB via D2XX. 
✔ Diamond Programmer internally drives the low-level protocol: you typically don’t write your own programming routines unless you’re doing a custom bootloader.
⸻
If you want sample code snippets for D2XX/MPSSE JTAG bit-banging for a MachXO2 programming tool, I can provide C/C++ examples too! (Would you like that?)