@@ -8,204 +8,67 @@ Supports:
88
99Right now the backend uses raw hid reports for debug communication, terminal.py will open an interactive terminal to the device.
1010
11- ### How to flash to the teensy board:
12- ``` sh
13- pio run -e teensy41 --target upload
14- pio run -e teensy31 --target upload
15- pio run -e teensy36 --target upload
16- ```
11+ ### Building
1712
18- ### Modifications required to teensy 3.1 codebase:
19-
20- For this to work you need to modify the teensy source code to set the RAWHID iInterface field to 2 to use the product string around line 1136 in ` ~/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_desc.c `
21-
22- ``` c
23- #ifdef RAWHID_INTERFACE
24- // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
25- 9, // bLength
26- 4, // bDescriptorType
27- RAWHID_INTERFACE, // bInterfaceNumber
28- 0, // bAlternateSetting
29- 2, // bNumEndpoints
30- 0x03, // bInterfaceClass (0x03 = HID)
31- 0x00, // bInterfaceSubClass
32- 0x00, // bInterfaceProtocol
33- 2, // iInterface <-------------------Modify this!
34- ```
13+ Pre-requisites:
3514
36- `usb_desc.h`
37- ```c
38- // Add the following to the usb definitions section after USB_EVERYTHING
39- #elif defined(USB_RAWHID_TRIPLESERIAL)
40- #define VENDOR_ID 0x16C0
41- #define PRODUCT_ID 0x048C
42- #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
43- #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
44- #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
45- #define MANUFACTURER_NAME_LEN 11
46- #define PRODUCT_NAME {'C','M','S','I','S','-','D','A','P'}
47- #define PRODUCT_NAME_LEN 9
48- #define EP0_SIZE 64
49- #define NUM_ENDPOINTS 12
50- #define NUM_USB_BUFFERS 32
51- #define NUM_INTERFACE 7
52-
53- #define CDC_IAD_DESCRIPTOR 1 // Serial
54- #define CDC_STATUS_INTERFACE 0
55- #define CDC_DATA_INTERFACE 1
56- #define CDC_ACM_ENDPOINT 2
57- #define CDC_RX_ENDPOINT 3
58- #define CDC_TX_ENDPOINT 4
59- #define CDC_ACM_SIZE 16
60- #define CDC_RX_SIZE 64
61- #define CDC_TX_SIZE 64
62-
63- #define CDC2_STATUS_INTERFACE 2 // SerialUSB1
64- #define CDC2_DATA_INTERFACE 3
65- #define CDC2_ACM_ENDPOINT 5
66- #define CDC2_RX_ENDPOINT 6
67- #define CDC2_TX_ENDPOINT 7
68- #define CDC2_ACM_SIZE 16
69- #define CDC2_RX_SIZE 64
70- #define CDC2_TX_SIZE 64
71-
72- #define CDC3_STATUS_INTERFACE 4 // SerialUSB2
73- #define CDC3_DATA_INTERFACE 5
74- #define CDC3_ACM_ENDPOINT 8
75- #define CDC3_RX_ENDPOINT 9
76- #define CDC3_TX_ENDPOINT 10
77- #define CDC3_ACM_SIZE 16
78- #define CDC3_RX_SIZE 64
79- #define CDC3_TX_SIZE 64
80-
81- #define RAWHID_INTERFACE 6 // RawHID
82- #define RAWHID_TX_ENDPOINT 11
83- #define RAWHID_TX_SIZE 64
84- #define RAWHID_TX_INTERVAL 1
85- #define RAWHID_RX_ENDPOINT 12
86- #define RAWHID_RX_SIZE 64
87- #define RAWHID_RX_INTERVAL 1
88-
89- #define ENDPOINT2_CONFIG ENDPOINT_TRANSMIT_ONLY
90- #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
91- #define ENDPOINT4_CONFIG ENDPOINT_TRANSMIT_ONLY
92-
93- #define ENDPOINT5_CONFIG ENDPOINT_TRANSMIT_ONLY
94- #define ENDPOINT6_CONFIG ENDPOINT_RECEIVE_ONLY
95- #define ENDPOINT7_CONFIG ENDPOINT_TRANSMIT_ONLY
96-
97- #define ENDPOINT8_CONFIG ENDPOINT_TRANSMIT_ONLY
98- #define ENDPOINT9_CONFIG ENDPOINT_RECEIVE_ONLY
99- #define ENDPOINT10_CONFIG ENDPOINT_TRANSMIT_ONLY
100-
101- #define ENDPOINT11_CONFIG ENDPOINT_TRANSMIT_ONLY
102- #define ENDPOINT12_CONFIG ENDPOINT_RECEIVE_ONLY
103- ```
15+ - [ Install PlatformIO] ( https://docs.platformio.org/en/latest/core/installation/index.html )
16+
17+ ###### Pre-build
10418
19+ Build all of the platforms you need. It will fetch source and dependencies but
20+ will fail! After this first attempt at building, the patches listed below need
21+ to be applied.
10522
106- ` yeld.cpp `
107- ``` c
108- // Need to add USB_RAWHID_TRIPLESERIAL wherever USB_TRIPLE_SERIAL is.
109- defined (USB_TRIPLE_SERIAL) || defined (USB_RAWHID_TRIPLESERIAL)
23+ ``` sh
24+ pio run -e teensy41
25+ pio run -e teensy31
26+ pio run -e teensy36
11027```
11128
112- ` usb_inst.cpp `
113- ``` c
114- // Add defined(USB_RAWHID_TRIPLESERIAL) to
115- defined (USB_SERIAL) || defined (USB_DUAL_SERIAL) ||....
29+ ###### Patching Arduino Source
30+
31+ Required for all teensy versions.
32+
33+ ``` sh
34+ patch -d ~ /.platformio/ -p0 < diff/arduino.py.diff
11635```
11736
118- ` ./platforms/teensy/builder/frameworks/arduino.py `
119- ``` c
120- // Add USB_RAWHID_TRIPLESERIAL
121- // to the section
122- BUILTIN_USB_FLAGS = (
37+ ###### Patching Teensy3 Source
38+
39+ ``` sh
40+ patch -d ~ /.platformio/ -p0 < diff/teensy3/usb_desc.c.diff
41+ patch -d ~ /.platformio/ -p0 < diff/teensy3/usb_desc.h.diff
42+ patch -d ~ /.platformio/ -p0 < diff/teensy3/usb_inst.cpp.diff
43+ patch -d ~ /.platformio/ -p0 < diff/teensy3/yield.cpp.diff
12344```
12445
46+ ###### Patching Teensy4 Source
12547
126- ### Modifications required for teensy 4.1
127- For this to work you need to modify the teensy source code to set the RAWHID iInterface field to 2 to use the product string
128- --------------------------------------
129- Around line 1191 in ` ~/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_desc.c `
130- ``` c
131- #ifdef RAWHID_INTERFACE
132- // configuration for 480 Mbit/sec speed
133- // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
134- 9, // bLength
135- 4, // bDescriptorType
136- RAWHID_INTERFACE, // bInterfaceNumber
137- 0, // bAlternateSetting
138- 2, // bNumEndpoints
139- 0x03, // bInterfaceClass (0x03 = HID)
140- 0x00, // bInterfaceSubClass
141- 0x00, // bInterfaceProtocol
142- 2, // iInterface
48+ ``` sh
49+ patch -d ~ /.platformio/ -p0 < diff/arduino.py.diff
50+ patch -d ~ /.platformio/ -p0 < diff/teensy4/usb_desc.c.diff
51+ patch -d ~ /.platformio/ -p0 < diff/teensy4/usb_desc.h.diff
52+ patch -d ~ /.platformio/ -p0 < diff/teensy4/usb_inst.cpp.diff
53+ patch -d ~ /.platformio/ -p0 < diff/teensy4/yield.cpp.diff
14354```
14455
56+ ###### Build again
14557
146- `usb_desc.h`
147- ```c
148- #elif defined(USB_RAWHID_TRIPLESERIAL)
149- #define VENDOR_ID 0x16C0
150- #define PRODUCT_ID 0x048C
151- #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
152- #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
153- #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
154- #define MANUFACTURER_NAME_LEN 11
155- #define PRODUCT_NAME {'T','r','i','p','l','e',' ','S','e','r','i','a','l'}
156- #define PRODUCT_NAME_LEN 13
157- #define EP0_SIZE 64
158- #define NUM_ENDPOINTS 9
159- #define NUM_INTERFACE 7
160-
161- #define CDC_IAD_DESCRIPTOR 1 // Serial
162- #define CDC_STATUS_INTERFACE 0
163- #define CDC_DATA_INTERFACE 1
164- #define CDC_ACM_ENDPOINT 2
165- #define CDC_RX_ENDPOINT 3
166- #define CDC_TX_ENDPOINT 3
167- #define CDC_ACM_SIZE 16
168- #define CDC_RX_SIZE_480 512
169- #define CDC_TX_SIZE_480 512
170- #define CDC_RX_SIZE_12 64
171- #define CDC_TX_SIZE_12 64
172- #define SEREMU_TX_SIZE 64
173-
174- #define CDC2_STATUS_INTERFACE 2 // SerialUSB1
175- #define CDC2_DATA_INTERFACE 3
176- #define CDC2_ACM_ENDPOINT 4
177- #define CDC2_RX_ENDPOINT 5
178- #define CDC2_TX_ENDPOINT 5
179-
180- #define CDC3_STATUS_INTERFACE 4 // SerialUSB2
181- #define CDC3_DATA_INTERFACE 5
182- #define CDC3_ACM_ENDPOINT 6
183- #define CDC3_RX_ENDPOINT 7
184- #define CDC3_TX_ENDPOINT 7
185-
186- #define RAWHID_INTERFACE 6 // RawHID
187- #define RAWHID_TX_ENDPOINT 8
188- #define RAWHID_TX_SIZE 64
189- #define RAWHID_TX_INTERVAL 1 // TODO: is this ok for 480 Mbit speed
190- #define RAWHID_RX_ENDPOINT 9
191- #define RAWHID_RX_SIZE 64
192- #define RAWHID_RX_INTERVAL 1 // TODO: is this ok for 480 Mbit speed
193-
194- #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
195- #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
196- #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
197- #define ENDPOINT5_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
198- #define ENDPOINT6_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
199- #define ENDPOINT7_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
200- /* for raw hid */
201- #define ENDPOINT8_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
202- #define ENDPOINT9_CONFIG ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_UNUSED
58+ Now all the builds should succeed.
59+
60+ ``` sh
61+ pio run -e teensy41
62+ pio run -e teensy31
63+ pio run -e teensy36
20364```
20465
66+ ### Flashing to Teensy
67+
68+ Flash to whatever teensy hardware you have attached.
20569
206- ` ./platforms/teensy/builder/frameworks/arduino.py `
207- ``` c
208- // Add USB_RAWHID_TRIPLESERIAL
209- // to the section
210- BUILTIN_USB_FLAGS = (
211- ```
70+ ``` sh
71+ pio run -e teensy41 --target upload
72+ pio run -e teensy31 --target upload
73+ pio run -e teensy36 --target upload
74+ ```
0 commit comments