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. SPI. 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

味噌

RX

TDO

B6

CS

TX

TMS

B5

奧克斯

奧克斯

奧克斯

奧克斯

奧克斯

地面

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搜索7bit 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時鐘滴答 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:空閒 - >指令寄存器(延遲TMS的一位)
610 JTAG ready TO write IR <– JTAG chain instruction register 620 JTAG WRITE: 0xFE <– request ID xxx JTAGSM: (WROte延遲位)ir->空閒< - ack到空閒 XXX JTAGSM:空閒 - >數據寄存器<-IDLE到數據寄存器 611 JTAG準備讀/寫博士 630 JTAG閱讀:0x93 <-DEVICE ID 630 JTAG閱讀:0x40 630 JTAG閱讀:0x60 630 JTAG閱讀:0x59 xxx jtagsm:dr->空閒< - ack到空閒 640 JTAG閒置 JTAG>

這是與Xilinx XC9572 CPLD的簡短交互。我們轉到指令寄存器([),並發送設備ID請求命令(0xFE)。然後,我們去數據寄存器({),讀取四個字節(rrrr,或r:4速記),並返回空閒(})。

什麼是延遲的寫點?

JTAG要求將寫入指令寄存器的最後數據位與狀態更改同時輸入。因為總線海盜無法預測,當我們實際更改狀態時,它會延遲每個字節寫入的最後一點,直到三件事中的一個發生:

退出使用A},]或{命令的指令寄存器

寫另一個字節值

讀命令

不通過按位操作(如!或^)清除待處理位。在編寫最後一個字節之前執行這些,或更改代碼。我們還沒有將待定寫入數據寄存器,但可能需要。如果您正在編寫數據寄存器,而是只要讀取,您可能需要執行此操作。

JTAG宏

JTAG>(1)<-Macro 1 xxx jtagsm:重置 xxx jtagsm:reset->空閒
JTAG>

JTAG宏(1)重置JTAG鏈,然後將其前進到空閒狀態。

JTAG>(2)<-macro 2 XXX JTAG INIT鏈 xxx jtagsm:重置 xxx jtagsm:reset->空閒
XXX JTAGSM:空閒 – >指令寄存器(延遲TMS的一位)
xxx jtagsm:ir->空閒
XXX JTAGSM:空閒 – >數據寄存器
xxx jtagsm:dr->空閒
xxx jtagsm:重置
xxx jtagsm:reset->空閒
XXX JTAGSM:空閒 – >數據寄存器
XXX JTAG鏈報告:<-start報告 0x01設備 #0x01:0x93 0x40 0x60 0x59 <-device ID xxx jtagsm:dr->空閒
JTAG>

宏(2)重置鏈,計算設備,並報告所有設備ID。

JTAG>(3)<-Macro 3 6xx JTAG XSVF播放器 XXX XON / XOFF流量控制所需<-required! XXX按Z繼續< - 按Z XXX Begin XSVF提交< - 提交文件 6×0 XSVF OK < - 結果或錯誤 XOFF之後,您的PC可驅動最大0x05字節(即確定) 6xx按z 5次繼續< - 繼續 JTAG>

宏3是XSVF播放器/程序員使用來自Xilinx的代碼。 XSVF是字節格式SVF,如Xilinx(PDF)所述。可以使用適當的通用JTAG定義文件,即使是非Xilinx設備的任何鏈編譯XSVF文件。我們成功使用Hercules和Tera術語中的二進制傳輸功能來向程序員發送XSVF文件。

JTAG在某些情況下暫停超過PC要傳輸數據的字節,因此我們為XSVF播放器實現了XON / XOFF軟件流控制。在提交XSVF文件之前,您的終端應在XON / XOFF流控制模式下,或者程序員將失敗。即使使用軟件流量控制,在接收到流量控制信號之前,現代PC已經通過操作系統的層發送了幾個字節。我們通過在繼續之前捕獲這些字節來處理這一點,這將報告為最大字節數“滴下”。

如果上傳中有錯誤,則PC可能會繼續在總線海盜上吐字節。為了使錯誤消息可見,避免終端中的垃圾,XSVF播放器在返回提示之前等待五個小寫z。我們選擇了這個序列,因為它永遠不會發生在XSVF文件中。

*請注意,XSVF播放器不尊重JTAG Hi-Z引腳設置。它做了,它失敗了。在沒有緩衝器的情況下仔細混合電壓。

更好的代碼結構

版本0B和0C固件之間最顯著的差異是代碼結構的大量改進。在我們打包初始文章之前,總線海盜存在於許多化身。 V.0C協調代碼庫並更簡單地添加新協議。

如何添加自定義協議

總線海盜代碼處理用戶界面,並將兩個變量傳遞給活動協議庫。第一個變量是命令,例如cmd_read,cmd_readbulk或cmd_write。整個命令集在base.h中定義第二變量是可選值。一個簡單的cmd_read命令通過沒有值,批量讀命令通過讀取的字節數,寫命令通過將值寫入總線等。至少,自定義協議需要一個接收這些變量並轉換它們公交車行動。

我們使用了三種不同的技術來將命令鏈接到總線動作。簡單的代碼可以直接進入一個巨大的交換機語句,如spi.c.外部庫使用單鏈接函數,如i2c.c和m_i2c_1.c。更複雜的協議使用Switch語句來調用庫中包含的函數(raw2wire.c,raw3wire.c,jtag.cuart.c)。終端IO的有用功能包含在base.h / c中。

由於代碼的巨大改進,它現在只有輕度混淆,可以使用總線海盜註冊新協議:

base.h – 創建一個d協議的efinition。最後一個條目目前是“#define Raw3wire 7”,所以下一個條目可能是“#define mycustomwire 8”。

Buspirate.c – 包含帶有該標題文件,可以訪問處理功能。在char * mode [] =變量列表中添加菜單條目。菜單條目應在列表上的相同位置,作為在Base.h中分配的數字。如果mycustomwire是8號,則應是模式變量中的八個條目。最後,當模式設置為“mycustomwire”時,將附加切換添加到調用自定義庫處理例程的BPProcess()函數。

進一步接受:一天願望清單

我們編譯了我們已經進入三個願望清單:協議,功能和宏的反饋。

協議

1線,枚舉(*一旦我們有零件測試就準備就緒)

OBD-II(謝謝[Shadyman])

能夠

MIDI(維基百科)

DMX512-A.

IRDA,RC5X等

某些協議將需要外部收發器。

特徵

脈衝寬度調製器,頻率發生器

“等到中斷”命令

將頻率測量轉換為輸入捕獲外設

允許任何引腳頻率測量

顯示當前配置設置和PIN狀態的報告。

整數批量讀取,時鐘滴答,延遲等重複值。

CRC發電機

透明UART橋樑

SD卡初始化,元數據提取物和轉儲

EEPROM程序/轉儲(I2C / SPI)

諾基亞6100 LCD初始化,控制

NMEA GPS數據解碼器

您有什麼要添加到列表的嗎?

固件下載:Buspirate.v0c.zip

Leave a Reply

Your email address will not be published.