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] Media Init Fail #26910

Closed
1 task done
raavhimself opened this issue Mar 26, 2024 · 6 comments
Closed
1 task done

[BUG] Media Init Fail #26910

raavhimself opened this issue Mar 26, 2024 · 6 comments

Comments

@raavhimself
Copy link

raavhimself commented Mar 26, 2024

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

Yes, and the problem still exists.

Bug Description

SD card doesn´t work- Screen messages say "Media Init Fail" in the status screen, and "No media" in the menu

Bug Timeline

It looks like it's always been there.

Expected behavior

I expected the SD card to work

Actual behavior

SD card cannot be initialized.

Steps to Reproduce

1- switch on
2- Insert card
3 - Card cannot be read

Version of Marlin Firmware

2.1.2.2., but I have tried with other versions with the same result

Printer model

Custom CNC

Electronics

Mega2560, RAMPS 1.4, RepRap Discount Full graphic Smart Controller

LCD/Controller

RepRap Discount Full graphic Smart Controller

Other add-ons

No other hardware involved

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

WhatsApp Image 2024-03-26 at 10 40 40

Marlin.zip
Marlinbugfix.zip

In order to check if the card was poorly formatted, or if there was any hardware issue, I have compiled and run the SD library example "Cardinfo", setting it to pin 49 of the RAMPS, and this is the output:

Initializing SD card...Wiring is correct and a card is present.
Card type: SDHC
Clusters: 3898368
Blocks x Cluster: 8
Total Blocks: 31186944
Volume type is: FAT32
Volume size (Kb): 15593472
Volume size (Mb): 15228
Volume size (Gb): 14.87
Files found on the card (name, date and size in bytes):
SYSTEM1/ 2024-03-25 23:06:52
WPSETT
1.DAT 2024-03-25 23:06:52 12
INDEXE~1 2024-03-25 23:06:54 76

Therefore, I'd say the SD card is working OK and card reader (embedded with the RepRap Graphic Controller) is also working OK

So I suppose there's either an issue with the FW or I am just terrible with my config, but I have been unable so far to find that big mistake.

I have posted here both the 2.1.2.2. config, (with SDSUPPORT) and version bugfix 2.1.x (with HAS_MEDIA). They behave exactly the same way.

Here is a summary of the SD commands as you'll find them in the Configuration.h and the Configuration_adv.h

#define SDSUPPORT

#if ENABLED(SDSUPPORT)
//#define SD_SPI_SPEED SPI_HALF_SPEED - I have tried full, half, a quarter and an eighth - same result
#define SD_PROCEDURE_DEPTH 1 // Increase if you need more nested M32 calls
#define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished
#define SD_FINISHED_RELEASECOMMAND "M84" // Use "M84XYE" to keep Z enabled so your bed stays in place
#define SDCARD_RATHERRECENTFIRST
#define SD_MENU_CONFIRM_START // Confirm the selected SD file before printing
#define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
#if ENABLED(PRINTER_EVENT_LEDS)
#define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination
#endif
#define SDCARD_CONNECTION LCD
#endif // SDSUPPORT

I think the only other modification I have made in the marlin code is a custom config menu to activate (or not) a laser cross with M42 P11 S255 (or S0), and also a custom bootscreen and a custom status screen image but these two lines have been commented in the files I have attached here.

@raavhimself
Copy link
Author

raavhimself commented Mar 26, 2024

I can see in file Marlin/scr/HAL/AVR/HAL_SPI.cpp the following - void spiBegin() {
#if PIN_EXISTS(SD_SS)
// Do not init HIGH for boards with pin 4 used as Fans or Heaters or otherwise, not likely to have multiple SPI devices anyway.
And as I am using PIN4 for Spindle enable, I have changed the following line to:
OUT_WRITE(SD_SS_PIN, LOW);
#endif
But this hasn´t worked either.
The PINS I am using are the following:
PIN D11 as an ONOFF switch for a laser cross
PIN D6 as Spindle PWM
PinD4 as Spindle ENA
PIN D1 and PIN D0 as TX RX for a ESP8266 wifi module - These needed nothing to be done in the firmware to work properly, but when the ESP3D is on, the USB gets disabled so the wifi module is unplugged while programming and testing

@raavhimself
Copy link
Author

Well, I can´t make it work. Don´t know why tthe issue closed

@raavhimself
Copy link
Author

I have found in file scr/sd/Sd2Card.cpp what looks like the code to initialize de SD card. There's a note which says /**

  • Initialize an SD flash memory card.
  • \param[in] sckRateID SPI clock rate selector. See setSckRate().
  • \param[in] chipSelectPin SD chip select pin number.
  • \return true for success, false for failure.
  • The reason for failure can be determined by calling errorCode() and errorData().
    */
    Unfortunately, I do not know how to use these two methods to diagnose the error.

@raavhimself
Copy link
Author

I have tried inserting in the same file
#include <Arduino.h>
#include <Serial.h>
Serial.begin();
and a couple of lines after the FAIL:
Serial.println (errorCode());
Serial.println (errorData());
to see if I can produce some output to diagnose the error through the serial port - but it looks like this is not the way to get these error codes

@raavhimself
Copy link
Author

It was hardware. The RAMPS 1.4 - For whatever reason PIN53 was faulty. I am very sorry to anyone who bothered to look into the issue

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 14, 2024
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