sle118 / squeezelite-esp32

ESP32 Music streaming based on Squeezelite, with support for multi-room sync, AirPlay, Bluetooth, Hardware buttons, display and more
1.07k stars 100 forks source link

ILI9341 display only works during initialization #280

Closed lelithium closed 10 months ago

lelithium commented 10 months ago

Hi !

My ILI9341 display works, but only during the initialization code. When I reset the device, the display flashes to reset, then displays SqueezeESP32, and that's it.

Display: ILI9341 2.8" SPI https://www.amazon.fr/dp/B07YTWRZGR Board: ESP32 "audio kit" 2.2 (with ES8388 DAC) https://docs.ai-thinker.com/en/esp32-audio-kit

Connected through (omitting VCC, GND, LED): Screen pin ESP GPIO
CS 0
Reset 23
DC 5
MOSI 18
SCK 13
MISO 22

Note that MISO seems to not be needed to display the SqueezeESP32 text.

My (current, see explanations below) NVS config for display/GPIO related things:

Key Value
dac_config model=ES8388,bck=27,ws=25,do=26,sda=33,scl=32,di=35,i2c=16
display_config SPI:width=320,height=240,cs=0,reset=23,speed=1000000,driver=ILI9341
set_GPIO 21=amp,39=jack:0
spi_config mosi=18,clk=13,dc=5,host=1,miso=22

I've tried different things:

I think I might be missing something obvious here in the config (this is my first SqueezeLite32). I followed the pinout from this blog post first, which is a different display, but still SPI, and that works https://ale.cx/ALEX/2021/01/esp32-audio-kit-with-squeezelite-esp32/.

The fact that I can get something to display seems to point out that the display connection is, in fact, working. I guess there's something tying one of the pins after that to GND or VCC, which would prevent the screen from receiving its SPI data, but I have no clue where to start.

Full logs, from reset to Bluetooth connection + play

Unroll ``` rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:6424 load:0x40078000,len:15632 load:0x40080400,len:4348 entry 0x40080688 I (27) boot: ESP-IDF v4.3.5-dirty 2nd stage bootloader I (27) boot: compile time 05:15:25 I (27) boot: chip revision: v3.0 I (31) qio_mode: Enabling default flash chip QIO I (36) boot.esp32: SPI Speed : 80MHz I (41) boot.esp32: SPI Mode : QIO I (45) boot.esp32: SPI Flash Size : 4MB I (50) boot: Enabling RNG early entropy source... I (55) boot: Partition Table: I (59) boot: ## Label Usage Type ST Offset Length I (66) boot: 0 nvs WiFi data 01 02 00009000 00004000 I (74) boot: 1 otadata OTA data 01 00 0000d000 00002000 I (81) boot: 2 phy_init RF data 01 01 0000f000 00001000 I (89) boot: 3 recovery factory app 00 00 00010000 00140000 I (96) boot: 4 ota_0 OTA app 00 10 00150000 002a0000 I (104) boot: 5 settings WiFi data 01 02 003f0000 00010000 I (111) boot: End of partition table I (115) esp_image: segment 0: paddr=00150020 vaddr=3f400020 size=adfa4h (712612) map I (320) esp_image: segment 1: paddr=001fdfcc vaddr=3ffbdb60 size=0204ch ( 8268) load I (323) esp_image: segment 2: paddr=00200020 vaddr=400d0020 size=1afa08h (1767944) map I (813) esp_image: segment 3: paddr=003afa30 vaddr=3ffbfbac size=039c0h ( 14784) load I (818) esp_image: segment 4: paddr=003b33f8 vaddr=40080000 size=1e1cch (123340) load I (859) esp_image: segment 5: paddr=003d15cc vaddr=400c0000 size=00068h ( 104) load I (874) boot: Loaded app from partition at offset 0x150000 I (874) boot: Disabling RNG early entropy source... I (886) psram: This chip is ESP32-D0WD I (886) spiram: Found 64MBit SPI RAM device I (886) spiram: SPI RAM mode: flash 80m sram 80m I (889) spiram: PSRAM initialized, cache is in low/high (2-core) mode. I (896) cpu_start: Pro cpu up. I (900) cpu_start: Starting app cpu, entry point is 0x400813ec I (0) cpu_start: App cpu up. I (1405) spiram: SPI SRAM memory test OK I (1418) cpu_start: Pro cpu start user code I (1418) cpu_start: cpu freq: 240000000 I (1418) cpu_start: Application information: I (1421) cpu_start: Project name: Squeezelite-ESP32 I (1427) cpu_start: App version: I2S-4MFlash-1334 I (1433) cpu_start: Compile time: Aug 5 2023 05:17:54 I (1439) cpu_start: ELF file SHA256: 0000000000000000... I (1445) cpu_start: ESP-IDF: v4.3.5-dirty I (1450) cpu_start: Min chip rev: v1.0 I (1455) cpu_start: Max chip rev: v3.99 I (1460) cpu_start: Chip rev: v3.0 I (1465) heap_init: Initializing. RAM available for dynamic allocation: I (1472) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM I (1478) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM I (1484) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM I (1491) heap_init: At 3FFC6E98 len 00019168 (100 KiB): DRAM I (1497) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (1503) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (1510) heap_init: At 4009E1CC len 00001E34 (7 KiB): IRAM I (1516) spiram: Adding pool of 4023K of external SPI memory to heap allocator I (1525) spi_flash: detected chip: generic I (1529) spi_flash: flash io: qio I (1536) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (1544) spiram: Reserving pool of 64K of internal memory for DMA/internal allocations I (1554) esp_app_main: System is booting from power on. I (1564) esp_app_main: Reset reason is: 1 I (1564) esp_app_main: Reboot counter=1 I (1564) esp_app_main: Starting app_main I (1574) nvs_utilities: Initializing flash nvs I (1594) nvs_utilities: Initializing nvs partition settings I (1634) esp_app_main: Setting up telnet. I (1634) telnet: Telnet support disabled I (1634) esp_app_main: Setting up config subsystem. W (1704) nvs_utilities: Configuration memory usage. Heap internal:228615 (min:228471) (used:216) external:4100119 (min:4092447) (used:15384) I (1714) esp_app_main: Registering default values I (1714) system_api: Base MAC address is not set I (1724) system_api: read default base MAC address from EFUSE W (1724) config: Waiting for config commit ... I (2714) config: configuration has some uncommitted entries I (2714) config: Committing configuration to nvs. Locking config object. I (2714) config: Done Committing configuration to nvs. I (2714) config: Config committed! I (2724) esp_app_main: Configuring services I (2724) services: Configuring I2C sda:-1 scl:-1 port:1 speed:400000 W (2734) services: no I2C configured I (2734) services: Configuring SPI mosi:18 miso:22 clk:13 host:1 dc:5 I (2744) gpio: GPIO[5]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 W (2754) led: LED GPIO -1 ignored W (2754) led: LED GPIO -1 ignored I (2764) led: Configuring LEDs green:-1 (active:0 -1%), red:-1 (active:0 -1%) I (2774) battery: No battery I (2774) monitor: Initializing monitoring I (2774) monitor: Adding jack (low) detection GPIO 39 I (2784) buttons: Creating button using GPIO 39, type 0, pull-up/down 0, long press 0 shifter -1 I (2794) buttons: starting button tasks W (2794) buttons: creating polled gpio 39, level 1 I (2804) monitor: Heap internal:228863 (min:228367) external:4083015 (min:4082991) dma:221511 (min:221031) I (2814) esp_app_main: Initializing display I (2814) display: Trying to configure display with SPI:width=320,height=240,cs=0,reset=23,speed=1000000,driver=ILI9341 I (2834) ILI9341: ILI9341_Detect 391 Driver= driver=ILI9341 Depth=16 I (2954) ILI9341: ILI9341 with bit default-depth 16, page 3, iRAM 0x3ffc8a2c I (2954) ILI9341: SetLayout 197 HFlip=0 VFlip=0 Rotate=0 (1=true) I (2954) ILI9341: SetLayout 255 Private->MADCtl=32 I (2964) ILI9341: ILI9341_Init 312 device-depth 16, 0x66/0x55=0x55 I (4234) display: Display is SPI host 1 with cs:0 I (4234) ILI9341: SetLayout 197 HFlip=0 VFlip=0 Rotate=0 (1=true) I (4234) ILI9341: SetLayout 255 Private->MADCtl=32 I (5524) gds: Adding line 1 at -3 (height:14) I (5524) gds: Adding line 2 at 8 (height:24) I (5524) esp_app_main: Checking for update url W (5534) config: Value not found for key fwurl W (5534) config: Value not found for key 0;33mW (5554) config: Value not found for key apdelay I (5554) uart: queue free spaces: 3 I (5554) network_handlers: Network manager configuration: polling max 10176, polling min 15000, ap delay 20000, dhcp timeout 8000, eth timeout 8000 I (5584) http_server: Initializing HTTP Server I (5584) network_ethernet: Attempting to initialize Ethernet I (5584) network_ethernet: No Ethernet configuration, or configuration invalid I (5604) wifi:wifi driver task: 3ffdf8f4, prio:23, stack:6656, core=0 I (5604) wifi:wifi firmware version: 9ec65ef I (5604) wifi:wifi certification version: v7.0 I (5604) wifi:config NVS flash: enabled I (5614) wifi:config nano formating: disabled I (5614) wifi:Init data frame dynamic rx buffer num: 40 I (5614) wifi:Init management frame dynamic rx buffer num: 40 I (5624) wifi:Init management short buffer num: 32 I (5624) wifi:Init static tx buffer num: 12 I (5634) wifi:Init tx cache buffer num: 32 I (5644) wifi:Init static rx buffer size: 1600 I (5644) wifi:Init static rx buffer num: 12 I (5654) wifi:Init dynamic rx buffer num: 40 I (5654) wifi_init: tcpip mbox: 32 I (5654) wifi_init: udp mbox: 32 I (5654) wifi_init: tcp mbox: 32 I (5664) wifi_init: tcp tx win: 8192 I (5664) wifi_init: tcp rx win: 32768 I (5674) wifi_init: tcp mss: 1440 I (5674) wifi_init: WiFi/LWIP prefer SPIRAM I (5674) network_wifi: Starting wifi I (5684) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07 I (5774) wifi:mode : sta (40:22:d8:7e:04:e4) I (5774) wifi:enable tsf I (5774) network_handlers: Existing wifi config found. Attempting to connect. I (5784) network: Starting DHCP client I (5794) network_wifi: Wifi Connecting to DatWifi... [... interactive term help notice ...] W (6044) console: Processing autoexec commands while network manager active. Wifi related commands will be ignored. I (6054) console: autoexec is set to perform auto-process I (6054) console: Running command autoexec1 = squeezelite -o I2S -b 500:2000 -d all=info -C 30 -W -n "Redux" W (6064) config: Value not found for key autoexec2 squeezelite-esp32> I (6064) squeezelite_cmd: Calling squeezelite [00:00:04.660] sb_controls_init:249 initializing audio (buttons/rotary/ir) controls (raw:0) [00:00:04.672] sendSETD:431 sending dimension 320x240 [00:00:04.674] stream_init:387 init stream [00:00:04.675] output_init_embedded:70 init device: I2S [00:00:04.687] equalizer_init:42 initializing equalizer [00:00:04.688] output_init_common:433 supported rates: 192000 176400 96000 88200 48000 44100 32000 24000 22050 16000 12000 11025 8000 [00:00:04.700] output_init_embedded:92 init I2S/SPDIF I (6134) DAC core: DAC uses I2C port:0, sda:33, scl:32 I (6134) DAC external: DAC on I2C @16 [00:00:04.718] output_init_i2s:325 configuring MCLK on GPIO 0 I (6134) I2S: DMA Malloc info, datalen=blocksize=2048, dma_buf_count=12 I (6154) I2S: APLL: Req RATE: 44100, real rate: 44099.988, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 11289597.000, SCLK: 1411199.625000, diva: 1, divb: 0 [00:00:04.743] output_init_i2s:354 ES8388 DAC using I2S bck:27, ws:25, do:26, mute:-1:0 (res:0) [00:00:04.755] output_init_i2s:374 Initializing I2S mode normal with rate: 44100, bits per sample: 16, buffer frames: 512, number of buffers: 12 [00:00:04.767] output_init_i2s:393 setting amplifier GPIO 21 (active:1) [00:00:04.769] output_thread_i2s:498 Output state is -1 [00:00:04.769] output_visu_init:75 Initialize VISUEXPORT 512 16 bits samples [00:00:04.780] output_thread_i2s:502 switching off amp GPIO 21 [00:00:04.781] output_init_embedded:100 init completed. [00:00:04.792] decode_init:153 init decode [00:00:04.793] register_alac:547 using alac to decode alc [00:00:04.804] register_helixaac:686 using helix-aac to decode aac [00:00:04.805] register_vorbis:506 using vorbis to decode ogg [00:00:04.816] register_opus:444 using opus to decode ops [00:00:04.816] register_flac:332 using flac to decode ogf,flc [00:00:04.827] register_pcm:468 using pcm to decode wav,aif,pcm [00:00:04.828] register_mad:417 using mad to decode mp3 W (6254) BT_AV: BT Sink pin code is: [1234] I (6254) BTDM_INIT: BT controller compile version [2c56073] [00:00:04.841] register_external:446 Initializing AirPlay sink [00:00:04.853] register_external:457 Initializing CSpot sink [00:00:04.857] discover_server:828 sending discovery [00:00:04.858] discover_server:832 error sending discovery I (6624) BT_AV: Bluetooth Init complete I (7784) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1 I (8304) wifi:state: init -> auth (b0) I (8314) wifi:state: auth -> assoc (0) I (8314) wifi:state: assoc -> run (10) I (8324) wifi:connected with [REDACTED], aid = 4, channel 6, BW20, bssid = [REDACTED] I (8334) wifi:security: WPA2-PSK, phy: bgn, rssi: -72 I (8344) wifi:pm start, type: 1 I (8354) network: Got an IP address from interface Wifi. IP=192.168.1.84, Gateway=192.168.1.254, NetMask=255.255.255.0, Address was changed I (8374) esp_netif_handlers: sta ip: 192.168.1.84, mask: 255.255.255.0, gw: 192.168.1.254 I (8374) esp_app_main: Network connected and mDNS initialized with Redux [00:00:06.967] raop_sink_start:173 Starting Airplay for ip 192.168.1.84 with servicename Redux [00:00:06.970] raop_create:201 starting mDNS with 4022D87E04E4@Redux I (8414) cspot: Starting Spotify (CSpot) servicename Redux with id 4022d87e04e4 I (8454) wifi:AP's beacon interval = 122880 us, DTIM period = 2 I (8834) httpd_handlers: serving /status.json to peer 192.168.1.126 port 43656 [00:00:09.866] discover_server:828 sending discovery I (11854) httpd_handlers: serving /status.json to peer 192.168.1.126 port 24240 [00:00:14.866] discover_server:828 sending discovery [00:00:18.718] bt_sink_cmd_handler:170 Setting BT sample rate 44100 I (20134) BT_AV: Configure audio player 21-15-2-35 I (20134) BT_AV: Audio player configured, sample rate=44100 [00:00:19.866] discover_server:828 sending discovery [00:00:24.866] discover_server:828 sending discovery [00:00:25.858] bt_sink_cmd_handler:143 BT sink started [00:00:25.859] display_bus_handler:383 Display bus command 0 [00:00:25.860] bt_sink_cmd_handler:155 BT play [00:00:25.874] display_bus_handler:383 Display bus command 0 I (27294) display: playing Krack [00:00:25.883] output_thread_i2s:498 Output state is 2 [00:00:25.885] output_thread_i2s:564 Restarting I2S. [00:00:25.888] equalizer_open:71 equalizer initialized 0 [00:00:27.301] bt_sink_cmd_handler:166 BT pause, just silence [00:00:29.866] discover_server:828 sending discovery [00:00:30.373] bt_sink_cmd_handler:150 BT sink stopped [00:00:30.374] display_bus_handler:383 Display bus command 1 ```

Let me know if there's anything else I can do to help pinpoint the issue here ! I

Thanks for your hard work on this project

sle118 commented 10 months ago

Did you install the most recent version of the SqueezeESP plugin by @philippe44 on your LMS instance? The screen is independent from it during boot, and seeing something during that time means config is ok and wiring too, but it's the server that sends display data when connected.

lelithium commented 10 months ago

Thanks for the quick answer @sle118 !

Updated to latest (0.362) didn't change the issue With the LMS available, I see in the logs messages such as:

[00:00:09.968] sendSETD:431 sending dimension 320x240
[00:00:09.975] notify:228 notified server 192.168.1.145 hport 9000 cport 9090
I (11394) network_status: LMS IP: 192.168.1.145, hport: 9000, cport: 9090
[00:00:09.989] decode_flush:251 decode flush
[00:00:09.990] output_flush:446 flush output buffer
[00:00:09.991] decode_flush:251 decode flush
[00:00:09.992] output_flush:446 flush output buffer
[00:00:10.004] grfb_handler:743 brightness 4
[00:00:10.204] visu_handler:1232 Stopping visualizer
[00:00:10.208] handler:54 got equalizer 14
[00:00:10.212] visu_handler:1232 Stopping visualizer
I (13124) httpd_handlers: serving /messages.json to peer 192.168.1.126 port 48845
[00:00:18.899] decode_flush:251 decode flush
[00:00:18.900] output_flush:446 flush output buffer
[00:00:18.902] visu_handler:1232 Stopping visualizer
[00:00:19.071] grfs_handler:795 scroller current size 1280 (w:360)
[00:00:19.072] grfs_handler:795 scroller current size 2560 (w:360)
[00:00:19.074] grfs_handler:795 scroller current size 2712 (w:360)
[00:00:19.276] codec_open:283 codec open: 'm'
[00:00:19.279] stream_sock:508 connecting to 192.168.1.145:9000

[00:00:19.656] stream_thread:264 headers: len: 486

[00:00:20.681] output_thread_i2s:498 Output state is 1
[00:00:20.683] output_thread_i2s:564 Restarting I2S.
[00:00:20.685] equalizer_open:71 equalizer initialized 0
[00:00:20.740] mad_decode:247 setting track_start
[00:00:20.800] _output_frames:65 start buffer frames: 7535
[00:00:20.802] _output_frames:150 track start sample rate: 44100 replay_gain: 0
[00:00:20.803] output_thread_i2s:498 Output state is 2
[00:00:29.979] decode_flush:251 decode flush
[00:00:29.980] output_flush:446 flush output buffer
[00:00:29.995] output_thread_i2s:498 Output state is 0
[00:00:30.575] codec_open:283 codec open: 'm'
[00:00:30.577] stream_sock:508 connecting to 192.168.1.145:9000

Which I think show that the SqueezeESP is trying to output to the screen (scroller and visu messages especially)

Also - I thought in headless mode (i.e. no LMS) the display should still work with Bluetooth, and display "Now playing - [trackname]" messages

philippe44 commented 10 months ago

ES8388 requires MCLK so GPIO0 is forced to that. This means that as soon as the codec is initialized, your display will stop to work as GPIO is preempted for it

lelithium commented 10 months ago

Switched CS from 0 to 22 and it works - thank you so much @philippe44 and @sle118 !