Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • YouTube
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

SG Community Forum

  1. Home
  2. Getting Started
  3. F1 Starter Kit
  4. How to access the micro-SD card on F1 starter kit?

How to access the micro-SD card on F1 starter kit?

Scheduled Pinned Locked Moved F1 Starter Kit
5 Posts 2 Posters 404 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jandls
    wrote on last edited by
    #1

    I tried to access the micro-SD card with the following script:

    import machine
    from machine import Pin
    
    sd = machine.SDCard(slot=1, width=4, sck=Pin(42), cmd=Pin(40), data=(Pin(41), Pin(18), Pin(17), Pin(16)), freq=20000000)
    

    But that gives the following error:

    >>> sd = machine.SDCard(slot=1, width=4, sck=Pin(42), cmd=Pin(40), data=(Pin(41), Pin(18), Pin(17), Pin(16)), freq=20000000)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: extra keyword arguments given`
    

    Also this does not work:

    >>> sd = machine.SDCard(slot=1, width=4, sck=42, cmd=40, data=(41, 18, 17, 16), freq=20000000)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: extra keyword arguments given
    

    From the schematic, I can see that the micro-SD card reader is connected as follows:
    CLK >> GPIO42
    CMD >> GPIO40
    DAT0 >> GPIO41
    DAT1 >> GPIO18
    DAT2 >> GPIO17
    DAT3 >> GPIO16

    Is that correct?
    From the explanation on link text I learned that for ESP32-S3 and using SD/MMC mode, slot 1 allows for the use of 4 data pins (width=4). Correct?

    1 Reply Last reply
    1
    • cehlersC Offline
      cehlersC Offline
      cehlers
      wrote on last edited by
      #2

      Hello @jandls,

      Please see the following from the MicroPython documentation:

      image.png

      Please note that on the Starter Kit, only 1 of the data pins is connected to the ESP32-S3 as anything else would require a hardware license from the SD Association. You would have to populate R506, R508 and R510 with 0Ohm resistors to connect the GPIO pins and if necessary R500-R502 for the pull-ups.

      3e223c30-2bd1-46a0-8c81-14ba4b42eb19-image.png

      On the starter kit, you can mount a FAT formatted SD Card like this:

      import machine
      sd = machine.SDCard()
      os.mount(sd, '/sd')
      os.listdir('/sd')
      

      The pins are hard coded but can be changed here: https://github.com/sg-wireless/sg-sdk/blob/main/src/platforms/F1/mpy-hooks/patches/machine_sdcard.c.patch on custom designs.

      F1 introduction video: https://youtu.be/8fsoL0ga_lo

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jandls
        wrote on last edited by
        #3

        Thanks very much! Yes, this works. In this way we are using the SPI protocol with only sck, miso and mosi connected (to GPIO42, 41 and 40, respectively).

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jandls
          wrote on last edited by
          #4

          It would be good if the documentation provided some more information on this hard coding that is done for the F1 starter kit, but that does not apply when the F1 is put on a custom board. There must still be other things that are hardcoded to make the F1 starter kit work, because when I try the following, it doesn’t work:

          >>> import machine, os
          >>> sd = machine.SDCard(slot=3, sck=42, miso=41, mosi=40)
          >>> os.mount(sd, '/sd')
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          OSError: 16
          
          

          The code that you gave works fine:

          >>> import machine
          >>> sd = machine.SDCard()
          >>> os.mount(sd, '/sd')
          >>> os.listdir('/sd')
          ['System Volume Information', 'rain.csv', 'sensor.csv', 'waterlevel.csv']
          
          
          1 Reply Last reply
          1
          • cehlersC Offline
            cehlersC Offline
            cehlers
            wrote on last edited by
            #5

            These are the defaults when using SPI mode according to the MicroPython source code ext/micropython/ports/esp32/machine_sdcard.c

                if (is_spi) {
                    // SPI interface
                    #if CONFIG_IDF_TARGET_ESP32S3
                    STATIC const sdspi_slot_config_t slot_defaults[2] = {
                        {
                            .gpio_miso = GPIO_NUM_36,
                            .gpio_mosi = GPIO_NUM_35,
                            .gpio_sck = GPIO_NUM_37,
                            .gpio_cs = GPIO_NUM_34,
                            .gpio_cd = SDSPI_SLOT_NO_CD,
                            .gpio_wp = SDSPI_SLOT_NO_WP,
                            .dma_channel = 2
                        },
                        SDSPI_SLOT_CONFIG_DEFAULT()
                    };
            

            F1 introduction video: https://youtu.be/8fsoL0ga_lo

            1 Reply Last reply
            0

            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • YouTube