From b092ffbcbe2c9398494f7dc9db6f0796971633e0 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 13 Sep 2020 23:04:30 +0000 Subject: Import Cryptech wiki dump --- raw-wiki-dump/GitRepositories%2Fsw%2Fstm32 | 179 +++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 raw-wiki-dump/GitRepositories%2Fsw%2Fstm32 (limited to 'raw-wiki-dump/GitRepositories%2Fsw%2Fstm32') diff --git a/raw-wiki-dump/GitRepositories%2Fsw%2Fstm32 b/raw-wiki-dump/GitRepositories%2Fsw%2Fstm32 new file mode 100644 index 0000000..04bfcf0 --- /dev/null +++ b/raw-wiki-dump/GitRepositories%2Fsw%2Fstm32 @@ -0,0 +1,179 @@ +{{{ +#!htmlcomment + +This page is maintained automatically by a script. Don't modify this page by hand, +your changes will just be overwritten the next time the script runs. Talk to your +Friendly Neighborhood Repository Maintainer if you need to change something here. + +}}} + +{{{ +#!html +

STM32 firmware for Cryptech Alpha board

+ +

The Alpha board is our first full prototype for an open-source hardware +security module (HSM). It is a custom board with an STM32 Cortex-M4 +microcontroller and an Artix-7 FPGA, flash-based keystore, separate memory +for the Key Encryption Key, etc. See the hardware repository for +schematics and production files. See the wiki for design documents.

+ +

The code in this repository builds the firmware that provides the HSM +functionality on the Alpha board.

+ +

There is some residual code here to support the "dev-bridge" board, a +daughterboard for the Novena, which talks to the Novena's FPGA through the +high-speed expansion connector. Only a few of these boards were ever made, +and all development/testing ceased as soon as the Alpha became available, +so the dev-bridge should be considered deprecated, and support may be +removed in the future.

+ +

Copyrights

+ +

The license for all work done on this in the CrypTech project is a +3-clause BSD license.

+ +

Third-party components, as well as code generated using the +STMicroelectronics initialization code generator STM32CubeMX, or adapted +from STM example/support code, may have different licensing, detailed +below.

+ +

Components

+ +

Libraries

+ + + +

Projects

+ +

These directories build different firmware images for the Alpha board.

+ + + +

Building

+ +

Our primary build environments are Debian and Ubuntu, but this should work +on any system with Gnu tools installed.

+ +

The following packages need to be installed:

+ +
$ apt-get install gcc-arm-none-eabi gdb-arm-none-eabi openocd
+
+ +

The Makefile assumes that all Cryptech repositories have been fetched into +a canonical directory structure, e.g. libhal and thirdparty are +siblings to this directory, under sw.

+ +

To build the source code, issue make from the top level directory +(where this file is). The first time, this will build the complete STM +CMSIS library. A subsequent make clean will not clean away the CMSIS +library, but a make distclean will.

+ +

Installing

+ +

Do bin/flash-target from the top level directory (where this file is) +to flash a built image into the microcontroller. See the section ST-LINK +below for information about the actual hardware programming device needed.

+ +

Example loading the HSM firmware:

+ +
$ make hsm
+$ ./bin/flash-target projects/hsm/hsm
+
+ +

At this point, the STM32 will reset into the bootloader which flashes the +blue LED five times in one second, and then jumps to the primary firmware.

+ +

Once the bootloader is installed, regular firmware can be loaded without +an ST-LINK cable like this:

+ +
$ cryptech_upload --firmware -i projects/hsm/hsm.bin
+
+ +

Then reboot the Alpha board.

+ +

ST-LINK

+ +

To program the MCU, an ST-LINK adapter is used. The cheapest way to get +one is to buy an evaluation board with an ST-LINK integrated, and pinouts +to program external chips. This should work with any evaluation board from +STM; we have tested with STM32F4DISCOVERY (with ST-LINK v2.0) and +NUCLEO-F411RE (with ST-LINK v2.1).

+ +

The ST-LINK programming pins is called J1 and is near the CrypTech logo +printed on the circuit board. The pin-outs is shown on the circuit board +(follow the thin white line from J1 to the white box with STM32_SWD +written in it). From left to right, the pins are

+ +
3V3, CLK, GND, I/O, NRST and N/C
+
+ +

This matches the pin-out on the DISCO and NUCLEO boards we have tried.

+ +

First remove the pair of ST-LINK jumpers (CN4 on the DISCO, CN2 on the +NUCLEO). Then find the 6-pin SWD header on the left of the STM board (CN2 +on the DISCO, CN4 on the NUCLEO), and connect them to the Alpha board:

+ +
NUCLEO / DISCO           CRYPTECH ALPHA
+--------------           --------------
+* 1 VDD_TARGET      <->  3V3
+* 2 SWCLK / T_JTCK  <->  CLK
+* 3 GND             <->  GND
+* 4 SWDIO / T_JTMS  <->  IO
+* 5 NRST / T_NRST   <->  NRST
+* 6 N/C
+
+ +

The Alpha board should be powered on before attempting to flash it.

+ +

Debugging the firmware

+ +

This site shows several ways +to use various debuggers to debug the firmware in an STM32.

+ +

There is a shell script called 'bin/debug' that starts an OpenOCD server +and GDB. Example:

+ +
$ ./bin/debug projects/hsm/hsm
+
+ +

Once in GDB, issue monitor reset halt to reset the STM32 before debugging.

+ +

Remember that the first code to run will be the bootloader, but if you do +e.g. break main and continue you will end up in main() after the +bootloader has jumped there.

+}}} + +[[RepositoryIndex(format=table,glob=sw/stm32)]] + +|| Clone `https://git.cryptech.is/sw/stm32.git` || -- cgit v1.2.3