Quicr / hactar

Hardware design for test device
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

HACTAR

Hardware design for test device

Table of contents:

  1. Where To Find Things
  2. Hardware
  3. Firmware
    1. Management
    2. User Interface
    3. Network
    4. Security
  4. Tools
    1. Echo Server
    2. Python Serial Monitor
  5. STM32 Toolchain
  6. ESP32 Toolchain
  7. Hactar Installation
    1. EV1 - WIP
    2. EV2 - WIP
    3. EV3 - WIP
    4. EV4 - WIP
    5. EV5 - WIP
    6. EV6 - WIP
    7. EV7 - WIP
    8. EV8 - Current

Where To Find Things

Hardware

Technologies

Firmware

The Firmware is split into 4 categories. Management, User Interface, Security, and Network.

Management

The management chip is responsible for uploading firmware to the stm32 - main chip and the esp32 network chip using a ch340 usb chip.

The management chip receives commands from the usb communication that informs it what chip we are currently uploading.

Commands

User Interface

The User Interface chip is where most of the processing takes place. It utilizes a STM32F405 chip empowered by the STM HAL Library. To generate the baseline HAL Library code and Makefile, ST's CubeMX was used.

Target Overview

Source code

All source code for the User Interface can be found in firmware/ui and firmware/shared_inc. Adding C/C++ files in firmware/ui/src and firmware/ui/inc does not require any changes in the makefile.

Making a shared header between chips should be added into firmware/shared_inc.

At any point if you're including or using any additional STM32 HAL library files such as stm32f4xx_hal_sd.h then you must add the respective source file stm32f4xx_hal_sd.c to HAL C Sources line ~50 in firmware/ui/Makefile.

Additionally, any new Assembly source files need to be added to the ASM sources line ~77 in firmware/ui/Makefile.

Network

The network chip is responsible for all communications between servers and the entire board. The network chip communicates with the UI chip via UART serial communication.

We are leveraging the esp-idf framework.

Target Overview

Source code

All source code for the network chip can be found in firmware/net and firmware/shared_inc.

Security

WIP

Tools

Echo Server

Very basic server that echo's the message it receives.

Python Serial Monitor

Located in firmware/tools

Requirements

This monitor can be used by the following command: python monitor.py \[port] \[baudrate]

ex.

python monitor.py /dev/ttyUSB0 115200

Installation - STM32 Toolchain

The following tools are used for Management and User Interface.

Make [required]

Make is used for compiling and uploading automation for each chip firmware.

Debian

sudo apt install make

Windows

MacOS

brew install make

ARM GNU Toolchain [required]

Debian

sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi

Windows

MacOS


STM32 Programmer CLI [required]

The STM32 Programmer CLI comes packages with the STM32 Cube Programmer. You'll need to download and install The STM32 Cube Programmer and add the STM32_Programmer_CLI binary to your path.

https://www.st.com/en/development-tools/stm32cubeprog.html

Debian

Windows

MacOS


OpenOCD [optional]

Open On Chip Debugger, created by Dominic Rath, is a debugging software that can be used with micro-controllers to run debugging tools and stepping through code.


Debian

Run the following command:

sudo apt install openocd gdb-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib

If you don't have python3.8 installed, which is used for arm-none-eabi-gdb, then you'll need to install it

sudo add-apt-repository ppa:deadsnakes/ppa
apt update
sudo apt install python3.8

Windows

MacOS

Run the following commands in a terminal to install openocd

brew update
brew install open-ocd --HEAD

Installation - ESP32 Toolchain

This project leverages the usage of the Arduino Library for the network chip.

The following tools are used for the Network.

Make [required]

Make is used for compiling and uploading automation for each chip firmware.

Debian

sudo apt install make

Windows

MacOS

brew install make

esp-idf [required]

Debian

Windows

MacOS

Hactar Installation

EV1

WIP

EV2

WIP

EV3

WIP

EV4

WIP

EV5

WIP

EV6

WIP

EV7

WIP

EV8 - Current

Management Chip - Prerequisites - Stlink-v2 - STM32 Cube Programmer CLI - arm-none-eabi-g++ - make - Hook up the stlink-v2 to the connector beside the usb-c connector. - Note, you will probably want to make a connector that has female dupoint headers on one end and a PH 2.0 connector on the other end. - Build the mgmt code by navigating to `hactar/firmware/mgmt` and entering `make compile` - Upload the mgmt code by entering `make upload` - After this you should see a couple of LED's light up Userinterface Chip - Prerequisites - A programmed `management chip` - USB-C Cable - STM32 Cube Programmer CLI - arm-none-eabi-g++ - make - Plug in the USB-C cable to the Hactar board. - Build the ui code by navigating to the `hactar/firmware/ui` folder and entering `make compile` - Upload the ui code by entering `make upload` - **NOTE** - Update your the `port` variable, based on your OS and usb input, in the `hactar/firmware/ui/makefile` - Once the process begins, a python script is called to send the command `ui_upload` to the management chip, turns off other LED's and turns on the third LED from the left, and puts the ui chip into bootloader mode. - Then the stm32 cube programmer cli is called to upload the firmware. - After finishing uploading the firmware to the ui chip, it will return to running mode after 5 seconds. Network Chip - Prerequisites - A programmed `management chip` - USB-C Cable - esp-idf - must be on your path - make - Plug in the USB-C cable to the Hactar board. - Build the net code by navigating to the `hactar/firmware/net` folder and entering `make compile` - Upload the net code by entering `make upload` - **NOTE** - Update your the `port` variable, based on your OS and usb input, in the `hactar/firmware/net/makefile` - Once the process begins, a python script is called to send the command `net_upload` to the management chip, turns off other LED's and turns on the first LED from the left, and puts the net chip into bootloader mode. - Then the stm32 cube programmer cli is called to upload the firmware. - After finishing uploading the firmware to the net chip, the management chip will return to running mode. Debug mode example - Prerequisites - Python3 - **pyserial** - download using `pip3 install pyserial` - make - USB-C Cable - Have your hactar board programmed and plugged in using a USB-C cable - Navigate to either `hactar/firmware/ui` or `hactar/firmware/net` - **NOTE** - Update your ports appropriately in the makefile - Enter `make py_monitor` into your terminal - You should see a serial monitor open in your terminal requesting a command. Enter `debug` to put the hactar board into debugging mode. - See [Management Commands](#management_commands) for more commands that can be sent to the hactar board. - The first and third LED from the left will turn blue indicating debug mode and your console will receive serial debug messages from the UI and Net chips. - Enter `exit` to leave the monitor