From d977756ad69c37ec57326ffa4d407b4929cc6042 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 10 Oct 2023 16:00:50 +0200 Subject: [PATCH 1/7] allow different build folder via BUILDDIR env variable --- Makefile | 163 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 88 insertions(+), 75 deletions(-) diff --git a/Makefile b/Makefile index 5de94be..5317d36 100644 --- a/Makefile +++ b/Makefile @@ -70,78 +70,84 @@ INCLUDES = \ -Ilibraries/openamp_arduino/openamp \ -Ilibraries/openamp_arduino/metal \ -OBJS = \ - src/system_stm32h7xx_dualcore_boot_cm4_cm7.o \ - src/main.o \ - src/can.o \ - src/can_util.o \ - src/peripherals.o \ - src/ringbuffer.o \ - src/rpc.o \ - src/stm32h7xx_it.o \ - src/syscalls.o \ - src/sysmem.o \ - src/adc.o \ - src/uart.o \ - src/pwm.o \ - src/gpio.o \ - src/timer.o \ - src/rtc.o \ - src/spi.o \ - src/system.o \ - src/watchdog.o \ - src/m4_utilities.o \ - startup/startup_stm32h747xx.o \ - libraries/openamp_arduino/src/condition.o \ - libraries/openamp_arduino/src/device.o \ - libraries/openamp_arduino/src/generic_device.o \ - libraries/openamp_arduino/src/generic_init.o \ - libraries/openamp_arduino/src/generic_io.o \ - libraries/openamp_arduino/src/init.o \ - libraries/openamp_arduino/src/io.o \ - libraries/openamp_arduino/src/irq.o \ - libraries/openamp_arduino/src/log.o \ - libraries/openamp_arduino/src/mailbox_hsem_if.o \ - libraries/openamp_arduino/src/openamp.o \ - libraries/openamp_arduino/src/remoteproc_virtio.o \ - libraries/openamp_arduino/src/rpmsg.o \ - libraries/openamp_arduino/src/rpmsg_virtio.o \ - libraries/openamp_arduino/src/rsc_table.o \ - libraries/openamp_arduino/src/shmem.o \ - libraries/openamp_arduino/src/sys.o \ - libraries/openamp_arduino/src/time.o \ - libraries/openamp_arduino/src/virtio.o \ - libraries/openamp_arduino/src/virtqueue.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fdcan.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hrtim.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_iwdg.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.o \ - libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.o - +SRCS = \ + src/system_stm32h7xx_dualcore_boot_cm4_cm7.c \ + src/main.c \ + src/can.c \ + src/can_util.c \ + src/peripherals.c \ + src/ringbuffer.c \ + src/rpc.c \ + src/stm32h7xx_it.c \ + src/syscalls.c \ + src/sysmem.c \ + src/adc.c \ + src/uart.c \ + src/pwm.c \ + src/gpio.c \ + src/timer.c \ + src/rtc.c \ + src/spi.c \ + src/system.c \ + src/watchdog.c \ + src/m4_utilities.c \ + libraries/openamp_arduino/src/condition.c \ + libraries/openamp_arduino/src/device.c \ + libraries/openamp_arduino/src/generic_device.c \ + libraries/openamp_arduino/src/generic_init.c \ + libraries/openamp_arduino/src/generic_io.c \ + libraries/openamp_arduino/src/init.c \ + libraries/openamp_arduino/src/io.c \ + libraries/openamp_arduino/src/irq.c \ + libraries/openamp_arduino/src/log.c \ + libraries/openamp_arduino/src/mailbox_hsem_if.c \ + libraries/openamp_arduino/src/openamp.c \ + libraries/openamp_arduino/src/remoteproc_virtio.c \ + libraries/openamp_arduino/src/rpmsg.c \ + libraries/openamp_arduino/src/rpmsg_virtio.c \ + libraries/openamp_arduino/src/rsc_table.c \ + libraries/openamp_arduino/src/shmem.c \ + libraries/openamp_arduino/src/sys.c \ + libraries/openamp_arduino/src/time.c \ + libraries/openamp_arduino/src/virtio.c \ + libraries/openamp_arduino/src/virtqueue.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fdcan.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hrtim.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_iwdg.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c \ + libraries/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c + +SRCS_ASM = \ + startup/startup_stm32h747xx.s + +BUILDDIR?=. + +OBJS = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS)) +OBJS += $(patsubst %.s,$(BUILDDIR)/%.o,$(SRCS_ASM)) # ----- Verbosity control ----------------------------------------------------- @@ -173,7 +179,14 @@ debug: CFLAGS += -DDEBUG debug: CXXFLAGS += -DDEBUG debug: $(NAME).bin $(NAME).hex -$(NAME).elf: $(OBJS) +builddir: + mkdir -p $(BUILDDIR) && \ + mkdir -p $(BUILDDIR)/src && \ + mkdir -p $(BUILDDIR)/startup && \ + mkdir -p $(BUILDDIR)/libraries/openamp_arduino/src/ && \ + mkdir -p $(BUILDDIR)/libraries/STM32H7xx_HAL_Driver/Src/ + +$(NAME).elf: builddir $(OBJS) $(CC) -o $@ $(OBJS) $(DEFINES) $(CFLAGS) $(LDFLAGS) $(SIZE) $@ @@ -204,11 +217,11 @@ MKDEP = \ [ "$${PIPESTATUS[*]}" = "0 0" ] || \ { rm -f $(basename $@).d; exit 1; } -%.o: %.c +$(BUILDDIR)/%.o: %.c $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@ $(MKDEP) -%.o: %.S +$(BUILDDIR)/%.o: %.s $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -D__ASSEMBLY__ -c $< -o $@ $(MKDEP) From 959e783633bf11db70d5ab1d73fcc64aff257788 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 11 Oct 2023 06:36:34 +0200 Subject: [PATCH 2/7] Document option BUILDDIR for specifying the build directory. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4bdab4d..e3e7302 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ This repository contains the firmware running on the `STM32H747AIIX`/Cortex-M7 c * Either `make` ```bash make +# or +BUILDDIR=build make -j8 ``` * or `bitbake`. ```bash From 019b1bce86732d231d9b04808875e4852773081c Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 11 Oct 2023 06:37:17 +0200 Subject: [PATCH 3/7] Change CI build for using "build" as a build folder. --- .github/workflows/smoke-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 4108012..2ba3a77 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -25,4 +25,4 @@ jobs: run: sudo apt-get update && sudo apt-get install gcc-arm-none-eabi - name: Build firmware with make - run: make + run: BUILDDIR=build make -j8 From f42e2215a14c32102c5e7e362ab03d17dc51ce25 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 11 Oct 2023 06:38:02 +0200 Subject: [PATCH 4/7] Ignore build folder. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8bbc580..35e1058 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.o STM32H747AII6* .idea/ +build/ From dbe4a5931198e6dc3a4a8486f69fa6e3c4736411 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 11 Oct 2023 06:40:41 +0200 Subject: [PATCH 5/7] Remove "build" folder during cleanup. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5317d36..d4e2091 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,7 @@ clean: rm -f $(OBJS) $(OBJS:.o=.d) rm -f $(OBJS) $(OBJS:.o=.su) rm -f *~ + rm -rf $(BUILDDIR) # ----- Dependencies ---------------------------------------------------------- From 882df13133211037a4836fd741843db8e0a01ec2 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 11 Oct 2023 09:40:20 +0200 Subject: [PATCH 6/7] Set "build" as default build folder. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d4e2091..2cda239 100644 --- a/Makefile +++ b/Makefile @@ -144,7 +144,7 @@ SRCS = \ SRCS_ASM = \ startup/startup_stm32h747xx.s -BUILDDIR?=. +BUILDDIR?=build OBJS = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS)) OBJS += $(patsubst %.s,$(BUILDDIR)/%.o,$(SRCS_ASM)) From 39ab57433aa1fa7156658564f07e4ff9ffb8abe7 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 11 Oct 2023 09:41:21 +0200 Subject: [PATCH 7/7] Update documentation/run CI without build-dir. --- .github/workflows/smoke-test.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 2ba3a77..30e8a0b 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -25,4 +25,4 @@ jobs: run: sudo apt-get update && sudo apt-get install gcc-arm-none-eabi - name: Build firmware with make - run: BUILDDIR=build make -j8 + run: make -j8 diff --git a/README.md b/README.md index e3e7302..d236144 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This repository contains the firmware running on the `STM32H747AIIX`/Cortex-M7 c ```bash make # or -BUILDDIR=build make -j8 +BUILDDIR=my-build-dir make -j8 ``` * or `bitbake`. ```bash