Skip to content

Commit

Permalink
Fix MKS Robin Nano V2 build / upload (MarlinFirmware#18784)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhapsodyv authored and vgadreau committed Dec 9, 2020
1 parent 3971bbb commit 5f9b2d3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
7 changes: 7 additions & 0 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ typedef struct {
uint8_t waitEndMoves;
uint16_t moveSpeed;
float move_dist;
uint8_t F[4];
} UI_CFG;

typedef enum {
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -599,18 +601,16 @@ 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) {
char buf[30];
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;
Expand Down
10 changes: 9 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,16 @@ 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);
}

#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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 9 additions & 16 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -564,27 +564,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

Expand Down

0 comments on commit 5f9b2d3

Please sign in to comment.