summaryrefslogtreecommitdiff
path: root/README.md
blob: 64da0430e0cf5101f442535a01d6a58352ccca57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# iot-contact

iot-contact is an IoT device to check if doors and windows are closed or open.
Furthermore roller shutter motors should be controlled.

## Usage

The firmware for iot-contact is cryptographically signed to only allow the
device booting a firmware from a trusted source. The required key with both the
private and the public part can be generated like this:

```
./fw/zephyrproject/bootloader/mcuboot/scripts/imgtool.py \
    keygen \
    --key ~/mcuboot/key.pem \
    --type ed25519
```

The content of this repository can be build with CMake and Ninja. The signing
key is passed to include the public part into the bootloader and used to sign
the application firmware:

```
cmake -Bbuild -GNinja -DKEY=~/mcuboot/key.pem
ninja -C build
./fw/sign.sh ~/mcuboot/key.pem
```

Exported files related to the printed circuit board (PCB) can be found in the
build folder.

```
tree build/pcb
```

The resulting firmware can be flashed via a ST-LINK debugger / programmer.

```
st-flash --connect-under-reset write build/fw/bootloader/zephyr/zephyr.bin 0x8000000
st-flash --connect-under-reset write build/fw/zephyr/zephyr.bin.signed 0x8040000
```

UART shell output can be retrieved with `picocom`.

```
picocom -b 115200 /dev/ttyACM0
```

Finally the firmware can be erased from the device with the ST-LINK.

```
st-flash --connect-under-reset erase
```

[1]: https://docs.kicad.org/