Skip to content

GreenPAK Universal Dev Board 1

whitequark edited this page Jul 5, 2016 · 33 revisions

This page describes the USB protocol used by the GreenPAK Universal Dev Board 1, as shipped in the GreenPAK 4 Development Kit and probably others as well. Protocol RE is done by @whitequark with board revision v1.3.1 and firmware v2.4.

Protocol

The protocol is based on USBHID. It uses interrupt URBs, always with a 63 byte payload. All numbers below are in hexadecimal.

Overall URB payload format:

Offset Length Meaning
00 01 HID report number, always 01
01 02 Packet type
03 01 Packet sequence number

The packet sequence number only makes sense in the case where a single command has to be split between several packets because of the URB length limit. For write-type commands, the WRITE packet contains the amount of packets to be written after this one and its READ counterpart contains 00. For read-type commands, the WRITE packet contains 00 and its READ counterpart contains the amount of packets to be read after this one.

Every byte not specified in the individual packet format was always observed as 00.

"Read back command for ..." means that the returned payload for this READ command is exactly the same as what was provided for the WRITE command it refers to.

Packets

WRITE 0500

This packet (likely) resets the board controller.

READ 053f

Read back for WRITE 0500.

WRITE 2104

This packet turns the STATUS LED on and off.

Offset Length Meaning
04 01 STATUS LED enabled

READ 213f

Read back for WRITE 2104.

WRITE 0439

This packet configures the I/O buffers, LEDs, and the expansion connector.

Format:

Offset Length Meaning
04 02 TP2 output configuration
06 02 TP3 output configuration
08 02 TP4 output configuration
0a 02 TP5 output configuration
0c 02 TP6 output configuration
0e 02 TP7 output configuration
10 02 TP8 output configuration
12 02 TP9 output configuration
14 02 TP10 output configuration
16 02 TP12 output configuration
18 02 TP13 output configuration
1a 02 TP14 output configuration
1c 02 TP15 output configuration
1e 02 TP16 output configuration
20 02 TP17 output configuration
22 02 TP18 output configuration
24 02 TP19 output configuration
26 02 TP20 output configuration
2f 03 Expansion connector configuration
32 01 TP3..TP6 LED configuration
33 01 TP7..TP10 LED configuration
34 01 TP12..TP15 LED configuration
35 02 TP16..TP20 LED configuration
37 01 "POWER" LED status? Observed as 01

TPx output configuration:

Value Meaning
0200 N/C
0c01 VDD
0c00 GND
0e01 Pull-up
0e00 Pull-down
0c03 Logic generator, push-pull
0403 Logic generator, open-drain + pull-up
0603 Logic generator, open-drain + pull-down
0a03 Logic generator, open-drain, drives HI
0803 Logic generator, open-drain, drives LO
0e03 Logic generator, pull-up/down

TP3..TP6, TP7..TP10 and TP12..TP15 LED configuration (a bit mask):

Value Meaning
01 TP(n+0) LED enabled
02 TP(n+1) LED enabled
04 TP(n+2) LED enabled
08 TP(n+3) LED enabled
10 TP(n+0) LED inverted
20 TP(n+1) LED inverted
40 TP(n+2) LED inverted
80 TP(n+3) LED inverted

TP16..TP20 LED configuration (a bit mask):

Value Meaning
0100 TP(n+0) LED enabled
0200 TP(n+1) LED enabled
0400 TP(n+2) LED enabled
0800 TP(n+3) LED enabled
1000 TP(n+4) LED enabled
0001 TP(n+0) LED inverted
0002 TP(n+1) LED inverted
0004 TP(n+2) LED inverted
0008 TP(n+3) LED inverted
0010 TP(n+4) LED inverted

Expansion connector configuration (a bit mask):

Value Meaning
000100 VDD
000004 TP2
000001 TP3
000010 TP4
000040 TP5
010000 TP6
040000 TP7
100000 TP8
400000 TP9
800000 TP10
200000 TP12
000008 TP13
000002 TP14
008000 TP15
000020 TP16
020000 TP17
002000 TP18
000800 TP19
080000 TP20

WRITE 490b

This command trims the oscillator.

Offset Length Meaning
05 01 Trim value
06 06 Unknown; observed as 05040a110201

READ 493f

Read back for WRITE 490b. Note that the payload is not identical.

Offset Length Meaning
06 06 Unknown; observed as 05040a110201

WRITE 4204

This command starts measuring the oscillator frequency.

READ 423f

This command reads back the oscillator frequency after WRITE 4204.

Offset Length Meaning
06 02 Oscillator frequency

WRITE 033f / WRITE 0318

This command transfers the bitstream with the purpose of verification.

With sequence number 04:

Offset Length Meaning
04 01 Unknown; observed as 08
07 02 The number of SCL cycles to use, 0898 (including the trailing cycles)
09 38 reg<0:447>

With sequence number 03:

Offset Length Meaning
04 3d reg<448:935>

With sequence number 02:

Offset Length Meaning
04 3d reg<936:1423>

With sequence number 01:

Offset Length Meaning
04 3d reg<1424:1911>

With sequence number 00:

Offset Length Meaning
04 15 reg<1912:X>, 32 bits of unknown purpose, reg<X:2047>

READ 073f / READ 1a3f

Read back for WRITE 033f / WRITE 0318, respectively.

Command sequences

Trimming

In a loop, searching by changing the trim value between ff to 00:

  1. WRITE 490b
  2. READ 493f
  3. WRITE 4204
  4. READ 423f

Verifying

  1. WRITE 033f SEQ 04
  2. READ 073f
  3. WRITE 033f SEQ 03
  4. READ 073f
  5. WRITE 033f SEQ 02
  6. READ 073f
  7. WRITE 033f SEQ 01
  8. READ 073f
  9. WRITE 0318 SEQ 00
  10. READ 1a3f

It is unknown how to determine verification status.