Last active
June 29, 2026 06:28
-
-
Save kellertk/1522c505c9d724cddfc26201cc36fbf0 to your computer and use it in GitHub Desktop.
Atmel ATDH1150USB on OpenOCD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Atmel ATDH1150USB as an OpenOCD JTAG adapter (Linux) | |
| # | |
| # This is Microchip's official USB JTAG adapter for their CPLD devices. On | |
| # Windows you can use ATMISP. The robots would have you believe it's not | |
| # supported on Linux, but I think that's because nobody has bothered to write an | |
| # OpenOCD config file for it. This one works for me. | |
| # | |
| # Inside the adapter is a FT2232D, 74HC244 output buffer, a few SN74LVC1T45 | |
| # level shifters and a status LED. VCCT needs to be supplied on the JTAG header | |
| # to power the buffer and shifters. (See document revision | |
| # Atmel-8909A-CPLD-ATDH1150USB-ATF15-JTAG-ISP-Download-Cable-UserGuide_072015 | |
| # for details) | |
| # | |
| # The adapter will show up as two FT2232D devices. Only the first is used. | |
| # | |
| # VID:PID 0403:6010 (EEPROM strings ATMEL / ATDH1150USB). MPSSE channel 0. | |
| # | |
| # Channel-A pin map: | |
| # AD0=TCK AD1=TDI(out) AD2=TDO(in) AD3=TMS | |
| # ACBUS0 (0x100) = 74HC244 /OE | |
| # ACBUS2 (0x400) = Red LED -> active low | |
| # ACBUS3 (0x800) = Green LED -> active low | |
| # | |
| # layout_init default = 0x0ef8 0x0ffb: | |
| # dir 0x0ffb: TCK,TDI,TMS,ACBUS0-3,AD4-7 outputs; TDO input | |
| # data 0x0ef8: TMS high, ACBUS0 LOW (buffers on), RED+GREEN high (LEDs OFF) | |
| adapter driver ftdi | |
| ftdi vid_pid 0x0403 0x6010 | |
| ftdi channel 0 | |
| ftdi layout_init 0x0ef8 0x0ffb | |
| ftdi layout_signal TCK -data 0x0001 | |
| ftdi layout_signal TDI -data 0x0002 | |
| ftdi layout_signal TDO -data 0x0004 | |
| ftdi layout_signal TMS -data 0x0008 | |
| transport select jtag | |
| adapter speed 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Flash an SVF to the ATF1504AS via the Atmel ATDH1150USB + OpenOCD. | |
| # | |
| # Usage: flash_cpld.sh <file.svf> | |
| set -euo pipefail | |
| HERE="$(dirname "$(readlink -f "$0")")" | |
| CFG="$HERE/atdh1150usb.cfg" | |
| SVF="${1:?usage: flash_cpld.sh <file.svf>}" | |
| IDCODE=0x0150403f # ATF1504AS | |
| DIR=0x0ffb # all JTAG + ACBUS0-3 + AD4-7 outputs; TDO input | |
| # layout_init data | |
| AMBER=0x02f8 # RED on + GREEN on | |
| GREEN=0x06f8 # GREEN on (RED off) -> success | |
| RED=0x0af8 # RED on (GREEN off) -> failure | |
| led() { # $1 = layout_init data | |
| openocd -f "$CFG" -c "ftdi layout_init $1 $DIR" \ | |
| -c "jtag newtap atf tap -irlen 10" \ | |
| -c "catch { init }" -c shutdown >/dev/null 2>&1 || true | |
| } | |
| log="$(mktemp)" | |
| trap 'rm -f "$log"' EXIT | |
| echo ">>> Programming $(basename "$SVF")..." | |
| openocd -f "$CFG" -c "ftdi layout_init $AMBER $DIR" \ | |
| -c "jtag newtap atf tap -irlen 10 -expected-id $IDCODE" \ | |
| -c init -c "svf $SVF" -c shutdown 2>&1 | tee "$log" || true | |
| if grep -q "programmed successfully" "$log" && grep -q "with 0 errors" "$log"; then | |
| echo ">>> SUCCESS" | |
| led "$GREEN" | |
| exit 0 | |
| else | |
| echo ">>> FAILED" >&2 | |
| led "$RED" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment