Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

[BUG] Ender 3 v2 does not boot when E0_DRIVER_TYPE is TMC2208 with pin PA3 on 2.0.9.2+ versions

Open TOTA42 opened this issue 4 years ago • 24 comments

Did you test the latest bugfix-2.0.x code?

Yes, and the problem still exists.

Bug Description

I have done a board modification on the stock Ender 3 v2 mainboard (4.2.2 with TMC2208 steppers) that would enable me to use the UART on the TMC2208. This was done by adding a blue wire on PA3 to the E stepper driver's UART pin. This works on 2.0.8, but on 2.0.9.2 versions, it appears that Marlin fails to boot, or at least the LCD stays black until I flash a firmware that will boot. I either have to switch the E0 back to TMC2208_STANDALONE for 2.0.9.2 versions or revert back to 2.0.8 if I wanted to keep E0 as TMC2208.

There seems to be some consensus with the oddity with PA3 pin particularly. There is some discussion in https://github.com/Jyers/Marlin/discussions/1346 where it seems to work again if it's PA13 instead of PA3 if using post 2.0.8 versions.

Note: I have only tried this on 2.0.8 (working), 2.0.9.2 (does not boot), and 2.x.x SHA 1f41437 (does not boot). I have not attempted a git bisect to narrow down the commit, but I can do so if you think it would help.

Bug Timeline

2.0.9.2

Expected behavior

Expected Marlin to boot or at least the LCD to display something

Actual behavior

Marlin appears to fail to boot, LCD screen is black and must either set E0 driver back to TMC2208_STANDALONE or revert to 2.0.8 with E0 set to TMC2208.

Steps to Reproduce

  1. Compile Marlin (used 2.0.9.2 and 2.x.x fix 1f41437 with changes noted in patch_UART_enable.txt)
  2. Place in SD card and turn on printer

Version of Marlin Firmware

2.0.9.2

Printer model

Creality Ender 3 v2

Electronics

Stock electronics with blue wire from PA3 pin to E stepper driver's UART pin

Add-ons

N/A

Bed Leveling

MBL Manual Bed Leveling

Your Slicer

Cura

Host Software

SD Card (headless)

Additional information & file uploads

Configuration files used

Patch to apply on clean Marlin with Ender-3 V2 MarlinUI configuration copied

Discussion in Jyers with blackscreen with Pin PA3 specifically

TOTA42 avatar Oct 07 '21 16:10 TOTA42

Ran a git bisect between 2.0.8 and 2.0.9.1 (git bisect log in link below) and traced it down to the failing commit: d13ffa0a, which happens to be:

🔨 Creality v4 with STM32 HAL (#21999)

- New STM32 env for Creality V4 boards.
- Separate Libmaple targets into their own `ini` file.
- Temporarily remove unusable targets from `pins.h`.

git_bisect_log.txt

TOTA42 avatar Oct 08 '21 04:10 TOTA42

so does environment STM32F103RET6_creality_maple work as expected then? Sadly this is a bit like saying It worked under Windows XP, but it doesn't work under Windows 10... but is a start

ellensp avatar Oct 08 '21 04:10 ellensp

Did a quick build on 2.0.9.2 with the STM32F103RET6_creality_maple instead of the STM32F103RET6_creality and it does seem to boot with the E0_DRIVER_TYPE as TMC2208. I haven't checked any other functionality besides that it boots.

TOTA42 avatar Oct 08 '21 06:10 TOTA42

I was able to run the M122 command and received the expected register responses from the TMC2208 with the STM32F103RET6_creality_maple environment. Any ideas/tests I can run to trace down the boot issue with the STM32F103RET6_creality environment?

TOTA42 avatar Oct 12 '21 04:10 TOTA42

Can confirm, not booting. Does with libmaple. Could be nice to have this fixed or find out what we are doing wrong :/

masterxq avatar Feb 14 '22 05:02 masterxq

Hello, I have same issue. Someone find this problem?

stikzoo avatar Mar 13 '22 14:03 stikzoo

Hello, do you have working firmware? BLTouch No matter what I do, I always get an error. I don't have any in my code info.

EntasDisk avatar Jul 22 '22 09:07 EntasDisk

This is still an issue

ellensp avatar Jul 28 '22 15:07 ellensp

How's it going? So let's see what we can see, here…

According to the datasheet pin PA3 is connected to TIM5_CH4. In Marlin the STM32F103RE_creality environment used to build this board has the build argument -DTIMER_SERVO=TIM5 to use timer 5 as the timer for servos. If you want to use PA3 for your own purposes, and there is a BLTouch, servo, or even potential servo use in Marlin, then you'll need to change that TIM5 to some other free timer. Or, you can try defining SERVO0_PIN as -1 in your configuration, and this should prevent Marlin from trying to do anything servo-related.

thinkyhead avatar Aug 06 '22 01:08 thinkyhead

SERVO0_PIN

Which file will we set this "SERVO0_PIN" exactly. I don't know about it. I'm trying to learn.

EntasDisk avatar Aug 17 '22 14:08 EntasDisk

add #define SERVO0_PIN -1 to your Configuration.h

This overrides the one set in your boards pin.h file.

ellensp avatar Aug 17 '22 15:08 ellensp

Such an error occurs.

Marlin\src\HAL\STM32../../inc/SanityCheck.h:1523:8: error: #error "SERVO0_PIN must be defined for your servo or BLTOUCH probe." 1523 | #error "SERVO0_PIN must be defined for your servo or BLTOUCH probe."

EntasDisk avatar Aug 18 '22 17:08 EntasDisk

Hmm, looks like a conundrum here. My setup has a BLTouch (and uses it for Z-homing, so disabling it is not an option). But I can't really see any timers that don't conflict... I'm trying to set up a SoftwareSerial on PA7 (the Z-endstop) to one driver only. I'm having the printer hang before loading as well (screen powers up, but nothing is drawn; serial through the CH340 chip is never initialised; but if I set the driver back to standalone configuration, and attempt to SD flash again, it comes back to life).

TIM1: default uses PB12 through PB15 and PA8 through PA12; these pins are used for the screen encoder and beeper, along with serial communication to the CH340 and EEPROM access. TIM2: default uses PA0 through PA3, which are used to control the MOSFETs for heating elements and cooling fans, and wouldn't work anyway for PA3, since we are trying to free that one up! TIM3: default uses PA6 and PA7, as well as PB0 and PB1; connected to Y- and Z- endstops, and to the BLTouch. TIM4: defaults to PB6 through PB9; Y and Z stepper driver control. TIM5: what we already have: see TIM2, it is tied to the same four pins TIM6, TIM7: both basic timers, unsure if suitable for handling servos. TIM8: see TIM3, shared pins; also uses PC6-PC9, 7-9 are used for SD card interface.

DragRedSim avatar Sep 06 '22 09:09 DragRedSim

add #define SERVO0_PIN -1 to your Configuration.h

This overrides the one set in your boards pin.h file.

This results in multiple errors as below:

Marlin\src\HAL\STM32\tft\../../../inc/SanityCheck.h:1700:8: error: #error "SERVO0_PIN must be defined for your servo or BLTOUCH probe."
 1700 |       #error "SERVO0_PIN must be defined for your servo or BLTOUCH probe."

If I comment out the SERVO0_PIN check from SanityCheck.h it compiles fine, however the firmware still gets stuck at a blank screen.

I've finally caved in today and modded my Ender 3 with the link for UART today and now I'm learning I can't use linear advance with the current firmware, rip :(

EDIT: compiling maple makes the LCD intiialize and get to home screen and update values, however pressing the rotary encoder results in a printer reset (fw reboots) making it unusable :(

d-rez avatar Sep 28 '22 11:09 d-rez

#define SERVO0_PIN -1 breaks a bltouch which thinks its a servo to deploy and retract the probe.

ellensp avatar Sep 28 '22 11:09 ellensp

I guess my question is what has changed since 2.0.8 (in regard to timers) if the older version had no issues working with PA3? What's the root cause and would it be possible to work around this?

I'll look at soldering to PA13 in the meantime

EDIT: PA13 works fine (at least based on initial limited tests, it's technically easier to use since it's the SWDIO pin of ICSP pin header solderpoints).

d-rez avatar Sep 28 '22 11:09 d-rez

Did you solve the problem with the Pa 13? Is it true that you did it as pa13 and R19? Do you have the settings files and output sample you made?

EntasDisk avatar Sep 29 '22 07:09 EntasDisk

@EntasDisk yes linear advance seems to operate on PA13 although results don't look very satisfying.

And no, I didn't use R19, my board is a v4.2.7 with TMC2225's so I used a different one that goes to uart pin of the extruder driver. Which is R52 on my board.

Schematics for both boards here:

https://klipper.discourse.group/t/creality-board-4-2-2-and-4-2-7-schematics/3104

As for settings I can make a patch sometime later based off my config.

d-rez avatar Sep 29 '22 07:09 d-rez

I’m not sure if you saw the latest release, but as of Marlin 2.1.1, Linear Advance works on 2208s/2225s now, including non-modded Creality boards.

thisiskeithb avatar Sep 29 '22 08:09 thisiskeithb

@thisiskeithb interesting, I definitely didn't go through the whole changelog as I was updating from mid-2021 build of 2.0.x bugfix to most recent 2.1.x bugfix

So LA should work without UART access? Did I just waste time modding my board? 😂

Also hmm is there even any advantage to using uart now? I wonder. I'll try to find some info/discussions on this. Thanks.

EDIT: https://github.com/MarlinFirmware/Marlin/pull/24533 is the PR for this fix

d-rez avatar Sep 29 '22 09:09 d-rez

Looking for 1 more working PIn I guess to make things work non-maple with a BLtouch in it's stock port. Been toying with this the past few days on a board with 2209's (B) on the SD card slot.

PA13, PA14 , PA15 (chip soldered).
PA3 and PA4 only seem to work in the Maple env due to the Timer issues, It does work with maple on PA4 here, would hang boot with oem.

>>> M122
SENDING:M122
		X	Y	Z	E
Address		3	3	3	3
Enabled		false	false	false	false
Set current	800	800	800	800
RMS current	795	795	795	795
MAX current	1121	1121	1121	1121
Run current	25/31	25/31	25/31	25/31
Hold current	12/31	12/31	12/31	12/31
CS actual	12/31	12/31	12/31	12/31
PWM scale
vsense		1=.18	1=.18	1=.18	1=.18
stealthChop	false	false	true	false
msteps		16	16	16	16
interp		true	true	true	true
tstep		max	max	max	max
PWM thresh.
[mm/s]
OT prewarn	false	false	false	false
pwm scale sum	14	14	14	14
pwm scale auto	0	0	0	0
pwm offset auto	36	36	36	36
pwm grad auto	14	14	14	14
off time	4	4	4	4
blank time	24	24	24	24
hysteresis
 -end		2	2	2	2
 -start		1	1	1	1
Stallguard thrs	0	0	0	0
uStep count	24	24	8	24
DRVSTATUS	X	Y	Z	E
sg_result	0	0	0	0
stst
olb		*	*		*
ola		*	*		*
s2gb
s2ga
otpw
ot
157C
150C
143C
120C
s2vsa
s2vsb
Driver registers:
		X	0x80:0C:00:C0
		Y	0x80:0C:00:C0
		Z	0xC0:0C:00:00
		E	0x80:0C:00:C0
Testing X connection... OK
Testing Y connection... OK
Testing Z connection... OK
Testing E connection... OK

I tried TIM6 and TIM3 , it compiles, but fails to boot. Lack of TMC coms I guess. It's also somewhat odd that it's not catching this state with the TMC COMM ERROR? Tried 7 and it fails to compile with timer conflicts.

Looks like PC0, PC1, PC13, PC14, PC15 are all NC and might be potentially useable like PA15, but will have to tinker more to make that happen. If building against maple is fine, it might not really be worth it to be mucking around with more mod wire? Should I be trying to make this work non-maple on another un-used pin? I haven't connected the board to a printer yet, so I've been mostly unable to test if it's actually broken in some other way. Why does maple not have this Servo/Timer conflict? Like asked above, can the root cause be corrected, or is maple flawed/sharing a line in some way and it just appears to work fine?

Trying to judge if it's worth the risk to stay out of deprecation?

Emerica avatar Jan 20 '23 15:01 Emerica

Does any one have any updates? Well, after finding a guide for putting all my 2225's (Creality 4.2.7) into uart mode, I guess it's not entirely needed anymore since LA is working? I wanted uart for vref and I could only presume it would work better for some of these 'new' features. I have BLT, and used PA4, PA7, PA13 and PA14. I was having compile issues with commenting out z_stop_pin, so I set that to PC0. Same problem, blank LCD screen, no serial > USB comms come up. Flash with only Z and E as 2208 (non-stand alone mode) it boots up at least, add in X or Y and same results - blank screen no D4 LED activity. All my testing has been just board, and LCD (E3V2 Display), nothing else, so firmware with Z, E, might still fail when I go to attempt a print.

phantum29 avatar Aug 15 '23 05:08 phantum29

I converted that machine to Switchwire, so it's running klipper now.

Emerica avatar Aug 16 '23 08:08 Emerica