MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.17k stars 19.21k forks source link

--> Using both SD2CARD_SDIO and SD2CARD_SPI… And being able to use card.changemedia to select them #25197

Open OneMonkeyArmy opened 1 year ago

OneMonkeyArmy commented 1 year ago

Is your feature request related to a problem? Please describe.

By simply adding #define SDIO_SUPPORT in configuration.h , I have full access to my onboard micro SD_CARD(sdio)... but my SD CARD is disabled...

To have access to my SD CARD, I have to comment // #define SDIO_SUPPORT, then MY SD CARD is available, but of course the micro sd-card(sdio) is no longer...

IT will be very usefull to add the possibility to have both.. and use card.changemedia(), to switch from one to the other....

Are you looking for hardware support?

No response

Describe the feature you want

By simply adding #define SDIO_SUPPORT in configuration.h , I have full access to my onboard micro SD_CARD(sdio)... but my SD CARD is disabled...

To have access to my SD CARD, I have to comment // #define SDIO_SUPPORT, then MY SD CARD is available, but of course the micro sd-card(sdio) is no longer...

IT will be very usefull to add the possibility to have both.. and use card.changemedia(), to switch from one to the other....

Additional context

No response

OneMonkeyArmy commented 1 year ago

Done... no help needed !!!

added in configuration.h

define SDIO_SUPPORT

changed in cardreader.h ......

REMOVED:

if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI

 typedef TERN(NEED_SD2CARD_SDIO, DiskIODriver_SDIO, DiskIODriver_SPI_SD) sdcard_driver_t;
 static sdcard_driver_t media_driver_sdcard;
#endif

ADDED:

if NEED_SD2CARD_SPI

typedef DiskIODriver_SPI_SD sdcard_driver_t;
static sdcard_driver_t media_driver_sdcard;

endif

ADDED:

if NEED_SD2CARD_SDIO

typedef DiskIODriver_SDIO sdiocard_driver_t;
static sdiocard_driver_t media_driver_sdiocard;

endif

changed in cardreader.cpp ......

REMOVED:

if NEED_SD2CARD_SDIO || NEED_SD2CARD_SPI

CardReader::sdcard_driver_t CardReader::media_driver_sdcard;

endif

ADDED:

if NEED_SD2CARD_SPI

CardReader::sdcard_driver_t CardReader::media_driver_sdcard;

endif

ADDED:

if NEED_SD2CARD_SDIO

CardReader::sdiocard_driver_t CardReader::media_driver_sdiocard;

endif

and in conditionals_post.h

if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD)

#if ENABLED(SDIO_SUPPORT)
  #define NEED_SD2CARD_SDIO 1
  #define NEED_SD2CARD_SPI 1      // added this line
#else
  #define NEED_SD2CARD_SPI 1
#endif

endif

also changed in SdVolume.h

REMOVED:

if NEED_SD2CARD_SDIO

include "Sd2Card_sdio.h"

elif NEED_SD2CARD_SPI

include "Sd2Card.h"

endif

ADDED:

if NEED_SD2CARD_SDIO

include "Sd2Card_sdio.h"

endif

ADDED:

if NEED_SD2CARD_SPI

include "Sd2Card.h"

endif

and finally in configuration_adv.h

CHANGED the DEFAULT_SHARED_VOLUME to SV_SD_ONBOARD ...

define MULTI_VOLUME

if ENABLED(MULTI_VOLUME)

#define VOLUME_SD_ONBOARD
#define VOLUME_USB_FLASH_DRIVE
#define DEFAULT_VOLUME SV_SD_ONBOARD
#define DEFAULT_SHARED_VOLUME SV_SD_ONBOARD    // SV_USB_FLASH_DRIVE

endif

only have to use ...

card.changeMedia(&card.media_driver_sdcard); // to use external SD CARD or card.changeMedia(&card.media_driver_sdiocard); // to use internal (on board) micro sd card (sdio)

then card.mount();

Probably forgot a few things, but it is a starting point! A WORKING solution, just waiting to be improved by someone !!

OneMonkeyArmy commented 1 year ago

I have solved the problem long ago... I handle the volumes and the file manipulation like the good old DOS !!! All that on the serial with the Gcode... From Repetier , Octoprint ... also have support for USB flash drive ...

image image