IkonoDim
IkonoDim

Reputation: 27

Why does readblocks() return only zeros when reading raw data from an SD card in MicroPython on ESP32-S3

I am working on a project using an ESP32-S3-CAM WROOM FREENOVE board and MicroPython v1.24.1. I need to read and write raw data directly to an SD card without using a filesystem, as the card has a capacity of 256GB and I want to utilize its full space. However, when I use readblocks(), it always returns a bytearray filled with 0x00.

Here is the code I'm using:

from machine import SDCard

sd = SDCard(sck=39, mosi=38, miso=40) 

data = bytearray(512) 

sd.readblocks(1, data)

print(data)

What I've Tried

  1. I wrote a text file containing some content onto the SD card using my PC to ensure there was data present.
  2. I verified that my readblocks() call aligns with the block size and block address conventions of the SD card.
  3. I tried using writeblocks() to see if I could modify the raw data on the SD card, but there was no observable effect.

Observations

Questions

  1. Why is readblocks() returning only zeros?
  2. Are there additional steps needed to properly configure the SD card for raw read/write access in MicroPython?
  3. Is there an issue with my hardware or the machine.SDCard implementation?

Additional Information

Any insights or suggestions would be appreciated. Let me know if more information is needed!

Upvotes: 1

Views: 33

Answers (0)

Related Questions