Skip to content

pokusew/fel-krp-project

Repository files navigation

FIDO2 USB Security Key

A working FIDO2 USB hardware external authenticator (also called “security key”) 🔑 implemented on STM32F4.

Running on the STM3240G-EVAL board with the STM32F407IGH6 MCU.

Written in C. Uses STM32CubeF4.

See the full 👉 Project Description.

Note: This project was created a semestral project in the CTU FEE (ČVUT FEL) B4M38KRP (Computer Interfaces) course.

Content

Development

Use JetBrains CLion (free for non-commercial use for students) for development. The project is already imported and fully configured, use File > Open... to just open it.

But before opening, you'll probably need to install a few things in your system:

  1. Arm GNU Toolchain
    • Download AArch32 bare-metal target (arm-none-eabi) from the Arm website here.
    • On macOS, brew install --cask gcc-arm-embedded can be used.
  2. OpenOCD
    • Download prebuilt binary from xPack OpenOCD Releases.
    • Note, that the packages in apt repository in Ubuntu are outdated.
    • On macOS, brew install open-ocd can be used.

If you have all the tools installed, you should be able to open, build and run the project from CLion.

You can read more in this CLion's Embedded development with STM32CubeMX projects guide.

Build from the Command Line

Also, it is possible to build, flash and start the whole project from the command line. Building is done via cmake since this project is a standard CMake project (see CMakeLists.txt). Flashing can be done for example using openocd like this (run from the project root):

openocd -s /usr/local/share/openocd/scripts -f stm3240g_eval_stlink.cfg -c "tcl_port disabled" -c "gdb_port disabled" -c "tcl_port disabled" -c "program \"cmake-build-debug/fel-krp-project.elf\"" -c reset -c shutdown

SVD file for the MCU

CLion and other IDEs support SVD files for describing the layout of registers for debugging.

Note: We downloaded the SVD file to svd/STM32F407.svd, so you don't need to download it yourselves.

For more information, see the README in the svd dir.

STM32CubeF4

We use the STM32CubeF4 package via the STM32CubeMX generator.

Relevant resources:

STM32CubeMX

Note: This section is here only for future reference. You don't need to download STM32CubeMX and don't need to follow steps in this section.

This project was created by STM32CubeMX. Here is the procedure we used:

  1. New Project > Board Selector > STM3240G-EVAL > Start Project > Initialize all peripherals with their default Mode? Yes
  2. Then in the Project Manager tab:
    1. Fill in the Project Name.
    2. Change the Application structure to Basic. Keep the Do not generate the main() unchecked.
    3. Change the Toolchain / IDE to STM32CubeIDE (so that the project is compatible with CLion). Check Generate Under Root option.
    4. The other fields should be okay with the default values.

Customization

We tried to maintain compatibility with the STM32CubeMX as much as we could (so that the project could be modified in STM32CubeMX while the custom code remained in place). This was somehow possible until we implemented USB support. The generated USB middleware is very hard to customize, and some required changes must be made in the automatically generated code. So for now, one must carefully diff the changes using git after using STM32CubeMX to avoid losing some of our custom changes.

About

A FIDO2 USB Security Key 🔑 implemented on STM32F4

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages