Small ESP32 Modul ( all include in new ESP32-PICO )

User avatar
seonroz
Posts: 54
Joined: Thu Oct 25, 2018 3:51 am
Location: Melbourne, Australia
Contact:

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby seonroz » Wed Oct 31, 2018 10:30 am

Hey Boris,

None of my boards here have PSRAM (apart from me trying to add it to PICO_KIT atm)... that's my point, your code should not crash on them, but should say

E (684) spiram: SPI RAM enabled but initialization failed. Bailing out.
I (684) cpu_start: Failed to init external RAM; continuing without it.

But it doesn't - it just crashes.

In fact I never see mention of PSRAM in the logs before the crash.

If I build without PSRAM enabled, then the firmware works fine on all of my boards.

Image

If I install your pre-built firmware, it works, because the PICO-DS4 early exit is still there, but I remove it, it crashes.

If I put the early exit back in I get this on a PICO-D$ board:
D (1132) boot: start: 0x400816b0
E (1136) psram: ESP32PICOD4 do not support psram yet
E (1142) spiram: SPI RAM enabled but initialization failed. Bailing out.
W (2044) MicroPython: SPIRAM support enabled but SPIRAM not detected

Internal FS (SPIFFS): Mounted on partition 'internalfs' [size: 2555904; Flash address: 0x190000]
----------------
Filesystem size: 2341888 B
Used: 512 B
Free: 2341376 B
----------------
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on TinyPICO with ESP32 PICO D4
Type "help()" for more information.
>>>


But I get a complete hang on a WROOM32 board (with no PSRAM).... as exactly the same place.

"The first log message related to MicroPython is "D (ttt) MicroPython: Entry" (app_main() entry). Any crash before it is not in any way related to MicroPython."

It's def crashing inside or from the spiram_psram.c :(

Seon
unexpectedmaker.com
Last edited by seonroz on Wed Oct 31, 2018 10:33 am, edited 1 time in total.
Seon
unexpectedmaker.com

User avatar
seonroz
Posts: 54
Joined: Thu Oct 25, 2018 3:51 am
Location: Melbourne, Australia
Contact:

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby seonroz » Wed Oct 31, 2018 10:33 am

loboris wrote:I've just remembered I have a ESP32-PICO-D4 module (TTGO Micro-32) which I've never used.
I'll try to attach psRAM chip and test it later today.
Awesome! Can you test your code with and without the PSRAM attached please? And if you do get it attached and working, please please please let me know the correct pinout ;)

Thanks :-)

Seon
unexpectedmaker.com
Seon
unexpectedmaker.com

User avatar
seonroz
Posts: 54
Joined: Thu Oct 25, 2018 3:51 am
Location: Melbourne, Australia
Contact:

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby seonroz » Wed Oct 31, 2018 10:47 am

Ok, more digging...

I flashed my LOLIN32 with your pre-built psram_all firmware and it worked... so I copied your sdkconfig from that folder to my build folder and built again, and still freeze after flash and boot.

So something is screwed in my local repro. I started with a clean folder and cloned into it ... I do have the Arduino IDE installed on this machine, with ESP32 support so maybe there is a conflict happening between the 2 versions?

I'm thought the build tools would pickup stuff from within the folder first, but it could just be a conflict with the "other" installation :(

I don't have another "clean" machine I can test this on :(

I'm going to do a fresh clone and start again...

Seon
unexpectedmaker.com
Seon
unexpectedmaker.com

User avatar
seonroz
Posts: 54
Joined: Thu Oct 25, 2018 3:51 am
Location: Melbourne, Australia
Contact:

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby seonroz » Wed Oct 31, 2018 11:09 am

Ok, I re cloned and then followed these steps.

1. copied sdkconfig from pre-built psram-all firmware folder to build folder
2. cleaned and built
3. flashed my Lolin32 - worked great, got to REPL :-)
4. flashed my TTGO PICO - psram not supported on PICO.... but got to REPL :-)
5. checked "ignore PSRAM when not found" was checked
6. removed early exit in spiram_psram.c for PICO-D4
7. cleaned and built
8. flashed my Lolin32 - worked great, got to REPL :-)
9. flashed my TTGO PICO -CRASH

I (914) boot: Disabling RNG early entropy source...
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40083633 PS : 0x00060b30 A0 : 0x800844a4 A1 : 0x3ffe3bc0
A2 : 0xc00fffff A3 : 0xffffffff A4 : 0x00013ffc A5 : 0x00000000
A6 : 0x000008ff A7 : 0x00000200 A8 : 0x800835bc A9 : 0x3ffe3ba0
A10 : 0x00000000 A11 : 0x3ff42000 A12 : 0x00000034 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000004 SAR : 0x00000017 EXCCAUSE: 0x0000001c
EXCVADDR: 0xffffffff LBEG : 0x4009bc88 LEND : 0x4009bc93 LCOUNT : 0x00000000

Backtrace: 0x40083633:0x3ffe3bc0 0x400844a1:0x3ffe3be0 0x400d42b9:0x3ffe3c10 0x4008176a:0x3ffe3c30 0x400790ef:0x3ffe3c50 0x400791a1:0x3ffe3c80 0x400791bf:0x3ffe3cc0 0x400794c1:0x3ffe3ce0 0x40080359:0x3ffe3df0 0x40007c31:0x3ffe3eb0 0x4000073d:0x3ffe3f20

CPU halted.


So just removing the PICO-D4 check is not enough, something else is going wrong on the PICO... I can't wait to see what you find Boris!

That's it for me for tonight... been a long day and I need to get to bed.

Cheers,
Seon
unexpectedmaker.com
Seon
unexpectedmaker.com

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby rudi ;-) » Wed Oct 31, 2018 11:23 am

@seonroz
https://esp32.com/viewtopic.php?f=2&t=2 ... 463#p13380
https://esp32.com/viewtopic.php?f=2&t=2 ... 463#p13463


how you connect PSRAM ( 3.3V ) to the PINHEADER of Pico-D4 ? ( FSD0, FSD1, FSD2, FSD3 )
which pins you use for PSRAM CS# and CLK ?
don't use FCLK ( flash clock ) for psram CLK
don't use FCS ( flash cs ) for psram CS#
...


PSRAM

PIN1(CS#)= "hope you use IO9"
PIN2(SO/SIO1)= ??
PIN3(SIO2)= ??
PIN4(VSS/GND)=
PIN5(SI/SIO0)= ??
PIN6(SCLK)= "hope you use IO10"
PIN7(SIO3)= ??
PIN8(Vcc)= ??



btw:
if you want try connect PSRAM ( lowvoltage versions 1.8V ) to PICO-D4 ( flash is 3.3v ) you need VCC 1.8V ( not 3.3V ) and important CS# pulled up to 1.8V ( not 3.3V )

cause VDD_SDIO is NC ( not connected, not break out from SIP to pinheader ) you need to create 1.8V by self ( LDO or other )

i suggest you to use in pico-d4 3.3v versions psram's chip's.

best wishes
rudi ;-)
Last edited by rudi ;-) on Wed Oct 31, 2018 12:02 pm, edited 3 times in total.
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby rudi ;-) » Wed Oct 31, 2018 11:44 am

@loboris

psram.c

Code: Select all

#define PICO 1

#ifdef PICO
#define PSRAM_CS_IO        9
#define PSRAM_CLK_IO       10
#else
#define PSRAM_CS_IO        16
#define PSRAM_CLK_IO       17
#endif

psram.c
"psram_gpio_config"

Code: Select all


#ifdef PICO
   /* TEST Config for the PICO-D4
       * - ESP32_PICO_Core_Board_V2
       * - ESP32_PICO_Core_Board_V3
       * Note: V2 & V3 Boards have ESP32 Rev=0
       * psram_enable works correctly only with v1 (post Feb 2017) and later ESP32 revisions.
       * 29 August 2017 rudi ;-)
       */
   /* SPICS0 CS */
   gpio_matrix_out(16, SPICS0_OUT_IDX, 0, 0); //11
    /* SPICLK CLK */
   gpio_matrix_out(6, SPICLK_OUT_IDX, 0, 0);
    /* SPIQ alias SD0 */
    gpio_matrix_out(17, SPIQ_OUT_IDX, 0, 0);   // 7
    gpio_matrix_in(17,SPIQ_IN_IDX, 0);         // 7
    /* SPID alias SD1 */
    gpio_matrix_out(8, SPID_OUT_IDX, 0, 0);
    gpio_matrix_in(8, SPID_IN_IDX, 0);
    /* SPIHD HOLD alias SD2 */
    gpio_matrix_out(11, SPIHD_OUT_IDX, 0, 0); // 9
    gpio_matrix_in(11, SPIHD_IN_IDX, 0);      // 9
    /* WP alias SD3 */
    gpio_matrix_out(7, SPIWP_OUT_IDX, 0, 0); // 10 a try with 7 like D2WD
    gpio_matrix_in(7, SPIWP_IN_IDX, 0);      // 10 a try with 7 like D2WD

#else

    gpio_matrix_out(6, SPICLK_OUT_IDX, 0, 0);
    gpio_matrix_out(11, SPICS0_OUT_IDX, 0, 0);
    gpio_matrix_out(7, SPIQ_OUT_IDX, 0, 0);
    gpio_matrix_in(7,SPIQ_IN_IDX, 0);
    gpio_matrix_out(8, SPID_OUT_IDX, 0, 0);
    gpio_matrix_in(8, SPID_IN_IDX, 0);
    gpio_matrix_out(10, SPIWP_OUT_IDX, 0, 0);
    gpio_matrix_in(10, SPIWP_IN_IDX, 0);
    gpio_matrix_out(9, SPIHD_OUT_IDX, 0, 0);
    gpio_matrix_in(9, SPIHD_IN_IDX, 0);
#endif

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby rudi ;-) » Wed Oct 31, 2018 1:01 pm

loboris wrote: You have to modify the esp-idf/components/esp32/spiram_psram.c, (I'll do it in the next MicroPython repository update), to enable psRAM initialization for ESP32-PICO-D4 and rebuild the firmware.
See this for instructions.

The correct pin mapping should be like this (latest response from esp-idf team).
https://github.com/espressif/esp-idf/is ... -434665343

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
seonroz
Posts: 54
Joined: Thu Oct 25, 2018 3:51 am
Location: Melbourne, Australia
Contact:

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby seonroz » Wed Oct 31, 2018 9:31 pm

An *almost* good nights sleep and some *almost* fresh eyes and help from rudi (big thanks rudi!!!) and I have made some progress...

E (915) spiram: SPI RAM enabled but initialization failed. Bailing out.
I (921) cpu_start: Failed to init external RAM; continuing without it.

I (928) cpu_start: Pro cpu up.
I (932) cpu_start: Starting app cpu, entry point is 0x40081694
I (0) cpu_start: App cpu up.
I (942) heap_init: Initializing. RAM available for dynamic allocation:
D (949) heap_init: New heap initialised at 0x3ffae6e0
I (954) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
D (960) heap_init: New heap initialised at 0x3ffbdb08
I (965) heap_init: At 3FFBDB08 len 000224F8 (137 KiB): DRAM
I (972) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (978) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (984) heap_init: New heap initialised at 0x4009d1dc
I (990) heap_init: At 4009D1DC len 00002E24 (11 KiB): IRAM
I (996) cpu_start: Pro cpu start user code
D (1008) clk: RTC_SLOW_CLK calibration value: 3098163
I (124) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
D (126) heap_init: New heap initialised at 0x3ffe0440
D (130) heap_init: New heap initialised at 0x3ffe4350
D (135) MicroPython: Entry
W (1138) MicroPython: SPIRAM support enabled but SPIRAM not detected
D (1138) MicroPython: SPIRAM: Disabled

D (1139) nvs: nvs_flash_init_custom partition=nvs start=9 count=6
D (1188) MicroPython: Configure stack
D (1189) nvs: nvs_open_from_partition MPY_NVM 1
D (1189) nvs: nvs_get MPY_StackSize 4
D (1190) nvs: nvs_get_str_or_blob MpyTimeZone
D (1194) MicroPython: MPy stack: 0x3ffc122c - 0x3ffc5234 (16392)
D (1200) MicroPython: Configure heap
D (1203) nvs: nvs_get MPY_HeapSize 4
D (1207) MicroPython: MPy heap: 0x3ffc5238 - 0x3ffd7278 (73728)
D (1213) MicroPython: Main task exit, stack used: 1392
I (1215) MicroPython: [=== MicroPython FreeRTOS task started (sp=3ffc5180) ===]


Internal FS (SPIFFS): Mounted on partition 'internalfs' [size: 1900544; Flash address: 0x230000]
----------------
Filesystem size: 1739520 B
Used: 512 B
Free: 1739008 B
----------------
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on ESP32 board with ESP32
Type "help()" for more information.
>>>


This is using the following code:

Code: Select all

#define PICO 1

#ifdef PICO
    #define PSRAM_CS_IO        9
    #define PSRAM_CLK_IO       10
    #define PSRAM_SPIQ_IO     17 // SIO[1] - D0 on PICO-KIT
    #define PSRAM_SPID_IO     8 // SIO[0] - D1 on PICO-KIT
    #define PSRAM_SPIWP_IO    7 // SIO[2] D3 on PICO-KIT (stupid)
    #define PSRAM_SPIHD_IO    11 // SIO[3] D2 on PICO-KIT (stupid )
#else
    #define PSRAM_CS_IO        16
    #define PSRAM_CLK_IO       17
    #define PSRAM_SPIQ_IO     7
    #define PSRAM_SPID_IO     8
    #define PSRAM_SPIWP_IO    10
    #define PSRAM_SPIHD_IO    9
#endif
So no more crashing - it seems the crashing was being caused by configuring an IO that was not allowed to be changed, at least on the PICO-KIT, which makes sense... but not going to try to hunt down which IO(s) it was ;)

Now I just need to find the combo of SIO[0]-SIO[3] that works on the PICO-KIT that actually initialises the ram and passes the ram test, assuming I have not killed this SPIRAM I am testing with ;)

I also had this happen TWICE - yay - but I can't seem to make it happen consistently :(

I (919) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (926) cpu_start: Pro cpu up.
I (930) cpu_start: Starting app cpu, entry point is 0x40081694
I (0) cpu_start: App cpu up.
E (1832) spiram: SPI SRAM memory test fail. 131072/131072 writes failed, first @ 3F800000

E (1832) cpu_start: External RAM failed memory test!

abort() was called at PC 0x4008185f on core 0

Backtrace: 0x40095b64:0x3ffe3bf0 0x40095d2b:0x3ffe3c10 0x4008185f:0x3ffe3c30 0x400790ef:0x3ffe3c50 0x400791a1:0x3ffe3c80 0x400791bf:0x3ffe3cc0 0x400794c1:0x3ffe3ce0 0x40080335:0x3ffe3df0 0x40007c31:0x3ffe3eb0 0x4000073d:0x3ffe3f20

CPU halted.



Cheers,
Seon
unexpectedmaker.com
Seon
unexpectedmaker.com

User avatar
seonroz
Posts: 54
Joined: Thu Oct 25, 2018 3:51 am
Location: Melbourne, Australia
Contact:

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby seonroz » Wed Oct 31, 2018 10:13 pm

Hey rudi... the CLK and DATA pin can share an IO (GPIO10) ? How is that possible?

Cheers,

Seon
unexpectedmaker.com
Seon
unexpectedmaker.com

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: Small ESP32 Modul ( all include in new ESP32-PICO )

Postby rudi ;-) » Wed Oct 31, 2018 10:23 pm

seonroz wrote:Hey rudi... the CLK and DATA pin can share an IO (GPIO10) ? How is that possible?

Cheers,

Seon
unexpectedmaker.com

damn... now the confuse begins from start again :) want edit it but to late - you read my last (deleted) post :)

you can share only the data pins between psram and flash.
for flash you need own cs ( and clk )
and for psram you need own cs ( and clk )
the limits for clk is cause 80MHz / 40 MHz

sry for confuse :)

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: No registered users and 102 guests