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

[BUG] SKR Mini e3 v1.2 USB Not Working #25705

Closed
1 task done
ThisIsMyGithubRepo opened this issue Apr 18, 2023 · 8 comments
Closed
1 task done

[BUG] SKR Mini e3 v1.2 USB Not Working #25705

ThisIsMyGithubRepo opened this issue Apr 18, 2023 · 8 comments

Comments

@ThisIsMyGithubRepo
Copy link

ThisIsMyGithubRepo commented Apr 18, 2023

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

Yes, and the problem still exists.

Bug Description

Using Marlin Autobuild and target STM32F103RC_btt_USB with the sample Ender3 SKR Mini e3 v1.2 from the 2.1 bugfix branch ZIP
Once flashed, Marlin boots:
PC makes a USB connected noise
No USB drive appears
No COM port appears

Note that I tried with the non-bugfix 2.1 build, and that results in the unit being unresponsive (blank LCD).
Reverting back to a 2.0.x firmware fixes things, restoring USB Composite functionality.

Bug Timeline

No response

Expected behavior

Expect normal USB Composite (Drive and COM) behaviour.

Actual behavior

Neither USB drive or COM ports appear.

Steps to Reproduce

Build bugfix with the sample ender 3 skr mini e3 v1.2 config.
Copy firmware.bin to an SD card
Insert the SD card into printer and reboot.

Version of Marlin Firmware

2.1.x Bugfix

Printer model

Ender 3

Electronics

SKR Mini e3 v1.2

Add-ons

Clone BLTouch

Bed Leveling

None

Your Slicer

None

Host Software

None

Don't forget to include

  • A ZIP file containing your Configuration.h and Configuration_adv.h.

Additional information & file uploads

USB Device Diagnostic on my PC tells me this:

    =========================== USB Port4 ===========================

Connection Status        : Device is connected
Port Chain               : 3-3-1-4
Supported Protocols      : 0x03 (1.1, 2.0)
Properties               : 0x00
 IsUserConnectable       : no
 PortIsDebugCapable      : no

      ======================== USB Device ========================

        +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : USB Composite Device
Device ID                : USB\VID_0483&PID_5740\56DE53593555
Driver KeyName           : {36fc9e60-c465-11cf-8056-444553540000}\0002 (GUID_DEVCLASS_USB)
Driver                   : C:\WINDOWS\System32\drivers\usbccgp.sys (Version: 10.0.19041.2546  Date: 2023-02-19)
Driver Inf               : C:\WINDOWS\inf\usb.inf
Legacy BusType           : PNPBus
Class                    : USB
Service                  : usbccgp
Enumerator               : USB
Location Info            : Port_#0004.Hub_#0004
Container ID             : {8c50a048-35be-5ee2-b88f-ae7265d166f3}
Manufacturer Info        : (Standard USB Host Controller)
Capabilities             : Removable, UniqueID
Address                  : 9   (*!*ERROR  Should be equal to the port number)
Problem Code             : 10 (CM_PROB_FAILED_START)
Power State              : D3 (supported: D0, D2, D3)

        ---------------- Connection Information ---------------
Connection Index         : 0x04
Connection Status        : 0x01 (DeviceConnected)
Current Config Value     : 0x00
Device Address           : 0x09
Is Hub                   : 0x00 (no)
Number Of Open Pipes     : 0x00 (0)
Device Bus Speed         : 0x01 (Full-Speed)

        ------------------ Device Descriptor ------------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Descriptor)
bcdUSB                   : 0x200 (USB Version 2.00)
bDeviceClass             : 0xEF (Miscellaneous)
bDeviceSubClass          : 0x02
bDeviceProtocol          : 0x01
bMaxPacketSize0          : 0x40 (64 bytes)
idVendor                 : 0x0483 (STMicroelectronics)
idProduct                : 0x5740
bcdDevice                : 0x00
iManufacturer            : 0x01
 *!*  string descriptors are not available because device is in low power state
iProduct                 : 0x02
 *!*  string descriptors are not available because device is in low power state
iSerialNumber            : 0x03
 *!*  string descriptors are not available because device is in low power state
bNumConfigurations       : 0x01

        -------------- Configuration Descriptor ---------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x0062 (98 bytes)
bNumInterfaces           : 0x03
bConfigurationValue      : 0x01
iConfiguration           : 0x02
 *!*  string descriptors are not available because device is in low power state
bmAttributes             : 0xC0
 D7: Reserved, set 1     : 0x01
 D6: Self Powered        : 0x01 (yes)
 D5: Remote Wakeup       : 0x00 (no)
 D4..0: Reserved, set 0  : 0x00
MaxPower                 : 0x32 (100 mA)

        ------------------- IAD Descriptor --------------------
bLength                  : 0x08 (8 bytes)
bDescriptorType          : 0x0B
bFirstInterface          : 0x00
bInterfaceCount          : 0x02
bFunctionClass           : 0x02 (Communications and CDC Control)
bFunctionSubClass        : 0x02
bFunctionProtocol        : 0x01
iFunction                : 0x04
 *!*  string descriptors are not available because device is in low power state

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting        : 0x00
bNumEndpoints            : 0x01 (1 Endpoints)
bInterfaceClass          : 0x02 (Communications and CDC Control)
bInterfaceSubClass       : 0x02
bInterfaceProtocol       : 0x01
iInterface               : 0x05
 *!*  string descriptors are not available because device is in low power state

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x00 (Header Functional Descriptor)
bcdCDC                   : 0x110 (CDC Version 1.10)

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x01 (Call Management Functional Descriptor)
bmCapabilities           : 0x00
bDataInterface           : 0x01

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x04 (4 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x02 (Abstract Control Management Functional Descriptor)
bmCapabilities           : 0x02

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x06 (Union Functional Descriptor)
bControlInterface        : 0x00
bSubordinateInterface[0] : 0x01

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x82 (Direction=IN  EndpointID=2)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize           : 0x08 (8 bytes)
bInterval                : 0x10 (16 ms)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x0A (CDC-Data)
bInterfaceSubClass       : 0x00
bInterfaceProtocol       : 0x00
iInterface               : 0x05
 *!*  string descriptors are not available because device is in low power state

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x01 (Direction=OUT  EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=IN  EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x02
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x08 (Mass Storage)
bInterfaceSubClass       : 0x06 (SCSI transparent command set)
bInterfaceProtocol       : 0x50 (Bulk­Only Transport)
iInterface               : 0x05
 *!*  string descriptors are not available because device is in low power state

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x83 (Direction=IN  EndpointID=3)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x03 (Direction=OUT  EndpointID=3)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

Bug25705Config.zip

@thisiskeithb
Copy link
Member

thisiskeithb commented Apr 19, 2023

Using your configs with current bugfix-2.1.x (19b4ae8) on an SKR Mini E3 V1.2, I cannot replicate this.

Connection log & M503 output:

Connecting...
Printer is now online.
>>> M115
SENDING:M115
FIRMWARE_NAME:Marlin bugfix-2.1.x (Apr 18 2023 21:43:55) SOURCE_CODE_URL:github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender-3 EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
Cap:SERIAL_XON_XOFF:0
Cap:BINARY_FILE_TRANSFER:0
Cap:EEPROM:1
Cap:VOLUMETRIC:1
Cap:AUTOREPORT_POS:0
Cap:AUTOREPORT_TEMP:1
Cap:PROGRESS:0
Cap:PRINT_JOB:1
Cap:AUTOLEVEL:0
Cap:RUNOUT:0
Cap:Z_PROBE:0
Cap:LEVELING_DATA:1
Cap:BUILD_PERCENT:1
Cap:SOFTWARE_POWER:0
Cap:TOGGLE_LIGHTS:0
Cap:CASE_LIGHT_BRIGHTNESS:0
Cap:EMERGENCY_PARSER:1
Cap:HOST_ACTION_COMMANDS:0
Cap:PROMPT_SUPPORT:0
Cap:SDCARD:1
Cap:MULTI_VOLUME:0
Cap:REPEAT:0
Cap:SD_WRITE:1
Cap:AUTOREPORT_SD_STATUS:0
Cap:LONG_FILENAME:1
Cap:LFN_WRITE:0
Cap:CUSTOM_FIRMWARE_UPLOAD:0
Cap:EXTENDED_M20:1
Cap:THERMAL_PROTECTION:1
Cap:MOTION_MODES:0
Cap:ARCS:0
Cap:BABYSTEPPING:1
Cap:CHAMBER_TEMPERATURE:0
Cap:COOLER_TEMPERATURE:0
Cap:MEATPACK:0
Cap:CONFIG_EXPORT:0

Here's the binary that was generated: Issue-25705-firmware_bin.zip

The onboard SD card also shows up under macOS & Windows.


Delete the hidden .pio folder at the root of your Marlin project and try compiling again.

If that doesn't work:

  1. Delete the hidden .platformio folder from your User directory:

    • Windows: %USERPROFILE%\.platformio\
    • macOS, Unix, Unix-like: ~/.platformio/
  2. Re-install PlatformIO.

@ThisIsMyGithubRepo
Copy link
Author

ThisIsMyGithubRepo commented Apr 19, 2023

Hmm @thisiskeithb oddness...
Using your firmware... a USB volume does appear, but the media on it is inaccessible (trying to view the volume contents brings up a "please insert a disk into USB Drive" error...
Meanwhile, the printer can view the SD card contents just fine.
That seems to be when things start to break - prior to trying to browse the media, the USB com port appears to work correctly. Afterwards, it dies.

I basically did this:

  1. Turned off the printer and rebooted my laptop (Win10).
  2. Turned on the printer with USB connected.
  3. A USB volume and COM port appeared.
  4. Connected via serial to the printer and issued a few commands, with good responses coming back.
  5. Inserted an SD card into the printer. Using the LCD, attached and browsed the files. Worked fine.
  6. Attempted to browse the media on the PC.
  7. "Insert a disk" error appears after ~20seconds.
  8. At this point the USB stops working...serial comms fail (with the port still open, serial returns "The operation was canceled" and attempting to disconnect/reconnect returns "A device attached to the system is not functioning"

Should be noted that once this has happened, it's like the USB device is remembered as broken.... subsequent reboots of the printer will not make a COM port appear (even though a USB device does connect). Connecting the printer to a different USB port will repeat the process.

Note: The above is all very likely what happened with my build too. The USB volume did appear, but wasn't browsable, that I know for sure, and the rest of the behaviour seems about right, I just hadn't figured it out yet.

Any suggestions at this point? I'll again note that my Marlin 2.0.x bugfix firmware (built from the branch around April 2021) is bulletproof on USB.

Here is what that USB reports as:

    =========================== USB Port4 ===========================

Connection Status        : Device is connected
Port Chain               : 3-3-1-4
Supported Protocols      : 0x03 (1.1, 2.0)
Properties               : 0x00
 IsUserConnectable       : no
 PortIsDebugCapable      : no

      ======================== USB Device ========================

        +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : USB Composite Device
Device Path              : \\?\usb#vid_1eaf&pid_0029#14000030#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
Device ID                : USB\VID_1EAF&PID_0029\14000030
Driver KeyName           : {36fc9e60-c465-11cf-8056-444553540000}\0024 (GUID_DEVCLASS_USB)
Driver                   : C:\WINDOWS\System32\drivers\usbccgp.sys (Version: 10.0.19041.2546  Date: 2023-02-19)
Driver Inf               : C:\WINDOWS\inf\usb.inf
Legacy BusType           : PNPBus
Class                    : USB
Service                  : usbccgp
Enumerator               : USB
Location Info            : Port_#0004.Hub_#0004
Container ID             : {6d9a1c31-7e6b-5775-89c4-363d2e82a675}
Manufacturer Info        : (Standard USB Host Controller)
Capabilities             : Removable, UniqueID, SurpriseRemovalOK
Address                  : 9   (*!*ERROR  Should be equal to the port number)
Problem Code             : 0
Power State              : D0 (supported: D0, D2, D3)
 Child Device 1          : USB Mass Storage Device
  Device ID              : USB\VID_1EAF&PID_0029&MI_00\F&1D2B8326&0&0000
  Class                  : USB
   Child Device 1        : Disk drive
    Device ID            : USBSTOR\DISK&VEN_STM&PROD_SD_FLASH_DISK&REV_1.0\10&1C03FEE0&0
    Class                : DiskDrive
     Volume              : \\?\Volume{25bed8b8-6213-11ed-a5c1-645d86a8afdf}\
     Kernel Name         : \Device\HarddiskVolume12
     Mountpoint          : E:\
 Child Device 2          : USB Serial Device
  Device ID              : USB\VID_1EAF&PID_0029&MI_01\F&1D2B8326&0&0001
  Class                  : Ports
  COM-Port               : COM3 (\Device\USBSER000)

        ---------------- Connection Information ---------------
Connection Index         : 0x04
Connection Status        : 0x01 (DeviceConnected)
Current Config Value     : 0x01
Device Address           : 0x09
Is Hub                   : 0x00 (no)
Number Of Open Pipes     : 0x05 (5)
Device Bus Speed         : 0x01 (Full-Speed)
Pipe0ScheduleOffset      : 0x00 (0)
Pipe1ScheduleOffset      : 0x00 (0)
Pipe2ScheduleOffset      : 0x00 (0)
Pipe3ScheduleOffset      : 0x00 (0)
Pipe4ScheduleOffset      : 0x00 (0)

        ------------------ Device Descriptor ------------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Descriptor)
bcdUSB                   : 0x200 (USB Version 2.00)
bDeviceClass             : 0x00 (defined by the interface descriptors)
bDeviceSubClass          : 0x00
bDeviceProtocol          : 0x01
bMaxPacketSize0          : 0x40 (64 bytes)
idVendor                 : 0x1EAF
idProduct                : 0x0029
bcdDevice                : 0x200
iManufacturer            : 0x01
 Language 0x0409         : "LeafLabs"
iProduct                 : 0x02
 Language 0x0409         : "Maple"
iSerialNumber            : 0x03
 *!*ERROR  string descriptor 3 not found
bNumConfigurations       : 0x01

        ------------------ String Descriptors -----------------
             ------ String Descriptor 0 ------
bLength                  : 0x04 (4 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language ID[0]           : 0x0409 (English - United States)
             ------ String Descriptor 1 ------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "LeafLabs"
             ------ String Descriptor 2 ------
bLength                  : 0x0C (12 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "Maple"

        -------------- Configuration Descriptor ---------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x0062 (98 bytes)
bNumInterfaces           : 0x03
bConfigurationValue      : 0x01
iConfiguration           : 0x00
bmAttributes             : 0xC0
 D7: Reserved, set 1     : 0x01
 D6: Self Powered        : 0x01 (yes)
 D5: Remote Wakeup       : 0x00 (no)
 D4..0: Reserved, set 0  : 0x00
MaxPower                 : 0x32 (100 mA)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x08 (Mass Storage)
bInterfaceSubClass       : 0x06 (SCSI transparent command set)
bInterfaceProtocol       : 0x50 (Bulk­Only Transport)
iInterface               : 0x00

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=IN  EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x02 (Direction=OUT  EndpointID=2)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x01 (ignored)

        ------------------- IAD Descriptor --------------------
bLength                  : 0x08 (8 bytes)
bDescriptorType          : 0x0B
bFirstInterface          : 0x01
bInterfaceCount          : 0x02
bFunctionClass           : 0x02 (Communications and CDC Control)
bFunctionSubClass        : 0x02
bFunctionProtocol        : 0x01
iFunction                : 0x02
 Language 0x0409         : "Maple"

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01
bAlternateSetting        : 0x00
bNumEndpoints            : 0x01 (1 Endpoints)
bInterfaceClass          : 0x02 (Communications and CDC Control)
bInterfaceSubClass       : 0x02
bInterfaceProtocol       : 0x01
iInterface               : 0x00

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x00 (Header Functional Descriptor)
bcdCDC                   : 0x1001 (CDC Version 10.01)

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x01 (Call Management Functional Descriptor)
bmCapabilities           : 0x03
bDataInterface           : 0x02

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x04 (4 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x02 (Abstract Control Management Functional Descriptor)
bmCapabilities           : 0x06

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x06 (Union Functional Descriptor)
bControlInterface        : 0x01
bSubordinateInterface[0] : 0x02

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x84 (Direction=IN  EndpointID=4)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize           : 0x10 (16 bytes)
bInterval                : 0xFF (255 ms)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x02
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x0A (CDC-Data)
bInterfaceSubClass       : 0x00
bInterfaceProtocol       : 0x00
iInterface               : 0x00

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x05 (Direction=OUT  EndpointID=5)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x83 (Direction=IN  EndpointID=3)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x40 (64 bytes)
bInterval                : 0x00 (ignored)

@thisiskeithb
Copy link
Member

The USB volume did appear, but wasn't browsable

No issues browsing the SD card contents on Windows or macOS.

Try a different SD card? USB cable?

For best results getting help with configuration and troubleshooting, please use the following resources:

After seeking help from the community, if the consensus points to a bug in Marlin, then you should post a bug report.

@ThisIsMyGithubRepo
Copy link
Author

Thanks @thisiskeithb

I went and did some more digging...I realize this works on your machine, which is admittedly confusing, however working in the 2.0.x bugfix branch, this is the exact PR that breaks composite USB on my machine/laptop combination:

...in that PR the onboard_sd.cpp file is modified, along with a bunch of SKR pin file stuff. That can't be a coincidence...

I'll try applying the changes from within that PR one by one to see if I can get the line of code that caused it.... obvious first thing I'll check is the onboard_sd.cpp which changed how the CS_HIGH is executed. it goes from:

#define OUT_WRITE(IO,V)         do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH); // Set CS# high

to:

#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high
#define WRITE(IO,V)             (PIN_MAP[IO].gpio_device->regs->BSRR = _BV32(PIN_MAP[IO].gpio_bit) << ((V) ? 0 : 16))
CS_HIGH()

....and I'll be honest I can't follow that CS_HIGH() alias just by looking at it...but...it seems different and I'm wondering if it's leaving some register bits in a weird state.

@ThisIsMyGithubRepo
Copy link
Author

Ok - so:
#22621 works as is.
#22628 does not work on my machine (the USB drive does not appear at all). BUT with the onboard_sd.cpp change reverted, it works again.

Now, taking the latest from the bugfix branch and undoing that onboard_sd.cpp doesn't fix the firmware for me.

So, my list of mysteries is:

  1. Pins cleanup, define some EXP1/2 #22628 makes the USB drive not appear, but at some point in the build history the USB drive will appear but will appear to not have a disk (to my PC).
  2. At some point the thing stops showing up as COM3 and starts showing up as COM5 on my PC... I'm assuming windows is trying to remember devices and matching COM ports to them...so maybe at some point the firmware starts "looking' different to windows....?

@ThisIsMyGithubRepo
Copy link
Author

Ok, so more digging:

#23685 also modifies ONBOARD_SD.CPP, with this change:

#if PIN_EXISTS(ONBOARD_SD_CS) && ONBOARD_SD_CS_PIN != SD_SS_PIN #define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low #define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high #else #define CS_LOW() #define CS_HIGH() #endif

Note that in my case, ONBOARD_SD_CS_PIN does equal SD_SS_PIN, so both CS_LOW() and CS_HIGH() will map to empty functions.

So...what has shaped up then is that:
#22621 modified how CS is set HIGH. That breaks the SD card over USB for me. Undoing that change makes it work...untill
#23685 modifies how CS is set LOW. That again brakes the SD card over USB.

If I undo both of those changes, and force the following mapping for CS_LOW() and CS_HIGH():

  #define CS_LOW()  WRITE(ONBOARD_SD_CS_PIN, LOW)  // Set OnboardSPI cs low
  #define CS_HIGH() OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH)

Then the SD card works again....

@ThisIsMyGithubRepo
Copy link
Author

ThisIsMyGithubRepo commented Apr 23, 2023

Ok @thisiskeithb:

Current bugfix 2.0 (as of 70c5bca8c287f36a77d97b1cfe402d9334339d46 does not work with the default config on my printer.

If I change Marlin/src/HAL/STM32F1/onboard_sd.cpp to make the following function mappings:

#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low
#define CS_HIGH() OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH)

Then it works again...so this appears to be something with how the firmware is interacting with the hardware on the board. I feel like I've demonstrated there is a bug here. Should this be re-opened? Or should a file a new and more specific bug?

I'll see if I can get the same result in the 2.1.x branch (but not today)

EDIT: Should note that the schematic for my board shows that the CS input for the SD card peripheral is wired to be pulled-high, and thus the STM32F1 needs to pull it down to activate it. I would guess the current 2.0.x branch is leaving the pin floating. I don't think that is a correct way to handle that pin?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants