Skip to content

Commit

Permalink
🔨 Better build, envs, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 10, 2024
1 parent a53ad3b commit 550a303
Show file tree
Hide file tree
Showing 97 changed files with 15,884 additions and 14,337 deletions.
30 changes: 13 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ CONTAINER_IMAGE := marlin-dev

help:
@echo "Tasks for local development:"
@echo "* format-pins: Reformat all pins files
@echo "* tests-single-ci: Run a single test from inside the CI"
@echo "* tests-single-local: Run a single test locally"
@echo "* tests-single-local-docker: Run a single test locally, using docker"
@echo "* tests-all-local: Run all tests locally"
@echo "* tests-all-local-docker: Run all tests locally, using docker"
@echo "* setup-local-docker: Build the local docker image"
@echo "make marlin : Build marlin for the configured board"
@echo "make format-pins : Reformat all pins files"
@echo "make tests-single-ci : Run a single test from inside the CI"
@echo "make tests-single-local : Run a single test locally"
@echo "make tests-single-local-docker : Run a single test locally, using docker"
@echo "make tests-all-local : Run all tests locally"
@echo "make tests-all-local-docker : Run all tests locally, using docker"
@echo "make setup-local-docker : Build the local docker image"
@echo ""
@echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the"
Expand All @@ -24,46 +25,41 @@ help:
@echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
@echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
.PHONY: help

marlin:
./buildroot/bin/mftest -a
.PHONY: marlin

tests-single-ci:
export GIT_RESET_HARD=true
$(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) PLATFORMIO_BUILD_FLAGS=-DGITHUB_ACTION
.PHONY: tests-single-ci

tests-single-local:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& run_tests . $(TEST_TARGET) "$(ONLY_TEST)"
.PHONY: tests-single-local

tests-single-local-docker:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
.PHONY: tests-single-local-docker

tests-all-local:
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
.PHONY: tests-all-local

tests-all-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
.PHONY: tests-all-local-docker

setup-local-docker:
$(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
.PHONY: setup-local-docker

PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')

.PHONY: $(PINS)

$(PINS): %:
@echo "Formatting $@" && node buildroot/share/scripts/pinsformat.js $@
@echo "Formatting $@" && node $(SCRIPTS_DIR)/pinsformat.js $@

format-pins: $(PINS)
6 changes: 4 additions & 2 deletions buildroot/bin/build_all_examples
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# build_all_examples [...] branch [resume-from]
#

. mfutil
HERE=`dirname $0`

. "$HERE/mfutil"

GITREPO=https://github.com/MarlinFirmware/Configurations.git
STAT_FILE=./.pio/.buildall
Expand Down Expand Up @@ -123,7 +125,7 @@ CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/
for CONF in $CONF_TREE ; do

# Get a config's directory name
DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
DIR=$( echo $CONF | "$SED" "s|$TMP/config/examples/||" )

# If looking for a config, skip others
[[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
Expand Down
6 changes: 4 additions & 2 deletions buildroot/bin/build_example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# Usage: build_example internal config-home config-folder
#

. mfutil
HERE=`dirname $0`

. "$HERE/mfutil"

# Require 'internal' as the first argument
[[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
Expand Down Expand Up @@ -36,6 +38,6 @@ unset IFS; set +f
echo -e "\n#define NO_CONTROLLER_CUSTOM_WIRING_WARNING" >> Marlin/Configuration.h

echo "Building the firmware now..."
$HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
"$HERE/mftest" -s -a -n1 || { echo "Failed"; exit 1; }

echo "Success"
2 changes: 2 additions & 0 deletions buildroot/bin/mftest
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; }

which pio || { echo "Make sure 'pio' is in your execution PATH." ; exit 1 ; }

perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
errout() { echo -e "\033[0;31m$1\033[0m" ; }
bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; }
Expand Down
3 changes: 1 addition & 2 deletions buildroot/bin/mfutil
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }

SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
SED=$(which gsed sed | head -n1)
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }

OPEN=$( which gnome-open xdg-open open | head -n1 )

SELF=`basename "$0"`
HERE=`dirname "$0"`

# Check if called in the right location
[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
]
],
"ldscript": "ldscript.ld",
"mcu": "stm32f401rct6",
"variant": "MARLIN_CREALITY_STM32F401RC"
"mcu": "stm32f401ret6",
"variant": "MARLIN_CREALITY_STM32F401RE"
},
"debug": {
"jlink_device": "STM32F401RC",
"jlink_device": "STM32F401RE",
"openocd_target": "stm32f4x",
"svd_path": "STM32F40x.svd",
"tools": {
Expand All @@ -45,11 +45,11 @@
"arduino",
"stm32cube"
],
"name": "STM32F401RC (64k RAM. 256k Flash)",
"name": "STM32F401RE (64k RAM. 512k Flash)",
"upload": {
"disable_flushing": false,
"maximum_ram_size": 65536,
"maximum_size": 262144,
"maximum_size": 514288,
"protocol": "stlink",
"protocols": [
"stlink",
Expand All @@ -60,6 +60,6 @@
"use_1200bps_touch": false,
"wait_for_upload_port": false
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f401rc.html",
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f401re.html",
"vendor": "Generic"
}
35 changes: 35 additions & 0 deletions buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V30.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"build": {
"cpu": "cortex-m4",
"extra_flags": "-DSTM32F446xx",
"f_cpu": "180000000L",
"mcu": "stm32f446ret6",
"variant": "MARLIN_F446VE"
},
"connectivity": [
"can"
],
"debug": {
"jlink_device": "STM32F446RE",
"openocd_target": "stm32f4x",
"svd_path": "STM32F446x.svd"
},
"frameworks": [
"arduino",
"stm32cube"
],
"name": "3D Printer control board",
"upload": {
"maximum_ram_size": 131072,
"maximum_size": 524288,
"protocol": "stlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"serial"
]
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html",
"vendor": "FYSETC"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"cpu": "cortex-m7",
"extra_flags": "-DSTM32H7xx -DSTM32H723xx",
"f_cpu": "550000000L",
"mcu": "stm32h723vet6",
"mcu": "stm32h723vgt6",
"product_line": "STM32H723xx",
"variant": "MARLIN_H723Vx"
"variant": "MARLIN_H723VG"
},
"connectivity": [
"can",
"ethernet"
],
"debug": {
"jlink_device": "STM32H723VE",
"jlink_device": "STM32H723VG",
"openocd_target": "stm32h7x",
"svd_path": "STM32H7x3.svd",
"tools": {
Expand All @@ -39,11 +39,11 @@
"arduino",
"stm32cube"
],
"name": "STM32H723VE (564k RAM. 512k Flash)",
"name": "STM32H723VG (564k RAM. 1024k Flash)",
"upload": {
"disable_flushing": false,
"maximum_ram_size": 577536,
"maximum_size": 524288,
"maximum_size": 1048576,
"protocol": "stlink",
"protocols": [
"stlink",
Expand All @@ -56,6 +56,6 @@
"use_1200bps_touch": false,
"wait_for_upload_port": false
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h723ze.html",
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h723vg.html",
"vendor": "ST"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"f_cpu": "550000000L",
"mcu": "stm32h723zet6",
"product_line": "STM32H723xx",
"variant": "MARLIN_H723Zx"
"variant": "MARLIN_H723ZE"
},
"connectivity": [
"can",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"f_cpu": "480000000L",
"mcu": "stm32h743vit6",
"product_line": "STM32H743xx",
"variant": "MARLIN_H743Vx"
"variant": "MARLIN_H743VI"
},
"connectivity": [
"can",
Expand Down
14 changes: 14 additions & 0 deletions buildroot/share/PlatformIO/ldscripts/creality256k.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40
rom (rx) : ORIGIN = 0x08007000, LENGTH = 256K - 28K
}

/* Provide memory region aliases for common.inc */
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
REGION_ALIAS("REGION_RODATA", rom);

/* Let common.inc handle the real work. */
INCLUDE common.inc
4 changes: 2 additions & 2 deletions buildroot/share/PlatformIO/scripts/common-dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define HAS_MENU_BACKLASH
#endif
#if ENABLED(LCD_BED_TRAMMING)
#define HAS_MENU_BED_CORNERS
#define HAS_MENU_BED_TRAMMING
#endif
#if ENABLED(CANCEL_OBJECTS)
#define HAS_MENU_CANCELOBJECT
Expand Down Expand Up @@ -99,7 +99,7 @@
#define HAS_MENU_TOUCH_SCREEN
#endif
#if ENABLED(ASSISTED_TRAMMING_WIZARD)
#define HAS_MENU_TRAMMING
#define HAS_MENU_TRAMMING_WIZARD
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
#define HAS_MENU_UBL
Expand Down
Loading

0 comments on commit 550a303

Please sign in to comment.