Skip to content

Commit 2cfc89c

Browse files
committed
🐢 TurtlePass v3 - major architecture refactor
# Added - Runtime seed loading (encrypted in flash/EEPROM using board unique ID) - Protocol Buffers communication with host for structured data exchange - HID keyboard via TinyUSB (faster typing) - Migration to PlatformIO (VSCode) for cleaner builds - Native tests + Embedded tests for storage, seed manager, encryption and kdf - Per-slot seed encryption and password generation # Changed - Flash precompiled binaries to avoid per-device compilation - Improved seed initialization and retrieval - Modernized project structure and CI compatibility # Removed - Hardware 2FA Manager (OTP generation) - Hardware file encryption # BREAKING CHANGES - Removed hardware 2FA and ChaCha20-based encryption features
1 parent 3bd38f4 commit 2cfc89c

File tree

110 files changed

+14335
-2551
lines changed

Some content is hidden

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

110 files changed

+14335
-2551
lines changed

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1+
# macOS
12
.DS_Store
2-
/.idea
3-
/build
4-
/app/build
5-
/.gradle
6-
/local.properties
7-
/app/plugins/internal/build/
8-
/app/plugins/internal/.gradle/
9-
/turtlpass-firmware/Seed.cpp

BUILD.md

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
# 🧑‍💻 Building TurtlPass Firmware from Source
2+
3+
This guide explains how to compile and customize the **TurtlPass Firmware** using [**PlatformIO**](https://platformio.org/).
4+
Most users can rely on pre-built releases — building from source is ideal for developers or power users.
5+
6+
---
7+
8+
## 📚 Table of Contents
9+
10+
* [⚙️ Overview](#️-overview)
11+
* [🧰 Prerequisites](#-prerequisites)
12+
* [🚀 Quick Start](#-quick-start)
13+
* [⚡ Building and Uploading](#-building-and-uploading)
14+
* [🖥️ Supported Boards / Environments](#️-supported-boards--environments)
15+
* [⚙️ Optional Build Flags](#️-optional-build-flags)
16+
* [🔄 Building for Other Boards](#-building-for-other-boards)
17+
* [👆 Using a Touch Sensor (Optional)](#-using-a-touch-sensor-optional)
18+
* [🧪 Testing](#-testing)
19+
* [⚙️ Advanced PlatformIO Commands](#️-advanced-platformio-commands)
20+
* [💡 VS Code Integration](#-vs-code-integration)
21+
* [🧱 Troubleshooting](#-troubleshooting)
22+
* [🚀 Next Steps](#-next-steps)
23+
24+
---
25+
26+
## ⚙️ Overview
27+
28+
* **Core:** [Earle Philhower’s Arduino-Pico](https://github.com/earlephilhower/arduino-pico)
29+
* **Platform:** [Max Gerhardt’s RP2040 fork](https://github.com/maxgerhardt/platform-raspberrypi)
30+
31+
TurtlPass firmware supports **RP2040** and **RP2350** microcontrollers across a wide range of boards while maintaining full Arduino compatibility.
32+
33+
---
34+
35+
## 🧰 Prerequisites
36+
37+
* [PlatformIO Core or VSCode Extension](https://platformio.org/install/ide?install=vscode)
38+
* Supported RP2040 / RP2350 board
39+
* USB cable for flashing (with data support)
40+
* *(Optional)* TTP-223 capacitive touch sensor
41+
42+
---
43+
44+
## 🚀 Quick Start
45+
46+
1. **Clone the repository**
47+
48+
```bash
49+
git clone https://github.com/TurtlPass/turtlpass-firmware-arduino.git
50+
cd turtlpass-firmware-arduino/firmware
51+
```
52+
53+
2. **Build the firmware**
54+
55+
```bash
56+
pio run -e pico
57+
```
58+
59+
3. **(Optional) Upload to your board**
60+
61+
```bash
62+
pio run -e pico -t upload
63+
```
64+
65+
> 💡 **Tip:** PlatformIO automatically handles toolchains, dependencies, and builds — no manual setup required.
66+
67+
---
68+
69+
## ⚡ Building and Uploading
70+
71+
```bash
72+
# Build firmware
73+
pio run -e <env>
74+
75+
# Upload firmware
76+
pio run -e <env> -t upload
77+
```
78+
79+
Replace `<env>` with one of the [supported environments](#️-supported-boards--environments).
80+
81+
---
82+
83+
## 🖥️ Supported Boards / Environments
84+
85+
| Board | Environment | LED Type |
86+
| :------------------------------------ | :------------------------- | :----------- |
87+
| Raspberry Pi Pico (RP2040) | `pico` | Single-color |
88+
| Raspberry Pi Pico W (RP2040 + Wi-Fi) | `rpipicow` | Single-color |
89+
| Raspberry Pi Pico 2 (RP2350) | `rpipico2` | Single-color |
90+
| Raspberry Pi Pico 2W (RP2350 + Wi-Fi) | `rpipico2w` | Single-color |
91+
| Adafruit Feather RP2040 | `adafruit_feather` | RGB |
92+
| Adafruit QT Py RP2040 | `adafruit_qtpy` | RGB |
93+
| Adafruit Trinkey QT2040 | `adafruit_trinkeyrp2040qt` | RGB |
94+
| Seeed Xiao RP2040 | `seeed_xiao_rp2040` | RGB |
95+
| Seeed Xiao RP2350 | `seeed_xiao_rp2350` | RGB |
96+
| Waveshare RP2040-Zero | `waveshare_rp2040_zero` | RGB |
97+
| Waveshare RP2350-Zero | `waveshare_rp2350_zero` | RGB |
98+
| **Generic RP2040** | `generic` | Single/RGB |
99+
| **Generic RP2350** | `generic_rp2350` | Single/RGB |
100+
101+
---
102+
103+
## ⚙️ Optional Build Flags
104+
105+
Customize firmware parameters via `build_flags`:
106+
107+
| Flag | Description | Default |
108+
| :-------------------------- | :------------------------------ | :------------ |
109+
| `__TURTLPASS_VERSION__` | Firmware version string | `"3.0.0"` |
110+
| `__TURTLPASS_LED_PIN__` | Onboard LED pin number | `LED_BUILTIN` |
111+
| `__TURTLPASS_LED_IS_RGB__` | Enable RGB LED (`true`/`false`) | `false` |
112+
| `__TURTLPASS_EEPROM_SIZE__` | Emulated EEPROM size (bytes) | `4096` |
113+
| `__TURTLPASS_PIN_TTP223__` | GPIO pin for touch sensor | *undefined* |
114+
115+
### 💡 Inline Override Example
116+
117+
```bash
118+
pio run -e pico -D__TURTLPASS_EEPROM_SIZE__=2048
119+
```
120+
121+
---
122+
123+
## 🔄 Building for Other Boards
124+
125+
TurtlPass supports any board based on **RP2040** or **RP2350** — including fully custom configurations.
126+
127+
---
128+
129+
### 🧩 Supported Boards Reference
130+
131+
See the full list here:
132+
👉 [maxgerhardt/platform-raspberrypi — boards](https://github.com/maxgerhardt/platform-raspberrypi/tree/develop/boards)
133+
134+
To build for one, create a new environment in your `platformio.ini` file.
135+
136+
#### ⚙️ Example — Waveshare RP2040 Zero
137+
138+
```ini
139+
[env:waveshare_rp2040_zero]
140+
extends = env:base
141+
board = waveshare_rp2040_zero
142+
build_flags =
143+
${env:base.build_flags}
144+
-D__TURTLPASS_LED_IS_RGB__=true ; RGB LED
145+
```
146+
147+
Then build it:
148+
149+
```bash
150+
pio run -e waveshare_rp2040_zero
151+
```
152+
153+
---
154+
155+
### 🧠 Custom Boards
156+
157+
> 🧭 **Tip:**
158+
> Use `generic` for RP2040 or `generic_rp2350` for RP2350, and manually define LED pin and RGB settings.
159+
160+
#### Example
161+
162+
```bash
163+
pio run -e generic \
164+
-D__TURTLPASS_LED_PIN__=16 \
165+
-D__TURTLPASS_LED_IS_RGB__=true
166+
```
167+
168+
**Notes:**
169+
170+
* `__TURTLPASS_LED_PIN__` — sets the LED pin number
171+
* `__TURTLPASS_LED_IS_RGB__` — set `true` for RGB LED
172+
173+
---
174+
175+
## 👆 Using a Touch Sensor (Optional)
176+
177+
Attach a **TTP-223 capacitive touch sensor** to replace the BOOTSEL button.
178+
179+
```ini
180+
-D__TURTLPASS_PIN_TTP223__=2
181+
```
182+
183+
This configures the firmware to use the external touch input instead of **BOOTSEL**.
184+
185+
### 🔌 Circuit Diagram
186+
187+
```
188+
RP2040/RP2350 Touch Sensor
189+
+-----------+ +----------+
190+
| GND | ---------- | GND |
191+
| GPIO 2 | ---------- | I/O |
192+
| 3.3V | ---------- | VCC |
193+
+-----------+ +----------+
194+
```
195+
196+
**Connection steps:**
197+
198+
1. Connect **GND → GND**
199+
2. Connect **GPIO 2 → I/O**
200+
3. Connect **3.3V → VCC**
201+
202+
---
203+
204+
## 🧪 Testing
205+
206+
TurtlPass includes both **embedded** (hardware-level) and **native** (host-level) tests.
207+
208+
### 🧭 Embedded Tests — Run on Hardware
209+
210+
```bash
211+
pio test -e pico-tests
212+
pio test -e pico-tests --filter embedded/test_seedmanager_basic
213+
```
214+
215+
### 💻 Native Tests — Run on Host Machine
216+
217+
```bash
218+
pio test -e native
219+
pio test -e native --filter native/test_key_derivation
220+
```
221+
222+
> **Note:** Native tests run on your PC — fast, reproducible, and ideal for CI pipelines.
223+
224+
---
225+
226+
## ⚙️ Advanced PlatformIO Commands
227+
228+
### 🔄 Clean and Rebuild
229+
230+
```bash
231+
pio run -t clean
232+
pio run -e pico
233+
```
234+
235+
### 📦 Generate `.uf2` Firmware (Manual Flash)
236+
237+
```bash
238+
pio run -e pico --target buildfs
239+
```
240+
241+
Output file:
242+
243+
```
244+
.pio/build/<env>/firmware.uf2
245+
```
246+
247+
---
248+
249+
## 💡 VS Code Integration
250+
251+
When using **PlatformIO in VS Code**:
252+
253+
* ▶️ **Build** compiles the firmware
254+
* 🔌 **Upload** flashes it automatically
255+
* 🧩 Auto-detects connected devices and can enter **BOOTSEL mode**
256+
257+
> 🪫 **If upload fails:**
258+
> Drag `.pio/build/pico/firmware.uf2` onto the **RPI-RP2** drive manually.
259+
260+
---
261+
262+
## 🧱 Troubleshooting
263+
264+
### 🧭 General Checks
265+
266+
* Run with verbose output: `pio run -v`
267+
* Hold **BOOTSEL** while connecting
268+
* Check connected devices:
269+
270+
```bash
271+
pio device list
272+
```
273+
274+
### `Unknown board` or `Missing platform`
275+
276+
Install the correct platform fork:
277+
278+
```bash
279+
pio platform install https://github.com/maxgerhardt/platform-raspberrypi.git
280+
```
281+
282+
### ⚠️ `Upload failed`
283+
284+
1. Hold **BOOTSEL**
285+
2. Connect USB
286+
3. Release when it mounts as a drive
287+
Then rerun:
288+
289+
```bash
290+
pio run -e pico -t upload
291+
```
292+
293+
### ⚙️ Missing Arduino Core
294+
295+
Add this line to enforce:
296+
297+
```ini
298+
board_build.core = earlephilhower
299+
```
300+
301+
---
302+
303+
## 🚀 Next Steps
304+
305+
Now that you’ve built the **TurtlPass Firmware**, explore the rest of the [TurtlPass Ecosystem](https://github.com/TurtlPass) to unlock its full potential.
306+
307+
Happy hacking! ✨🐢

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
631631
state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634-
Copyright (C) 2023 Ryan Amaral <ryanamaral.com>
634+
Copyright (C) 2023 TurtlPass <turtlpass@ryanamaral.com>
635635

636636
This program is free software: you can redistribute it and/or modify
637637
it under the terms of the GNU General Public License as published by
@@ -651,7 +651,7 @@ Also add information on how to contact you by electronic and paper mail.
651651
If the program does terminal interaction, make it output a short
652652
notice like this when it starts in an interactive mode:
653653

654-
TurtlPass Firmware Copyright (C) 2023 Ryan Amaral <ryanamaral.com>
654+
TurtlPass Firmware Copyright (C) 2023 <turtlpass@ryanamaral.com>
655655
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
656656
This is free software, and you are welcome to redistribute it
657657
under certain conditions; type `show c' for details.

0 commit comments

Comments
 (0)