Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix STM32F1 SPI device init, MKS_LCD12864 #19271

Conversation

rhapsodyv
Copy link
Sponsor Member

@rhapsodyv rhapsodyv commented Sep 5, 2020

Description

Some PINs file have ENABLE_SPI2, to select the SPI 2 as the main device. But the current code start the SPI object with the SPI 1.
If any code try to use SPI before calling spiInit function (that set it according to board pins), the SPI will not work.

And this is the problem with #19269 . The LCD code in u8glib don't call spiInit, it rely on the current SPI selected from the global SPI object.

The MKS fix call SD card mount in the init of marlin code. The SD mount code call spiInit, putting the SPI to the right device, so its the reason why LCD works after the sd card mount. That SD mount just hide the real problem.

This fix start the SPI object with according with the board definition. It solves the problem in the root cause.

@thisiskeithb tested it and solved the LCD problem.

But it generate other issue: a very long boot time, that I'm looking for and SD Init Fail error. We check and that issue always happens, even with the old and mks pr. It's a boot loader issue. The delay happens before marlin ever starts.

Benefits

Configurations

Related Issues

#19269
#19159

@rhapsodyv rhapsodyv marked this pull request as draft September 5, 2020 19:47
@thisiskeithb
Copy link
Member

But it generate other issue: a very long boot time, that I'm looking for and SD Init Fail error

To add to this, it's only an issue if you boot with an SD card inserted and it takes 30 seconds (vs. booting without one which only takes ~3 seconds). After Marlin is done booting, inserting an SD card works fine and I get a Media Inserted message instead of SD Init Fail.

@thisiskeithb
Copy link
Member

thisiskeithb commented Sep 5, 2020

To save you from reading all the text below, this is likely a board/bootloader issue causing a 30 second delay when cold booting with an SD card inserted and not a Marlin issue.


I tried some additional LCD controllers on the Robin E3 board and still get the 30 second lockup on boot with an SD card inserted:
-MKS_MINI_12864
-MKS_LCD12864
-REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
-CR10_STOCKDISPLAY (using onboard slot)*

* Note: Onboard SD card pins are shared with the LCD controller pins on this board

Working with @rhapsodyv on Discord, it's likely the board/bootloader since I don't get serial output from Marlin until right after that 30 seconds and Marlin appears to boot normally (except for the SD Init Fail error):

15:07:58.806 -> echo:[178] HAL_init()
15:07:58.806 -> echo:[178] setup_killpin()
15:07:58.806 -> echo:[178] tmc_serial_begin()
15:07:58.806 -> echo:[181] setup_powerhold()
15:07:58.806 -> echo:[183] esp_wifi_init()
15:07:58.806 -> PowerUp
15:07:58.806 -> Marlin bugfix-2.0.x
15:07:58.840 -> 
15:07:58.840 -> echo: Last Updated: 2020-09-05 | Author: (thisiskeithb, Ender-3)
15:07:58.840 -> echo:Compiled: Sep  5 2020
15:07:58.840 -> echo: Free Memory: 24503  PlannerBufferBytes: 3456
15:07:58.840 -> echo:[201] ui.init()
15:07:58.840 -> echo:[202] ui.show_bootscreen()
15:08:03.059 -> echo:[4427] ui.reset_status()
15:08:03.059 -> echo:[4427] settings.first_load()
15:08:04.228 -> echo:V81 stored settings retrieved (670 bytes; crc 40203)
15:08:04.228 -> echo:[5588] thermalManager.init()
15:08:04.477 -> echo:[5840] print_job_timer.init()
15:08:04.477 -> echo:[5841] endstops.init()
15:08:04.477 -> echo:[5841] stepper.init()
15:08:04.477 -> echo:[5843] watchdog_init()
15:08:04.477 -> echo:[5846] test_tmc_connection(0x1, 0x1, 0x1, 0x1)
15:08:04.477 -> Testing X connection... OK
15:08:04.511 -> Testing Y connection... OK
15:08:04.511 -> Testing Z connection... OK
15:08:04.511 -> Testing E connection... OK
15:08:04.511 -> echo:[5887] setup() completed.
15:08:04.511 -> SD: Status changed from 2 to 1
15:08:07.041 -> echo:No SD card

@makerbase-mks / @mks-viva : Why does the board lock up with "boot..." on the LCD for 30 seconds while an SD card is inserted on boot?

@rhapsodyv rhapsodyv changed the title Correct SPI device init, according with pins file Correct SPI device init + MKS_LCD12864 fixes for STM32F1 Sep 6, 2020
@thisiskeithb
Copy link
Member

thisiskeithb commented Sep 6, 2020

After more testing with @rhapsodyv, the Marlin bootscreen can now be enabled on the Nano V2, Robin E3, and Robin Lite3 boards with MKS Mini 12864 & LCD12864 LCDs after adding a delay and the LCD has proper contrast from the start of the boot process.

@rhapsodyv
Copy link
Sponsor Member Author

Thanks to @thisiskeithb dedication to get everything as right as possible, and his tests, we fixed more old issues with the MKS_LCD12864. Now its even show the marlin boot screen correctly!

🚀

@rhapsodyv rhapsodyv force-pushed the correct-spi-default-on-startup branch from 297cf1e to 2f20711 Compare September 6, 2020 01:54
@thinkyhead thinkyhead changed the title Correct SPI device init + MKS_LCD12864 fixes for STM32F1 Fix STM32F1 SPI device init, MKS_LCD12864 Sep 6, 2020
@thinkyhead thinkyhead merged commit 4867311 into MarlinFirmware:bugfix-2.0.x Sep 6, 2020
@makerbase-mks
Copy link
Contributor

@thisiskeithb @rhapsodyv
I has test it and this works perfectly! This screen has been fully working on LPC and STM32F1.

@thisiskeithb
Copy link
Member

@thisiskeithb @rhapsodyv
I has test it and this works perfectly! This screen has been fully working on LPC and STM32F1.

The original issue (#19159) was for a Gen-L (8-bit) and the LCD12864A, but that hasn't been addressed yet since neither @rhapsodyv or I have that LCD. AVR uses software serial, so this fix doesn't apply.

Can you work on getting that LCD/motherboard combo working?

davidveg added a commit to davidveg/Marlin that referenced this pull request Sep 9, 2020
* commit 'bc7720c0cd3917f44200c0b78e1b635e4c7b6797': (483 commits)
  Minor HAL cleanup
  [cron] Bump distribution date (2020-09-09)
  Update HAL/STM32 platform to 8.0 (MarlinFirmware#18496)
  Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
  [cron] Bump distribution date (2020-09-08)
  TFT is neither "graphical" nor "character" (MarlinFirmware#19297)
  Sanity-check BABYSTEP_DISPLAY_TOTAL with ColorUI (MarlinFirmware#19284)
  Fix M166 Gradient Mix for DELTA (MarlinFirmware#19285)
  Separate Neopixel followup (MarlinFirmware#19287)
  Clean up LCD conditionals, DWIN
  Whitespace cleanup
  Adjust GTR PeripheralPins to avoid timer conflicts (MarlinFirmware#19183)
  STM32F1 EP with USB_COMPOSITE (MarlinFirmware#19281)
  Menu items for Separate NeoPixel (MarlinFirmware#19280)
  [cron] Bump distribution date (2020-09-07)
  Clarify disabling StallGuard for axes (MarlinFirmware#19263)
  Touch UI long filenames fixes (MarlinFirmware#19262)
  Fix Ender 3 V2 (DWIN) buffer overrun (MarlinFirmware#19268)
  Fix STM32F1 SPI device init, MKS_LCD12864 (MarlinFirmware#19271)
  Emergency Parser for STM32F1 (MarlinFirmware#19279)
  ...

# Conflicts:
#	.github/issue_template.md
#	Marlin/Configuration.h
#	Marlin/Configuration_adv.h
#	README.md
davidveg added a commit to davidveg/Marlin that referenced this pull request Sep 9, 2020
* commit 'bc7720c0cd3917f44200c0b78e1b635e4c7b6797': (483 commits)
  Minor HAL cleanup
  [cron] Bump distribution date (2020-09-09)
  Update HAL/STM32 platform to 8.0 (MarlinFirmware#18496)
  Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
  [cron] Bump distribution date (2020-09-08)
  TFT is neither "graphical" nor "character" (MarlinFirmware#19297)
  Sanity-check BABYSTEP_DISPLAY_TOTAL with ColorUI (MarlinFirmware#19284)
  Fix M166 Gradient Mix for DELTA (MarlinFirmware#19285)
  Separate Neopixel followup (MarlinFirmware#19287)
  Clean up LCD conditionals, DWIN
  Whitespace cleanup
  Adjust GTR PeripheralPins to avoid timer conflicts (MarlinFirmware#19183)
  STM32F1 EP with USB_COMPOSITE (MarlinFirmware#19281)
  Menu items for Separate NeoPixel (MarlinFirmware#19280)
  [cron] Bump distribution date (2020-09-07)
  Clarify disabling StallGuard for axes (MarlinFirmware#19263)
  Touch UI long filenames fixes (MarlinFirmware#19262)
  Fix Ender 3 V2 (DWIN) buffer overrun (MarlinFirmware#19268)
  Fix STM32F1 SPI device init, MKS_LCD12864 (MarlinFirmware#19271)
  Emergency Parser for STM32F1 (MarlinFirmware#19279)
  ...

# Conflicts:
#	.github/issue_template.md
#	README.md
davidveg added a commit to davidveg/Marlin that referenced this pull request Sep 9, 2020
* 2.0.x: (483 commits)
  Minor HAL cleanup
  [cron] Bump distribution date (2020-09-09)
  Update HAL/STM32 platform to 8.0 (MarlinFirmware#18496)
  Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
  [cron] Bump distribution date (2020-09-08)
  TFT is neither "graphical" nor "character" (MarlinFirmware#19297)
  Sanity-check BABYSTEP_DISPLAY_TOTAL with ColorUI (MarlinFirmware#19284)
  Fix M166 Gradient Mix for DELTA (MarlinFirmware#19285)
  Separate Neopixel followup (MarlinFirmware#19287)
  Clean up LCD conditionals, DWIN
  Whitespace cleanup
  Adjust GTR PeripheralPins to avoid timer conflicts (MarlinFirmware#19183)
  STM32F1 EP with USB_COMPOSITE (MarlinFirmware#19281)
  Menu items for Separate NeoPixel (MarlinFirmware#19280)
  [cron] Bump distribution date (2020-09-07)
  Clarify disabling StallGuard for axes (MarlinFirmware#19263)
  Touch UI long filenames fixes (MarlinFirmware#19262)
  Fix Ender 3 V2 (DWIN) buffer overrun (MarlinFirmware#19268)
  Fix STM32F1 SPI device init, MKS_LCD12864 (MarlinFirmware#19271)
  Emergency Parser for STM32F1 (MarlinFirmware#19279)
  ...

# Conflicts:
#	Marlin/Configuration.h
#	platformio.ini
@ShadowOfTheDamn
Copy link

Hi every body. tried the new bugfix but doesn't help with character LCD.
[BUG] RADDS v1.5 LCD 2004 Initialization problem #18132

@thisiskeithb
Copy link
Member

RADDS v1.5 LCD 2004 Initialization problem

That’s completely different hardware than what this PR addresses.

@sjasonsmith
Copy link
Contributor

@thisiskeithb i had asked them to re-test, not knowing if the delays from this would impact it at all. Apparently not, so further discussion on it should not occur here.

@ShadowOfTheDamn
Copy link

ok tnx for the information.

@rhapsodyv rhapsodyv deleted the correct-spi-default-on-startup branch October 25, 2020 00:33
vgadreau pushed a commit to vgadreau/Marlin that referenced this pull request Dec 9, 2020
kageurufu pushed a commit to CR30-Users/Marlin-CR30 that referenced this pull request Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants