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

[2.0.x] Anet A8 SD still not working #8746

Closed
Phr3d13 opened this issue Dec 11, 2017 · 19 comments
Closed

[2.0.x] Anet A8 SD still not working #8746

Phr3d13 opened this issue Dec 11, 2017 · 19 comments
Labels
C: Boards/Pins Needs: Work More work is needed T: HAL & APIs Topic related to the HAL and internal APIs.

Comments

@Phr3d13
Copy link
Contributor

Phr3d13 commented Dec 11, 2017

  • Description: SD Not Working

  • Expected behaviour: SD card initialised/read and contents displayed

  • Actual behaviour: Prolonged part cooling fan spin, no sd detected

  • Steps to reproduce:

    • Flash 2.0.x bugfix
    • Insert SD
    • Power On

Anet A8 Marlin 2.0 default configs.zip

@thinkyhead thinkyhead added Needs: Work More work is needed T: HAL & APIs Topic related to the HAL and internal APIs. C: Boards/Pins labels Dec 14, 2017
@thinkyhead
Copy link
Member

Does it work with bugfix-1.1.x then?

@Phr3d13
Copy link
Contributor Author

Phr3d13 commented Dec 27, 2017

Yes.

@Phr3d13
Copy link
Contributor Author

Phr3d13 commented Dec 30, 2017

Can confirm still happening with bugfix-2.0.x from 12/29/17, and still works with bugfix-1.1.x from 12/29/17

@Phr3d13
Copy link
Contributor Author

Phr3d13 commented Jan 6, 2018

Anyone have any ideas as to where I should start looking to squash this bug?

@thinkyhead
Copy link
Member

A lot of changes to the 2.0.x work branch lately. Has this issue been resolved yet?

@Phr3d13
Copy link
Contributor Author

Phr3d13 commented Feb 11, 2018 via email

@MikeLud
Copy link
Contributor

MikeLud commented Feb 16, 2018

Thinkyhead,

I am using a 2.0.x that was downloaded today and the SD card still is not working

@thinkyhead
Copy link
Member

There are some clear differences in Sd2Card.cpp so that's where I'd expect the trouble to be. I'm not sure why it only affects Anet A8's, but by process of elimination — replacing new (2.0) bits of code with old (1.1) bits of code — it should be possible to narrow down the culprit.

@MikeLud
Copy link
Contributor

MikeLud commented Feb 25, 2018 via email

@thinkyhead
Copy link
Member

I would test it myself, but all my SD card readers work fine with 2.0.x at this time. If you feel ambitious you can try tweaking the code in Sd2Card.cpp and see if anything shakes out.

@thinkyhead
Copy link
Member

Also, don't forget to play around with the various SD card-related settings like check-and-retry, etc.

@benlye
Copy link
Contributor

benlye commented Feb 25, 2018

I dusted off my old Anet board to see if I could help with this problem. I can confirm that I was able to reproduce it right away.

First stop was pins debugging, but on bugfix-1.0.x I get garbage output from M43, e.g.:

PIN:   4   Port: B4        �������TXD                  protected 
.                          ���                         protected 
.                          ������������

���          protected 

On bugfix-2.0.x it looks sane:

PIN:   4   Port: B4        AVR_SS_PIN                             protected
.              FAN_PIN                                protected
.              SS_PIN                                 protected

@Bob-the-Kuhn, any pointers? Is this a known issue with M43 on bugfix-1.1.x?

Compiling with PlatformIO in VS Code, if that makes any difference.

@benlye
Copy link
Contributor

benlye commented Feb 26, 2018

@thinkyhead pushed some commits for pin debuggung and that now 'works' (the output is no longer garbage, but the pin readings still look odd - that's a conversation for another issue).

Anyhoo, I figured out how to make the Anet SD card work.

I have no idea what effect this has on other boards, but I suspect it may fix #9209 as well.

At line line 253 of Sd2Card.cpp, insert this:

pinMode(chipSelectPin_, OUTPUT);

So that it looks like this:

//todo: should use chipSelectPin ?
  pinMode(chipSelectPin_, OUTPUT);
  spiBegin();

  // set SCK rate for initialization commands
  spiRate_ = SPI_SD_INIT_RATE;
  spiInit(spiRate_);

I suppose the pinMode call could go inside the spiBegin function, but that's beyond my pay grade.

@benlye
Copy link
Contributor

benlye commented Feb 26, 2018

Just tested my change on a RAMPS board with RRDFG Smart Controller and it didn't seem to cause anything adverse - SD is detected, mounted, read as expected.

@thinkyhead
Copy link
Member

Thanks immensely @benlye — How did we miss that comment? Marlin 1.1.x clearly sets the pin to an output, and why it was dropped for 2.0.x is a mystery.

@thinkyhead
Copy link
Member

thinkyhead commented Feb 26, 2018

Looking at 4b16fa3 I can see why @p3p left it out, since the SPI pins are otherwise pre-defined. On the other hand there should have been no harm in leaving the line setting the passed pin as an output. And now we know, it's better. Well I'm utterly relieved this is sorted out. Only a few small things remain before we can put out 1.1.9.

@MikeLud
Copy link
Contributor

MikeLud commented Feb 27, 2018 via email

@RamonPanganiban
Copy link

I just upgraded to marlin 1.1.9 on anet a8 and lost my sd card. been browsing on solutions and found this thread. I looked at sd2card.cpp and can't find where spi is invoked as in " spiBegin();"
No errors on compile and upload in arduino though. I am missing out on something, so i cannot try benlye's solution above.

@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 Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: Boards/Pins Needs: Work More work is needed T: HAL & APIs Topic related to the HAL and internal APIs.
Projects
None yet
Development

No branches or pull requests

5 participants