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

No SD_CHECK_AND_RETRY with USE_USB_COMPOSITE (STM32F103 + SDIO) #18108

Merged

Conversation

Bob-the-Kuhn
Copy link
Contributor

@Bob-the-Kuhn Bob-the-Kuhn commented May 25, 2020

SD_CHECK_AND_RETRY is not compatible with USE_USB_COMPOSITE. The resulting virtual drive causes error popups on the PC and is eventually disabled by the PC.

This fixes Issue #18097.

The proposed change is to append !ENABLED(USE_USB_COMPOSITE) to #if ENABLED(SD_CHECK_AND_RETRY) in Sd2Card.cpp.

The only other effective change I found was adding a check to SanityCheck.h.

/**
 * STM32F1xx boards with SDIO have run time errors if SD_CHECK_AND_RETRY and USE_USB_COMPOSITE are both enabled.
 */
#if ALL(SDSUPPORT, SD_CHECK_AND_RETRY, USE_USB_COMPOSITE, __STM32F1__ ) && SD_CONNECTION_IS(ONBOARD) && ANY(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
  #error "Disable SD_CHECK_AND_RETRY. Retries and CRC automatically implemented.
#18018 

Adding a #undef SD_CHECK_AND_RETRY to the pins_YOUR_BOARD.h files or to sdio.cpp did not work.


USE_USB_COMPOSITE is only available in the following environments:

  • STM32F103RC_btt_USB
  • STM32F103RC_btt_512K_USB
  • STM32F103RE_btt_USB

These are used only with the following boards:

  • BTT_SKR_MINI_V1_1
  • BTT_SKR_MINI_E3_V1_0
  • BTT_SKR_MINI_E3_V1_2
  • BTT_SKR_E3_DIP

@sjasonsmith
Copy link
Contributor

I personally like compiler errors when incompatible options are used, so people know a feature isn’t going to work as expected.

@Bob-the-Kuhn
Copy link
Contributor Author

Marlin has gone both ways on the decision of compiler error vs. change code. Scott will let us know which way he wants it. In this instance I don't have a strong opinion either way.

FYI - the functionality of SD_CHECK_AND_RETRY is already in the code enabled by USE_USB_COMPOSITE.

@thinkyhead thinkyhead changed the title disable SD_CHECK_AND_RETRY when USE_USB_COMPOSITE is enabled (STM32F103 boards using SDIO) No SD_CHECK_AND_RETRY with USE_USB_COMPOSITE (STM32F103 + SDIO) May 25, 2020
@thinkyhead
Copy link
Member

thinkyhead commented May 25, 2020

True, we have a few different approaches on the menu…

  • A sanity check most explicitly tells users all about the condition and makes them change it. Best approach when users need to know to be careful or they might blow something up.
  • A conditional that silently (or with #warning) turns off the incompatible setting. OK as a middle ground when users ought to know for safety or for setup purposes.
  • A conditional that silently disables the setting. Fine when an option is basically N/A and can be ignored.

In this case the option is sort-of N/A so silently disabling SD_CHECK_AND_RETRY makes sense. (In that case, the option means "bring in Marlin's own check-and-retry code.")

One other consideration is whether the chosen approach helps in "the Marlin encyclopedia project," where we treat Marlin as a "reference guide" to document the relationship between all these chips, their pins, common peripherals, libraries, and custom software routines all in one codebase. Considering that aspect it's better to have these kinds of checks in the 'Conditional' files — either the global one or just the affected HALs'.

@thinkyhead thinkyhead merged commit 6c99400 into MarlinFirmware:bugfix-2.0.x May 26, 2020
vgadreau pushed a commit to vgadreau/Marlin that referenced this pull request May 29, 2020
…inFirmware#18108)

* disable SD_CHECK_AND_RETRY when USE_USB_COMPOSITE is enabled

* Update Sd2Card.cpp

* Disable SD_CHECK_AND_RETRY with USE_USB_COMPOSITE

Co-authored-by: Scott Lahteine <[email protected]>
Co-authored-by: Scott Lahteine <[email protected]>
@Bob-the-Kuhn Bob-the-Kuhn deleted the SD_CHECK_AND_RETRY branch June 8, 2020 16:45
jmp0x0000 pushed a commit to jmp0x0000/Marlin that referenced this pull request Aug 7, 2020
…inFirmware#18108)

* disable SD_CHECK_AND_RETRY when USE_USB_COMPOSITE is enabled

* Update Sd2Card.cpp

* Disable SD_CHECK_AND_RETRY with USE_USB_COMPOSITE

Co-authored-by: Scott Lahteine <[email protected]>
Co-authored-by: Scott Lahteine <[email protected]>
HairingX pushed a commit to HairingX/Marlin that referenced this pull request Jun 16, 2021
…inFirmware#18108)

* disable SD_CHECK_AND_RETRY when USE_USB_COMPOSITE is enabled

* Update Sd2Card.cpp

* Disable SD_CHECK_AND_RETRY with USE_USB_COMPOSITE

Co-authored-by: Scott Lahteine <[email protected]>
Co-authored-by: Scott Lahteine <[email protected]>
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.

3 participants