Skip to content

Commit 18d9f68

Browse files
committed
fix: pin dependencies via on nix and create flake
1 parent 24d1137 commit 18d9f68

File tree

7 files changed

+143
-19
lines changed

7 files changed

+143
-19
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ release
88
.idea
99
.vscode
1010
.DS_Store
11+
.direnv

docs/build.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,35 @@ Clone the repository recursively `git clone https://github.com/cryptoadvance/spe
66

77
## Prerequisities
88

9+
There are multiple ways to get all necessary tools. The recommended way is to use the Nix flake with direnv.
10+
If that's too complicated for you, you can use the traditional `nix-shell` or install the tools manually (which mighty be tricky to get the dependencies right).
11+
12+
### Nix flake (Recommended)
13+
14+
The easiest way to get all necessary tools is to use the Nix flake from the root of the repository. You need to have [Nix](https://nixos.org/) (on Mac use [determinate](https://github.com/DeterminateSystems/nix-installer)) with flakes enabled.
15+
Install direnv with `brew install direnv` (on Mac) or `sudo apt install direnv` (on Linux).
16+
17+
Make sure that [flakes are enabled](https://nixos.wiki/wiki/Flakes) in your Nix config.
18+
19+
```sh
20+
# Enter development shell
21+
nix develop
22+
23+
# Or use with direnv for automatic activation
24+
direnv allow
25+
```
26+
27+
928
### Nix shell
1029

11-
The easiest way to get all necessary tools is to run `nix-shell` from the root of the repository. You need to have [Nix](https://nixos.org/) installed.
30+
Alternatively, you can use the traditional `shell.nix`:
31+
32+
```sh
33+
nix-shell
34+
```
35+
You'll need to have [Nix](https://nixos.org/) installed as well.
1236

13-
### Prerequisities: Board
37+
### Prerequisities (Manually): Board
1438

1539
To compile the firmware for the board you will need `arm-none-eabi-gcc` compiler.
1640

@@ -34,7 +58,7 @@ brew install arm-none-eabi-gcc
3458

3559
On **Windows**: Install linux subsystem and follow Linux instructions.
3660

37-
### Prerequisities: Simulator
61+
### Prerequisities (Manually): Simulator
3862

3963
You may need to install SDL2 library to simulate the screen of the device.
4064

docs/development.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,36 @@
22

33
## Compiling the code yourself
44

5-
We use this build as a platform for Specter: https://github.com/diybitcoinhardware/f469-disco
5+
See the [build documentation](build.md) for instructions on how to compile the code.
66

7-
To compile the firmware you will need `arm-none-eabi-gcc` compiler.
8-
9-
On MacOS install it using brew: `brew install arm-none-eabi-gcc`
10-
11-
On Debian: `sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi gdb-arm-none-eabi openocd`
12-
13-
On Arch Linux: `sudo pacman -S arm-none-eabi-gcc arm-none-eabi-binutils arm-none-eabi-gdb arm-none-eabi-newlib openocd`
7+
## Enabling developer mode
148

15-
Run `make disco` to get the binary or `make unix` to compile the simulator. They will be in the `bin` folder.
9+
By default developer mode and USB communication are turned off. This means that when you connect the board to the computer it will NOT mount the `PYBFLASH` anymore and there will be no way to connect to debug shell.
1610

17-
`specter-diy.bin` file is the firmware that you need to copy to the device.
1811

19-
The easiest way to start developing is to use a [simulator](./simulator.md), and when you are done - try it on a real hardware.
12+
~~To turn on the developer mode get to the main screen (enter PIN code, generate recovery phrase, enter password), and then go to **Settings - Security - turn on Developer mode - Save**.~~
13+
(Currently deactivated for securtiy reasons)
2014

21-
## Enabling developer mode
15+
~~Now the board will restart and get mounted to the computer as before. You can also connect to the board over miniUSB and get to interactive console (baudrate 115200). You can use `screen` or `putty` or `minicom` for that, i.e. `screen /dev/tty.usbmodem14403 115200`.~~
2216

23-
By default developer mode and USB communication are turned off. This means that when you connect the board to the computer it will NOT mount the `PYBFLASH` anymore and there will be no way to connect to debug shell.
17+
In order to connect to the board, modify those lines in [boot.py](https://github.com/cryptoadvance/specter-diy/blob/2f51e152bcdb184cf719792e6c5f972214e3dd36/boot/main/boot.py#L33-L40) like this:
18+
```python
19+
# configure usb from start if you want,
20+
# otherwise will be configured after PIN
21+
pyb.usb_mode("VCP+MSC") # debug mode with USB and mounted storages from start
22+
#pyb.usb_mode("VCP") # debug mode with USB from start
23+
# disable at start
24+
# pyb.usb_mode(None)
25+
```
2426

25-
To turn on the developer mode get to the main screen (enter PIN code, generate recovery phrase, enter password), and then go to **Settings - Security - turn on Developer mode - Save**.
27+
and after flashing, you can connect with something like:
28+
```
29+
# Linux
30+
screen /dev/ttyACM0 115200 # or maybe ttyACM1 or ttyACM2
31+
# Mac
32+
screen /dev/tty.usbmodem14403 115200`.
33+
```
2634

27-
Now the board will restart and get mounted to the computer as before. You can also connect to the board over miniUSB and get to interactive console (baudrate 115200). You can use `screen` or `putty` or `minicom` for that, i.e. `screen /dev/tty.usbmodem14403 115200`.
2835

2936
## Writing a simple app
3037

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
description = "Specter DIY development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
in
14+
{
15+
devShells.default = pkgs.mkShell {
16+
nativeBuildInputs = [
17+
pkgs.buildPackages.gcc-arm-embedded-9
18+
pkgs.buildPackages.python39
19+
pkgs.openocd
20+
pkgs.stlink
21+
pkgs.SDL2
22+
];
23+
hardeningDisable = ["all"];
24+
};
25+
});
26+
}

shell.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{ pkgs ? import <nixpkgs> {} }:
1+
{ pkgs ? import (fetchTarball {
2+
url = "https://github.com/NixOS/nixpkgs/archive/nixos-22.05.tar.gz";
3+
sha256 = "154x9swf494mqwi4z8nbq2f0sp8pwp4fvx51lqzindjfbb9yxxv5";
4+
}) {}
5+
}:
26
pkgs.mkShell {
37
nativeBuildInputs = [
48
pkgs.buildPackages.gcc-arm-embedded-9

0 commit comments

Comments
 (0)