mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
docker: Fix build.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
d289c539db
commit
2a32f788f3
@ -1,23 +1,38 @@
|
||||
FROM ubuntu:22.04 AS dapper
|
||||
ARG DAPPER_HOST_ARCH
|
||||
ENV DAPPER_ENV TARGET
|
||||
ENV ARCH $DAPPER_HOST_ARCH
|
||||
ENV DAPPER_OUTPUT ./docker/build
|
||||
ENV DAPPER_DOCKER_SOCKET true
|
||||
ENV DAPPER_TARGET dapper
|
||||
RUN apt update && apt install -y build-essential wget git python3 python-is-python3
|
||||
FROM ubuntu:24.04
|
||||
|
||||
RUN mkdir -p /source/gcc
|
||||
ENV GCC_URL="https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz"
|
||||
RUN wget --no-check-certificate -O - ${GCC_URL} | tar --strip-components=1 -Jx -C /source/gcc
|
||||
# Install dependencies
|
||||
RUN apt update && apt install -y \
|
||||
build-essential \
|
||||
wget \
|
||||
git \
|
||||
python3 \
|
||||
python-is-python3
|
||||
|
||||
RUN mkdir -p /source/llvm
|
||||
# Download and extract GCC
|
||||
RUN mkdir -p /workspace/gcc
|
||||
ENV GCC_URL="https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz"
|
||||
RUN wget --no-check-certificate -O - ${GCC_URL} | tar --strip-components=1 -Jx -C /workspace/gcc
|
||||
|
||||
# Download and extract LLVM
|
||||
RUN mkdir -p /workspace/llvm
|
||||
ENV LLVM_URL="https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-18.1.3/LLVM-ET-Arm-18.1.3-Linux-x86_64.tar.xz"
|
||||
RUN wget --no-check-certificate -O - ${LLVM_URL} | tar --strip-components=1 -Jx -C /source/llvm
|
||||
RUN wget --no-check-certificate -O - ${LLVM_URL} | tar --strip-components=1 -Jx -C /workspace/llvm
|
||||
|
||||
RUN mkdir -p /source/cmake
|
||||
# Download and extract CMake
|
||||
RUN mkdir -p /workspace/cmake
|
||||
ENV CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v3.30.2/cmake-3.30.2.tar.gz"
|
||||
RUN wget --no-check-certificate -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C /source/cmake
|
||||
RUN wget --no-check-certificate -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C /workspace/cmake
|
||||
|
||||
WORKDIR /source
|
||||
ENTRYPOINT ["./docker/build.sh"]
|
||||
# Download, build, and install Make
|
||||
RUN mkdir -p /workspace/make
|
||||
ENV MAKE_URL="https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
|
||||
RUN wget --no-check-certificate -O - ${MAKE_URL} | tar --strip-components=1 -xz -C /workspace/make
|
||||
RUN cd /workspace/make && ./configure && make -j$(nproc)
|
||||
|
||||
# Set up directories
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN git config --global --add safe.directory '*'
|
||||
ENV PATH="/workspace/gcc/bin:/workspace/llvm/bin:/workspace/cmake/bin:/workspace/make:$PATH"
|
||||
|
@ -1,12 +1,27 @@
|
||||
.PHONY: default
|
||||
default: in-docker-build
|
||||
DOCKER_IMAGE_NAME = firmware-builder
|
||||
DOCKER_TAG = latest
|
||||
CONTAINER_NAME = firmware-container
|
||||
DOCKERFILE_PATH = Dockerfile
|
||||
|
||||
./.dapper:
|
||||
@echo Downloading dapper
|
||||
@curl -sL https://releases.rancher.com/dapper/v0.5.0/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp
|
||||
@@chmod +x .dapper.tmp
|
||||
@./.dapper.tmp -v
|
||||
@mv .dapper.tmp .dapper
|
||||
# Build the Docker image
|
||||
build-image:
|
||||
docker build \
|
||||
-t $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) \
|
||||
-f $(DOCKERFILE_PATH) ../
|
||||
|
||||
in-docker-build: .dapper
|
||||
./.dapper -C ../ -f docker/Dockerfile --target dapper make
|
||||
# Run the container with a volume mount to build the firmware
|
||||
build-firmware: build-image
|
||||
docker run --rm \
|
||||
-e TARGET=$(TARGET) \
|
||||
-v $(PWD)/build:/workspace/build \
|
||||
--name $(CONTAINER_NAME) \
|
||||
$(DOCKER_IMAGE_NAME):$(DOCKER_TAG) docker/build.sh
|
||||
|
||||
# Run an interactive shell in the container
|
||||
shell:
|
||||
docker run --rm -it \
|
||||
-e shell="true" \
|
||||
-v $(PWD)/build:/workspace/build \
|
||||
$(DOCKER_IMAGE_NAME):$(DOCKER_TAG) bash
|
||||
|
||||
.DEFAULT_GOAL := build-firmware
|
||||
|
@ -3,7 +3,7 @@
|
||||
To build the firmware using docker, follow the following steps:
|
||||
|
||||
```
|
||||
git clone https://github.com/openmv/openmv.git --depth=50
|
||||
git clone https://github.com/openmv/openmv.git --depth=1
|
||||
cd openmv/docker
|
||||
make TARGET=<TARGET NAME>
|
||||
```
|
||||
|
@ -1,15 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e -x
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
|
||||
export PATH=/source/gcc/bin:/source/cmake/bin:$PATH
|
||||
git config --global --add safe.directory '*'
|
||||
git submodule update --init --depth=1
|
||||
git -C src/lib/micropython/ submodule update --init --depth=1
|
||||
make -C src -j$(nproc) TARGET=$TARGET submodules
|
||||
|
||||
# Build the firmware.
|
||||
make -j$(nproc) -C src clean
|
||||
make -j$(nproc) -C src/lib/micropython/mpy-cross
|
||||
make -j$(nproc) TARGET=$TARGET LLVM_PATH=/source/llvm/bin -C src
|
||||
mkdir -p ./docker/build/$TARGET
|
||||
cp -r src/build/bin/* ./docker/build/$TARGET
|
||||
make -j$(nproc) -C src TARGET=$TARGET LLVM_PATH=/workspace/llvm/bin
|
||||
|
||||
rm -fr /workspace/build/$TARGET
|
||||
mkdir -p /workspace/build/$TARGET
|
||||
cp -r src/build/bin/* /workspace/build/$TARGET
|
||||
|
@ -225,3 +225,6 @@ jlink:
|
||||
${JLINK_GDB_SERVER} -speed ${JLINK_SPEED} -nogui 1 \
|
||||
-if ${JLINK_INTERFACE} -halt -cpu cortex-m \
|
||||
-device ${JLINK_DEVICE} -novd ${JLINK_SCRIPT}
|
||||
|
||||
submodules:
|
||||
$(MAKE) -C $(MICROPY_DIR)/ports/$(PORT) BOARD=$(TARGET) submodules
|
||||
|
Loading…
Reference in New Issue
Block a user