Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED Using sd card on m5stack
Does anyone have the sd card and display both working on an m5stack (with psram)?  If so, can you share the configuration.
(03-21-2018, 05:49 PM)slzatz Wrote: Does anyone have the sd card and display both working on an m5stack (with psram)?  If so, can you share the configuration.

Use the following initialization:

import machine, display, uos

# SDCard configuration for M5Stack
>>> uos.sdconfig(uos.SDMODE_SPI, clk=18, mosi=23, miso=19, cs=4)
>>> os.mountsd()
Mode: SPI
Name: SU08G
Speed: default speed (25 MHz)
Size: 7580 MB
 CSD: ver=1, sector_size=512, capacity=15523840 read_bl_len=9
 SCR: sd_spec=2, bus_width=5

>>> tft = display.TFT()
# Display configuration for M5Stack
>>> tft.init(tft.M5STACK, width=240, height=320, rst_pin=33, backl_pin=32, miso=19, mosi=23, clk=18, cs=14, dc=27, bgr=True, backl_on=1, rot=tft.LANDSCAPE)
>>> tft.image(0,0,'/sd/test1.jpg')

There are some issues with using SPI and SDCard in SPI mode at the same time in esp-idf.
I've had to use a special SPI handling to solve it.
As a result, it now works without problem, except that displaying images from sdcard is performed without using DMA and is much slower than from internal filesystem. All other display functions runs with the same performance.

Tested with M5Stack 2018 with psRAM, but should also work on any M5Stack without psRAM.
Boris, worked perfectly. Thanks, Steve
OK. Declared the problem solved a little prematurely.

The issue is that tft.image(...) does not display anything on the m5stack screen.  Text displays fine but when I try to display an image the call just returns and nothing happens.

This is what I have tried:

1) Made sure the jpg image was baseline only.
2) Tested a small 240 x 240 image
3) Moved the image from the sd card to flash
4) Tried a bitmap image instead of a jpg
5) ran jpegtran on the image

When I do file on the image, I get:

test_image.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 240x240, frames 1

The fact that tft.image(...) just returns silently seems a little odd but, in any event, this is the first time that I had tried to display an image (as opposed to text, which works fine) on the m5stack.  I am running current software (although not updated to the last commit related to LittleFS).

Any thoughts would be much appreciated.
There are some limitations for images, from Wiki:

  • JPG images are supported.
    Baseline only. Progressive and Lossless JPEG format are not supported.Image size: Up to 65520 x 65520 pixelsColor space: YCbCr three components only. Gray scale image is not supported.Sampling factor: 4:4:4, 4:2:2 or 4:2:0.
  • BMP images are supported.
    Only uncompressed RGB 24-bit with no color space information BMP images can be displayed.

Attached is one of the files tested to work both from sdcard and internal fs.

Attached Files Thumbnail(s)
Thanks. That worked.  I'll try to figure out what the issue is with the image I was testing with.

Forum Jump:

Users browsing this thread: 1 Guest(s)