Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 02ba6f9
Author: thinkyhead <[email protected]>
Date:   Fri Apr 19 00:21:25 2024 +0000

    [cron] Bump distribution date (2024-04-19)

commit dba0010
Author: Andrew <[email protected]>
Date:   Thu Apr 18 19:04:03 2024 -0400

    🎨 Rename some G-code files (MarlinFirmware#26981)

commit 90667f6
Author: I3DBeeTech <[email protected]>
Date:   Fri Apr 19 02:24:17 2024 +0530

    🐛 Fix BLACKBEEZMINI fan, info (MarlinFirmware#26983)

commit d6961b2
Author: thinkyhead <[email protected]>
Date:   Wed Apr 17 06:06:51 2024 +0000

    [cron] Bump distribution date (2024-04-17)

commit 07ebb81
Author: Javlon Sodikov <[email protected]>
Date:   Wed Apr 17 10:25:22 2024 +0500

    🩹Fix ProUI error when !CASELIGHT_USES_BRIGHTNESS (MarlinFirmware#26976)

    * Fix the compile error with the case light menu

    Fix the compile error with the case light menu

    * Add failing test

    ---------

    Co-authored-by: Jason Smith <[email protected]>

commit 245db73
Author: thinkyhead <[email protected]>
Date:   Tue Apr 16 18:06:16 2024 +0000

    [cron] Bump distribution date (2024-04-16)

commit 9342dae
Author: Scott Lahteine <[email protected]>
Date:   Tue Apr 16 12:17:47 2024 -0500

    📝 Remove dead PDF links

commit 1f84f50
Author: thinkyhead <[email protected]>
Date:   Mon Apr 15 02:38:10 2024 +0000

    [cron] Bump distribution date (2024-04-15)

commit 3326c74
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 14 16:26:16 2024 -0500

    📝 Minor README changes

commit 0269106
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 14 16:24:14 2024 -0500

    🎨 Dagoma D6 followup

commit 95d38a8
Author: Sophist <[email protected]>
Date:   Sun Apr 14 21:04:52 2024 +0100

    ✨ Add Dagoma D6 as found in DiscoUltimate v2 TMC (MarlinFirmware#26874)

    * Add Dagoma D6 board as used in their DiscoUltimate v2 TMC.

    Taken from the Dagoma fork of Marlin DU_MC branch where it is called FYSETC_DAGOMA_F5 and explicitly confirmed by Dagoma as being the D6:

    "the BOARD_FYSETC_DAGOMA_F5 is effectively the definition for the D6"

    ---------

    Co-authored-by: thisiskeithb <[email protected]>
    Co-authored-by: Orel <[email protected]>

commit dca6afc
Author: Chris <[email protected]>
Date:   Sun Apr 14 20:42:57 2024 +0200

    ✨🐛 HC32 - Add SERIAL_DMA, fix SDIO and MEATPACK (MarlinFirmware#26845)

    * fix meatpack on hc32

    * add support for SERIAL_DMA on HC32

    * add additional checks in HC32 HAL

    * migrate HC32 HAL to use app_config.h

    * fix memory leak in HC32 sdio HAL
    MarlinFirmware#26845 (comment)

    * hc32: fail if both EMERGENCY_PARSER and SERIAL_DMA are enabled

commit 19684f2
Author: Jason Smith <[email protected]>
Date:   Sat Apr 13 17:49:08 2024 -0700

    ✅ Add unit tests for macros.h (MarlinFirmware#26968)

commit 52a5613
Author: Keith Bennett <[email protected]>
Date:   Sat Apr 13 17:47:16 2024 -0700

    ⏪️ Revert unintended README changes (MarlinFirmware#26967)

    * Revert all the changes that went in with the unit test framework
    This restored broken links and other changes. Restoring to the prior revision seems the most appropriate action until the intentions of those file changes are known.
    ---------

    Co-authored-by: Jason Smith <[email protected]>

commit 0683e8a
Author: thinkyhead <[email protected]>
Date:   Sun Apr 14 00:24:15 2024 +0000

    [cron] Bump distribution date (2024-04-14)

commit 1bb4a04
Author: Jason Smith <[email protected]>
Date:   Sat Apr 13 14:11:51 2024 -0700

    ✅Unit test improvements (MarlinFirmware#26965)

    * Do not warn about display in unit tests

    * Treat warnings as errors in unit tests

    * Report actual filenames with unit tests

commit d10861e
Author: Jason Smith <[email protected]>
Date:   Sat Apr 13 12:06:08 2024 -0700

    ✅ Add unit testing framework (MarlinFirmware#26948)

    - Add a framework to build and execute unit tests for Marlin.
    - Enable unit test execution as part of PR checks.

    ---------

    Co-authored-by: Costas Basdekis <[email protected]>
    Co-authored-by: Scott Lahteine <[email protected]>

commit cf7c86d
Author: Andrew <[email protected]>
Date:   Sat Apr 13 14:59:59 2024 -0400

    🔧Fix M936 in features.ini (MarlinFirmware#26957)

commit d99e150
Author: David Buezas <[email protected]>
Date:   Sat Apr 13 18:54:25 2024 +0200

    ⚡️Reduce DISPLAY_SLEEP_MINUTES overhead (MarlinFirmware#26964)
  • Loading branch information
blu28 committed Apr 20, 2024
1 parent 43ecf11 commit 566e4d1
Show file tree
Hide file tree
Showing 125 changed files with 2,410 additions and 389 deletions.
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -27,7 +27,7 @@ on:

jobs:
test_builds:
name: Run All Tests
name: Build Test
if: github.repository == 'MarlinFirmware/Marlin'

runs-on: ubuntu-latest
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/ci-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 30 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}" \
Expand All @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2024-04-13"
//#define STRING_DISTRIBUTION_DATE "2024-04-19"

/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
Expand Down
31 changes: 30 additions & 1 deletion Marlin/src/HAL/HC32/MarlinHAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand All @@ -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
Expand Down
26 changes: 23 additions & 3 deletions Marlin/src/HAL/HC32/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 38 additions & 8 deletions Marlin/src/HAL/HC32/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
70 changes: 70 additions & 0 deletions Marlin/src/HAL/HC32/app_config.h
Original file line number Diff line number Diff line change
@@ -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_
Loading

0 comments on commit 566e4d1

Please sign in to comment.