BUS PIRATE FIRMWARE update (V.0C), JTAG and much more

Download: buspirate.v0c.zip

A few weeks ago we wrote about our Bus Pirate universal serial interface tool. We used the recent holiday to add some new features, like a JTAG programmer, macros, frequency measurement, and more. A major code reorganization makes everything simpler to read and update.

Check out the a demonstration of the new features below. We’re compiling a roadmap and wish list, so share your ideas in the comments. You can also see how we used the Bus Pirate to read a smart card and test-drive an I2C crystal oscillator.

New protocols

I2C>m <–setup mode 1. HiZ <– high impedance pins (safe mode) 2. 1-WIRE <– not ready for this release 3. UART. 4. I2C. 5. 스파 6. JTAG <– interface and programmer 7. Raw2wire. 8. raw3wire. MODE>1
900 모드 설정
HiZ>

This firmware release lists three new protocols.

Hi-Z makes all pins high impedance/input, a safe state that won’t damage an attached circuit. To be safe, the Bus Pirate now starts in this mode.

1-Wire is listed, but we couldn’t include it in this release because we still don’t have any parts to test with our library. This is just a placeholder for now, but it will be added as soon as we get a 1-Wire part to test.

We wrote a simplified JTAG interface that includes a XSVF player for programming JTAG device chains.

**We included a hardware I2C library, but according to the device errata there’s a bug in the 24FJ64GA002 rev3 I2C module. This will work with a different chip (e.g. a 28pin dsPIC33).

Connection table

1-Wire

I2C*

SPI**

RS232

JTAG

B9

SDA.

SDA.

MOSI

TDI

B8

SCL.

CLK

TCK

B7

MISO

RX

TDO

B6

CS

TX

TMS

B5

AUX

AUX

AUX

AUX

AUX

지면

GND.

GND.

GND.

GND.

GND.

*also raw 2 wire. **also raw 3 wire.

The new modes connect to the Bus Pirate as described in the table.

New features and settings

Frequency measurement

HiZ>F <– do a frequency count 9xx FREQ count ON AUX: 22199552Hz (22MHz) HiZ>

As seen in the DS1077 demonstration, we added a frequency counter to the Bus Pirate’s AUX pin.  ‘F’ steps frequency, maximum of about 50MHz.

Assign axillary control

HiZ>c <– menu c AUX PIN 1. AUX (DEFAULT) 2. CS/TMS MODE>1 <– set AUX control mode 9xx AUX: DEFAULT setting (AUX PIN) HiZ>

Sometimes we need to control the chip select (CS) /JTAG state device (TMS) pins manually. ‘c’ toggles the pin control between the axillary pin and the chip select pin.

Set terminal speed

HiZ>b <– menu b Set serial port speed: (bps) 1. 300 ...에 ... 9. 115200 SPEED>9 <– set speed Adjust your terminal and press space to continue HiZ>

‘b’ adjusts the PC-side serial port speed.

Macros

A new syntax addition, ‘(#)’, triggers protocol dependent macros.

JTAG>(0) <–macro 0 0.Macro 메뉴 1.Reset chain 2.Probe chain 3.XSVF player JTAG>

In any mode, use the macro (0) to display a menu of available macros.

I2C address search

I2C>(1) <–scan I2C addresses macro XXX 7 비트 I2C 주소 공간을 검색합니다. 에서 장치를 찾았습니다. 0xB0 0xB1 <–DS1077 responds to write and read address I2C>

The I2C library includes a macro to automatically search the I2C address range for devices. helpful when you work with an unknown chip.

Raw2wire smart card ISO 7813-3 ATR

RAW2WIRE>(1)<–ATR and decode macro ISO 7813-3 ATR 950 AUX LOW 951 AUX HIGH 4xx RAW2WIRE 0x01 CLOCK TICKS 950 AUX LOW ISO 7813-3 reply: 0xA2 0x13 0x10 0x91<–ATR bytes Protocol: 2 wire <–decoded ATR data Read type: to end<– Data units: 256 <– Data unit length: 8 bits <– RAW2WIRE>

Macro 1 resets and identifies a smart card. For much more about the ISO7813-3 ATR, see how we used the Bus Pirate to read a smart card.

JTAG

JTAG is a debugging and programming interface for all kinds of electronics. The raw hardware interface can be accessed with the Bus Pirate’s raw 3 wire library, but we added a few features to make it much easier.

JTAG has different modes where data entry does different things. Modes are navigated with the JTAG TMS signal; there are a bunch of JTAG modes, called states.The Bus Pirate’s JTAG library is just the raw 3 wire library, enhanced to help with JTAG state changes.

We only implemented the JTAG states we need to get data in and out of a JTAG device chain: reset, idle, data register, and instruction register. Macro (1) issues a JTAG chain reset, and initializes the chain to the idle state. { puts the JTAG chain in data register mode. [ puts the chain in instruction register mode. ] or } return the chain to the idle state. The Bus Pirate has an internal state device tracker that is smart enough to manage the chain without explicitly returning the chain to idle; in other words, you don’t have to close your tags. The state device tracker reports every state change to help debug problems.

JTAG>[0xfe {rrrr} <– same as [0xfe]{rrrr} xxx JTAGSM: already IDLE xxx jtagsm : IDLE-> 명령어 레지스터 (TMS 용 1 비트 지연)
610 JTAG ready TO write IR <– JTAG chain instruction register 620 JTAG WRITE: 0xFE <– request ID xxx JTAGSM: (WROTE 지연된 비트) IR-> 유휴 <-back to Idle xxx jtagsm : IDLE-> 데이터 레지스터 <- 데이터 레지스터에 611 JTAG 준비 준비 / 쓰기 DR. 630 JTAG 읽기 : 0x93 <-device ID. 630 JTAG 읽기 : 0x40. 630 JTAG 읽기 : 0x60. 630 JTAG 읽기 : 0x59. xxx jtagsm : DR-> IDLE <-BACK to IDLE 640 JTAG IDLE. JTAG>

다음은 Xilinx XC9572 CPLD와 짧은 상호 작용입니다. 우리는 명령 레지스터 ([)로 이동하여 장치 ID 요청 명령 (0xFE)을 보냅니다. 그런 다음 데이터 레지스터 ({), 4 바이트 (RRRR 또는 R : 4 속기)를 읽고 유휴 상태로 돌아 가기.

지연된 비트 쓰기는 무엇입니까?

JTAG에서는 명령 레지스터에 기록 된 마지막 데이터 비트가 상태 변경과 동시에 입력해야합니다. 버스 해적은 실제로 상태를 변경할 때 예측 방법이 없기 때문에 세 가지 중 하나가 발생할 때까지 각 바이트 쓰기의 마지막 비트가 지연됩니다.

명령 레지스터를 a},] 또는 {명령으로 종료하십시오.

다른 바이트 값을 씁니다

읽기 명령

보류중인 비트는 비트 연산 (예 :! 또는 ^)에 의해 지워지지 않습니다. 마지막 바이트를 쓰기 전에이 작업을 수행하거나 코드를 변경하십시오. 우리는 데이터 레지스터에 대한 보류중인 기록을 구현하지는 않았지만 아마 필요할 것입니다. 우리가 한 것처럼 데이터 등록을 쓰는 것만 짓는 경우이 문제를 실행해야 할 수도 있습니다.

JTAG 매크로

JTAG> (1) <-macro 1. xxx jtagsm : 재설정 xxx jtagsm : 재설정 -> 유휴
JTAG>

JTAG 매크로 (1) JTAG 체인을 재설정 한 다음 IDLE 상태로 향상시킵니다.

JTAG> (2) <-macro2. xxx JTAG init 체인 xxx jtagsm : 재설정 xxx jtagsm : 재설정 -> 유휴
xxx jtagsm : IDLE-> 명령어 레지스터 (TMS 용 1 비트 지연)
xxx jtagsm : IR-> 유휴
xxx jtagsm : IDLE-> 데이터 등록기
xxx jtagsm : DR-> 유휴
xxx jtagsm : 재설정
xxx jtagsm : 재설정 -> 유휴
xxx jtagsm : IDLE-> 데이터 등록기
XXX JTAG 체인 보고서 : <- 보고서의 시작 0x01 장치 (들) # 0x01 : 0x93 0x40 0x60 0x59 <-device IDS xxx jtagsm : DR-> 유휴
JTAG>

매크로 (2) 체인을 재설정하고 장치를 계산하고 모든 장치 ID를보고합니다.

JTAG> (3) <-macro 3. 6xx JTAG XSVF Player. XXX XON / XOFF 흐름 제어 필수 <- 리드! xxx z를 눌러 계속 <- Z를 누릅니다 xxx begin xsvf 제출 <- 파일을 제출하십시오 6 × 0 XSVF OK <- 결과 또는 오류 PC는 XOFF 후 최대 0x05 바이트를 드리블했습니다 (괜찮습니다) 6xx 계속 <- 계속하려면 5 번 Z를 누릅니다. JTAG>

매크로 3은 자일링스에서 코드를 사용하는 XSVF 플레이어 / 프로그래머입니다. XSVF는 Xilinx (PDF)에서 설명한대로 바이트 형식의 SVF입니다. XSVF 파일은 적절한 일반 JTAG 정의 파일, 심지어 XILINX 장치조차도 컴파일 할 수 있습니다. 우리는 Hercules 및 Tera Term의 바이너리 전송 기능을 프로그래머에게 XSVF 파일을 보내는 데 성공적으로 사용했습니다.

어떤 경우에는 JTAG가 PC가 데이터의 바이트를 전송하는 것보다 오래 일시 중지되므로 XSVF 플레이어에 대한 XON / XOFF 소프트웨어 흐름 제어를 구현했습니다. XSVF 파일을 제출하기 전에 터미널이 XON / XOFF 흐름 제어 모드에 있어야하거나 프로그래머가 실패합니다. 소프트웨어 흐름 제어가 있더라도 현대 PC는 흐름 제어 신호를 수신하기 전에 운영 체제의 레이어를 통해 이미 여러 바이트를 전송했습니다. 우리는이 바이트를 이사하기 전에이 바이트를 잡아서이를 처리합니다. 이것은 최대 바이트 수 “드리블링”으로보고됩니다.

업로드에 오류가 발생하면 PC는 버스 해적에서 바이트를 계속 뱉어 낼 것입니다. 오류 메시지를 표시하고 터미널에서 가비지를 피하기 위해 XSVF 플레이어는 프롬프트로 돌아 오기 전에 5 개의 소문자 Z를 대기합니다. XSVF 파일에서 결코 발생하지 않기 때문에이 순서를 선택했습니다.

* XSVF 플레이어는 JTAG HI-Z 핀 설정을 존중하지 않습니다. 그것이 갔다, 그것은 실패한다. 버퍼없이 조심스럽게 전압을 혼합하십시오.

더 나은 코드 구조

버전 0b와 0C 펌웨어 간의 가장 중요한 차이점은 코드 구조가 엄청난 향상되었습니다. 버스 해적은 초기 기사에 대해 포장하기 전에 수많은 화신으로 존재했습니다. V.0C는 코드 라이브러리를 조화시키고 새로운 프로토콜을 더 간단하게 만듭니다.

사용자 정의 프로토콜을 추가하는 방법

버스 해적 코드는 사용자 인터페이스를 처리하고 두 변수를 활성 프로토콜 라이브러리에 전달합니다. 첫 번째 변수는 cmd_read, cmd_readbulk 또는 cmd_write와 같은 명령입니다. 전체 명령 세트는 BASE.H에서 정의됩니다. 두 번째 변수는 선택적 값입니다. 쉬운 cmd_read 명령이 값을 전달하고, 대량 읽기 명령은 바이트 수를 전달하고, 쓰기 명령은 버스에 쓰기 위해 값을 전달합니다. 최소한이 변수를 수신하고 번역하는 기능이 필요합니다. 버스 조치에.

우리는 버스 조치에 명령을 연결하기 위해 세 가지 기술을 사용했습니다. 쉬운 코드는 spi.c와 같은 거대한 switch 문에서 직접 이동할 수 있습니다. 외부 라이브러리 I2C.C 및 M_I2C_1.C와 같은 단일 링크 기능을 사용합니다. 훨씬 더 복잡한 프로토콜은 스위치 문을 사용하여 라이브러리에 포함 된 함수를 호출합니다 (RAW2Wire.c, raw3wirec, jtag.c uart.c). 터미널 IO에 대한 유용한 기능은 base.h / c에 포함됩니다.

대규모 코드 개선으로 인해 버스 해적이있는 새로운 프로토콜을 등록하기 위해 가볍게 혼란스러워합니다.

base.h – D를 만듭니다프로토콜에 대한 에이시션. 마지막 항목은 현재 “#define raw3wire 7″이므로 다음 항목은 “#define mycustomwire 8″일 수 있습니다.

buspirate.c – 처리 기능에 액세스 할 수있는 헤더 파일을 포함합니다. char * mode [] = 변수 목록에 메뉴 항목을 추가하십시오. 메뉴 항목은 Degy.h 정의에 할당 된 번호와 동일한 위치에 있어야합니다. myCustomwire가 8 숫자 인 경우 모드 변수의 8 개의 항목이어야합니다. 마지막으로 모드가 “MyCustomWire”로 설정된 경우 사용자 지정 라이브러리 처리 루틴을 호출하는 BPProcess () 함수에 추가 스위치를 추가하십시오.

그것을 더 멀리 : 하루 하루에 해킹 목록

우리는 프로토콜, 기능 및 매크로의 세 가지 위시 목록으로 얻은 의견을 수집했습니다.

프로토콜

열거 형 (* 테스트 할 부분이있는 즉시 준비가 된 경우) 1-Wire

OBD-II (감사합니다 [Shadyman])

할 수있다

미디 (위키피디아)

DMX512-A.

Irda, RC5x 등

일부 프로토콜에는 외부 트랜시버가 필요합니다.

특징

펄스 폭 변조기, 주파수 발생기

“인터럽트까지 기다림”명령

주파수 측정을 입력하여 캡처 주변 장치를 변환합니다

모든 PIN에서 주파수 측정을 허용합니다

현재 구성 설정 및 PIN 상태에 대한 보고서를 보여줍니다.

벌크 읽기, 클록 틱, 지연 등에 대한 정수 반복 값

CRC 생성기

매크로

투명 UART 다리

SD 카드 초기화, 메타 데이터 추출 및 덤프

EEPROM 프로그램 / 덤프 (I2C / SPI)

노키아 6100 LCD 초기화, 제어

NMEA GPS 데이터 디코더

목록에 추가 할 것이 있습니까?

펌웨어 다운로드 : buspirate.v0c.zip.

Leave a Reply

Your email address will not be published. Required fields are marked *