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

SDIO storage Read/write, M21, and print from media menu selectable access #25683

Open
wants to merge 26 commits into
base: bugfix-2.1.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
152c3c6
Update SdVolume.h
ansonl Apr 15, 2023
173c007
Update Conditionals_post.h
ansonl Apr 15, 2023
7fda542
Update cardreader.h
ansonl Apr 15, 2023
8f41dcf
Update cardreader.cpp
ansonl Apr 15, 2023
7a40ece
Update language_en.h
ansonl Apr 15, 2023
a5f50bd
Update menu_media.cpp
ansonl Apr 15, 2023
7978fc7
Update Configuration.h
ansonl Apr 15, 2023
0146597
Update Configuration_adv.h
ansonl Apr 15, 2023
20d800f
Update cardreader.h
ansonl Apr 15, 2023
b9a919c
Update M21_M22.cpp
ansonl Apr 15, 2023
71aed05
already defined in configuration_adv.h
thinkyhead Apr 16, 2023
64f6773
Tweaks to M21
thinkyhead Apr 16, 2023
7cdecba
shared lambda
thinkyhead Apr 16, 2023
baf4fbe
DEFAULT_VOLUME is obsolete
thinkyhead Apr 16, 2023
b9e9627
Merge branch 'MarlinFirmware:bugfix-2.1.x' into sdio-support
ansonl Apr 19, 2023
14da059
Refactor code for user friendly onboard SD label
ansonl Apr 20, 2023
79cb734
Add external SD card label option
ansonl Apr 20, 2023
51e9ee3
Update Configuration.h
ansonl Apr 20, 2023
7a2bd81
Update Configuration_adv.h
ansonl Apr 20, 2023
42be78d
Update Conditionals_post.h
ansonl Apr 20, 2023
7ce7d97
Update cardreader.h
ansonl Apr 20, 2023
f4160ec
cleanup
thinkyhead Apr 20, 2023
b806822
Merge branch 'MarlinFirmware:bugfix-2.1.x' into sdio-support
ansonl Apr 20, 2023
16da160
Merge branch 'bugfix-2.1.x' into pr/25683
thinkyhead Aug 4, 2023
4eaab03
Merge branch 'bugfix-2.1.x' into pr/25683
thinkyhead Oct 26, 2023
852fd6f
Merge branch 'bugfix-2.1.x' into pr/25683
thinkyhead Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Conditionals_post.h
Try to fix CI error
  • Loading branch information
ansonl authored Apr 20, 2023
commit 42be78dd4c12a9083c31be6acf81cf3dfc5868ab
4 changes: 2 additions & 2 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@
#if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD)
#if ENABLED(SDSUPPORT)
#define NEED_SD2CARD_SPI 1
#if ENABLED(SDIO_SUPPORT)
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDSUPPORT option is used as the flag for any and all media types, not just SD Cards. If SDSUPPORT is not enabled, none of the file access code (e.g., cardreader.cpp) will be compiled in. So the code needs to be reworked a lot more if the intent is to make SDSUPPORT only refer to SPI-based SD cards.

Since it is possible to have both onboard and external media drives, we would also need to rework the code to remove the assumption that there is only one SD card, either ONBOARD, LCD, or CUSTOM_CABLE.

Copy link
Contributor Author

@ansonl ansonl Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have SD_SPI_STORAGE, SD_SDIO_STORAGE, and USBFLASH_STORAGE options underneath that requires SDSUPPORT to be defined. I see that there are currently 3 media_driver_X types implemented:

  1. media_driver_usbFlash (USB)
  2. media_driver_sdcard (SPI)
  3. media_driver_sdiocard (SDIO)

Even though the location of the SD slots may be onboard or on LCD to the user, the access method for the SD slots can vary between all three methods no matter where the slots physically are. There is a maximum of one SD slot connected for each media_driver_X type, I think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current assumptions are probably a little constrained. As I've been working on separating out the LCD pins in another PR I've become better acquainted with the way that SD Card pins are allocated, either with or without an LCD controller. Here we have a number of different possibilities.

  • Onboard SD Card drive with dedicated pins, sometimes but not always the native Hardware SPI.
  • Onboard SD Card drive with SDIO, so the card can be released by Marlin and seen by the host PC over USB.
    • I'm not sure whether SPI-based SD Cards can be shared in this way.
  • No onboard SD Card drive, but the LCD has one, usually sharing SPI pins with the (SPI-based) LCD.
  • No onboard SD Card drive, but an SD Card can be added. With native Hardware SPI or Software SPI.
  • Onboard USB Flash Drive is rare, but I have a board or two with one. Presumably Hardware SPI.
    • I'm not sure whether any board has SDIO Flash Drive, or if SDIO is a thing for Flash Drives.
    • I'm not sure whether SPI or SDIO Flash Drives can be released and seen by the host PC over USB.

Right now pins files tend to follow the configuration of the original machine they came with, so if there is an LCD Controller with an SD Card drive, the pins file assumes that the presence of an LCD indicates the use of the SD Card drive on the LCD. Most pins files allow that to be overridden.

The "Custom Cable" option for SD Card drives is handled by very few pins files, and it could be better. If you define your own SPI pins (with SD_ prefix) and use CUSTOM_CABLE then pins files should allow it, but the logic is not there.

There is a lot of overlap between the allocation of pins for the LCD and SD, so it might be good to tackle these two problems at the same time or in a similar manner. See #25650 for that little project, which is coming along slowly but steadily. There I'm trying to weed out assumptions about whether Software or Hardware SPI is used, but also trying to see if that can be based on the chosen pins. i.e., If the pins are not the standard SPI0, SPI1, etc., then we can assume Software-based SPI for that drive.

#if ENABLED(SDIO_SUPPORT)
#define NEED_SD2CARD_SDIO 1
#endif
#endif
#endif

#if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2)
Expand Down