Skip to content

Commit

Permalink
Merge pull request #1 from jorgeacortes/feature/github-actions
Browse files Browse the repository at this point in the history
Feature/GitHub actions
  • Loading branch information
jorgeacortes authored Aug 22, 2020
2 parents d658c8d + b3e1949 commit 9a0d09b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 55 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build action

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build project
uses: docker://cortesja/stm32-cmake:latest
with:
args: bash -c "sh build.sh"
106 changes: 57 additions & 49 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,64 @@ LABEL description="Image for compiling STM32 families with cmake"
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y make gcc cmake git \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update \
&& apt-get install -y wget \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --user-group --system --create-home --no-log-init stm32
USER stm32
RUN mkdir /home/stm32/temp
WORKDIR /home/stm32/temp

&& apt-get install -y make gcc cmake git wget g++ \
# Temporary directory
&& mkdir -p /home/stm32/temp \
&& cd /home/stm32/temp \
# Download gcc-arm-none-eabi toolchain for compiling STM32
RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
RUN mkdir /home/stm32/lib
RUN tar xjf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 -C /home/stm32/lib

WORKDIR /home/stm32/lib
# Download stm32-cmake project for using CMake for STM32
RUN git clone --depth=1 https://github.com/ObKo/stm32-cmake

# Download Firmware for F0, F1, F3, F4, F7, L0, L1, G0, H7 families
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF0
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF1
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF2
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF3
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF4
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF7
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeL0
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeL1
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeG0
RUN git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeH7

RUN rm -rf /home/stm32/temp/
&& wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 \
&& mkdir /home/stm32/lib \
&& tar xjf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 -C /home/stm32/lib \
# Download stm32-cmake project for using CMake for STM32. G4 family not supported.
&& cd /home/stm32/lib \
&& git clone --depth=1 https://github.com/ObKo/stm32-cmake \
# Download Firmware for F0, F1, F3, F4, F7, L0, L1, L4, G0, G4 and H7 families.
# Clean not needed files from repository to reduce size.
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF0 \
&& mv STM32CubeF0/Drivers Drivers && rm -rf STM32CubeF0 && mkdir STM32CubeF0 && mv Drivers STM32CubeF0/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF1 \
&& mv STM32CubeF1/Drivers Drivers && rm -rf STM32CubeF1 && mkdir STM32CubeF1 && mv Drivers STM32CubeF1/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF2 \
&& mv STM32CubeF2/Drivers Drivers && rm -rf STM32CubeF2 && mkdir STM32CubeF2 && mv Drivers STM32CubeF2/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF3 \
&& mv STM32CubeF3/Drivers Drivers && rm -rf STM32CubeF3 && mkdir STM32CubeF3 && mv Drivers STM32CubeF3/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF4 \
&& mv STM32CubeF4/Drivers Drivers && rm -rf STM32CubeF4 && mkdir STM32CubeF4 && mv Drivers STM32CubeF4/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeF7 \
&& mv STM32CubeF7/Drivers Drivers && rm -rf STM32CubeF7 && mkdir STM32CubeF7 && mv Drivers STM32CubeF7/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeL0 \
&& mv STM32CubeL0/Drivers Drivers && rm -rf STM32CubeL0 && mkdir STM32CubeL0 && mv Drivers STM32CubeL0/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeL1 \
&& mv STM32CubeL1/Drivers Drivers && rm -rf STM32CubeL1 && mkdir STM32CubeL1 && mv Drivers STM32CubeL1/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeL4 \
&& mv STM32CubeL4/Drivers Drivers && rm -rf STM32CubeL4 && mkdir STM32CubeL4 && mv Drivers STM32CubeL4/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeG0 \
&& mv STM32CubeG0/Drivers Drivers && rm -rf STM32CubeG0 && mkdir STM32CubeG0 && mv Drivers STM32CubeG0/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeG4 \
&& mv STM32CubeG4/Drivers Drivers && rm -rf STM32CubeG4 && mkdir STM32CubeG4 && mv Drivers STM32CubeG4/Drivers \
&& git clone --depth=1 https://github.com/STMicroelectronics/STM32CubeH7 \
&& mv STM32CubeH7/Drivers Drivers && rm -rf STM32CubeH7 && mkdir STM32CubeH7 && mv Drivers STM32CubeH7/Drivers \
# Delete not needed packages and folders
&& apt-get remove -y wget \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /home/stm32/temp \
# Create working directory for sharing with repository
&& mkdir /home/stm32/ws

WORKDIR /home/stm32/ws

# Define paths
ENV STM32_CMAKE_MODULES /home/stm32/lib/stm32-cmake/cmake
ENV STM32_FW_F0 /home/stm32/lib/STM32CubeF0
ENV STM32_FW_F1 /home/stm32/lib/STM32CubeF1
ENV STM32_FW_F2 /home/stm32/lib/STM32CubeF2
ENV STM32_FW_F3 /home/stm32/lib/STM32CubeF3
ENV STM32_FW_F4 /home/stm32/lib/STM32CubeF4
ENV STM32_FW_F7 /home/stm32/lib/STM32CubeF7
ENV STM32_FW_L0 /home/stm32/lib/STM32CubeL0
ENV STM32_FW_L1 /home/stm32/lib/STM32CubeL1
ENV STM32_FW_G0 /home/stm32/lib/STM32CubeG0
ENV STM32_FW_H7 /home/stm32/lib/STM32CubeH7
ENV ARM_TOOLCHAIN /home/stm32/lib/gcc-arm-none-eabi-9-2020-q2-update

# Shared directory folder
RUN mkdir /home/stm32/ws
WORKDIR /home/stm32/ws
ENV STM32_CMAKE_MODULES=/home/stm32/lib/stm32-cmake/cmake \
STM32_FW_F0=/home/stm32/lib/STM32CubeF0 \
STM32_FW_F1=/home/stm32/lib/STM32CubeF1 \
STM32_FW_F2=/home/stm32/lib/STM32CubeF2 \
STM32_FW_F3=/home/stm32/lib/STM32CubeF3 \
STM32_FW_F4=/home/stm32/lib/STM32CubeF4 \
STM32_FW_F7=/home/stm32/lib/STM32CubeF7 \
STM32_FW_L0=/home/stm32/lib/STM32CubeL0 \
STM32_FW_L1=/home/stm32/lib/STM32CubeL1 \
STM32_FW_L4=/home/stm32/lib/STM32CubeL4 \
STM32_FW_G0=/home/stm32/lib/STM32CubeG0 \
STM32_FW_G4=/home/stm32/lib/STM32CubeG4 \
STM32_FW_H7=/home/stm32/lib/STM32CubeH7 \
ARM_TOOLCHAIN=/home/stm32/lib/gcc-arm-none-eabi-9-2020-q2-update
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# About

![Build action](https://github.com/jorgeacortes/stm32-cmake-docker/workflows/Build%20action/badge.svg)

This project is a sample project that contains a docker image that allows to compile STM32 ARM Cortex-M microcontrollers using cmake.

Supported families are: F0, F1, F2, F3, F4, F7, L0, L1, G0, H7
Supported families are: F0, F1, F2, F3, F4, F7, L0, L1, L4, G0 and H7.
G4 family is not supported by STM32 CMake modules.

## Project contents

Expand All @@ -11,7 +14,7 @@ Supported families are: F0, F1, F2, F3, F4, F7, L0, L1, G0, H7
* stm32-docker-cmake.ioc: Sample project configured with STM32CubeMX for board NUCLEO-F072RB.
* CMakeLists.txt file for compiling with cmake.
* build.sh / clean.sh bash script for compiling project inside the container.
* docker-clean.bat and docker-compile.bat as examples for launching docker from Windows CLI.
* docker-clean.bat and docker-compile.bat as examples for launching docker from Windows cmd or powershell.
* Project and launch files for flashing and debugging with STM32CubeIDE.

## Sample usage
Expand All @@ -26,16 +29,15 @@ docker run --rm -v $(pwd):/home/stm32/ws cortesja/stm32-cmake:latest bash -c "sh
* Ubuntu 20.04
* Cmake: 3.16.3
* STM32CubeMX 5.6.1
* STM32 FW: git clones from 18/07/2020
* STM32 FW: git clones from 22/08/2020 - You can review versions inside the image
* ARM Toolchain: gcc-arm-none-eabi-9-2020-q2-update
* Cmake modules: git clone from 18/07/2020
* STM32 CMake Modules: git clone from 22/08/2020 - You can review versions inside the image

## Open topics

* Flashing
* Add Github actions example for compiling
* L4 support missing

## Credits

* Cmake modules provided by: https://github.com/ObKo/stm32-cmake
* STM32 CMake Modules provided by: https://github.com/ObKo/stm32-cmake
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -e

if [ ! -d "build" ]; then
mkdir build
fi
Expand Down

0 comments on commit 9a0d09b

Please sign in to comment.