Skip to content

Commit

Permalink
Merge pull request #4 from tudelft/thebigmerge3
Browse files Browse the repository at this point in the history
Thebigmerge3
  • Loading branch information
tblaha authored Aug 28, 2024
2 parents 2c04940 + 2a4864e commit b07a92c
Show file tree
Hide file tree
Showing 173 changed files with 11,467 additions and 4,564 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ README.pdf
/tools/
/build/
# local changes only
make/local*
make/local*.mk

# artefacts for VisualGDB (running in Visual Studio)
mcu.mak
Expand All @@ -37,9 +37,6 @@ stm32.mak
# ozone launch configurations
/support/ozone

# artefacts for VS Code
/.vscode/settings.json

# artefacts for Visual Studio
/.vs

Expand All @@ -58,3 +55,6 @@ eeprom.bin

make/local.mk
__pycache__

# logs
logs/
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "lib/main/pi-protocol"]
path = lib/main/pi-protocol
url = git@github.com:tblaha/pi-protocol
url = https://www.github.com/tudelft/pi-protocol.git
[submodule "lib/main/ActiveSetCtlAlloc"]
path = lib/main/ActiveSetCtlAlloc
url = git@github.com:tblaha/ActiveSetCtlAlloc
url = https://www.github.com/tudelft/ActiveSetCtlAlloc.git
[submodule "lib/main/clapack"]
path = lib/main/clapack
url = https://www.github.com/tudelft/clapack.git
43 changes: 40 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,33 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/obj/main/indiflight_SITL.elf",
"args": ["127.0.0.1"],
"args": [
"127.0.0.1"
],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "INDIflight MOCKUP",
"type": "cppdbg",
"request": "launch",
"program": "${userHome}/.venv/bin/python3",
"args": ["${workspaceFolder}/src/utils/indiflight_mockup_interface.py"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand All @@ -28,12 +54,23 @@
}
]
},
{
// https://stackoverflow.com/questions/53519668/how-to-attach-to-remote-gdb-with-vscode
"name": "MOCKUP docker",
"type": "gdb",
"request": "attach",
"executable": "${workspaceFolder}/obj/main/indiflight_MOCKUP.so",
"target": "localhost:3333",
"remote": true,
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
},
{
"cwd": "${workspaceRoot}",
"executable": "obj/main/indiflight_STM32H743.elf",
"name": "Cortex OpenOCD",
"request": "launch",
"preLaunchTask": "start-openocd",
"preLaunchTask": "start-openocd",
"type": "cortex-debug",
"liveWatch": {
"enabled": true,
Expand All @@ -46,4 +83,4 @@
"objdumpPath": "/usr/bin/objdump"
}
]
}
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cortex-debug.gdbPath": "gdb-multiarch",
"cortex-debug.liveWatchRefreshRate": 1000,
}
9 changes: 0 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@
"revealProblems": "onProblem",
"close": true
}
},
{
"label": "getLogs",
"command": "${workspaceFolder}/support/scripts/get_logs.sh",
"args": [
"/dev/sda1",
"${workspaceFolder}/../../../WorkData/BlackboxLogs/MIRROR"
],
"type": "shell",
}
]
}
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM ubuntu:22.04

RUN apt-get update && \
apt-get --no-install-recommends install -y \
build-essential \
python3 \
python3-pip \
python3-dev \
git \
curl \
dfu-util \
ssh \
rsync \
sshpass \
&& apt-get clean

# install python utilities
RUN pip install --upgrade pip
COPY lib/main/pi-protocol/python/requirements.txt requirements.txt
RUN pip install -r requirements.txt && rm requirements.txt
RUN pip install intelhex

# install cross compiler
COPY make/tools.mk tools.mk
RUN mkdir -p /downloads && \
mkdir -p /tools && \
make -f tools.mk OSFAMILY=linux DL_DIR=/downloads TOOLS_DIR=/tools arm_sdk_install && \
rm tools.mk

RUN cp -r /tools/*/* /usr/

# git config
RUN git config --global --add safe.directory /indiflight

RUN echo "#!/bin/bash" > /entrypoint.sh && \
echo "cd /indiflight" >> /entrypoint.sh && \
echo 'make -j "$@"' >> /entrypoint.sh && \
chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
52 changes: 40 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ endif

include $(ROOT)/make/targets.mk

REVISION := norevision
ifeq ($(shell git diff --shortstat),)
REVISION := $(shell git log -1 --format="%h")
GITHASH := $(shell git log -1 --format="%h")
DIRTYFLAG =
ifneq ($(shell git diff --shortstat),)
DIRTYFLAG = +dirty
endif
REVISION := $(GITHASH)$(DIRTYFLAG)

FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
Expand Down Expand Up @@ -136,9 +138,10 @@ else
ifeq ($(DEBUG),INFO)
DEBUG_FLAGS = -ggdb3
endif
OPTIMISATION_BASE := -flto -fuse-linker-plugin -ffast-math -fmerge-all-constants
#OPTIMISATION_BASE := -flto -fuse-linker-plugin -ffast-math -fmerge-all-constants
OPTIMISATION_BASE := -flto -fuse-linker-plugin -fmerge-all-constants # todo: try -funroll-loops here
OPTIMISE_DEFAULT := -O2
OPTIMISE_SPEED := -Ofast
OPTIMISE_SPEED := -O3
OPTIMISE_SIZE := -Os

LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
Expand Down Expand Up @@ -223,15 +226,16 @@ CC_NO_OPTIMISATION :=
#
TEMPORARY_FLAGS :=

EXTRA_WARNING_FLAGS := -Wold-style-definition
WARNING_FLAGS := -Wall -Wextra -Werror -Wpedantic -Wunsafe-loop-optimizations -Wold-style-definition -Wdouble-promotion
#WARNING_FLAGS += -Wstack-usage=1024

# -Wall -Wextra -Werror -Wpedantic -Wunsafe-loop-optimizations -Wdouble-promotion
CFLAGS += $(ARCH_FLAGS) \
$(addprefix -D,$(OPTIONS)) \
$(addprefix -I,$(INCLUDE_DIRS)) \
$(DEBUG_FLAGS) \
-std=gnu17 \
-Wall -Wextra -Werror -Wpedantic -Wunsafe-loop-optimizations -Wdouble-promotion \
$(EXTRA_WARNING_FLAGS) \
$(WARNING_FLAGS) \
-ffunction-sections \
-fdata-sections \
-fno-common \
Expand Down Expand Up @@ -299,6 +303,7 @@ TARGET_DFU = $(BIN_DIR)/$(TARGET_FULLNAME).dfu
TARGET_ZIP = $(BIN_DIR)/$(TARGET_FULLNAME).zip
TARGET_OBJ_DIR = $(OBJECT_DIR)/$(TARGET_NAME)
TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET_NAME).elf
TARGET_SO = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET_NAME).so
TARGET_EXST_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET_NAME)_EXST.elf
TARGET_UNPATCHED_BIN = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET_NAME)_UNPATCHED.bin
TARGET_LST = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET_NAME).lst
Expand All @@ -313,7 +318,7 @@ TARGET_EF_HASH_FILE := $(TARGET_OBJ_DIR)/.efhash_$(TARGET_EF_HASH)

CLEAN_ARTIFACTS := $(TARGET_BIN)
CLEAN_ARTIFACTS += $(TARGET_HEX_REV) $(TARGET_HEX)
CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP) $(TARGET_SO)
CLEAN_ARTIFACTS += $(TARGET_LST)
CLEAN_ARTIFACTS += $(TARGET_DFU)

Expand Down Expand Up @@ -391,12 +396,21 @@ $(TARGET_ELF): $(TARGET_OBJS) $(LD_SCRIPT) $(LD_SCRIPTS)
$(V1) $(CROSS_CC) -o $@ $(filter-out %.ld,$^) $(LD_FLAGS)
$(V1) $(SIZE) $(TARGET_ELF)

$(TARGET_SO) : $(TARGET_OBJS)
@echo "Creating shared library"
$(V1) $(CROSS_CC) -o $@ $(filter-out %.ld,$^) $(LD_FLAGS) -shared

# Compile

## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
define compile_file
echo "%% ($(1)) $<" "$(STDOUT)" && \
$(CROSS_CC) -c -o $@ $(CFLAGS) $(2) $<
$(V1) $(if $(findstring $<,$(LAPACK_SOURCE)), \
echo "%% ($(1)) $<" "$(STDOUT)" && \
$(CROSS_CC) -c -o $@ $(CFLAGS) $(2) -Wno-maybe-uninitialized -Wno-parentheses -Wno-double-promotion -Wno-unused-variable -Wno-old-style-definition -Wno-unused-parameter -Wno-implicit-function-declaration -Wno-unused-but-set-variable -Wno-unused-variable -Wno-implicit-fallthrough -Wno-sign-compare $< \
, \
echo "%% ($(1)) $<" "$(STDOUT)" && \
$(CROSS_CC) -c -o $@ $(CFLAGS) $(2) $< \
)
endef

ifeq ($(DEBUG),GDB)
Expand Down Expand Up @@ -526,7 +540,18 @@ binary:
$(V0) $(MAKE) -j $(TARGET_BIN)

hex:
ifeq ($(TARGET),MOCKUP)
# generate shared library instead
$(V0) $(MAKE) -j $(TARGET_SO)
else
$(V0) $(MAKE) -j $(TARGET_HEX)
endif

dfu:
$(V0) $(MAKE) -j $(TARGET_DFU)

so:
$(V0) $(MAKE) -j $(TARGET_SO)

TARGETS_REVISION = $(addsuffix _rev,$(VALID_TARGETS))
## <TARGET>_rev : build target and add revision to filename
Expand Down Expand Up @@ -652,7 +677,7 @@ $(TARGET_EF_HASH_FILE):
$(V1) touch $(TARGET_EF_HASH_FILE)

# pi-protocol make script
$(PI_GEN_FILES) : $(PI_DIR)/pi-protocol.c $(PI_DIR)/../config.yaml $(wildcard $(PI_DIR)/../messages/*) $(wildcard $(PI_DIR)/../templates/*.j2) $(PI_DIR)/../python/generate.py
$(PI_GEN_FILES) : $(PI_DIR)/pi-protocol.c $(PI_DIR)/../config.yaml $(wildcard $(PI_DIR)/../msgs/*) $(wildcard $(PI_DIR)/../templates/*.j2) $(PI_DIR)/../python/generate.py
@echo "generating pi protocol headers"
cd lib/main/pi-protocol/ && make generate CONFIG=config.yaml
@echo "done"
Expand All @@ -664,3 +689,6 @@ $(TARGET_OBJS): $(TARGET_EF_HASH_FILE) Makefile $(TARGET_DIR)/target.mk $(wildca
-include $(TARGET_DEPS)

include $(ROOT)/make/remote_flash.mk

echo-cflags:
@echo $(CFLAGS)
Loading

0 comments on commit b07a92c

Please sign in to comment.