Coder Social home page Coder Social logo

lukezsmith / stm32-cli Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 20.57 MB

A FreeRTOS C project for the STM32F407 Discovery board that runs a number of GPIO tasks through a UART-driven command line interface. This project uses GoogleTest for unit testing.

Dockerfile 0.01% Shell 0.01% CMake 0.02% C 96.95% Assembly 2.93% C++ 0.10% Makefile 0.01%
cli freertos googletest gpio interrupts rtos stm32 uart

stm32-cli's Introduction

stm32-cli

A FreeRTOS C project for the STM32F407 Discovery board that runs a number of GPIO tasks through a UART-driven command line interface. This project uses GoogleTest for unit testing.

stm32-cli

Getting Started

Hardware Requirements

  • STM32F407G-DISC1 Board
    • Configurable to other STM32 setups but this project specifically uses on-board LEDs as well as on-board ST-MEMS accelerometer.
  • USB-TTL Serial Converter - Amazon

Dependencies

Installation

To install run git clone https://github.com/lukezsmith/stm32-cli to clone the repository.

Following installation, open the directory in Visual Studio Code.

Once the directory has been opened in Visual Studio Code, re-open the directory using the provided Docker container. It will take a while to install.

Building

The template uses CMake to build the code. To automate the process there is a Makefile in the root directory which can be run to automate the build.

This template has cross-compilation set up. There is a test build which compiles on the host machine. I use this to unit test the code. To run this simply run make or make TEST_MODE=TRUE in the terminal from the root directory of the repository. The build will be saved in /build/test.

To build for the STM32 microcontroller run make to build a version for debugging. To create a release build run make BUILD_TYPE=Release. These build will be saved in /build/release.

Flashing

Included in the Makefile is a flash command to flash the program to the STM32.

To flash the release build to the microcontroller run make flash.

NOTE: I haven't yet implemented USB pass-through for flashing (or debugging) whilst in the development container so flashing will fail if ran in the container. A workaround is to simply run the flash command from your host machine after building the project in the container.

Usage

Once the program has been flashed to a STM32F407G discovery board, connect the USB-TTL serial converter's GND pin, connect RX pin to PA2 pin, and TX pin to PA3 pin.

From there, open serial monitor at baud rate 115200.

The program's CLI will be visible (press reset button if CLI not visible):

To interact simply type the number of the command and press enter, alternatively press the blue USER button to log on-board accelerometer data. A demonstration video can be found at the bottom of this readme.

Testing

This template includes GoogleTest. The process for adding test modules is explained above. Testing runs automatically when the test target is built with make BUILD_TYPE=test. There is also a Visual Studio Code Task included with this template that automatically runs the test build (and associated tests) when the task is run. For me the keyboard shortcut to run this task is CMD+SHIFT+B. This task can be found in /.vscode/tasks.json.

Debugging

The project is ready for debugging via gdb through the Debug build. I usually use the cortex-debug Visual Studio Code extension. A configuration file for debugging with cortex-debug (with openocd, stlink) can be found at .vscode/launch.json. You will need to modify this file based on your debugging server/microcontroller setup.

Demonstration

Below is a video demonstrating the program:

Watch the video

https://youtube.com/watch?v=vJsOST5cdj0&feature=share&utm_source=EKLEiJECCKjOmKnC5IiRIQ

stm32-cli's People

Contributors

lukezsmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lenhatquang2512

stm32-cli's Issues

Getting errors after following instructions.

Hello Luke,

I've followed the steps in you instruction, but after the docker container has done its thing, I'm stuck with the following errors:
![image](https://user-images.githubusercontent.com/9851541/200527079-c23858db-67ff-4100-bad6-98766ba92973.png

I'm new to this Docker stuff, so forgive me.
The directory names for STM32F401 are missing (or named differently and the build directory for the Googletest is missing

Is this missing in the containier, or is there a setup problem on my sitde?

how to use HAL functions with Gtest module

Hi, thank you for your repo. I am very interested in your project.

As you may know, I utilized your stm32-dev template with my project, and now I need to build some unit tests for it using the Google Test framework. I followed your instructions in the stm32-dev repo, but I can only build the test mode if I don't utilize any HAL functions. I also investigated this repo, but you implemented both the gpio and uart modules without using any built-in HAL functions. I saw that you tried to include stm32f4xx.h in gpio_module.c, but you commented it out. So now my problem is that I need to use HAL functions with the Google Test framework; could you perhaps guide or explain to me how to do so? (For example, how to alter the CMakeLists.txt file, how to configure the modules, etc..). It would be very helpful if you could make some comments in the README file so that future people who are interested in your project and also have similar issues like me can easily follow the guidance. Thank you a lot.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.