Tufty2040 SDIO SD card

I’d like to use the Adafruit SDIO SD breakout with the Tufty2040. The pads on the back have SWC and SWD, but I’m wondering if I can repurpose INT as a data pin. Is i2c_int doing something important on the Tufty2040?

Responding to my own post: I tried it, it’s not practical.

  1. SWD and SWC are dedicated programming pins, you can not repurpose them
  2. The rest of the pins do expose SPI0 pins however…
  3. SPI0 SCK is connected to the LCD backlight control pin on GPIO2, and the only other pin it can be mapped to is also in use by the LCD 8-bit interface
  4. To use GPIO2 you would have to cut very small traces and re-route SCK to the SD card adapter and then map either the RX or SCL pad to the backlight control pin

tl;dr don’t buy a Tufty2040 if you need to use an SD card.

Follow up:
It can be done!
Steps:

  • obtain a microsd adapter, preferably one which doesn’t have a regulator or level shifter (if it does, bypass the regulator and hook up power to 3.3V), and attach it to the back with double-sided tape
  • remove the 103 resistor pack between the MCU and the reset/program buttons (goodbye I2C)
  • sck will use gpio6 which is “SWA” (use the pad closest to the LCD)
  • mosi will use gpio7 which is the SCL pad
  • miso will use gpio4 which is the SDA pad
  • cs will use gpio5 which is “SW_DOWN” (use the pad closest to the LCD)

Use a fine pitch solid core wire, like wire-wrap wire. The buttons are wired to connect to 3.3V when pressed but otherwise have no pull-ups or pull-downs, so you can retain using them normally if you’re not using the sd card, just don’t press them when the sd card is operating.

This will set up the SD card on SPI0.

This library worked for me:

Example:

import machine
import sdcard
import uos

sd = sdcard.SDCard(0, 6, 7, 4, 5, led=25)
sd.detect(wait=True)

# Create a file and write something to it
with open("/sd/test01.txt", "w") as file:
    file.write("Hello, SD World!\r\n")
    file.write("This is a test\r\n")

# Open the file we just created and read from it
with open("/sd/test01.txt", "r") as file:
    data = file.read()
    print(data)

It works:

MicroPython 67fac4e on 2023-02-16; Pimoroni Tufty 2040 with RP2040
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
/sd Mounted
Hello, SD World!
This is a test

>>> 
1 Like