Boot from winbond 25q128 - how?

sazanof
Posts: 22
Joined: Wed Sep 13, 2023 10:22 am

Boot from winbond 25q128 - how?

Postby sazanof » Sun Feb 11, 2024 3:22 pm

Hello everyone The question seemed to be simple, but I ran into difficulties...

ESP-WROOM-32 and Winbond 25q128 are available.

Since my program is expanding and I want to use ota for software updates and web server files (about 2 megabytes), I do not have enough internal memory ESP-WROOM-32.

It seems to me that even if the web server files take up to 1 megabyte, the program itself up to 1 megabyte, 2x1mb of ota, 1mb of user data (json configurations), then the best option is to use external memory to download the program.

There are several topics on the forum discussing my problem, but I haven't found a solution, so I'm asking for help again.

So, I opened the esp-wroom-32 manual and looked at how its memory is connected:
Снимок экрана от 2024-02-11 17-46-12.png
Снимок экрана от 2024-02-11 17-46-12.png (43.93 KiB) Viewed 1516 times
With the exception of SCS/CMD (/CS), I connected everything else as shown in the diagram and changed SPI_PAD_CONFIG_CS0 pin using espefuse.py to GPIO17

Code: Select all

espefuse.py burn_efuse SPI_PAD_CONFIG_CS0 17
Check espefuse.py summary:

Code: Select all

Spi Pad fuses:
SPI_PAD_CONFIG_HD (BLOCK0)                         read for SPI_pad_config_hd                         = 0 R/W (0b00000)
SPI_PAD_CONFIG_CLK (BLOCK0)                        Override SD_CLK pad (GPIO6/SPICLK)                 = 0 R/W (0b00000)
SPI_PAD_CONFIG_Q (BLOCK0)                          Override SD_DATA_0 pad (GPIO7/SPIQ)                = 0 R/W (0b00000)
SPI_PAD_CONFIG_D (BLOCK0)                          Override SD_DATA_1 pad (GPIO8/SPID)                = 0 R/W (0b00000)
SPI_PAD_CONFIG_CS0 (BLOCK0)                        Override SD_CMD pad (GPIO11/SPICS0)                = 17 R/W (0b10001)
After these actions, I believe that the esp should automatically boot from the external flash memory - but no. The blink sketch I uploaded earlier has been successfully uploaded from build-in flash. I tried to flash it - the firmware was installed on the built-in flash

I also tried various DIO and QIO configurations - but to no avail =(

The option of desoldering the upper shield and replace flash memory does not suit me - I want to be able to directly access the memory not on the ESP-WROOM-32 module.

I think if my problem is solved and there is a clear solution to it, it will help many who have faced the same question, since so far I have not found a direct "guide to connecting external memory".

As a result, I have the following questions:

1) How to connect the external memory "winbond 25q128" correctly esp-wroom-32 board to loads the program directly from it?
2) What settings or software manipulations do I need to do in order to start the external memory "winbond 25q128 "?

sazanof
Posts: 22
Joined: Wed Sep 13, 2023 10:22 am

Re: Boot from winbond 25q128 - how?

Postby sazanof » Sun Feb 11, 2024 7:39 pm

I've made progress! Flashed all efuse

Code: Select all

espefuse.py burn_efuse SPI_PAD_CONFIG_HD 9
espefuse.py burn_efuse SPI_PAD_CONFIG_D 8
espefuse.py burn_efuse SPI_PAD_CONFIG_Q 7
espefuse.py burn_efuse SPI_PAD_CONFIG_CLK 6
Also, I made changes in config, from here
To set the SPI WP pin assignment, run "make menuconfig", go to "Serial flasher config" and enable QIO or QOUT mode. Then leave that submenu and go into "Bootloader Configuration". There will be a newly visible item "SPI Flash WP Pin when customising pin via efuse...". Set this to the WP pin GPIO number (10 if you are keeping the default pin layout).
viewtopic.php?f=12&t=2884&start=10

Code: Select all

Spi Pad fuses:
SPI_PAD_CONFIG_HD (BLOCK0)                         read for SPI_pad_config_hd                         = 9 R/W (0b01001)
SPI_PAD_CONFIG_CLK (BLOCK0)                        Override SD_CLK pad (GPIO6/SPICLK)                 = 6 R/W (0b00110)
SPI_PAD_CONFIG_Q (BLOCK0)                          Override SD_DATA_0 pad (GPIO7/SPIQ)                = 7 R/W (0b00111)
SPI_PAD_CONFIG_D (BLOCK0)                          Override SD_DATA_1 pad (GPIO8/SPID)                = 8 R/W (0b01000)
SPI_PAD_CONFIG_CS0 (BLOCK0)                        Override SD_CMD pad (GPIO11/SPICS0)                = 17 R/W (0b10001)
But now I get an error (after successful firmware)

Code: Select all

I (58) boot: ESP-IDF v5.1.2 2nd stage bootloader
I (58) boot: compile time Feb 11 2024 22:30:14
I (58) boot: Multicore bootloader
I (63) boot: chip revision: v1.0
I (77) qio_mode: Enabling QIO for flash chip WinBond
I (77) boot.esp32: SPI Speed      : 40MHz
I (77) boot.esp32: SPI Mode       : QIO
I (81) boot.esp32: SPI Flash Size : 16MB
I (86) boot: Enabling RNG early entropy source...
E (91) flash_parts: partition 1 invalid - offset 0xf00 size 0x5000100 exceeds flash chip size 0x1000000
E (101) boot: Failed to verify partition table
E (107) boot: load partition table error!
ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 155484614, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7428
load:0x40078000,len:16556
load:0x40080400,len:4
0x40080400: _init at ??:?

load:0x40080404,len:4240
entry 0x40080668
What I doing wrong?

MicroController
Posts: 1739
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Boot from winbond 25q128 - how?

Postby MicroController » Sun Feb 11, 2024 9:37 pm

Not an actual answer to your question, but
1mb of user data (json configurations)
You don't really have more than a few kilobytes of JSON configuration stored in flash, do you?

And as to the web server: Depending on the kind of files you want to serve, you may want to look into storing the files in gzipped format, and send the gzipped data to the client using 'Content-Encoding: gzip'.

MicroController
Posts: 1739
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Boot from winbond 25q128 - how?

Postby MicroController » Sun Feb 11, 2024 9:58 pm

Also,

Code: Select all

I (81) boot.esp32: SPI Flash Size : 16MB
...
E (91) flash_parts: partition 1 invalid - offset 0xf00 size 0x5000100 exceeds flash chip size 0x1000000
reads pretty clearly to me. Either the partition table is corrupted, or you tried to put some 80+MB of partitions into the 16MB (128Mbit) of flash the 25Q128 has.

sazanof
Posts: 22
Joined: Wed Sep 13, 2023 10:22 am

Re: Boot from winbond 25q128 - how?

Postby sazanof » Mon Feb 12, 2024 4:16 am

MicroController wrote:
Sun Feb 11, 2024 9:58 pm
Either the partition table is corrupted, or you tried to put some 80+MB of partitions into the 16MB (128Mbit) of flash the 25Q128 has.
Thank you! The irony is that I'm trying to download a original "blink" from the standard repository with standart settings.

The program loads successfully on the flash memory, but does not start
partition-table:

Code: Select all

Executing action: partition-table
Running ninja in directory /home/sazanof/esp/esp-idf/examples/get-started/blink/build
Executing "ninja partition-table"...
[1/1] cd /home/sazanof/esp/esp-idf/examples/get-started/blink/build/esp-idf/parti..."*******************************************************************************"Partition table binary generated. Contents:
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
ota_0,app,ota_0,0x110000,1M,
ota_1,app,ota_1,0x210000,1M,
*******************************************************************************
I also tried without OTA.

That is, I did not mess with the partition table and the program is definitely less than 16 megabytes. What did I miss?

MicroController
Posts: 1739
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Boot from winbond 25q128 - how?

Postby MicroController » Mon Feb 12, 2024 10:30 am

I suggest flashing with verify. If that errors out, try different flash modes: qout, dio, dout.
You may also want to verify you're using the correct VDD_SPI for the flash chip. - And of course make sure the electrical connections are good enough for the 40MHz signals.

sazanof
Posts: 22
Joined: Wed Sep 13, 2023 10:22 am

Re: Boot from winbond 25q128 - how?

Postby sazanof » Mon Feb 12, 2024 6:54 pm

MicroController wrote:
Mon Feb 12, 2024 10:30 am
I suggest flashing with verify. If that errors out, try different flash modes: qout, dio, dout.
You may also want to verify you're using the correct VDD_SPI for the flash chip. - And of course make sure the electrical connections are good enough for the 40MHz signals.
Thank you! So I changed QIO->DIO and it works!

I think there should be no problems using memory. Although, who knows. Also, thank you for the advice to use compression for the web server. I will definitely apply it!
I (265) heap_init: Initializing. RAM available for dynamic allocation:
I (272) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (278) heap_init: At 3FFB29D0 len 0002D630 (181 KiB): DRAM
I (284) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (290) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (297) heap_init: At 4008C000 len 00014000 (80 KiB): IRAM
I (304) spi_flash: detected chip: winbond
I (307) spi_flash: flash io: dio
I (312) app_start: Starting scheduler on CPU0
I (316) app_start: Starting scheduler on CPU1
I (316) main_task: Started on CPU0
I (326) main_task: Calling app_main()
I (326) example: Example configured to blink GPIO LED!
I (326) gpio: GPIO[5]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (336) example: Turning the LED OFF!
I (1346) example: Turning the LED ON!
I (2346) example: Turning the LED OFF!
I (3346) example: Turning the LED ON!

Who is online

Users browsing this forum: No registered users and 58 guests