Merge branch 'bugfix-2.1.x' into CrealityDwin2.0_Bleeding
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# test-builds.yml
|
||||
# ci-build-tests.yml
|
||||
# Do test builds to catch compile errors
|
||||
#
|
||||
|
||||
name: CI
|
||||
name: CI - Build Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@@ -27,7 +27,7 @@ on:
|
||||
|
||||
jobs:
|
||||
test_builds:
|
||||
name: Run All Tests
|
||||
name: Build Test
|
||||
if: github.repository == 'MarlinFirmware/Marlin'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
@@ -0,0 +1,73 @@
|
||||
#
|
||||
# ci-unit-tests.yml
|
||||
# Build and execute unit tests to catch functional issues in code
|
||||
#
|
||||
|
||||
name: CI - Unit Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- bugfix-2.1.x
|
||||
# Cannot be enabled on 2.1.x until it contains the unit test framework
|
||||
#- 2.1.x
|
||||
paths-ignore:
|
||||
- config/**
|
||||
- data/**
|
||||
- docs/**
|
||||
- '**/*.md'
|
||||
push:
|
||||
branches:
|
||||
- bugfix-2.1.x
|
||||
# Cannot be enabled on 2.1.x until it contains the unit test framework
|
||||
#- 2.1.x
|
||||
paths-ignore:
|
||||
- config/**
|
||||
- data/**
|
||||
- docs/**
|
||||
- '**/*.md'
|
||||
|
||||
jobs:
|
||||
# This runs all unit tests as a single job. While it should be possible to break this up into
|
||||
# multiple jobs, they currently run quickly and finish long before the compilation tests.
|
||||
run_unit_tests:
|
||||
name: Unit Test
|
||||
# These tests will only be able to run on the bugfix-2.1.x branch, until the next release
|
||||
# pulls them into additional branches.
|
||||
if: github.repository == 'MarlinFirmware/Marlin'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out the PR
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Select Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.9'
|
||||
architecture: 'x64'
|
||||
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
pip install -U platformio
|
||||
pio upgrade --dev
|
||||
pio pkg update --global
|
||||
|
||||
- name: Run All Unit Tests
|
||||
run: |
|
||||
make unit-test-all-local
|
||||
@@ -12,7 +12,12 @@ help:
|
||||
@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 "make unit-test-single-ci : Run a single code test from inside the CI"
|
||||
# @echo "make unit-test-single-local : Run a single code test locally"
|
||||
# @echo "make unit-test-single-local-docker : Run a single code test locally, using docker-compose"
|
||||
@echo "make unit-test-all-local : Run all code tests locally"
|
||||
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker-compose"
|
||||
@echo "make setup-local-docker : Setup local docker-compose"
|
||||
@echo ""
|
||||
@echo "Options for testing:"
|
||||
@echo " TEST_TARGET Set when running tests-single-*, to select the"
|
||||
@@ -43,7 +48,7 @@ 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)"
|
||||
$(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)"
|
||||
|
||||
tests-all-local:
|
||||
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
|
||||
@@ -52,10 +57,31 @@ 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)
|
||||
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
|
||||
|
||||
#unit-test-single-ci:
|
||||
# export GIT_RESET_HARD=true
|
||||
# $(MAKE) unit-test-single-local TEST_TARGET=$(TEST_TARGET)
|
||||
|
||||
# TODO: How can we limit tests with ONLY_TEST with platformio?
|
||||
#unit-test-single-local:
|
||||
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local" ; return 1; fi
|
||||
# platformio run -t marlin_$(TEST_TARGET)
|
||||
|
||||
#unit-test-single-local-docker:
|
||||
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-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 unit-test-single-local TEST_TARGET=$(TEST_TARGET) ONLY_TEST="$(ONLY_TEST)"
|
||||
|
||||
unit-test-all-local:
|
||||
platformio run -t test-marlin -e linux_native_test
|
||||
|
||||
unit-test-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 unit-test-all-local
|
||||
|
||||
setup-local-docker:
|
||||
$(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
|
||||
$(CONTAINER_RT_BIN) buildx build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
|
||||
|
||||
PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')
|
||||
|
||||
|
||||
@@ -2823,7 +2823,7 @@
|
||||
* This feature is EXPERIMENTAL so use with caution and test thoroughly.
|
||||
* Enable this option to receive data on the serial ports via the onboard DMA
|
||||
* controller for more stable and reliable high-speed serial communication.
|
||||
* Only some STM32 MCUs are currently supported.
|
||||
* Support is currently limited to some STM32 MCUs and all HC32 MCUs.
|
||||
* Note: This has no effect on emulated USB serial ports.
|
||||
*/
|
||||
//#define SERIAL_DMA
|
||||
@@ -4544,7 +4544,7 @@
|
||||
* Extras for an ESP32-based motherboard with WIFISUPPORT
|
||||
* These options don't apply to add-on WiFi modules based on ESP32 WiFi101.
|
||||
*/
|
||||
#if ENABLED(WIFISUPPORT)
|
||||
#if ANY(WIFISUPPORT, ESP3D_WIFISUPPORT)
|
||||
//#define WEBSUPPORT // Start a webserver (which may include auto-discovery) using SPIFFS
|
||||
//#define OTASUPPORT // Support over-the-air firmware updates
|
||||
//#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
|
||||
|
||||
@@ -123,6 +123,11 @@ void MarlinHAL::init() {
|
||||
|
||||
// Register min serial
|
||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial());
|
||||
|
||||
// warn if low memory after init
|
||||
if (freeMemory() < 1024) {
|
||||
SERIAL_WARN_MSG("HAL: low memory after init!\n");
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinHAL::init_board() {}
|
||||
@@ -147,7 +152,31 @@ void MarlinHAL::delay_ms(const int ms) {
|
||||
delay(ms);
|
||||
}
|
||||
|
||||
void MarlinHAL::idletask() {}
|
||||
void MarlinHAL::idletask() {
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
// check & print serial RX errors
|
||||
MSerialT *serials[] = { &MSerial1, &MSerial2 };
|
||||
for (int serial = 0; serial < 2; serial++) {
|
||||
usart_receive_error_t err = serials[serial]->getReceiveError();
|
||||
if (err != usart_receive_error_t::None) {
|
||||
// "Warning: MSerial[n] RX [Framing|Parity|Overrun] Error"
|
||||
SERIAL_WARN_START();
|
||||
SERIAL_ECHOPGM(" MSerial");
|
||||
SERIAL_ECHO(serial + 1);
|
||||
SERIAL_ECHOPGM(" RX ");
|
||||
switch(err) {
|
||||
case usart_receive_error_t::FramingError: SERIAL_ECHOPGM("Framing"); break;
|
||||
case usart_receive_error_t::ParityError: SERIAL_ECHOPGM("Parity"); break;
|
||||
case usart_receive_error_t::OverrunError: SERIAL_ECHOPGM("Overrun"); break;
|
||||
case usart_receive_error_t::RxDataDropped: SERIAL_ECHOPGM("DataDropped"); break;
|
||||
default: break;
|
||||
}
|
||||
SERIAL_ECHOPGM(" Error");
|
||||
SERIAL_EOL();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
// Query reset cause from RMU
|
||||
|
||||
@@ -46,14 +46,34 @@ constexpr bool serial_handles_emergency(int port) {
|
||||
//
|
||||
// Define serial ports
|
||||
//
|
||||
#define DEFINE_HWSERIAL_MARLIN(name, n) \
|
||||
|
||||
// serial port where RX and TX use IRQs
|
||||
#define DEFINE_IRQ_SERIAL_MARLIN(name, n) \
|
||||
MSerialT name(serial_handles_emergency(n), \
|
||||
&USART##n##_config, \
|
||||
BOARD_USART##n##_TX_PIN, \
|
||||
BOARD_USART##n##_RX_PIN);
|
||||
|
||||
DEFINE_HWSERIAL_MARLIN(MSerial1, 1);
|
||||
DEFINE_HWSERIAL_MARLIN(MSerial2, 2);
|
||||
// serial port where RX uses DMA and TX uses IRQs
|
||||
// all serial ports use DMA1
|
||||
// since there are 4 USARTs and 4 DMA channels, we can use the USART number as the DMA channel
|
||||
#define DEFINE_DMA_SERIAL_MARLIN(name, n) \
|
||||
MSerialT name(serial_handles_emergency(n), \
|
||||
&USART##n##_config, \
|
||||
BOARD_USART##n##_TX_PIN, \
|
||||
BOARD_USART##n##_RX_PIN, \
|
||||
M4_DMA1, \
|
||||
((en_dma_channel_t)(n - 1))); // map USART1 to DMA channel 0, USART2 to DMA channel 1, etc.
|
||||
|
||||
#define DEFINE_SERIAL_MARLIN(name, n) TERN(SERIAL_DMA, DEFINE_DMA_SERIAL_MARLIN(name, n), DEFINE_IRQ_SERIAL_MARLIN(name, n))
|
||||
|
||||
DEFINE_SERIAL_MARLIN(MSerial1, 1);
|
||||
DEFINE_SERIAL_MARLIN(MSerial2, 2);
|
||||
|
||||
// TODO: remove this warning when SERIAL_DMA has been tested some more
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
#warning "SERIAL_DMA may be unstable on HC32F460."
|
||||
#endif
|
||||
|
||||
//
|
||||
// Serial port assertions
|
||||
|
||||
@@ -25,17 +25,42 @@
|
||||
#include <drivers/usart/Usart.h>
|
||||
|
||||
// Optionally set uart IRQ priority to reduce overflow errors
|
||||
// #define UART_IRQ_PRIO 1
|
||||
//#define UART_RX_IRQ_PRIO 1
|
||||
//#define UART_TX_IRQ_PRIO 1
|
||||
//#define UART_RX_DMA_IRQ_PRIO 1
|
||||
|
||||
struct MarlinSerial : public Usart {
|
||||
MarlinSerial(struct usart_config_t *usart_device, gpio_pin_t tx_pin, gpio_pin_t rx_pin) : Usart(usart_device, tx_pin, rx_pin) {}
|
||||
MarlinSerial(
|
||||
struct usart_config_t *usart_device,
|
||||
gpio_pin_t tx_pin,
|
||||
gpio_pin_t rx_pin
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
, M4_DMA_TypeDef *dma_unit = nullptr,
|
||||
en_dma_channel_t rx_dma_channel = DmaCh0
|
||||
#endif
|
||||
) : Usart(usart_device, tx_pin, rx_pin) {
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
if (dma_unit != nullptr) {
|
||||
enableRxDma(dma_unit, rx_dma_channel);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef UART_IRQ_PRIO
|
||||
#if defined(UART_RX_IRQ_PRIO) || defined(UART_TX_IRQ_PRIO) || defined(UART_RX_DMA_IRQ_PRIO)
|
||||
void setPriority() {
|
||||
NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_IRQ_PRIO);
|
||||
NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_IRQ_PRIO);
|
||||
NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_IRQ_PRIO);
|
||||
NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_IRQ_PRIO);
|
||||
#if defined(UART_RX_IRQ_PRIO)
|
||||
NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_RX_IRQ_PRIO);
|
||||
NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_RX_IRQ_PRIO);
|
||||
#endif
|
||||
|
||||
#if defined(UART_TX_IRQ_PRIO)
|
||||
NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_TX_IRQ_PRIO);
|
||||
NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_TX_IRQ_PRIO);
|
||||
#endif
|
||||
|
||||
#if defined(UART_RX_DMA_IRQ_PRIO) && ENABLED(SERIAL_DMA)
|
||||
NVIC_SetPriority(c_dev()->dma.rx.rx_data_available_dma_btc.interrupt_number, UART_RX_DMA_IRQ_PRIO);
|
||||
#endif
|
||||
}
|
||||
|
||||
void begin(uint32_t baud) {
|
||||
@@ -47,7 +72,12 @@ struct MarlinSerial : public Usart {
|
||||
Usart::begin(baud, config);
|
||||
setPriority();
|
||||
}
|
||||
#endif
|
||||
|
||||
void begin(uint32_t baud, const stc_usart_uart_init_t *config, const bool rxNoiseFilter = true) {
|
||||
Usart::begin(baud, config, rxNoiseFilter);
|
||||
setPriority();
|
||||
}
|
||||
#endif // UART_RX_IRQ_PRIO || UART_TX_IRQ_PRIO || UART_RX_DMA_IRQ_PRIO
|
||||
};
|
||||
|
||||
typedef Serial1Class<MarlinSerial> MSerialT;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* app_config.h is included by the hc32f460 arduino build script for every source file.
|
||||
* it is used to configure the arduino core (and ddl) automatically according
|
||||
* to the settings in Configuration.h and Configuration_adv.h.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef _HC32_APP_CONFIG_H_
|
||||
#define _HC32_APP_CONFIG_H_
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
//
|
||||
// dev mode
|
||||
//
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
#define __DEBUG 1
|
||||
#define __CORE_DEBUG 1
|
||||
#endif
|
||||
|
||||
//
|
||||
// Fault Handlers and Panic
|
||||
//
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
// disable arduino core fault handler, as we define our own
|
||||
#define CORE_DISABLE_FAULT_HANDLER 1
|
||||
#endif
|
||||
|
||||
// force-enable panic handler so that we can use our custom one (in MinSerial)
|
||||
#define PANIC_ENABLE 1
|
||||
|
||||
// use short filenames in ddl debug and core panic output
|
||||
#define __DEBUG_SHORT_FILENAMES 1
|
||||
#define __PANIC_SHORT_FILENAMES 1
|
||||
|
||||
// omit panic messages in core panic output
|
||||
#define __OMIT_PANIC_MESSAGE 1
|
||||
|
||||
//
|
||||
// Usart
|
||||
//
|
||||
|
||||
// disable serial globals (Serial1, Serial2, ...), as we define our own
|
||||
#define DISABLE_SERIAL_GLOBALS 1
|
||||
|
||||
// increase the size of the Usart buffers (both RX and TX)
|
||||
// NOTE:
|
||||
// the heap usage will increase by (SERIAL_BUFFER_SIZE - 64) * "number of serial ports used"
|
||||
// if running out of heap, the system may become unstable
|
||||
//#define SERIAL_BUFFER_SIZE 256
|
||||
|
||||
// enable support for Usart Clock Divider / Oversampling auto config
|
||||
#define USART_AUTO_CLKDIV_OS_CONFIG 1
|
||||
|
||||
// enable USART_RX_DMA_SUPPORT core option when SERIAL_DMA is enabled
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
#define USART_RX_DMA_SUPPORT 1
|
||||
#endif
|
||||
|
||||
//
|
||||
// Misc.
|
||||
//
|
||||
|
||||
// redirect printf to host serial
|
||||
#define REDIRECT_PRINTF_TO_SERIAL 1
|
||||
|
||||
// FIXME override F_CPU to PCLK1, as marlin freaks out otherwise
|
||||
#define F_CPU (SYSTEM_CLOCK_FREQUENCIES.pclk1)
|
||||
|
||||
#endif // _HC32_APP_CONFIG_H_
|
||||
@@ -20,6 +20,20 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include <core_util.h>
|
||||
|
||||
#if !defined(ARDUINO_CORE_VERSION_INT) || !defined(GET_VERSION_INT)
|
||||
// version macros were introduced in arduino core version 1.1.0
|
||||
// below that version, we polyfill them
|
||||
#define GET_VERSION_INT(major, minor, patch) ((major * 100000) + (minor * 1000) + patch)
|
||||
#define ARDUINO_CORE_VERSION_INT GET_VERSION_INT(1, 0, 0)
|
||||
#endif
|
||||
|
||||
#if ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 1, 0)
|
||||
// because we use app_config.h introduced in arduino core version 1.1.0, the
|
||||
// HAL is not compatible with older versions
|
||||
#error "The HC32 HAL is not compatible with Arduino Core versions < 1.1.0. Consider updating the Arduino Core."
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_XTAL_FREQUENCY
|
||||
#error "BOARD_XTAL_FREQUENCY is required for HC32F460."
|
||||
@@ -74,3 +88,18 @@
|
||||
#error "HC32 HAL uses a custom panic handler. Do not define PANIC_USARTx_TX_PIN."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
#if !defined(USART_RX_DMA_SUPPORT)
|
||||
#error "SERIAL_DMA requires USART_RX_DMA_SUPPORT to be enabled in the arduino core."
|
||||
#endif
|
||||
|
||||
// USART_RX_DMA_SUPPORT does not implement core_hook_usart_rx_irq, which is required for the emergency parser
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not supported with SERIAL_DMA. Please disable either SERIAL_DMA or EMERGENCY_PARSER."
|
||||
#endif
|
||||
|
||||
#if ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 1, 0)
|
||||
#error "SERIAL_DMA is not supported with arduino core version < 1.1.0."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
fn \
|
||||
}
|
||||
|
||||
stc_sd_handle_t *handle;
|
||||
stc_sd_handle_t *handle = nullptr;
|
||||
|
||||
bool SDIO_Init() {
|
||||
// Configure SDIO pins
|
||||
@@ -66,36 +66,45 @@ bool SDIO_Init() {
|
||||
GPIO_SetFunc(BOARD_SDIO_CMD, Func_Sdio);
|
||||
GPIO_SetFunc(BOARD_SDIO_DET, Func_Sdio);
|
||||
|
||||
// If a handle is already initialized, free it before creating a new one
|
||||
// otherwise, we will leak memory, which will eventually crash the system
|
||||
if (handle != nullptr) {
|
||||
delete handle->pstcDmaInitCfg;
|
||||
delete handle->pstcCardInitCfg;
|
||||
delete handle;
|
||||
handle = nullptr;
|
||||
}
|
||||
|
||||
// Create DMA configuration
|
||||
stc_sdcard_dma_init_t *dmaConf = new stc_sdcard_dma_init_t;
|
||||
dmaConf->DMAx = SDIO_DMA_PERIPHERAL;
|
||||
dmaConf->enDmaCh = SDIO_DMA_CHANNEL;
|
||||
|
||||
// Create card configuration
|
||||
// This should be a fairly safe configuration for most cards
|
||||
stc_sdcard_init_t *cardConf = new stc_sdcard_init_t;
|
||||
cardConf->enBusWidth = SdiocBusWidth4Bit;
|
||||
cardConf->enClkFreq = SdiocClk400K;
|
||||
cardConf->enSpeedMode = SdiocNormalSpeedMode;
|
||||
cardConf->pstcInitCfg = nullptr;
|
||||
|
||||
// Create handle in DMA mode
|
||||
handle = new stc_sd_handle_t;
|
||||
handle->SDIOCx = SDIO_PERIPHERAL;
|
||||
handle->enDevMode = SdCardDmaMode;
|
||||
handle->pstcDmaInitCfg = dmaConf;
|
||||
|
||||
// Create card configuration
|
||||
// This should be a fairly safe configuration for most cards
|
||||
stc_sdcard_init_t cardConf = {
|
||||
.enBusWidth = SdiocBusWidth4Bit,
|
||||
.enClkFreq = SdiocClk400K,
|
||||
.enSpeedMode = SdiocNormalSpeedMode,
|
||||
//.pstcInitCfg = NULL,
|
||||
};
|
||||
//handle->pstcCardInitCfg = cardConf; // assigned in SDCARD_Init
|
||||
|
||||
// Initialize sd card
|
||||
en_result_t rc = SDCARD_Init(handle, &cardConf);
|
||||
en_result_t rc = SDCARD_Init(handle, cardConf);
|
||||
if (rc != Ok) printf("SDIO_Init() error (rc=%u)\n", rc);
|
||||
|
||||
return rc == Ok;
|
||||
}
|
||||
|
||||
bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
|
||||
CORE_ASSERT(handle != NULL, "SDIO not initialized");
|
||||
CORE_ASSERT(dst != NULL, "SDIO_ReadBlock dst is NULL");
|
||||
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
|
||||
CORE_ASSERT(dst != nullptr, "SDIO_ReadBlock dst is NULL", return false);
|
||||
|
||||
WITH_RETRY(SDIO_READ_RETRIES, {
|
||||
en_result_t rc = SDCARD_ReadBlocks(handle, block, 1, dst, SDIO_READ_TIMEOUT);
|
||||
@@ -107,8 +116,8 @@ bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
|
||||
}
|
||||
|
||||
bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
|
||||
CORE_ASSERT(handle != NULL, "SDIO not initialized");
|
||||
CORE_ASSERT(src != NULL, "SDIO_WriteBlock src is NULL");
|
||||
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
|
||||
CORE_ASSERT(src != nullptr, "SDIO_WriteBlock src is NULL", return false);
|
||||
|
||||
WITH_RETRY(SDIO_WRITE_RETRIES, {
|
||||
en_result_t rc = SDCARD_WriteBlocks(handle, block, 1, (uint8_t *)src, SDIO_WRITE_TIMEOUT);
|
||||
@@ -120,12 +129,12 @@ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
|
||||
}
|
||||
|
||||
bool SDIO_IsReady() {
|
||||
CORE_ASSERT(handle != NULL, "SDIO not initialized");
|
||||
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
|
||||
return bool(handle->stcCardStatus.READY_FOR_DATA);
|
||||
}
|
||||
|
||||
uint32_t SDIO_GetCardSize() {
|
||||
CORE_ASSERT(handle != NULL, "SDIO not initialized");
|
||||
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return 0);
|
||||
|
||||
// Multiply number of blocks with block size to get size in bytes
|
||||
const uint64_t cardSizeBytes = uint64_t(handle->stcSdCardInfo.u32LogBlockNbr) * uint64_t(handle->stcSdCardInfo.u32LogBlockSize);
|
||||
|
||||
@@ -37,7 +37,10 @@ Timer::Timer() {
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
timer_delete(timerid);
|
||||
if (timerid != 0) {
|
||||
timer_delete(timerid);
|
||||
timerid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#ifdef __PLAT_LINUX__
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
//#define GPIO_LOGGING // Full GPIO and Positional Logging
|
||||
|
||||
@@ -135,4 +136,5 @@ int main() {
|
||||
read_serial.join();
|
||||
}
|
||||
|
||||
#endif // UNIT_TEST
|
||||
#endif // __PLAT_LINUX__
|
||||
|
||||
@@ -474,11 +474,16 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
|
||||
#if HAS_KILL
|
||||
|
||||
// Check if the kill button was pressed and wait just in case it was an accidental
|
||||
// key kill key press
|
||||
// Check if the kill button was pressed and wait to ensure the signal is not noise
|
||||
// typically caused by poor insulation and grounding on LCD cables.
|
||||
// Lower numbers here will increase response time and therefore safety rating.
|
||||
// It is recommended to set this as low as possibe without false triggers.
|
||||
// -------------------------------------------------------------------------------
|
||||
#ifndef KILL_DELAY
|
||||
#define KILL_DELAY 250
|
||||
#endif
|
||||
|
||||
static int killCount = 0; // make the inactivity button a bit less responsive
|
||||
const int KILL_DELAY = 750;
|
||||
if (kill_state())
|
||||
killCount++;
|
||||
else if (killCount > 0)
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
#define BOARD_PXMALION_CORE_I3 1164 // Pxmalion Core I3
|
||||
#define BOARD_PANOWIN_CUTLASS 1165 // Panowin Cutlass (as found in the Panowin F1)
|
||||
#define BOARD_KODAMA_BARDO 1166 // Kodama Bardo V1.x (as found in the Kodama Trinus)
|
||||
#define BOARD_DAGOMA_D6 1167 // Dagoma D6 (as found in the Dagoma DiscoUltimate V2 TMC)
|
||||
|
||||
//
|
||||
// RAMBo and derivatives
|
||||
|
||||
@@ -57,9 +57,7 @@ enum PauseMessage : char {
|
||||
};
|
||||
|
||||
#if M600_PURGE_MORE_RESUMABLE
|
||||
/**
|
||||
* Input methods can Purge More, Resume, or request input
|
||||
*/
|
||||
// Input methods can Purge More, Resume, or request input
|
||||
enum PauseMenuResponse : char {
|
||||
PAUSE_RESPONSE_WAIT_FOR,
|
||||
PAUSE_RESPONSE_EXTRUDE_MORE,
|
||||
@@ -109,7 +107,7 @@ void wait_for_confirmation(
|
||||
void resume_print(
|
||||
const_float_t slow_load_length=0, // (mm) Slow Load Length for finishing move
|
||||
const_float_t fast_load_length=0, // (mm) Fast Load Length for initial move
|
||||
const_float_t extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, // (mm) Purge length
|
||||
const_float_t purge_length=ADVANCED_PAUSE_PURGE_LENGTH, // (mm) Purge length
|
||||
const int8_t max_beep_count=0, // Beep alert for attention
|
||||
const celsius_t targetTemp=0 // (°C) A target temperature for the hotend
|
||||
DXC_PARAMS // Dual-X-Carriage extruder index
|
||||
@@ -118,7 +116,7 @@ void resume_print(
|
||||
bool load_filament(
|
||||
const_float_t slow_load_length=0, // (mm) Slow Load Length for finishing move
|
||||
const_float_t fast_load_length=0, // (mm) Fast Load Length for initial move
|
||||
const_float_t extrude_length=0, // (mm) Purge length
|
||||
const_float_t purge_length=0, // (mm) Purge length
|
||||
const int8_t max_beep_count=0, // Beep alert for attention
|
||||
const bool show_lcd=false, // Set LCD status messages?
|
||||
const bool pause_for_user=false, // Pause for user before returning?
|
||||
|
||||
@@ -72,6 +72,7 @@ void GcodeSuite::M413_report(const bool forReplay/*=true*/) {
|
||||
, " B", recovery.bed_temp_threshold
|
||||
#endif
|
||||
);
|
||||
SERIAL_ECHO(" ; ");
|
||||
serialprintln_onoff(recovery.enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -235,9 +235,11 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
|
||||
#error "SERIAL_XON_XOFF and SERIAL_STATS_* features not supported on USB-native AVR devices."
|
||||
#endif
|
||||
|
||||
// Serial DMA is only available for some STM32 MCUs
|
||||
// Serial DMA is only available for some STM32 MCUs and HC32
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
#if !HAL_STM32 || NONE(STM32F0xx, STM32F1xx, STM32F2xx, STM32F4xx, STM32F7xx)
|
||||
#if defined(ARDUINO_ARCH_HC32)
|
||||
// checks for HC32 are located in HAL/HC32/inc/SanityCheck.h
|
||||
#elif !HAL_STM32 || NONE(STM32F0xx, STM32F1xx, STM32F2xx, STM32F4xx, STM32F7xx)
|
||||
#error "SERIAL_DMA is only available for some STM32 MCUs and requires HAL/STM32."
|
||||
#elif !defined(HAL_UART_MODULE_ENABLED) || defined(HAL_UART_MODULE_ONLY)
|
||||
#error "SERIAL_DMA requires STM32 platform HAL UART (without HAL_UART_MODULE_ONLY)."
|
||||
@@ -4000,11 +4002,11 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive."
|
||||
#if !(defined(WIFI_SSID) && defined(WIFI_PWD))
|
||||
#error "ESP32 motherboard with WIFISUPPORT requires WIFI_SSID and WIFI_PWD."
|
||||
#endif
|
||||
#elif ENABLED(WIFI_CUSTOM_COMMAND)
|
||||
#elif ENABLED(WIFI_CUSTOM_COMMAND) && NONE(ESP3D_WIFISUPPORT, WIFISUPPORT)
|
||||
#error "WIFI_CUSTOM_COMMAND requires an ESP32 motherboard and WIFISUPPORT."
|
||||
#elif ENABLED(OTASUPPORT)
|
||||
#elif ENABLED(OTASUPPORT) && NONE(ESP3D_WIFISUPPORT, WIFISUPPORT)
|
||||
#error "OTASUPPORT requires an ESP32 motherboard and WIFISUPPORT."
|
||||
#elif defined(WIFI_SSID) || defined(WIFI_PWD)
|
||||
#elif (defined(WIFI_SSID) || defined(WIFI_PWD)) && NONE(ESP3D_WIFISUPPORT, WIFISUPPORT)
|
||||
#error "WIFI_SSID and WIFI_PWD only apply to ESP32 motherboard with WIFISUPPORT."
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* version was tagged.
|
||||
*/
|
||||
#ifndef STRING_DISTRIBUTION_DATE
|
||||
#define STRING_DISTRIBUTION_DATE "2024-04-08"
|
||||
#define STRING_DISTRIBUTION_DATE "2024-04-15"
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
#warning "Warning! Don't use dummy thermistors (998/999) for final build!"
|
||||
#endif
|
||||
|
||||
#if NONE(HAS_RESUME_CONTINUE, HOST_PROMPT_SUPPORT)
|
||||
#if NONE(HAS_RESUME_CONTINUE, HOST_PROMPT_SUPPORT, UNIT_TEST)
|
||||
#warning "Your Configuration provides no method to acquire user feedback!"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1169,7 +1169,7 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
lcd_moveto(LCD_WIDTH - 9, 2);
|
||||
lcd_put_lchar('S');
|
||||
|
||||
|
||||
|
||||
#endif // LCD_INFO_SCREEN_STYLE
|
||||
|
||||
|
||||
@@ -377,7 +377,13 @@ void MarlinUI::draw_kill_screen() {
|
||||
void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
|
||||
#if HAS_DISPLAY_SLEEP
|
||||
void MarlinUI::sleep_display(const bool sleep/*=true*/) { sleep ? u8g.sleepOn() : u8g.sleepOff(); }
|
||||
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
|
||||
static bool asleep = false;
|
||||
if (asleep != sleep){
|
||||
sleep ? u8g.sleepOn() : u8g.sleepOff();
|
||||
asleep = sleep;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
|
||||
@@ -84,7 +84,7 @@ TFT_IO tftio;
|
||||
#define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1)
|
||||
#define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1)
|
||||
|
||||
// RGB565 color picker: https://embeddednotepad.com/page/rgb565-color-picker
|
||||
// RGB565 color picker: https://rgbcolorpicker.com/565
|
||||
// Hex code to color name: https://www.color-name.com/
|
||||
|
||||
#define COLOR_BLACK 0x0000 // #000000
|
||||
|
||||
@@ -1668,7 +1668,7 @@ void MarlinUI::host_notify(const char * const cstr) {
|
||||
card.abortFilePrintSoon();
|
||||
else if (card.isMounted())
|
||||
card.closefile();
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ACTION_ON_CANCEL
|
||||
hostui.cancel();
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define COLOR(color) RGB(((color >> 16) & 0xFF), ((color >> 8) & 0xFF), (color & 0xFF))
|
||||
#define HALF(color) RGB(RED(color) >> 1, GREEN(color) >> 1, BLUE(color) >> 1)
|
||||
|
||||
// RGB565 color picker: https://embeddednotepad.com/page/rgb565-color-picker
|
||||
// RGB565 color picker: https://rgbcolorpicker.com/565
|
||||
// Hex code to color name: https://www.color-name.com/
|
||||
|
||||
#define COLOR_BLACK 0x0000 // #000000
|
||||
|
||||
@@ -224,6 +224,8 @@
|
||||
#include "ramps/pins_RAMPS_CREALITY.h" // ATmega2560 env:mega2560
|
||||
#elif MB(DAGOMA_F5)
|
||||
#include "ramps/pins_DAGOMA_F5.h" // ATmega2560 env:mega2560
|
||||
#elif MB(DAGOMA_D6)
|
||||
#include "ramps/pins_DAGOMA_D6.h" // ATmega2560 env:mega2560ext
|
||||
#elif MB(FYSETC_F6_13)
|
||||
#include "ramps/pins_FYSETC_F6_13.h" // ATmega2560 env:FYSETC_F6
|
||||
#elif MB(FYSETC_F6_14)
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if HOTENDS > 2 || E_STEPPERS > 2
|
||||
#error "Dagoma3D D6 supports up to 2 hotends / E-steppers."
|
||||
#endif
|
||||
|
||||
#define BOARD_INFO_NAME "Dagoma3D D6"
|
||||
|
||||
//
|
||||
// Trinamic Stallguard pins
|
||||
//
|
||||
#define X_DIAG_PIN 43
|
||||
#define Y_DIAG_PIN 41
|
||||
#define Z_DIAG_PIN 47
|
||||
#define E0_DIAG_PIN 21
|
||||
#define E1_DIAG_PIN 20
|
||||
|
||||
//
|
||||
// Endstops
|
||||
//
|
||||
#define X_STOP_PIN 2
|
||||
#define Y_STOP_PIN 3
|
||||
#define Z_STOP_PIN 15
|
||||
|
||||
//
|
||||
// Filament Runout Sensor
|
||||
//
|
||||
#ifndef FIL_RUNOUT_PIN
|
||||
#define FIL_RUNOUT_PIN 39
|
||||
#endif
|
||||
#if EXTRUDERS > 1 && !defined(FIL_RUNOUT2_PIN)
|
||||
#define FIL_RUNOUT2_PIN 14
|
||||
#endif
|
||||
|
||||
// Alter timing for graphical display
|
||||
#if IS_U8GLIB_ST7920
|
||||
#ifndef BOARD_ST7920_DELAY_1
|
||||
#define BOARD_ST7920_DELAY_1 0
|
||||
#endif
|
||||
#ifndef BOARD_ST7920_DELAY_2
|
||||
#define BOARD_ST7920_DELAY_2 250
|
||||
#endif
|
||||
#ifndef BOARD_ST7920_DELAY_3
|
||||
#define BOARD_ST7920_DELAY_3 250
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define KILL_PIN -1 // NC
|
||||
|
||||
#define LCD_CONTRAST_DEFAULT 255
|
||||
|
||||
//
|
||||
// Sensorless homing DIAG pin is not directly connected to the MCU. Close
|
||||
// the jumper next to the limit switch socket when using sensorless homing.
|
||||
//
|
||||
#if HAS_TMC_UART
|
||||
/**
|
||||
* TMC2208/TMC2209 stepper drivers
|
||||
*/
|
||||
#define X_SERIAL_RX_PIN 73
|
||||
#define X_SERIAL_TX_PIN 73
|
||||
#define Y_SERIAL_RX_PIN 73
|
||||
#define Y_SERIAL_TX_PIN 73
|
||||
#define Z_SERIAL_RX_PIN 73
|
||||
#define Z_SERIAL_TX_PIN 73
|
||||
#define E0_SERIAL_RX_PIN 73
|
||||
#define E0_SERIAL_TX_PIN 73
|
||||
#define E1_SERIAL_RX_PIN 12
|
||||
#define E1_SERIAL_TX_PIN 12
|
||||
|
||||
// Default TMC slave addresses
|
||||
#ifndef X_SLAVE_ADDRESS
|
||||
#define X_SLAVE_ADDRESS 0
|
||||
#endif
|
||||
#ifndef Y_SLAVE_ADDRESS
|
||||
#define Y_SLAVE_ADDRESS 1
|
||||
#endif
|
||||
#ifndef Z_SLAVE_ADDRESS
|
||||
#define Z_SLAVE_ADDRESS 2
|
||||
#endif
|
||||
#ifndef E0_SLAVE_ADDRESS
|
||||
#define E0_SLAVE_ADDRESS 3
|
||||
#endif
|
||||
#ifndef E1_SLAVE_ADDRESS
|
||||
#define E1_SLAVE_ADDRESS 3
|
||||
#endif
|
||||
static_assert(X_SLAVE_ADDRESS == 0, "X_SLAVE_ADDRESS must be 0 for BOARD_DAGOMA_D6.");
|
||||
static_assert(Y_SLAVE_ADDRESS == 1, "Y_SLAVE_ADDRESS must be 1 for BOARD_DAGOMA_D6.");
|
||||
static_assert(Z_SLAVE_ADDRESS == 2, "Z_SLAVE_ADDRESS must be 2 for BOARD_DAGOMA_D6.");
|
||||
static_assert(E0_SLAVE_ADDRESS == 3, "E0_SLAVE_ADDRESS must be 3 for BOARD_DAGOMA_D6.");
|
||||
static_assert(E1_SLAVE_ADDRESS == 3, "E1_SLAVE_ADDRESS must be 3 for BOARD_DAGOMA_D6.");
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Import default RAMPS 1.4 pins
|
||||
//
|
||||
#include "pins_RAMPS.h"
|
||||
@@ -37,41 +37,6 @@
|
||||
// Startup tests are run at the end of setup()
|
||||
void runStartupTests() {
|
||||
// Call post-setup tests here to validate behaviors.
|
||||
|
||||
// String with cutoff at 20 chars:
|
||||
// "F-string, 1234.50, 2"
|
||||
SString<20> str20;
|
||||
str20 = F("F-string, ");
|
||||
str20.append(1234.5f).append(',').append(' ')
|
||||
.append(2345.67).append(',').append(' ')
|
||||
.echoln();
|
||||
|
||||
// Truncate to "F-string"
|
||||
str20.trunc(8).echoln();
|
||||
|
||||
// 100 dashes, but chopped down to DEFAULT_MSTRING_SIZE (20)
|
||||
TSS(repchr_t('-', 100)).echoln();
|
||||
|
||||
// Hello World!-123456------ <spaces!33
|
||||
// ^ eol! ... 1234.50*2345.602 = 2895645.67
|
||||
SString<100> str(F("Hello"));
|
||||
str.append(F(" World!"));
|
||||
str += '-';
|
||||
str += uint8_t(123);
|
||||
str += F("456");
|
||||
str += repchr_t('-', 6);
|
||||
str += Spaces(3);
|
||||
str += "< spaces!";
|
||||
str += int8_t(33);
|
||||
str.eol();
|
||||
str += "^ eol!";
|
||||
|
||||
str.append("...", 1234.5f, '*', p_float_t(2345.602, 3), F(" = "), 1234.5 * 2345.602).echoln();
|
||||
|
||||
// Print it again with SERIAL_ECHOLN
|
||||
auto print_char_ptr = [](char * const str) { SERIAL_ECHOLN(str); };
|
||||
print_char_ptr(str);
|
||||
|
||||
}
|
||||
|
||||
// Periodic tests are run from within loop()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
These test files are executed by the unit-tests built from the `<root>/test` folder.
|
||||
|
||||
These are placed outside of the main PlatformIO test folder so we can collect all test files and compile them into multiple PlatformIO test binaries. This enables tests to be executed against a variety of Marlin configurations.
|
||||
|
||||
To execute these tests, refer to the top-level Makefile.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../test/unit_tests.h"
|
||||
#include <src/gcode/gcode.h>
|
||||
#include <src/gcode/parser.h>
|
||||
|
||||
MARLIN_TEST(gcode, process_parsed_command) {
|
||||
GcodeSuite suite;
|
||||
parser.command_letter = 'G';
|
||||
parser.codenum = 0;
|
||||
suite.process_parsed_command(false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(gcode, parse_g1_xz) {
|
||||
char current_command[] = "G0 X10 Z30";
|
||||
parser.command_letter = -128;
|
||||
parser.codenum = -1;
|
||||
parser.parse(current_command);
|
||||
TEST_ASSERT_EQUAL('G', parser.command_letter);
|
||||
TEST_ASSERT_EQUAL(0, parser.codenum);
|
||||
TEST_ASSERT_TRUE(parser.seen('X'));
|
||||
TEST_ASSERT_FALSE(parser.seen('Y'));
|
||||
TEST_ASSERT_TRUE(parser.seen('Z'));
|
||||
TEST_ASSERT_FALSE(parser.seen('E'));
|
||||
}
|
||||
|
||||
MARLIN_TEST(gcode, parse_g1_nxz) {
|
||||
char current_command[] = "N123 G0 X10 Z30";
|
||||
parser.command_letter = -128;
|
||||
parser.codenum = -1;
|
||||
parser.parse(current_command);
|
||||
TEST_ASSERT_EQUAL('G', parser.command_letter);
|
||||
TEST_ASSERT_EQUAL(0, parser.codenum);
|
||||
TEST_ASSERT_TRUE(parser.seen('X'));
|
||||
TEST_ASSERT_FALSE(parser.seen('Y'));
|
||||
TEST_ASSERT_TRUE(parser.seen('Z'));
|
||||
TEST_ASSERT_FALSE(parser.seen('E'));
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../test/unit_tests.h"
|
||||
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||
|
||||
#include <src/feature/runout.h>
|
||||
|
||||
MARLIN_TEST(runout, poll_runout_states) {
|
||||
FilamentSensorBase sensor;
|
||||
// Expected default value is one bit set for each extruder
|
||||
uint8_t expected = static_cast<uint8_t>(~(~0u << NUM_RUNOUT_SENSORS));
|
||||
TEST_ASSERT_EQUAL(expected, sensor.poll_runout_states());
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../test/unit_tests.h"
|
||||
#include "src/core/types.h"
|
||||
|
||||
MARLIN_TEST(types, XYval_const_as_bools) {
|
||||
const XYval<int> xy_const_true = {1, 2};
|
||||
TEST_ASSERT_TRUE(xy_const_true);
|
||||
|
||||
const XYval<int> xy_const_false = {0, 0};
|
||||
TEST_ASSERT_FALSE(xy_const_false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, XYval_non_const_as_bools) {
|
||||
XYval<int> xy_true = {1, 2};
|
||||
TEST_ASSERT_TRUE(xy_true);
|
||||
|
||||
XYval<int> xy_false = {0, 0};
|
||||
TEST_ASSERT_FALSE(xy_false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, XYZval_const_as_bools) {
|
||||
const XYZval<int> xyz_const_true = {1, 2, 3};
|
||||
TEST_ASSERT_TRUE(xyz_const_true);
|
||||
|
||||
const XYZval<int> xyz_const_false = {0, 0, 0};
|
||||
TEST_ASSERT_FALSE(xyz_const_false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, XYZval_non_const_as_bools) {
|
||||
XYZval<int> xyz_true = {1, 2, 3};
|
||||
TEST_ASSERT_TRUE(xyz_true);
|
||||
|
||||
XYZval<int> xyz_false = {0, 0, 0};
|
||||
TEST_ASSERT_FALSE(xyz_false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, XYZEval_const_as_bools) {
|
||||
const XYZEval<int> xyze_const_true = {1, 2, 3, 4};
|
||||
TEST_ASSERT_TRUE(xyze_const_true);
|
||||
|
||||
const XYZEval<int> xyze_const_false = {0, 0, 0, 0};
|
||||
TEST_ASSERT_FALSE(xyze_const_false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, XYZEval_non_const_as_bools) {
|
||||
XYZEval<int> xyze_true = {1, 2, 3, 4};
|
||||
TEST_ASSERT_TRUE(xyze_true);
|
||||
|
||||
XYZEval<int> xyze_false = {0, 0, 0, 0};
|
||||
TEST_ASSERT_FALSE(xyze_false);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, Flags_const_as_bools) {
|
||||
const Flags<32> flags_const_false = {0};
|
||||
TEST_ASSERT_FALSE(flags_const_false);
|
||||
|
||||
const Flags<32> flags_const_true = {1};
|
||||
TEST_ASSERT_TRUE(flags_const_true);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, Flags_non_const_as_bools) {
|
||||
Flags<32> flags_false = {0};
|
||||
TEST_ASSERT_FALSE(flags_false);
|
||||
|
||||
Flags<32> flags_true = {1};
|
||||
TEST_ASSERT_TRUE(flags_true);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, AxisFlags_const_as_bools) {
|
||||
const AxisFlags axis_flags_const_false = {0};
|
||||
TEST_ASSERT_FALSE(axis_flags_const_false);
|
||||
|
||||
const AxisFlags axis_flags_const_true = {1};
|
||||
TEST_ASSERT_TRUE(axis_flags_const_true);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, AxisFlags_non_const_as_bools) {
|
||||
AxisFlags axis_flags_false = {0};
|
||||
TEST_ASSERT_FALSE(axis_flags_false);
|
||||
|
||||
AxisFlags axis_flags_true = {1};
|
||||
TEST_ASSERT_TRUE(axis_flags_true);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, AxisBits_const_as_bools) {
|
||||
const AxisBits axis_bits_const_false = {0};
|
||||
TEST_ASSERT_FALSE(axis_bits_const_false);
|
||||
|
||||
const AxisBits axis_bits_const_true = {1};
|
||||
TEST_ASSERT_TRUE(axis_bits_const_true);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, AxisBits_non_const_as_bools) {
|
||||
AxisBits axis_bits_false = {0};
|
||||
TEST_ASSERT_FALSE(axis_bits_false);
|
||||
|
||||
AxisBits axis_bits_true = {1};
|
||||
TEST_ASSERT_TRUE(axis_bits_true);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, MString1) {
|
||||
// String with cutoff at 20 chars:
|
||||
// "F-string, 1234.50, 2"
|
||||
MString<20> str20;
|
||||
str20 = F("F-string, ");
|
||||
str20.append(1234.5f).append(',').append(' ')
|
||||
.append(2345.67).append(',').append(' ');
|
||||
|
||||
TEST_ASSERT_TRUE(strcmp_P(str20, PSTR("F-string, 1234.50, 2")) == 0);
|
||||
|
||||
// Truncate to "F-string"
|
||||
str20.trunc(8);
|
||||
|
||||
TEST_ASSERT_FALSE(strcmp_P(&str20, PSTR("F-string")) != 0);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, MString2) {
|
||||
// 100 dashes, but chopped down to DEFAULT_MSTRING_SIZE (20)
|
||||
TEST_ASSERT_TRUE(TSS(repchr_t('-', 100)).length() == 20);
|
||||
}
|
||||
|
||||
MARLIN_TEST(types, SString) {
|
||||
// Hello World!-123456------ < spaces!33
|
||||
// ^ eol! ... 1234.50*2345.602 = 2895645.67
|
||||
SString<100> str(F("Hello"));
|
||||
str.append(F(" World!"));
|
||||
str += '-';
|
||||
str += uint8_t(123);
|
||||
str += F("456");
|
||||
str += repchr_t('-', 6);
|
||||
str += Spaces(3);
|
||||
str += "< spaces!";
|
||||
str += int8_t(33);
|
||||
str.eol();
|
||||
str += "^ eol!";
|
||||
str.append(" ... ", 1234.5f, '*', p_float_t(2345.602, 3), F(" = "), 1234.5 * 2345.602);
|
||||
|
||||
TEST_ASSERT_TRUE(strcmp_P(str, PSTR("Hello World!-123456------ < spaces!33\n^ eol! ... 1234.50*2345.602 = 2895645.67")) == 0);
|
||||
}
|
||||
@@ -7,5 +7,5 @@ if [[ $1 == '-d' || $1 == '--default' ]]; then
|
||||
else
|
||||
git checkout Marlin/Configuration.h 2>/dev/null
|
||||
git checkout Marlin/Configuration_adv.h 2>/dev/null
|
||||
git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
|
||||
git checkout Marlin/src/pins/*/pins_*.h 2>/dev/null
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# collect-code-tests.py
|
||||
# Convenience script to collect all code tests. Used by env:linux_native_test in native.ini.
|
||||
#
|
||||
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
import os, re
|
||||
Import("env")
|
||||
Import("projenv")
|
||||
|
||||
os.environ['PATH'] = f"./buildroot/bin/:./buildroot/tests/:{os.environ['PATH']}"
|
||||
|
||||
def collect_test_suites():
|
||||
"""Get all the test suites"""
|
||||
from pathlib import Path
|
||||
return sorted(list(Path("./test").glob("*.ini")))
|
||||
|
||||
def register_test_suites():
|
||||
"""Register all the test suites"""
|
||||
targets = []
|
||||
test_suites = collect_test_suites()
|
||||
for path in test_suites:
|
||||
name = re.sub(r'^\d+-|\.ini$', '', path.name)
|
||||
targets += [name];
|
||||
|
||||
env.AddCustomTarget(
|
||||
name = f"marlin_{name}",
|
||||
dependencies = None,
|
||||
actions = [
|
||||
f"echo ====== Configuring for marlin_{name} ======",
|
||||
"restore_configs",
|
||||
f"cp -f {path} ./Marlin/config.ini",
|
||||
"python ./buildroot/share/PlatformIO/scripts/configuration.py",
|
||||
f"platformio test -e linux_native_test -f {name}",
|
||||
"restore_configs",
|
||||
],
|
||||
title = "Marlin: {}".format(name.lower().title().replace("_", " ")),
|
||||
description = (
|
||||
f"Run a Marlin test suite, with the appropriate configuration, "
|
||||
f"that sits in {path}"
|
||||
)
|
||||
)
|
||||
|
||||
env.AddCustomTarget(
|
||||
name = "test-marlin",
|
||||
dependencies = None,
|
||||
actions = [
|
||||
f"platformio run -t marlin_{name} -e linux_native_test"
|
||||
for name in targets
|
||||
],
|
||||
title = "Marlin: Test all code test suites",
|
||||
description = (
|
||||
f"Run all Marlin code test suites ({len(targets)} found)."
|
||||
),
|
||||
)
|
||||
|
||||
register_test_suites()
|
||||
+1
-1
@@ -315,7 +315,6 @@ HAS_ZV_SHAPING = build_src_filter=+<src/gcode/feature/in
|
||||
GCODE_MACROS = build_src_filter=+<src/gcode/feature/macro>
|
||||
GRADIENT_MIX = build_src_filter=+<src/gcode/feature/mixing/M166.cpp>
|
||||
NONLINEAR_EXTRUSION = build_src_filter=+<src/gcode/feature/nonlinear>
|
||||
OTA_FIRMWARE_UPDATE = build_src_filter=+<src/gcode/feature/ota>
|
||||
HAS_SAVED_POSITIONS = build_src_filter=+<src/gcode/feature/pause/G60.cpp> +<src/gcode/feature/pause/G61.cpp>
|
||||
PARK_HEAD_ON_PAUSE = build_src_filter=+<src/gcode/feature/pause/M125.cpp>
|
||||
FILAMENT_LOAD_UNLOAD_GCODES = build_src_filter=+<src/gcode/feature/pause/M701_M702.cpp>
|
||||
@@ -341,6 +340,7 @@ TOUCH_SCREEN_CALIBRATION = build_src_filter=+<src/gcode/lcd/M995.c
|
||||
ARC_SUPPORT = build_src_filter=+<src/gcode/motion/G2_G3.cpp>
|
||||
GCODE_MOTION_MODES = build_src_filter=+<src/gcode/motion/G80.cpp>
|
||||
BABYSTEPPING = build_src_filter=+<src/gcode/motion/M290.cpp> +<src/feature/babystep.cpp>
|
||||
OTA_FIRMWARE_UPDATE = build_src_filter=+<src/gcode/ota/M936.cpp>
|
||||
Z_PROBE_SLED = build_src_filter=+<src/gcode/probe/G31_G32.cpp>
|
||||
G38_PROBE_TARGET = build_src_filter=+<src/gcode/probe/G38.cpp>
|
||||
MAGNETIC_PARKING_EXTRUDER = build_src_filter=+<src/gcode/probe/M951.cpp>
|
||||
|
||||
+12
-15
@@ -33,22 +33,14 @@ build_src_filter = ${common.default_src_filter} +<src/HAL/HC32> +<src/HAL/shared
|
||||
build_type = release
|
||||
build_flags =
|
||||
-D ARDUINO_ARCH_HC32
|
||||
-D REDIRECT_PRINTF_TO_SERIAL # Redirect core-provided printf to host serial
|
||||
-D F_CPU=SYSTEM_CLOCK_FREQUENCIES.pclk1 # Override F_CPU to PCLK1, as marlin freaks out otherwise...
|
||||
-D PLATFORM_M997_SUPPORT # Enable M997 command
|
||||
-D PLATFORM_M997_SUPPORT # Enable M997 command
|
||||
# note: ddl and arduino debug mode are
|
||||
# automatically enabled with MARLIN_DEV_MODE
|
||||
#-D __DEBUG # force DDL debug mode
|
||||
#-D __CORE_DEBUG # force Arduino core debug mode
|
||||
|
||||
# DDL / Arduino Configuration
|
||||
-D DISABLE_SERIAL_GLOBALS # Disable global Serial objects, we use our own
|
||||
-D CORE_DISABLE_FAULT_HANDLER # Disable arduino core fault handler (we use our own)
|
||||
|
||||
# DDL / Arduino Debug Options
|
||||
#-D __DEBUG # DDL debug mode
|
||||
#-D __CORE_DEBUG # Arduino core debug mode
|
||||
-D PANIC_ENABLE # enable custom panic handlers (in MinSerial)
|
||||
# options to reduce debug mode footprint (-16K; messages are less verbose)
|
||||
-D __DEBUG_SHORT_FILENAMES # Use short filenames in DDL debug output
|
||||
-D __PANIC_SHORT_FILENAMES # Use short filenames in core panic output
|
||||
-D __OMIT_PANIC_MESSAGE # Omit panic messages in core panic output
|
||||
# hc32 app configuration file
|
||||
board_build.app_config = Marlin/src/HAL/HC32/app_config.h
|
||||
|
||||
# Drivers and Middleware required by the HC32 HAL
|
||||
board_build.ddl.ots = true
|
||||
@@ -58,6 +50,11 @@ board_build.ddl.timer0 = true
|
||||
board_build.ddl.timera = true
|
||||
board_build.mw.sd_card = true
|
||||
|
||||
# extra build flags
|
||||
board_build.flags.common =
|
||||
-g3 # Force emit debug symbols to elf. this does not affect the final binary size
|
||||
-fno-signed-char # Force unsigned chars. this is required for meatpack to work
|
||||
|
||||
# Additional flags to reduce binary size
|
||||
board_build.flags.cpp =
|
||||
-fno-threadsafe-statics # Disable thread-safe statics (only one core anyway)
|
||||
|
||||
+16
-3
@@ -15,13 +15,26 @@
|
||||
[env:linux_native]
|
||||
platform = native
|
||||
framework =
|
||||
build_flags = -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined
|
||||
build_flags = ${common.build_flags} -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined
|
||||
build_src_flags = -Wall -IMarlin/src/HAL/LINUX/include
|
||||
build_unflags = -Wall
|
||||
lib_ldf_mode = off
|
||||
lib_deps =
|
||||
build_src_filter = ${common.default_src_filter} +<src/HAL/LINUX>
|
||||
|
||||
# Environment specifically for unit testing through the Makefile
|
||||
# This is somewhat unorthodox, in that it uses the PlatformIO Unity testing framework,
|
||||
# but actual targets are dynamically generated during the build. This seems to prevent
|
||||
# Unity from being automatically included, so it is added here.
|
||||
[env:linux_native_test]
|
||||
extends = env:linux_native
|
||||
extra_scripts = ${common.extra_scripts}
|
||||
post:buildroot/share/PlatformIO/scripts/collect-code-tests.py
|
||||
build_src_filter = ${env:linux_native.build_src_filter} +<tests>
|
||||
lib_deps = throwtheswitch/Unity@^2.5.2
|
||||
test_build_src = true
|
||||
build_unflags =
|
||||
build_flags = ${env:linux_native.build_flags} -Werror
|
||||
|
||||
#
|
||||
# Native Simulation
|
||||
# Builds with a small subset of available features
|
||||
@@ -44,7 +57,7 @@ debug_build_flags = -fstack-protector-strong -g -g3 -ggdb
|
||||
lib_compat_mode = off
|
||||
build_src_filter = ${common.default_src_filter} +<src/HAL/NATIVE_SIM>
|
||||
lib_deps = ${common.lib_deps}
|
||||
MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/8791f3ff43.zip
|
||||
MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/66a2b82c8f.zip
|
||||
Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/c6b319f447.zip
|
||||
LiquidCrystal=https://github.com/p3p/LiquidCrystal/archive/322fb5fc23.zip
|
||||
extra_scripts = ${common.extra_scripts}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# This file should remain empty except for the motherboard.
|
||||
# If changes are needed by tests, it should be performed in another configuration.
|
||||
|
||||
[config:base]
|
||||
ini_use_config = base
|
||||
|
||||
# Unit tests must use BOARD_SIMULATED to run natively in Linux
|
||||
motherboard = BOARD_SIMULATED
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Test configuration with a single extruder and a filament runout sensor
|
||||
#
|
||||
[config:base]
|
||||
ini_use_config = base
|
||||
|
||||
# Unit tests must use BOARD_SIMULATED to run natively in Linux
|
||||
motherboard = BOARD_SIMULATED
|
||||
|
||||
# Options to support runout sensors test
|
||||
filament_runout_sensor = on
|
||||
fil_runout_pin = 4 # dummy
|
||||
advanced_pause_feature = on
|
||||
emergency_parser = on
|
||||
nozzle_park_feature = on
|
||||
|
||||
# Option to support testing parsing with parentheses comments enabled
|
||||
paren_comments = on
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Test configuration with three extruders and filament runout sensors
|
||||
#
|
||||
[config:base]
|
||||
ini_use_config = base
|
||||
|
||||
# Unit tests must use BOARD_SIMULATED to run natively in Linux
|
||||
motherboard = BOARD_SIMULATED
|
||||
|
||||
# Options to support runout sensor tests on three extruders.
|
||||
# Options marked "dummy" are simply required to pass sanity checks.
|
||||
extruders = 3
|
||||
temp_sensor_1 = 1
|
||||
temp_sensor_2 = 1
|
||||
temp_2_pin = 4 # dummy
|
||||
temp_3_pin = 4 # dummy
|
||||
heater_2_pin = 4 # dummy
|
||||
e2_step_pin = 4 # dummy
|
||||
e2_dir_pin = 4 # dummy
|
||||
e2_enable_pin = 4 # dummy
|
||||
e3_step_pin = 4 # dummy
|
||||
e3_dir_pin = 4 # dummy
|
||||
e3_enable_pin = 4 # dummy
|
||||
num_runout_sensors = 3
|
||||
filament_runout_sensor = on
|
||||
fil_runout_pin = 4 # dummy
|
||||
fil_runout2_pin = 4 # dummy
|
||||
fil_runout3_pin = 4 # dummy
|
||||
filament_runout_script = "M600 %%c"
|
||||
advanced_pause_feature = on
|
||||
emergency_parser = on
|
||||
nozzle_park_feature = on
|
||||
@@ -0,0 +1,40 @@
|
||||
# Testing Marlin
|
||||
|
||||
Marlin included two types of automated tests:
|
||||
- [Build Tests](../buildroot/tests) to catch syntax and code build errors.
|
||||
- Unit Tests (this folder) to catch implementation errors.
|
||||
|
||||
This document focuses on Unit tests.
|
||||
|
||||
## Unit tests
|
||||
|
||||
Unit testing allows for functional testing of Marlin logic on a local machine. This strategy is available to all developers, and will be able to be used on generic GitHub workers to automate testing. While PlatformIO does support the execution of unit tests on target controllers, that is not yet implemented and not really practical. This would require dedicated testing labs, and would be less broadly usable than testing directly on the development or build machine.
|
||||
|
||||
Unit tests verify the behavior of small discrete sections of Marlin code. By thoroughly unit testing important parts of Marlin code, we effectively provide "guard rails" which will prevent major regressions in behavior. As long as all submissions go through the Pull Request process and execute automated checks, it is possible to catch most major issues prior to completion of a PR.
|
||||
|
||||
## What unit tests can and can't do
|
||||
|
||||
Unit tests can be used to validate the logic of single functions or whole features, as long as that function or feature doesn't depend on real hardware. So, for example, we can test whether a G-code command is parsed correctly and produces all the expected state changes, but we can't test whether a G-code triggered an endstop or the filament runout sensor without adding a new layer to simulate pins.
|
||||
|
||||
Generally speaking, the types of errors caught by unit tests are most often caught in the initial process of writing the tests, and thereafter they shore up the codebase against regressions, especially in core classes and types, which can be very useful for refactoring.
|
||||
|
||||
### Unit test FAQ
|
||||
|
||||
#### Q: Isn't writing unit tests a lot of work?
|
||||
A: Yes, and it can be especially difficult with existing code that wasn't designed for unit testing. Some common sense should be used to decide where to employ unit testing, and at what level to perform it. While unit testing takes effort, it pays dividends in preventing regressions, and helping to pinpoint the source of failures when they do occur.
|
||||
|
||||
#### Q: Will this make refactoring harder?
|
||||
A: Yes and No. Of course if you refactor code that unit tests use directly, it will have to be reworked as well. It actually can make refactoring more efficient, by providing assurance that the mechanism still works as intended.
|
||||
|
||||
#### Q: How can I debug one of these failing unit tests?
|
||||
A: That's a great question, without a known immediate answer. It is likely possible to debug them interactively through PlatformIO, but that can at times take some creativity to configure. Unit tests are generally extremely small, so even without interactive debugging it can get you fairly close to the cause of the problem.
|
||||
|
||||
### Unit test architecture
|
||||
We are currently using [PlatformIO unit tests](https://docs.platformio.org/en/latest/plus/unit-testing.html).
|
||||
|
||||
Since Marlin only compiles code required by the configuration, a separate test binary must be generated for any configuration change. The following process is used to unit test a variety of configurations:
|
||||
|
||||
1. This folder contains a set of INI configuration files (See `config.ini`), each containing a distinct set of configuration options for unit testing. All applicable unit tests will be run for each of these configurations.
|
||||
2. The `Marlin/tests` folder contains the CPP code for all Unit Tests. Marlin macros (`ENABLED(feature)`, `TERN(FEATURE, A, B)`, etc.) are used to determine which tests should be registered and to alter test behavior.
|
||||
3. The `linux_native_test` PlatformIO environment specifies a script to collect all the tests from this folder and add them to PlatformIO's list of test targets.
|
||||
4. Tests are built and executed by the `Makefile` commands `unit-test-all-local` or `unit-test-all-local-docker`.
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provide the main() function used for all compiled unit test binaries.
|
||||
* It collects all the tests defined in the code and runs them through Unity.
|
||||
*/
|
||||
|
||||
#include "unit_tests.h"
|
||||
|
||||
static std::list<MarlinTest*> all_marlin_tests;
|
||||
|
||||
MarlinTest::MarlinTest(const std::string _name, const void(*_test)(), const char *_file, const int _line)
|
||||
: name(_name), test(_test), file(_file), line(_line) {
|
||||
all_marlin_tests.push_back(this);
|
||||
}
|
||||
|
||||
void MarlinTest::run() {
|
||||
Unity.TestFile = file.c_str();
|
||||
UnityDefaultTestRun((UnityTestFunction)test, name.c_str(), line);
|
||||
}
|
||||
|
||||
void run_all_marlin_tests() {
|
||||
for (const auto registration : all_marlin_tests) {
|
||||
registration->run();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
UNITY_BEGIN();
|
||||
run_all_marlin_tests();
|
||||
UNITY_END();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <unity.h>
|
||||
|
||||
// Include MarlinConfig so configurations are available to all tests
|
||||
#include "src/inc/MarlinConfig.h"
|
||||
|
||||
/**
|
||||
* Class that allows us to dynamically collect tests
|
||||
*/
|
||||
class MarlinTest {
|
||||
public:
|
||||
MarlinTest(const std::string name, const void(*test)(), const char *_file, const int line);
|
||||
/**
|
||||
* Run the test via Unity
|
||||
*/
|
||||
void run();
|
||||
|
||||
/**
|
||||
* The name, a pointer to the function, and the line number. These are
|
||||
* passed to the Unity test framework.
|
||||
*/
|
||||
const std::string name;
|
||||
const void(*test)();
|
||||
const std::string file;
|
||||
const int line;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal macros used by MARLIN_TEST
|
||||
*/
|
||||
#define _MARLIN_TEST_CLASS_NAME(SUITE, NAME) MarlinTestClass_##SUITE##_##NAME
|
||||
#define _MARLIN_TEST_INSTANCE_NAME(SUITE, NAME) MarlinTestClass_##SUITE##_##NAME##_instance
|
||||
|
||||
/**
|
||||
* Macro to define a test. This will create a class with the test body and
|
||||
* register it with the global list of tests.
|
||||
*
|
||||
* Usage:
|
||||
* MARLIN_TEST(test_suite_name, test_name) {
|
||||
* // Test body
|
||||
* }
|
||||
*/
|
||||
#define MARLIN_TEST(SUITE, NAME) \
|
||||
class _MARLIN_TEST_CLASS_NAME(SUITE, NAME) : public MarlinTest { \
|
||||
public: \
|
||||
_MARLIN_TEST_CLASS_NAME(SUITE, NAME)() : MarlinTest(#SUITE "___" #NAME, (const void(*)())&TestBody, __FILE__, __LINE__) {} \
|
||||
static void TestBody(); \
|
||||
}; \
|
||||
const _MARLIN_TEST_CLASS_NAME(SUITE, NAME) _MARLIN_TEST_INSTANCE_NAME(SUITE, NAME); \
|
||||
void _MARLIN_TEST_CLASS_NAME(SUITE, NAME)::TestBody()
|
||||
Reference in New Issue
Block a user