diff --git a/aidge_export_arm_cortexm/boards/stm32/H7/Makefile b/aidge_export_arm_cortexm/boards/stm32/H7/Makefile index aa708a42bd1f716abcd1a47f724de20220669548..414a5e4225ccac5c816684ad9f1a444997e6e329 100644 --- a/aidge_export_arm_cortexm/boards/stm32/H7/Makefile +++ b/aidge_export_arm_cortexm/boards/stm32/H7/Makefile @@ -1,6 +1,29 @@ +##################################################################### +##: Different options to compile the export +##: Usage : +##: +##: make / make help +##: display the different options available +##: make build +##: compile the export on host for C/C++ apps +##: (generate an executable in build/bin) +##: make build_image_docker +##: generate the docker image of the arm compiler +##: make build_docker +##: compile the export in a container for C/C++ apps +##: (generate an executable in build/bin) +##: make clean +##: clean up the build and bin folders +##: +##################################################################### + OPENOCD := /usr/local/bin/openocd OPENOCD_SCRIPT := /usr/local/share/openocd/scripts/board/stm32h7x3i_eval.cfg +MAKEFLAGS := --no-print-directory +DOCKER_COMPILER := tools/arm-none-eabi_compiler.Dockerfile +IMAGE := arm:arm-none-eabi_compiler +BOARD := stm32h7 OBJDIR := build BINDIR := bin @@ -34,30 +57,49 @@ ASM_OBJS := $(patsubst %.s,$(OBJDIR)/%.s.o,$(ASM_SRCS)) -all: build +all: help build: ${CC_OBJS} ${CXX_OBJS} ${ASM_OBJS} @mkdir -p $(dir ${TARGET}) ${CC} ${CC_OBJS} ${CXX_OBJS} ${ASM_OBJS} ${LINK_FLAGS} -o ${TARGET} + @chmod -R a+w ${BINDIR} ${OBJDIR}/%.c.o: %.c @mkdir -p $(dir $@) ${CC} ${CC_FLAGS} ${INCLUDE_DIRS} -o $@ $< + @chmod -R a+w ${OBJDIR} ${OBJDIR}/%.cpp.o: %.cpp @mkdir -p $(dir $@) ${CXX} ${CXX_FLAGS} ${INCLUDE_DIRS} -o $@ $< + @chmod -R a+w ${OBJDIR} ${OBJDIR}/%.s.o: %.s @mkdir -p $(dir $@) ${ASM} ${ASM_FLAGS} -o $@ $< + @chmod -R a+w ${OBJDIR} -.PHONY: clean +.PHONY: clean help clean: if [ -d "${OBJDIR}" ]; then rm -rf ${OBJDIR}; fi if [ -d "${BINDIR}" ]; then rm -rf ${BINDIR}; fi +help: + @grep -e "^##:" Makefile; + +# Makefile target for building the arm-none-eabi compiler image +.PHONY: build_image_docker + +build_image_docker: + @docker build --pull --rm -f "${DOCKER_COMPILER}" -t ${IMAGE} tools/ + +# Makefile targets for building export app via docker +.PHONY: build_docker + +build_docker: + @docker run --rm --name ${BOARD}_compiling -v "${PWD}":/usr/src/export -w /usr/src/export ${IMAGE} make build + -include $(DEPENDENCIES) diff --git a/aidge_export_arm_cortexm/boards/stm32/H7/tools/arm-none-eabi_compiler.Dockerfile b/aidge_export_arm_cortexm/boards/stm32/H7/tools/arm-none-eabi_compiler.Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e79d329d6dabe77f065b1ea67371990bcb30059a --- /dev/null +++ b/aidge_export_arm_cortexm/boards/stm32/H7/tools/arm-none-eabi_compiler.Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:22.04 + +# User can change those variables to update the toolchain +ARG ARM_VERSION=10.3-2021.10 +ARG ARM_PLATFORM=x86_64 + +# Install linux packages +RUN apt update \ + && apt install --no-install-recommends -y wget git tar build-essential cmake + +# Installation directory for the ARM tools +ENV ARM_TOOLCHAIN_ROOT=/opt/arm_compiler +WORKDIR ${ARM_TOOLCHAIN_ROOT} + +# Install GNU Arm Embedded Toolchain +RUN wget --no-check-certificate -c \ +https://developer.arm.com/-/media/Files/downloads/gnu-rm/${ARM_VERSION}/gcc-arm-none-eabi-${ARM_VERSION}-${ARM_PLATFORM}-linux.tar.bz2 + +# Unpack the tarball to the install directory +RUN tar xjf gcc-arm-none-eabi-${ARM_VERSION}-${ARM_PLATFORM}-linux.tar.bz2 + +# Make accessible the toolchain anywhere +ENV PATH=$PATH:${ARM_TOOLCHAIN_ROOT}/gcc-arm-none-eabi-${ARM_VERSION}/bin + +# Workspace directory +WORKDIR /workspace + +# Start bash login shell +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] +CMD ["/bin/bash", "-i"] diff --git a/aidge_export_arm_cortexm/boards/stm32/H7/tools/docker-entrypoint.sh b/aidge_export_arm_cortexm/boards/stm32/H7/tools/docker-entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..664527dd2f278459fcc6e4eb28659b52b9f19425 --- /dev/null +++ b/aidge_export_arm_cortexm/boards/stm32/H7/tools/docker-entrypoint.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +# first arg is `-f` or `--some-option` or there are no args +if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then + exec bash "$@" +fi + +exec "$@"