From 2ed55904dbee765e7508cc5d860280b4267d80a8 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:08:05 -0300 Subject: [PATCH 01/22] fix dma stream/channel for F4 --- Marlin/src/HAL/STM32/MarlinSPI.cpp | 12 ++++++++---- Marlin/src/HAL/STM32/tft/tft_spi.cpp | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Marlin/src/HAL/STM32/MarlinSPI.cpp b/Marlin/src/HAL/STM32/MarlinSPI.cpp index 399430f5eb94..5086b4178461 100644 --- a/Marlin/src/HAL/STM32/MarlinSPI.cpp +++ b/Marlin/src/HAL/STM32/MarlinSPI.cpp @@ -60,7 +60,6 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH _dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; } #ifdef STM32F4xx - _dmaHandle.Init.Channel = DMA_CHANNEL_3; _dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; #endif @@ -73,7 +72,8 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Channel3 : DMA1_Channel2; #elif defined(STM32F4xx) __HAL_RCC_DMA2_CLK_ENABLE(); - _dmaHandle.Instance = DMA2_Stream3; + _dmaHandle.Init.Channel = DMA_CHANNEL_3; + _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA2_Stream3 : DMA2_Stream0; #endif } #endif @@ -83,7 +83,9 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH __HAL_RCC_DMA1_CLK_ENABLE(); _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Channel5 : DMA1_Channel4; #elif defined(STM32F4xx) - //TODO: f4 dma config + __HAL_RCC_DMA1_CLK_ENABLE(); + _dmaHandle.Init.Channel = DMA_CHANNEL_0; + _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Stream4 : DMA1_Stream3; #endif } #endif @@ -93,7 +95,9 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH __HAL_RCC_DMA2_CLK_ENABLE(); _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA2_Channel2 : DMA2_Channel1; #elif defined(STM32F4xx) - //TODO: f4 dma config + __HAL_RCC_DMA1_CLK_ENABLE(); + _dmaHandle.Init.Channel = DMA_CHANNEL_0; + _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Stream5 : DMA1_Stream2; #endif } #endif diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 1c61d09529af..33895d891039 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -88,7 +88,7 @@ void TFT_SPI::Init() { #elif defined(STM32F4xx) __HAL_RCC_DMA1_CLK_ENABLE(); DMAtx.Instance = DMA1_Stream4; - DMAtx.Init.Channel = DMA_CHANNEL_4; + DMAtx.Init.Channel = DMA_CHANNEL_0; #endif } #endif @@ -101,7 +101,7 @@ void TFT_SPI::Init() { #elif defined(STM32F4xx) __HAL_RCC_DMA1_CLK_ENABLE(); DMAtx.Instance = DMA1_Stream5; - DMAtx.Init.Channel = DMA_CHANNEL_5; + DMAtx.Init.Channel = DMA_CHANNEL_0; #endif } #endif From 3b2c998baf0561394314497e850a6a8fd7ae96b1 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:10:34 -0300 Subject: [PATCH 02/22] stm32duino have a bug that we can use timer 13 until a new release --- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index c48cbc9e5650..1303d2775424 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -32,7 +32,7 @@ #define BOARD_INFO_NAME "MKS Robin Nano V3" // Avoid conflict with TIMER_TONE -#define STEP_TIMER 13 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 40da409185e4..debf87a3890c 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -30,7 +30,7 @@ #define BOARD_INFO_NAME "MKS Robin PRO V2" // Avoid conflict with TIMER_TONE -#define STEP_TIMER 13 +#define STEP_TIMER 10 // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation From c86e162ce31891d23a4462e4cd6ffb4ed6cf2d4c Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:11:19 -0300 Subject: [PATCH 03/22] enable uis on board --- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index 1303d2775424..2836b564ddc3 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -255,7 +255,7 @@ * EXP1 EXP2 */ -#if EITHER(TFT_480x320_SPI, TFT_LVGL_UI_SPI) +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) #ifndef TOUCH_CALIBRATION_X #define TOUCH_CALIBRATION_X -17253 #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index debf87a3890c..7bb65954385a 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -243,7 +243,7 @@ // // LCD / Controller #define SPI_FLASH -// #define HAS_SPI_FLASH 1 +#define HAS_SPI_FLASH 1 #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #if ENABLED(SPI_FLASH) @@ -264,7 +264,7 @@ * EXP1 EXP2 */ -#if EITHER(TFT_480x320_SPI, TFT_LVGL_UI_SPI) +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) #ifndef TOUCH_CALIBRATION_X #define TOUCH_CALIBRATION_X -17253 #endif From 106e560209dca8e396ac4cd8926d18f4adde9033 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:12:23 -0300 Subject: [PATCH 04/22] fix conditionals --- Marlin/src/inc/Conditionals_LCD.h | 7 ++----- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/marlinui.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7c581bef9087..38c4932ee5e3 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1185,11 +1185,8 @@ #endif // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' -#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT - #undef TOUCH_SCREEN - #if !HAS_TFT_LVGL_UI - #define HAS_TOUCH_BUTTONS 1 - #endif +#if ENABLED(TOUCH_SCREEN) && ENABLED(TFT_CLASSIC_UI) + #define HAS_TOUCH_BUTTONS 1 #endif // XPT2046_** Compatibility diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b56177462f35..1aebe7b4f12f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3244,7 +3244,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) /** * Touch Buttons */ -#if ENABLED(TOUCH_SCREEN) +#if ENABLED(TOUCH_SCREEN) && DISABLED(TOUCH_SCREEN_CALIBRATION) #ifndef TOUCH_CALIBRATION_X #error "TOUCH_CALIBRATION_X must be defined with TOUCH_SCREEN." #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 8e968abda0af..f3cb77778113 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -658,7 +658,7 @@ class MarlinUI { #endif static void update_buttons(); - static inline bool button_pressed() { return BUTTON_CLICK() || TERN(TOUCH_SCREEN, touch_pressed(), false); } + static inline bool button_pressed() { return BUTTON_CLICK() || TERN(TFT_COLOR_UI, touch_pressed(), false); } #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static void wait_for_release(); #endif From df375e494f38eae936080a5465f21bc53ba57a8d Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:13:31 -0300 Subject: [PATCH 05/22] update env to use our generic variant --- platformio.ini | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index bf44808b3265..7f84c5e3f077 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1385,19 +1385,18 @@ extra_scripts = ${common.extra_scripts} [env:mks_robin_pro2] platform = ${common_stm32.platform} extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DHAL_HCD_MODULE_ENABLED -DUSBHOST -DARDUINO_BLACK_F407VE +build_flags = ${common_stm32.build_flags} -DHAL_HCD_MODULE_ENABLED -DUSBHOST board = genericSTM32F407VET6 board_build.core = stm32 -board_build.variant = MARLIN_F407VE +board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld -board_build.firmware = Robin_nano35.bin +board_build.firmware = firmware.bin build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC debug_tool = jlink upload_protocol = jlink extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py # # MKS Robin Nano V3 From 0a139583d3df07636e93c4a756df8e93e55be6c4 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:14:35 -0300 Subject: [PATCH 06/22] we should not use setSSEL from stm32duino SPIClass, as it only accept hardware SS and will hang with a non hardware SS --- Marlin/src/HAL/STM32/HAL_SPI.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index f947e6ef3272..d79f72cad2b7 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -157,7 +157,6 @@ static SPISettings spiConfig; SPI.setMISO(MISO_PIN); SPI.setMOSI(MOSI_PIN); SPI.setSCLK(SCK_PIN); - SPI.setSSEL(SS_PIN); #endif SPI.begin(); From 7b2a4d15f5afc912a9f3650edd8298fa67a56c45 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:17:17 -0300 Subject: [PATCH 07/22] use dma sync for spi, to avoid conflits with other hardware resources --- Marlin/src/HAL/STM32/tft/tft_spi.cpp | 6 ++++++ Marlin/src/HAL/STM32/tft/tft_spi.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 33895d891039..3cb797d5f2a9 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -183,6 +183,9 @@ bool TFT_SPI::isBusy() { } void TFT_SPI::Abort() { + // Wait for any running spi + while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {} + while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {} // First, abort any running dma HAL_DMA_Abort(&DMAtx); // DeInit objects @@ -223,6 +226,9 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun __HAL_SPI_ENABLE(&SPIx); SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */ + + HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY); + Abort(); } #endif // HAS_SPI_TFT diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.h b/Marlin/src/HAL/STM32/tft/tft_spi.h index d477b58c004d..667b5f366b7e 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32/tft/tft_spi.h @@ -64,4 +64,11 @@ class TFT_SPI { static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteMultiple(uint16_t Color, uint32_t Count) { + static uint16_t Data; Data = Color; + while (Count > 0) { + TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); + Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + } + } }; From 0c73500b6706cae6af124870eb64d9e68154e7e1 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:19:27 -0300 Subject: [PATCH 08/22] we must keep spi pins --- .../share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c index 0fbd848dab74..51ebf605811b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c @@ -254,7 +254,7 @@ WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} @@ -266,7 +266,7 @@ WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} From 5c3cb7069425248886aced2bb527edc4ebb1f2e2 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:32:12 -0300 Subject: [PATCH 09/22] color ui working on stm32 --- .../dogm/u8g_dev_tft_upscale_from_128x64.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index cbb05bc356a7..7f88df7bc41f 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -339,6 +339,8 @@ static uint8_t page; } #endif // HAS_TOUCH_BUTTONS +static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT + uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); @@ -352,19 +354,21 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u switch (msg) { case U8G_DEV_MSG_INIT: dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, nullptr); - tftio.Init(); - tftio.InitTFT(); - TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset()); if (preinit) { preinit = false; return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } + if (msgInitCount) return -1; + tftio.Init(); + tftio.InitTFT(); + TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset()); + // Clear Screen setWindow(u8g, dev, 0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1); #if HAS_LCD_IO - tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT)); + tftio.WriteMultiple(TFT_MARLINBG_COLOR, (TFT_WIDTH) * (TFT_HEIGHT)); #else memset2(buffer, TFT_MARLINBG_COLOR, (TFT_WIDTH) / 2); for (uint16_t i = 0; i < (TFT_HEIGHT) * sq(GRAPHICAL_TFT_UPSCALE); i++) @@ -420,8 +424,6 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } -static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT - uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { if (msgInitCount) { if (msg == U8G_COM_MSG_INIT) msgInitCount--; @@ -433,8 +435,6 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p switch (msg) { case U8G_COM_MSG_STOP: break; case U8G_COM_MSG_INIT: - u8g_SetPIOutput(u8g, U8G_PI_RESET); - u8g_Delay(50); isCommand = 0; break; @@ -443,7 +443,6 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p break; case U8G_COM_MSG_RESET: - u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); break; case U8G_COM_MSG_WRITE_BYTE: From b423ba8156b8cd44b51ec6a33f75e91401d3aa99 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:35:17 -0300 Subject: [PATCH 10/22] Revert "fix conditionals" This reverts commit 106e560209dca8e396ac4cd8926d18f4adde9033. --- Marlin/src/inc/Conditionals_LCD.h | 7 +++++-- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/marlinui.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 38c4932ee5e3..7c581bef9087 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1185,8 +1185,11 @@ #endif // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' -#if ENABLED(TOUCH_SCREEN) && ENABLED(TFT_CLASSIC_UI) - #define HAS_TOUCH_BUTTONS 1 +#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT + #undef TOUCH_SCREEN + #if !HAS_TFT_LVGL_UI + #define HAS_TOUCH_BUTTONS 1 + #endif #endif // XPT2046_** Compatibility diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1aebe7b4f12f..b56177462f35 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3244,7 +3244,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) /** * Touch Buttons */ -#if ENABLED(TOUCH_SCREEN) && DISABLED(TOUCH_SCREEN_CALIBRATION) +#if ENABLED(TOUCH_SCREEN) #ifndef TOUCH_CALIBRATION_X #error "TOUCH_CALIBRATION_X must be defined with TOUCH_SCREEN." #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index f3cb77778113..8e968abda0af 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -658,7 +658,7 @@ class MarlinUI { #endif static void update_buttons(); - static inline bool button_pressed() { return BUTTON_CLICK() || TERN(TFT_COLOR_UI, touch_pressed(), false); } + static inline bool button_pressed() { return BUTTON_CLICK() || TERN(TOUCH_SCREEN, touch_pressed(), false); } #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static void wait_for_release(); #endif From 08ffae6c22a5186f7534d79265006231ce594594 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:41:34 -0300 Subject: [PATCH 11/22] update conditionals --- Marlin/src/HAL/STM32/tft/xpt2046.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.cpp b/Marlin/src/HAL/STM32/tft/xpt2046.cpp index 7e2dbfd15adb..af1d87422d3c 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32/tft/xpt2046.cpp @@ -23,7 +23,7 @@ #include "../../../inc/MarlinConfig.h" -#if HAS_TFT_XPT2046 +#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS #include "xpt2046.h" #include "pinconfig.h" diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7c581bef9087..3e61eb6d4a28 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1187,7 +1187,7 @@ // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' #if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT #undef TOUCH_SCREEN - #if !HAS_TFT_LVGL_UI + #if ENABLED(TFT_CLASSIC_UI) #define HAS_TOUCH_BUTTONS 1 #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b56177462f35..1aebe7b4f12f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3244,7 +3244,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) /** * Touch Buttons */ -#if ENABLED(TOUCH_SCREEN) +#if ENABLED(TOUCH_SCREEN) && DISABLED(TOUCH_SCREEN_CALIBRATION) #ifndef TOUCH_CALIBRATION_X #error "TOUCH_CALIBRATION_X must be defined with TOUCH_SCREEN." #endif From d6960771d4f1cfcb93462262b893e20846f99711 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:44:45 -0300 Subject: [PATCH 12/22] this class dont need dma --- Marlin/src/HAL/STM32/tft/xpt2046.cpp | 20 -------------------- Marlin/src/HAL/STM32/tft/xpt2046.h | 5 +---- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.cpp b/Marlin/src/HAL/STM32/tft/xpt2046.cpp index af1d87422d3c..04294e669c55 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32/tft/xpt2046.cpp @@ -31,7 +31,6 @@ uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; } SPI_HandleTypeDef XPT2046::SPIx; -DMA_HandleTypeDef XPT2046::DMAtx; void XPT2046::Init() { SPI_TypeDef *spiInstance; @@ -71,34 +70,16 @@ void XPT2046::Init() { if (SPIx.Instance == SPI1) { __HAL_RCC_SPI1_CLK_ENABLE(); SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; - #ifdef STM32F1xx - DMAtx.Instance = DMA1_Channel3; - #elif defined(STM32F4xx) - DMAtx.Instance = DMA2_Stream3; // DMA2_Stream5 - #endif - //SERIAL_ECHO_MSG(" Touch Screen on SPI1"); } #endif #ifdef SPI2_BASE if (SPIx.Instance == SPI2) { __HAL_RCC_SPI2_CLK_ENABLE(); - #ifdef STM32F1xx - DMAtx.Instance = DMA1_Channel5; - #elif defined(STM32F4xx) - DMAtx.Instance = DMA1_Stream4; - #endif - //SERIAL_ECHO_MSG(" Touch Screen on SPI2"); } #endif #ifdef SPI3_BASE if (SPIx.Instance == SPI3) { __HAL_RCC_SPI3_CLK_ENABLE(); - #ifdef STM32F1xx - DMAtx.Instance = DMA2_Channel2; - #elif defined(STM32F4xx) - DMAtx.Instance = DMA1_Stream5; // DMA1_Stream7 - #endif - //SERIAL_ECHO_MSG(" Touch Screen on SPI3"); } #endif } @@ -107,7 +88,6 @@ void XPT2046::Init() { SET_INPUT(TOUCH_MISO_PIN); SET_OUTPUT(TOUCH_MOSI_PIN); SET_OUTPUT(TOUCH_SCK_PIN); - //SERIAL_ECHO_MSG(" Touch Screen on Software SPI"); } getRawData(XPT2046_Z1); diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.h b/Marlin/src/HAL/STM32/tft/xpt2046.h index 78cb7a4ba54a..5b8acf4b87af 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32/tft/xpt2046.h @@ -23,10 +23,8 @@ #ifdef STM32F1xx #include - #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) #elif defined(STM32F4xx) #include - #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) #endif #include "../../../inc/MarlinConfig.h" @@ -65,9 +63,8 @@ enum XPTCoordinate : uint8_t { class XPT2046 { private: static SPI_HandleTypeDef SPIx; - static DMA_HandleTypeDef DMAtx; - static bool isBusy() { return SPIx.Instance ? __IS_DMA_ENABLED(&DMAtx) : false; } + static bool isBusy() { return false; } static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); From 8c0bf84cf19a1c083a045c8a94333e09b2f97ff6 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 01:58:35 -0300 Subject: [PATCH 13/22] nano v3 dont use encrypted firmware --- platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 7f84c5e3f077..a75a4aaf153b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1418,7 +1418,6 @@ upload_protocol = jlink extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py ################################# # # From 32eb938c94e5c96aac5bc0d97aceb5841e2403c9 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 16:31:43 -0300 Subject: [PATCH 14/22] reset tft io state on init --- Marlin/src/lcd/tft_io/tft_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index aa081be486bc..245635857186 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -121,7 +121,7 @@ class TFT_IO { static void write_esc_sequence(const uint16_t *Sequence); // Deletaged methods - inline static void Init() { io.Init(); }; + inline static void Init() { io.Init(); io.Abort(); }; inline static bool isBusy() { return io.isBusy(); }; inline static void Abort() { io.Abort(); }; inline static uint32_t GetID() { return io.GetID(); }; From cb41c282ca2d71f556d5a0fd09948221249fba68 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 16:32:11 -0300 Subject: [PATCH 15/22] more compatible FSMC code --- Marlin/src/HAL/STM32/tft/tft_fsmc.cpp | 30 +++++++++++++-------------- Marlin/src/HAL/STM32/tft/tft_fsmc.h | 9 ++++++-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index 2a5ad4595b71..87ca2dbbe18a 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -154,29 +154,27 @@ uint32_t TFT_FSMC::ReadID(tft_data_t Reg) { } bool TFT_FSMC::isBusy() { - if (__IS_DMA_ENABLED(&DMAtx)) + #if defined(STM32F1xx) + volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; + #elif defined(STM32F4xx) + volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; + #endif + if (dmaEnabled) { if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0) Abort(); - return __IS_DMA_ENABLED(&DMAtx); + } + else + Abort(); + return dmaEnabled; } void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.PeriphInc = MemoryIncrease; HAL_DMA_Init(&DMAtx); - - __HAL_DMA_CLEAR_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)); - __HAL_DMA_CLEAR_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)); - - #ifdef STM32F1xx - DMAtx.Instance->CNDTR = Count; - DMAtx.Instance->CPAR = (uint32_t)Data; - DMAtx.Instance->CMAR = (uint32_t)&(LCD->RAM); - #elif defined(STM32F4xx) - DMAtx.Instance->NDTR = Count; - DMAtx.Instance->PAR = (uint32_t)Data; - DMAtx.Instance->M0AR = (uint32_t)&(LCD->RAM); - #endif - __HAL_DMA_ENABLE(&DMAtx); + DataTransferBegin(); + HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(LCD->RAM), Count); + HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY); + Abort(); } #endif // HAS_FSMC_TFT diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.h b/Marlin/src/HAL/STM32/tft/tft_fsmc.h index ad39d10d632d..7c40151e2bdf 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.h @@ -25,10 +25,8 @@ #ifdef STM32F1xx #include "stm32f1xx_hal.h" - #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) #elif defined(STM32F4xx) #include "stm32f4xx_hal.h" - #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) #else #error "FSMC TFT is currently only supported on STM32F1 and STM32F4 hardware." #endif @@ -77,6 +75,13 @@ class TFT_FSMC { static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + static void WriteMultiple(uint16_t Color, uint32_t Count) { + static uint16_t Data; Data = Color; + while (Count > 0) { + TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); + Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + } + } }; From 91dcf1ad342d30972ff92c2dc717d9b0032ed38f Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 17:24:34 -0300 Subject: [PATCH 16/22] duplicated --- .../src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 20 ------------------- .../src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 20 ------------------- 2 files changed, 40 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index 2836b564ddc3..e2b3f2c317c6 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -345,26 +345,6 @@ #define BOARD_ST7920_DELAY_3 DELAY_NS(600) #endif // !MKS_MINI_12864 - -#elif ENABLED(SPI_GRAPHICAL_TFT) - #define SPI_TFT_CS_PIN PD11 - #define SPI_TFT_SCK_PIN PA5 - #define SPI_TFT_MISO_PIN PA6 - #define SPI_TFT_MOSI_PIN PA7 - #define SPI_TFT_DC_PIN PD10 - #define SPI_TFT_RST_PIN PC6 - - #define LCD_BACKLIGHT_PIN PD13 - - #define TOUCH_CS_PIN PE14 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define BTN_EN1 PE8 - #define BTN_EN2 PE11 - #define BEEPER_PIN PC5 - #define BTN_ENC PE13 #endif // HAS_SPI_LCD #define HAS_OTG_USB_HOST_SUPPORT diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 7bb65954385a..05648cf1207e 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -361,24 +361,4 @@ #endif #endif // !MKS_MINI_12864 - -#elif ENABLED(SPI_GRAPHICAL_TFT) - #define SPI_TFT_CS_PIN PD11 - #define SPI_TFT_SCK_PIN PA5 - #define SPI_TFT_MISO_PIN PA6 - #define SPI_TFT_MOSI_PIN PA7 - #define SPI_TFT_DC_PIN PD10 - #define SPI_TFT_RST_PIN PC6 - - #define LCD_BACKLIGHT_PIN PD13 - - #define TOUCH_CS_PIN PE14 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI - - #define BTN_EN1 PE8 - #define BTN_EN2 PE11 - #define BEEPER_PIN PC5 - #define BTN_ENC PE13 #endif // HAS_SPI_LCD From 802ae7f7b5fbf6314b4ccfc882ca3cc76edf9b5e Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 17:44:13 -0300 Subject: [PATCH 17/22] ANET ET4 classic ui compatibility --- Marlin/src/pins/stm32f4/pins_ANET_ET4.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h index c0bbe2f423f9..7f429d4497e0 100644 --- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -139,11 +139,15 @@ #define TFT_RS_PIN PD13 #define TFT_INTERFACE_FSMC_8BIT +#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT +#define FSMC_CS_PIN TFT_CS_PIN +#define FSMC_RS_PIN TFT_RS_PIN + // // Touch Screen // https://ldm-systems.ru/f/doc/catalog/HY-TFT-2,8/XPT2046.pdf // -#if ENABLED(TOUCH_SCREEN) +#if NEED_TOUCH_PINS #define TOUCH_CS_PIN PB2 #define TOUCH_SCK_PIN PB0 #define TOUCH_MOSI_PIN PE5 From e5d11de5a65280d267cdf2c7ef6ac969eafbb8d3 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 18:38:07 -0300 Subject: [PATCH 18/22] make our generic stm32 script aware of encryptation, and fix a bug that it will not update the firmware file when not using encriptation --- .../PlatformIO/scripts/stm32_bootloader.py | 10 ++++---- platformio.ini | 24 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index d517f1c8d1aa..b2937d514c0c 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -6,9 +6,7 @@ def noencrypt(source, target, env): firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) - # do not overwrite encrypted firmware if present - if not os.path.isfile(firmware): - shutil.copy(target[0].path, firmware) + shutil.copy(target[0].path, firmware) if 'offset' in board.get("build").keys(): LD_FLASH_OFFSET = board.get("build.offset") @@ -26,5 +24,7 @@ def noencrypt(source, target, env): if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) - if 'firmware' in board.get("build").keys(): - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt); +board_keys = board.get("build").keys() +# Only copy file if there's no encryptation +if 'firmware' in board_keys and not 'encrypt' in board_keys: + env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index a75a4aaf153b..b0ada65a7aa6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -970,6 +970,7 @@ board_build.core = stm32 board_build.variant = MARLIN_F103Zx board_build.ldscript = ldscript.ld board_build.offset = 0x7000 +board_build.encrypt = Yes board_build.firmware = Robin.bin build_flags = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 -DTIMER_SERIAL=TIM5 @@ -1155,6 +1156,7 @@ board_build.variant = MARLIN_F103Vx board_build.ldscript = ldscript.ld board_build.offset = 0x7000 board_build.firmware = Robin_mini.bin +board_build.encrypt = Yes board_upload.offset_address = 0x08007000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC extra_scripts = ${common.extra_scripts} @@ -1304,19 +1306,20 @@ extra_scripts = ${common.extra_scripts} # Lerdge base # [lerdge_common] -platform = ${common_stm32.platform} -extends = common_stm32 -board = LERDGE -board_build.offset = 0x10000 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/lerdge.py -build_flags = ${common_stm32.build_flags} +platform = ${common_stm32.platform} +extends = common_stm32 +board = LERDGE +board_build.offset = 0x10000 +board_build.encrypt = Yes +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/lerdge.py +build_flags = ${common_stm32.build_flags} -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE -DTRANSFER_CLOCK_DIV=8 -DHAL_SRAM_MODULE_ENABLED -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 # # Lerdge X @@ -1369,6 +1372,7 @@ board_build.core = stm32 board_build.variant = MARLIN_F103Vx board_build.ldscript = ldscript.ld board_build.offset = 0x7000 +board_build.encrypt = Yes board_build.firmware = Robin_nano35.bin board_upload.offset_address = 0x08007000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC From f68899592b986544929889f93720e6a3d94efe98 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 20:12:14 -0300 Subject: [PATCH 19/22] make classic ui aware of TOUCH_ORIENTATION --- Marlin/src/lcd/touch/touch_buttons.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index 8e231ca9abfe..3d1cc26cd6cf 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -32,6 +32,7 @@ XPT2046 touchIO; #endif #include "../marlinui.h" // For EN_C bit mask +#include "../tft_io/tft_io.h" #define DOGM_AREA_LEFT TFT_PIXEL_OFFSET_X #define DOGM_AREA_TOP TFT_PIXEL_OFFSET_Y @@ -49,7 +50,8 @@ uint8_t TouchButtons::read_buttons() { #ifdef HAS_WIRED_LCD int16_t x, y; - if (!touchIO.getRawPoint(&x, &y)) return 0; + const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y)); + if (!is_touched) return 0; #if ENABLED(TOUCH_SCREEN_CALIBRATION) const calibrationState state = touch_calibration.get_calibration_state(); From d572449728ee2e1ab00d5875f1e0e8358079ac02 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 20:17:31 -0300 Subject: [PATCH 20/22] fix anet_et4 firmware output --- .../share/PlatformIO/scripts/anet_et4_openblt.py | 14 ++++++++++++++ platformio.ini | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 buildroot/share/PlatformIO/scripts/anet_et4_openblt.py diff --git a/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py b/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py new file mode 100644 index 000000000000..9e40f01795aa --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py @@ -0,0 +1,14 @@ +# Generate the firmware as OpenBLT needs + +import os,sys +from os.path import join + +Import("env") + +env.AddPostAction( + "$BUILD_DIR/${PROGNAME}.elf", + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O", "srec", + "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\"" + ]), "Building " + join("$BUILD_DIR","${PROGNAME}.srec")) +) \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index b0ada65a7aa6..976f1ed3ce0f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1249,6 +1249,7 @@ board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld board_build.firmware = firmware.srec +board_build.encrypt = Yes # Just anet_et4_openblt.py generate the file, not stm32_bootloader.py board_build.offset = 0x10000 board_upload.offset_address = 0x08010000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 @@ -1257,6 +1258,7 @@ upload_protocol = jlink extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/anet_et4_openblt.py # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) From 0b3aa7a66a4cc4176417f8e3f3321471a81fa157 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Wed, 23 Dec 2020 20:36:44 -0300 Subject: [PATCH 21/22] typo --- Marlin/src/lcd/tft/tft.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 159d0e1c196d..431973b89480 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -30,7 +30,7 @@ #include "../../inc/MarlinConfig.h" -#if TFT_INTERFACE_FSMC_8BIT +#if ENABLED(TFT_INTERFACE_FSMC_8BIT) // When we have a 8 bit interface, we need to invert the bytes of the color #define ENDIAN_COLOR(C) (((C) >> 8) | ((C) << 8)) #else From 67511c55978a040b23ebaa3f51e1c5d1cc7480f3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Dec 2020 18:35:34 -0600 Subject: [PATCH 22/22] General cleanup --- Marlin/src/gcode/calibrate/G34.cpp | 2 +- buildroot/share/PlatformIO/scripts/anet_et4_openblt.py | 4 ++-- buildroot/share/PlatformIO/scripts/stm32_bootloader.py | 2 +- platformio.ini | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index e8d48411720b..bcca00dd42b3 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -42,7 +42,7 @@ void GcodeSuite::G34() { if (!all_axes_trusted()) home_all_axes(); TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false)); - + SET_SOFT_ENDSTOP_LOOSE(true); TemporaryGlobalEndstopsState unlock_z(false); diff --git a/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py b/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py index 9e40f01795aa..2911a28e789d 100644 --- a/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py +++ b/buildroot/share/PlatformIO/scripts/anet_et4_openblt.py @@ -8,7 +8,7 @@ env.AddPostAction( "$BUILD_DIR/${PROGNAME}.elf", env.VerboseAction(" ".join([ - "$OBJCOPY", "-O", "srec", + "$OBJCOPY", "-O", "srec", "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\"" ]), "Building " + join("$BUILD_DIR","${PROGNAME}.srec")) -) \ No newline at end of file +) diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index b2937d514c0c..7f49ea0e66f4 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -27,4 +27,4 @@ def noencrypt(source, target, env): board_keys = board.get("build").keys() # Only copy file if there's no encryptation if 'firmware' in board_keys and not 'encrypt' in board_keys: - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) \ No newline at end of file + env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) diff --git a/platformio.ini b/platformio.ini index 976f1ed3ce0f..a95647cf4298 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1249,7 +1249,8 @@ board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld board_build.firmware = firmware.srec -board_build.encrypt = Yes # Just anet_et4_openblt.py generate the file, not stm32_bootloader.py +# Just anet_et4_openblt.py generates the file, not stm32_bootloader.py +board_build.encrypt = Yes board_build.offset = 0x10000 board_upload.offset_address = 0x08010000 build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483