Teensy 4.1 SDIO direct multi-sector reads, no FAT

jammux

New member
Hoping someone can get me started. As post title says, I wish to perform multi-sector (either 4, 8 or 16) SDIO reads directly to memory using Teensy 4.1. I don't need FAT file system support. Looking at the code in SdioTeensy.cpp, it looks as though some multi-sector read requests end up simply doing "n" single sector reads, which is not what I want. How to I make sure that when I read more than one sector, it's only a single SD operation? Also, not sure where to start since FAT support seems interwoven into the SdFat code, and I just want to read sectors directly. Thanks.
 
I would look at the BlockDeviceInterface or in current version FsBlockDeviceInterface and see if it works for you.

The header file has a few different read operations available:
Code:
  /**
   * Read a sector.
   *
   * \param[in] sector Logical sector to be read.
   * \param[out] dst Pointer to the location that will receive the data.
   * \return true for success or false for failure.
   */
  virtual bool readSector(uint32_t sector, uint8_t* dst) = 0;

  /**
   * Read multiple sectors.
   *
   * \param[in] sector Logical sector to be read.
   * \param[in] ns Number of sectors to be read.
   * \param[out] dst Pointer to the location that will receive the data.
   * \return true for success or false for failure.
   */
  virtual bool readSectors(uint32_t sector, uint8_t* dst, size_t ns) = 0;

  /**
   * Read multiple sectors with callback as each sector's data
   *
   * \param[in] sector Logical sector to be read.
   * \param[in] ns Number of sectors to be read.
   * \param[out] dst Pointer to the location that will receive the data.
   * \param[in] callback Function to be called with each sector's data
   * \param[in] context Pointer to be passed to the callback function
   * \return true for success or false for failure.
   */
  virtual bool readSectorsCallback(uint32_t sector, uint8_t* dst, size_t ns,
   void (*callback)(uint32_t sector, uint8_t *buf, void *context), void *context) {
     for (size_t i = 0; i < ns; i++) {
       if (!readSector(sector + i, dst)) return false;
       callback(sector + i, dst, context);
     }
     return true;
  }

Then I that if you then setup the destination address to the constraints of the destination adders & 3 == 0... then it will I believe try to DMA the data...
But again I have not tried this...
 
About 3 years ago, I made a FAT free FS called ZeroFS
https://github.com/WMXZ-EU/zeroFS
Not that I suggest you to use this, but it may be easier to digest what I did than analysing FatFs
In general
you only have to initialize SdDisk, and then you can basic read/write commands
 
I would look at the BlockDeviceInterface or in current version FsBlockDeviceInterface and see if it works for you.

Thanks for the info. With the latest TeensyDuino installation, the hardware/teensy/avr/libraries/SdFat folder does not have FsBlockDeviceInterface, but I see that the greiman/SdFat GitHub repo does. Does this mean I should update the TeensyDuino SdFat? Not clear about where the official Teensy 4.1 SdFat lives...
 
Back
Top