Skip to content

Commit 037d2f2

Browse files
committed
framework swiss army knife debugger
Firmware used for debugging framework laptops using a hardware debug adapter. This uses the Teensy series of dev boards to create a multifunction debugger that supports DAP for SWD/JTAG - supported by pyocd, etc. flashrom SPI programmer. command uart that can toggle and control any teensy pin * Command uart can be used to trigger i2c transactions with the i2c peripheral. * Can be used to monitor pin toggles on any pin. * Can be used to measure analog voltage on analog pins. * Can be interfaced with a INA260 /voltage/current/power monitor. up to 3 separate hw uart bridges to bridge a hardware serial port to a virtual com port, allowing simultanious logging from multiple uarts. The firmware allows shared use of functions such as swd debugging and monitoring a serial port using a virtual com port at the same time. Signed-off-by: Kieran Levin <ktl@frame.work>
0 parents  commit 037d2f2

62 files changed

Lines changed: 8993 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

README.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
=== Multi purpose debugger - target controller
2+
3+
Supports
4+
CMSIS-DAP
5+
Multiple serial terminals
6+
GPIO read/write/port register control.
7+
8+
9+
right now the backend uses raw hid reports for debug communication, terminal.py will open an interactive terminal to the device.
10+
11+
= How to flash to the teensy board:
12+
pio run -e teensy41 --target upload
13+
pio run -e teensy31 --target upload
14+
pio run -e teensy36 --target upload
15+
16+
17+
= Modifications required to teensy 3.1 codebase:
18+
19+
* 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
20+
around line 1136 in ~/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_desc.c
21+
--------------------------------------
22+
#ifdef RAWHID_INTERFACE
23+
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
24+
9, // bLength
25+
4, // bDescriptorType
26+
RAWHID_INTERFACE, // bInterfaceNumber
27+
0, // bAlternateSetting
28+
2, // bNumEndpoints
29+
0x03, // bInterfaceClass (0x03 = HID)
30+
0x00, // bInterfaceSubClass
31+
0x00, // bInterfaceProtocol
32+
2, // iInterface <-------------------Modify this!
33+
34+
35+
usb_desc.h
36+
--------------------------------------
37+
Add the following to the usb definitions section after USB_EVERYTHING
38+
#elif defined(USB_RAWHID_TRIPLESERIAL)
39+
#define VENDOR_ID 0x16C0
40+
#define PRODUCT_ID 0x048C
41+
#define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
42+
#define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
43+
#define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
44+
#define MANUFACTURER_NAME_LEN 11
45+
#define PRODUCT_NAME {'C','M','S','I','S','-','D','A','P'}
46+
#define PRODUCT_NAME_LEN 9
47+
#define EP0_SIZE 64
48+
#define NUM_ENDPOINTS 12
49+
#define NUM_USB_BUFFERS 32
50+
#define NUM_INTERFACE 7
51+
52+
#define CDC_IAD_DESCRIPTOR 1 // Serial
53+
#define CDC_STATUS_INTERFACE 0
54+
#define CDC_DATA_INTERFACE 1
55+
#define CDC_ACM_ENDPOINT 2
56+
#define CDC_RX_ENDPOINT 3
57+
#define CDC_TX_ENDPOINT 4
58+
#define CDC_ACM_SIZE 16
59+
#define CDC_RX_SIZE 64
60+
#define CDC_TX_SIZE 64
61+
62+
#define CDC2_STATUS_INTERFACE 2 // SerialUSB1
63+
#define CDC2_DATA_INTERFACE 3
64+
#define CDC2_ACM_ENDPOINT 5
65+
#define CDC2_RX_ENDPOINT 6
66+
#define CDC2_TX_ENDPOINT 7
67+
#define CDC2_ACM_SIZE 16
68+
#define CDC2_RX_SIZE 64
69+
#define CDC2_TX_SIZE 64
70+
71+
#define CDC3_STATUS_INTERFACE 4 // SerialUSB2
72+
#define CDC3_DATA_INTERFACE 5
73+
#define CDC3_ACM_ENDPOINT 8
74+
#define CDC3_RX_ENDPOINT 9
75+
#define CDC3_TX_ENDPOINT 10
76+
#define CDC3_ACM_SIZE 16
77+
#define CDC3_RX_SIZE 64
78+
#define CDC3_TX_SIZE 64
79+
80+
#define RAWHID_INTERFACE 6 // RawHID
81+
#define RAWHID_TX_ENDPOINT 11
82+
#define RAWHID_TX_SIZE 64
83+
#define RAWHID_TX_INTERVAL 1
84+
#define RAWHID_RX_ENDPOINT 12
85+
#define RAWHID_RX_SIZE 64
86+
#define RAWHID_RX_INTERVAL 1
87+
88+
#define ENDPOINT2_CONFIG ENDPOINT_TRANSMIT_ONLY
89+
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
90+
#define ENDPOINT4_CONFIG ENDPOINT_TRANSMIT_ONLY
91+
92+
#define ENDPOINT5_CONFIG ENDPOINT_TRANSMIT_ONLY
93+
#define ENDPOINT6_CONFIG ENDPOINT_RECEIVE_ONLY
94+
#define ENDPOINT7_CONFIG ENDPOINT_TRANSMIT_ONLY
95+
96+
#define ENDPOINT8_CONFIG ENDPOINT_TRANSMIT_ONLY
97+
#define ENDPOINT9_CONFIG ENDPOINT_RECEIVE_ONLY
98+
#define ENDPOINT10_CONFIG ENDPOINT_TRANSMIT_ONLY
99+
100+
#define ENDPOINT11_CONFIG ENDPOINT_TRANSMIT_ONLY
101+
#define ENDPOINT12_CONFIG ENDPOINT_RECEIVE_ONLY
102+
103+
104+
105+
yeld.cpp
106+
--------------------------------------
107+
need to add USB_RAWHID_TRIPLESERIAL wherever USB_TRIPLE_SERIAL is.
108+
defined(USB_TRIPLE_SERIAL) || defined(USB_RAWHID_TRIPLESERIAL)
109+
110+
111+
usb_inst.cpp
112+
---------------------------------------
113+
Add defined(USB_RAWHID_TRIPLESERIAL) to
114+
defined(USB_SERIAL) || defined(USB_DUAL_SERIAL) ||....
115+
116+
./platforms/teensy/builder/frameworks/arduino.py
117+
---------------------------------------
118+
Add USB_RAWHID_TRIPLESERIAL
119+
120+
to the section
121+
BUILTIN_USB_FLAGS = (
122+
123+
124+
125+
= Modifications required for teensy 4.1
126+
* 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
127+
--------------------------------------
128+
Around line 1191 in ~/.platformio/packages/framework-arduinoteensy/cores/teensy4/usb_desc.c
129+
#ifdef RAWHID_INTERFACE
130+
// configuration for 480 Mbit/sec speed
131+
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
132+
9, // bLength
133+
4, // bDescriptorType
134+
RAWHID_INTERFACE, // bInterfaceNumber
135+
0, // bAlternateSetting
136+
2, // bNumEndpoints
137+
0x03, // bInterfaceClass (0x03 = HID)
138+
0x00, // bInterfaceSubClass
139+
0x00, // bInterfaceProtocol
140+
2, // iInterface
141+
142+
--------------------------------------
143+
usb_desc.h
144+
145+
#elif defined(USB_RAWHID_TRIPLESERIAL)
146+
#define VENDOR_ID 0x16C0
147+
#define PRODUCT_ID 0x048C
148+
#define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
149+
#define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
150+
#define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
151+
#define MANUFACTURER_NAME_LEN 11
152+
#define PRODUCT_NAME {'T','r','i','p','l','e',' ','S','e','r','i','a','l'}
153+
#define PRODUCT_NAME_LEN 13
154+
#define EP0_SIZE 64
155+
#define NUM_ENDPOINTS 9
156+
#define NUM_INTERFACE 7
157+
158+
#define CDC_IAD_DESCRIPTOR 1 // Serial
159+
#define CDC_STATUS_INTERFACE 0
160+
#define CDC_DATA_INTERFACE 1
161+
#define CDC_ACM_ENDPOINT 2
162+
#define CDC_RX_ENDPOINT 3
163+
#define CDC_TX_ENDPOINT 3
164+
#define CDC_ACM_SIZE 16
165+
#define CDC_RX_SIZE_480 512
166+
#define CDC_TX_SIZE_480 512
167+
#define CDC_RX_SIZE_12 64
168+
#define CDC_TX_SIZE_12 64
169+
#define SEREMU_TX_SIZE 64
170+
171+
#define CDC2_STATUS_INTERFACE 2 // SerialUSB1
172+
#define CDC2_DATA_INTERFACE 3
173+
#define CDC2_ACM_ENDPOINT 4
174+
#define CDC2_RX_ENDPOINT 5
175+
#define CDC2_TX_ENDPOINT 5
176+
177+
#define CDC3_STATUS_INTERFACE 4 // SerialUSB2
178+
#define CDC3_DATA_INTERFACE 5
179+
#define CDC3_ACM_ENDPOINT 6
180+
#define CDC3_RX_ENDPOINT 7
181+
#define CDC3_TX_ENDPOINT 7
182+
183+
#define RAWHID_INTERFACE 6 // RawHID
184+
#define RAWHID_TX_ENDPOINT 8
185+
#define RAWHID_TX_SIZE 64
186+
#define RAWHID_TX_INTERVAL 1 // TODO: is this ok for 480 Mbit speed
187+
#define RAWHID_RX_ENDPOINT 9
188+
#define RAWHID_RX_SIZE 64
189+
#define RAWHID_RX_INTERVAL 1 // TODO: is this ok for 480 Mbit speed
190+
191+
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
192+
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
193+
#define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
194+
#define ENDPOINT5_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
195+
#define ENDPOINT6_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
196+
#define ENDPOINT7_CONFIG ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
197+
/* for raw hid */
198+
#define ENDPOINT8_CONFIG ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
199+
#define ENDPOINT9_CONFIG ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_UNUSED
200+
201+
---------------------------------------
202+
./platforms/teensy/builder/frameworks/arduino.py
203+
---------------------------------------
204+
Add USB_RAWHID_TRIPLESERIAL
205+
206+
to the section
207+
BUILTIN_USB_FLAGS = (

include/README

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

lib/README

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in a an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html

0 commit comments

Comments
 (0)