From 3eef000e2a7623d0d1d1f56fbf3109023f5d74c2 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 26 Jul 2020 01:08:30 -0300 Subject: [PATCH] Fix MKS Robin Nano V2 build / upload (#18784) --- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 7 ++++++ Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 1 + .../extui/lib/mks_ui/mks_hardware_test.cpp | 10 ++++---- .../src/lcd/extui/lib/mks_ui/pic_manager.cpp | 10 +++++++- Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h | 3 ++- Marlin/src/pins/pins.h | 4 +-- platformio.ini | 25 +++++++------------ 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp index 5fb3bf6d73..e8899b9ad1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -126,6 +126,13 @@ void gCfgItems_init() { W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); } + + uiCfg.F[0] = 'N'; + uiCfg.F[1] = 'A'; + uiCfg.F[2] = 'N'; + uiCfg.F[3] = 'O'; + W25QXX.SPI_FLASH_BlockErase(REFLSHE_FLGA_ADD + 32 - 64*1024); + W25QXX.SPI_FLASH_BufferWrite(uiCfg.F,REFLSHE_FLGA_ADD,4); } void gCfg_to_spiFlah() { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h index 5c114c2ac1..595565e1c7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -161,6 +161,7 @@ typedef struct { uint8_t waitEndMoves; uint16_t moveSpeed; float move_dist; + uint8_t F[4]; } UI_CFG; typedef enum { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp b/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp index 54db9dd5b0..b5b77c50b2 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp @@ -590,6 +590,8 @@ void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint1 } void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor) { + // Select TFT SPI so it can receive data + TERN_(TFT_LVGL_UI_SPI, SPI_TFT.spi_init(SPI_FULL_SPEED)); while (*string != '\0') { disp_char_1624(x, y, *string, charColor, bkColor); string++; @@ -599,10 +601,8 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor //static lv_obj_t * scr_test; void disp_assets_update() { - #if DISABLED(TFT_LVGL_UI_SPI) - LCD_Clear(0x0000); - #endif - disp_string(100, 150, "Assets Updating...", 0xFFFF, 0x0000); + TERN(TFT_LVGL_UI_SPI,, LCD_Clear(0x0000)); + disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000); } void disp_assets_update_progress(const char *msg) { @@ -610,7 +610,7 @@ void disp_assets_update_progress(const char *msg) { memset(buf, ' ', COUNT(buf)); strncpy(buf, msg, strlen(msg)); buf[COUNT(buf)-1] = '\0'; - disp_string(100, 200, buf, 0xFFFF, 0x0000); + disp_string(100, 165, buf, 0xFFFF, 0x0000); } uint8_t mks_test_flag = 0; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index 3f9af712d1..2a16bcf1b3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -249,6 +249,7 @@ const char *bakPath = "_assets"; void spiFlashErase_PIC() { volatile uint32_t pic_sectorcnt = 0; + W25QXX.init(SPI_QUARTER_SPEED); for (pic_sectorcnt = 0; pic_sectorcnt < PIC_SIZE_xM * 1024 / 64; pic_sectorcnt++) W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024); } @@ -256,7 +257,8 @@ void spiFlashErase_PIC() { #if HAS_SPI_FLASH_FONT void spiFlashErase_FONT() { volatile uint32_t Font_sectorcnt = 0; - for (Font_sectorcnt = 0; Font_sectorcnt < FONT_SIZE_xM * 1024 / 64; Font_sectorcnt++) + W25QXX.init(SPI_QUARTER_SPEED); + for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024); } #endif @@ -386,6 +388,9 @@ uint8_t public_buf[512]; } disp_assets_update_progress(fn); + + W25QXX.init(SPI_QUARTER_SPEED); + uint16_t pbr; uint32_t pfileSize; uint32_t totalSizeLoaded = 0; @@ -444,11 +449,14 @@ uint8_t public_buf[512]; if (dir.open(&root, assetsPath, O_RDONLY)) { disp_assets_update(); + disp_assets_update_progress("Erasing pics..."); spiFlashErase_PIC(); #if HAS_SPI_FLASH_FONT + disp_assets_update_progress("Erasing fonts..."); spiFlashErase_FONT(); #endif + disp_assets_update_progress("Reading files..."); dir_t d; while (dir.readDir(&d, card.longFilename) > 0) { // if we dont get a long name, but gets a short one, try it diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h index 663a88d8db..3ef4ee4f86 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h @@ -120,6 +120,7 @@ extern "C" { /* C-declarations for C++ */ #endif // Flash flag +#define REFLSHE_FLGA_ADD (0X800000-32) #define FLASH_INF_VALID_FLAG 0xAA558761 // SD card information first addr #define VAR_INF_ADDR 0x000000 @@ -139,7 +140,7 @@ typedef struct pic_msg PIC_MSG; #define BMP_WRITE_BUF_LEN 512 -#define PICINFOADDR 0 +#define PICINFOADDR 0x1000 #define PIC_SIZE_xM 6 #define FONT_SIZE_xM 2 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index a8fb3f02f0..1b78b0f769 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -507,9 +507,9 @@ #elif MB(MKS_ROBIN_MINI) #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini #elif MB(MKS_ROBIN_NANO) - #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano env:mks_robin_nano35 + #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano35 #elif MB(MKS_ROBIN_NANO_V2) - #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano env:mks_robin_nano35 + #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 #elif MB(MKS_ROBIN_LITE) #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite #elif MB(BTT_SKR_MINI_V1_1) diff --git a/platformio.ini b/platformio.ini index 429091fbf0..543b837f54 100644 --- a/platformio.ini +++ b/platformio.ini @@ -574,27 +574,20 @@ build_flags = ${common_stm32f1.build_flags} -DMCU_STM32F103VE # -# MKS Robin Nano (STM32F103VET6) - Emulated Graphical 128x64 (DOGM) UI and LVGL UI +# MKS Robin Nano (STM32F103VET6) +# v1.2 - Emulated Graphical 128x64 (DOGM) UI and LVGL UI +# v2.0 - LVGL UI # -[env:mks_robin_nano] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -platform_packages = tool-stm32duino -extra_scripts = ${common.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_nano.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSS_TIMER=4 - -# -# MKS Robin Nano v2.0 (STM32F103VET6) - LVGL UI -# -[env:mks_robin_nano35_v2] +[env:mks_robin_nano35] platform = ${common_stm32f1.platform} -extends = env:mks_robin_nano +extends = common_stm32f1 +board = genericSTM32F103VE +platform_packages = tool-stm32duino extra_scripts = ${common.extra_scripts} buildroot/share/PlatformIO/scripts/mks_robin_nano35.py lib_deps = ${common_stm32f1.lib_deps} +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 debug_tool = jlink upload_protocol = jlink