Serial Command Mode Interface

This information is provided to allow you to issue commands to MULTOS Trust Anchor devices over a serial port. This information is only relevant when the device is operating in Command Mode (serial interface) which is instigated by pulling pin 18 low before power up or reset.

The Tutorials page contains an example Arduino sketch that implements this protocol.

The Developer board contains a built-in USB/SERIAL interface, the Nano board provides an FTDI compatible header and the Breakout board can be connected directly.

Message Format

All messages are encoded in a compact big-endian binary TLV format as follows:

Tag Length Value
1 or 2 bytes 0, 1 or 2 bytes n bytes

 

The upper two bits of the first tag byte are used to define the format of the TLV as follows:

Bits Tag Size Length Size
00 1 byte 0 bytes
01 1 byte 1 byte
10 1 byte 2 bytes
11 2 bytes 2 bytes

 

This means that the following tag ranges are possible:

Tag Range Data Size TLV Size
0x00-0x3F No data 1 byte
0x40-0x7F <= 0xFF bytes of data 2+n bytes
0x80-0xBF <= 0xFFFF bytes of data 2+n bytes
0xC000-0xFFFF <= 0xFFFF bytes of data 4+n bytes

Messages

The following user messages have been defined. Other messages are used for debugging.

Message Tag Length Value Direction Notes
ACK 0x01 0 M -> PC Used to indicate that the previously transmitted message was received OK.
Reset 0x06 0 PC -> M Requests a reset.
NACK 0x3F 0 M -> PC Used to indicate that the previously transmitted message was received in error (invalid structure/contents).
Comms Parameters 0x44 0x03
Option Baud Rate
1 byte:

  • 1: Do not send ACK message
  • 2: Send ACK message
2 bytes
PC -> M Changes the com port’s baud rate.  May take up to a second to process.  The ACK is transmitted after the baud rate has been changed.
Command APDU 0x80 0x0004-0xFFFF
CLA INS P1 P2 Lc Command Data Le
1 byte 1 byte 1 byte 1 byte (2 bytes) (Lc bytes) (2 bytes)
PC -> M Lc and command data only present for case 3 and case 4 commands.
Le only present for case 2 and case 4 commands.
Response APDU 0x81 0x0002-0xFFFF
Response Data SW12
(La bytes) 2 bytes
M -> PC Response data only present for case 2 and case 4 commands.
Startup  0xAA 0-0xFFFF
Data
0-64 Kbytes

M5 currently transmits zero bytes of data.

 M -> PC  Transmitted when MULTOS starts up in command mode.