Debian Codegraph @

doc/reveng/baofeng/dr1801/protocol.md

raw
1 # DR-1801A6 (BF1801) - Protocol
2
3 A new version of the popular DM-1801 by Baofeng. Is sold as DR-1801UV or DR-1801A6 and calls itself
4 BF1801. The communication is based on USB CDC-ACM (serial over USB).
5
6 This device uses the AUCTUS A6 chip and thus its protocol. For a detailed description, see jhart99s
7 brilliant [article series](https://jhart99.com/a6-hidden-interface/) on this chip.
8
9 ## Basic structure
10 The first few packets exchanged at a read:
11 ```
12 > aa 06 01 04 03 bb
13 < aa 07 81 04 01 83 bb
14
15 > aa 07 00 2b 00 2c bb
16 < aa 07 80 2b 02 ae bb
17
18 > aa 0a 01 00 00 01 c2 00 c8 bb
19 < aa 15 81 00 01 00 01 dd 90 00 00 00 68 00 02 e6 9e 09 2d ef bb
20
21 > aa 06 01 01 06 bb
22 < ... only packets from device to host from now on with no structure. Just plain data.
23 ```
24
25 The first few packets exchanged at a write:
26 ```
27 > aa 06 01 04 03 bb
28 < aa 07 81 04 01 83 bb
29
30 > aa 07 00 2b 00 2c bb
31 < aa 07 80 2b 02 ae bb
32
33 > aa 12 01 02 00 01 00 01 da 8c 7f f6 00 01 c2 00 0d bb
34 < aa 08 81 02 01 00 8a bb
35
36 > .... Codeplug is written in many large packets with no structure, just data.
37
38 < aa 09 81 03 01 00 00 8a bb
39
40 < 00 | .
41 < 00 | .
42 < 00 | .
43 ```
44
45 There appears to be two kind of messages command/response messages and status messages from the
46 device. The status messages do not appear to be triggered by by the host.
47
48 ## Command/response messages
49 They start with `aah` and end with `bbh`. The general structure of command/response messages are
50 ```
51 +---+---+---+---+---+...+---+---+---+
52 |aah|LEN| CMD | Params |CRC|bbh|
53 +---+---+---+---+---+...+---+---+---+
54 ```
55 The `LEN` field contains the length of the entire packet, including start and stop bytes. The
56 parameter field is optional and of variable length. The checksum is computed by simply xor-ing the
57 entire payload byte-wise. The command field has the following sub-structure:
58 ```
59 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
60 |C/R| Command 15bit, big-endian |
61 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
62 ```
63 The most significant bit contains a flag, that is set for responses and cleared for requests.
64
65 There are many commands already known see jhart99s
66 [list of commands](https://jhart99.com/atecps/#cps-commands).
67
68
69 ### 0000h Command -- Identify radio
70 Not used by the manufacturer CPS but handled by the radio. This command is send without any
71 parameters and the radio returns a string, identifying the radio. The response looks like
72 ```
73 aa 3a 80 00 01 20 2c 42 46 31 38 30 31 2c 41 36 ..... ,B F1801,A6
74 2d 30 30 30 30 2d 58 58 58 58 2c 70 6f 72 74 61 -0000-XX XX,porta
75 62 6c 65 2c 31 33 36 4d 2d 31 37 34 4d 2c 34 30 ble,136M -174M,40
76 30 4d 2d 34 38 30 4d 2c fd bb 0M-480M, ..
77 ```
78
79 The response payload starts with a status byte (0x01 success) followed by an ASCII string,
80 containing the information about the radio. The information is separated by comma (,).
81 The first entry is empty (single space), followed by the device name (BF1801), followed by
82 the firmware version (weird number here), device class (portable) and the frequency ranges.
83 There is likely space for three bands, however, the device only supports 136-174MHz and 400-480MHz.
84
85
86 ### 0104h Command -- Enter CPS mode (?)
87 First command send without any parameters irrespective of codeplug read or write.
88
89 Response contains a single parameter `01h`, likely status byte like *success*.
90
91
92 ### 002bh Command -- Check Programming Password
93 Checks the programming password. Request contains parameter `00h`. Likely, the length of the
94 password. Needs to be tested with a proper password.
95
96 The Response contains a single byte `02h`.
97
98 ### 0100h Command
99 Only send before reading the codeplug. Contains 4bytes of parameters. Seen
100 `00 01 c2 00` = 115200 big endian. Set UART speed?!?
101
102 Response parameters are quiet long, e.g.
103 `01 00 01 dd 90 00 00 00 68 00 02 e6 9e 09 2d`. 0x0001dd90 is the size of the codeplug file. Then,
104 it appears like two uint32 numbers i.e., 0x00000068 and 0x0002e69e. These numbers do not change. The
105 last two bytes, however, appear to be a checksum.
106
107 ### 0101h Command
108 Only send right before reading of the codeplug starts. There is no actual response to this request,
109 the radio responds with the codeplug. No parameters send with this command.
110
111 ### 0102h Command
112 Only send before writing the codeplug. Contains 12bytes of parameters. E.g.,
113 `00 01 00 01 da 8c 7f f6 00 01 c2 00`, again contains 0001c200h=115200.
114 As not the entire codeplug file is written to the device, `00 01 da 8c` may encode the amount to be
115 written.
116
117 Response only contains two bytes. E.g., `01 00`.
118
119 ### 0103h Command
120 Only seen after codeplug write. Contains 3 parameter bytes `01 00 00`.
121