nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP32 : spiffs image creation

fikin opened this issue · comments

generating spiffs image for ESP32 in following way:

sdk/esp32-esp-idf/components/spiffs/spiffsgen.py 0x100000 local/fs build/spiffs.img

using default partition table with changed sizes for lfs and spiffs only:

...
lfs,0xC2, 0x01, ,0x40000
storage, data, spiffs, ,0x100000

and flashing it together with bootloader and nodemcu.bin:

.../esptool.py ... write_flash ... 0x10000 build/nodemcu.bin 0x1d0000 build/spiffs.img

the device boots but spiffs stats are not working:

> =file.list()
Failed to stat init.lc err=-1
Failed to stat _lfs-reload.lc err=-1
Failed to stat LFS.img err=-1
...
table: 0x3ffc2dc4

boot banner for partition table seems to fit with used addresses :

I (59) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00180000
I (93) boot:  3 lfs              unknown          c2 01 00190000 00040000
I (100) boot:  4 storage          Unknown data     01 82 001d0000 00100000

if i do file.format(), its starts to work.

is that the technique to prepare and flash spiffs for esp32?

after reading 6429 and 9984 i thought of playing with the options a bit.

and there is partial progress using image produced by mkspiffs but not by spiffsgen.py.

how much are we deviating in dev-esp32 branch from master in esp-idf?

default sdkconfig is containing:

CONFIG_SPIFFS_PAGE_SIZE=256
CONFIG_SPIFFS_OBJ_NAME_LEN=32
CONFIG_SPIFFS_USE_MAGIC=y
CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
CONFIG_SPIFFS_META_LENGTH=4

if i compile image using ../mkspiffs/mkspiffs -c local/fs -s 0x100000 build/spiffs.img (mkspiffs is compiled with above settings),

i'm able to open a file using /<file name> path but file.list still fails to stat it.

rst:0x1 (POWERON_RESET),boot:0x13 (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:2
load:0x3fff0030,len:6676
load:0x40078000,len:14848
ho 0 tail 12 room 4
load:0x40080400,len:3792
entry 0x40080694
I (29) boot: ESP-IDF v4.4-dev-5344-g6407ecb3f8 2nd stage bootloader
I (29) boot: compile time 17:04:56
I (29) boot: chip revision: 1
I (33) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (40) boot.esp32: SPI Speed      : 40MHz
I (45) boot.esp32: SPI Mode       : DIO
I (49) boot.esp32: SPI Flash Size : 4MB
I (54) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00180000
I (93) boot:  3 lfs              unknown          c2 01 00190000 00040000
I (100) boot:  4 storage          Unknown data     01 82 001d0000 00100000
I (108) boot: End of partition table
I (112) boot_comm: chip revision: 1, min. application chip revision: 0
I (119) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=29d18h (171288) map
I (190) esp_image: segment 1: paddr=00039d40 vaddr=3ff80063 size=00008h (     8) load
I (190) esp_image: segment 2: paddr=00039d50 vaddr=3ffb0000 size=03884h ( 14468) load
I (201) esp_image: segment 3: paddr=0003d5dc vaddr=40080000 size=02a3ch ( 10812) load
I (209) esp_image: segment 4: paddr=00040020 vaddr=400d0020 size=baf50h (765776) map
I (490) esp_image: segment 5: paddr=000faf78 vaddr=40082a3c size=147a0h ( 83872) load
I (524) esp_image: segment 6: paddr=0010f720 vaddr=400c0000 size=00064h (   100) load
I (525) esp_image: segment 7: paddr=0010f78c vaddr=50000000 size=00010h (    16) load
I (541) boot: Loaded app from partition at offset 0x10000
I (541) boot: Disabling RNG early entropy source...
I (555) cpu_start: Pro cpu up.
D (555) efuse: In EFUSE_BLK0__DATA3_REG is used 1 bits starting with 15 bit
D (556) efuse: In EFUSE_BLK0__DATA5_REG is used 1 bits starting with 20 bit
D (564) efuse: In EFUSE_BLK0__DATA3_REG is used 3 bits starting with 9 bit
D (571) efuse: In EFUSE_BLK0__DATA3_REG is used 1 bits starting with 2 bit
I (578) cpu_start: Starting app cpu, entry point is 0x40081534
I (0) cpu_start: App cpu up.
D (592) clk: RTC_SLOW_CLK calibration value: 3251328
I (605) cpu_start: Pro cpu start user code
I (605) cpu_start: cpu freq: 160000000
I (605) cpu_start: Application information:
I (609) cpu_start: Project name:     nodemcu
I (614) cpu_start: App version:      32d03a2-dirty
I (620) cpu_start: Compile time:     Mar 23 2023 13:31:16
I (626) cpu_start: ELF file SHA256:  0962067f2af1b9cf...
I (632) cpu_start: ESP-IDF:          v4.4-dev-5344-g6407ecb3f8
D (638) memory_layout: Checking 7 reserved memory ranges:
D (644) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0
D (650) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb7b00
D (656) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440
D (663) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350
D (669) memory_layout: Reserved memory range 0x40070000 - 0x40078000
D (676) memory_layout: Reserved memory range 0x40078000 - 0x40080000
D (682) memory_layout: Reserved memory range 0x40080000 - 0x400971dc
D (689) memory_layout: Building list of available memory regions:
D (695) memory_layout: Available memory region 0x3ffae6e0 - 0x3ffb0000
D (701) memory_layout: Available memory region 0x3ffb7b00 - 0x3ffb8000
D (708) memory_layout: Available memory region 0x3ffb8000 - 0x3ffc0000
D (715) memory_layout: Available memory region 0x3ffc0000 - 0x3ffc2000
D (721) memory_layout: Available memory region 0x3ffc2000 - 0x3ffc4000
D (728) memory_layout: Available memory region 0x3ffc4000 - 0x3ffc6000
D (734) memory_layout: Available memory region 0x3ffc6000 - 0x3ffc8000
D (741) memory_layout: Available memory region 0x3ffc8000 - 0x3ffca000
D (748) memory_layout: Available memory region 0x3ffca000 - 0x3ffcc000
D (754) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000
D (761) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000
D (767) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000
D (774) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000
D (781) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000
D (787) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000
D (794) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000
D (800) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000
D (807) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000
D (813) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000
D (820) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20
D (827) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000
D (833) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000
D (840) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000
D (846) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (853) memory_layout: Available memory region 0x3fffc000 - 0x40000000
D (860) memory_layout: Available memory region 0x400971dc - 0x40098000
D (866) memory_layout: Available memory region 0x40098000 - 0x4009a000
D (873) memory_layout: Available memory region 0x4009a000 - 0x4009c000
D (879) memory_layout: Available memory region 0x4009c000 - 0x4009e000
D (886) memory_layout: Available memory region 0x4009e000 - 0x400a0000
I (893) heap_init: Initializing. RAM available for dynamic allocation:
D (900) heap_init: New heap initialised at 0x3ffae6e0
I (905) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
D (911) heap_init: New heap initialised at 0x3ffb7b00
I (916) heap_init: At 3FFB7B00 len 00028500 (161 KiB): DRAM
I (922) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (929) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (935) heap_init: New heap initialised at 0x400971dc
I (940) heap_init: At 400971DC len 00008E24 (35 KiB): IRAM
D (947) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (952) FLASH_HAL: extra_dummy: 1
D (955) spi_flash: trying chip: issi
D (959) spi_flash: trying chip: gd
I (962) spi_flash: detected chip: gd
I (966) spi_flash: flash io: dio
D (970) cpu_start: calling init function: 0x4016da1c
D (975) cpu_start: calling init function: 0x401090b4
D (980) cpu_start: calling init function: 0x400f99ac
D (986) cpu_start: calling init function: 0x400d3dac
D (990) cpu_start: calling init function: 0x400d3378
D (996) intr_alloc: Connected src 17 to int 3 (cpu 0)
D (1001) intr_alloc: Connected src 24 to int 9 (cpu 0)
I (1006) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (0) cpu_start: Starting scheduler on APP CPU.
D (1032) heap_init: New heap initialised at 0x3ffe0440
D (1032) heap_init: New heap initialised at 0x3ffe4350
D (1042) intr_alloc: Connected src 16 to int 12 (cpu 0)
D (1042) event: running task for loop 0x3ffbde30
D (1052) event: created task for loop 0x3ffbde30
D (1052) event: created event loop 0x3ffbde30
I (1052) uart: queue free spaces: 3
D (1062) intr_alloc: Connected src 34 to int 13 (cpu 0)

D (1062) partition: Loading the partition table
D (1072) partition: Partition table MD5 verified
D (1202) esp_netif_lwip: LwIP stack has been initialized
D (1202) esp_netif_lwip: esp-netif has been successfully initialized
D (1212) nvs: nvs_open_from_partition lfsload 0
D (1212) intr_alloc: Connected src 22 to int 17 (cpu 0)
D (1222) esp_netif_objects: esp_netif_add_to_list 0x3ffc26b0
D (1222) esp_netif_objects: esp_netif_add_to_list netif added successfully (total netifs: 1)
D (1232) esp_netif_objects: esp_netif_add_to_list 0x3ffc5b98
D (1232) esp_netif_objects: esp_netif_add_to_list netif added successfully (total netifs: 2)
D (1242) nvs: nvs_open_from_partition misc 1
I (1262) wifi:wifi driver task: 3ffc8034, prio:23, stack:6656, core=0
I (1262) system_api: Base MAC address is not set
I (1262) system_api: read default base MAC address from EFUSE
D (1272) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 8 bit
D (1272) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 0 bit
D (1282) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 24 bit
D (1292) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 16 bit
D (1292) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 8 bit
D (1302) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 0 bit
D (1312) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 16 bit
D (1322) nvs: nvs_open_from_partition nvs.net80211 1
D (1322) nvs: nvs_get opmode 1
D (1322) nvs: nvs_get_str_or_blob sta.ssid
D (1332) nvs: nvs_get sta.authmode 1
D (1332) nvs: nvs_get_str_or_blob sta.pswd
D (1342) nvs: nvs_get_str_or_blob sta.pmk
D (1342) nvs: nvs_get sta.chan 1
D (1342) nvs: nvs_get auto.conn 1
D (1352) nvs: nvs_get bssid.set 1
D (1352) nvs: nvs_get_str_or_blob sta.bssid
D (1352) nvs: nvs_get sta.lis_intval 2
D (1362) nvs: nvs_get sta.phym 1
D (1362) nvs: nvs_get sta.phybw 1
D (1362) nvs: nvs_get_str_or_blob sta.apsw
D (1372) nvs: nvs_get_str_or_blob sta.apinfo
D (1372) nvs: nvs_get sta.scan_method 1
D (1382) nvs: nvs_get sta.sort_method 1
D (1382) nvs: nvs_get sta.minrssi 1
D (1382) nvs: nvs_get sta.minauth 1
D (1392) nvs: nvs_get sta.pmf_e 1
D (1392) nvs: nvs_get sta.pmf_r 1
D (1392) nvs: nvs_get sta.btm_e 1
D (1402) nvs: nvs_get sta.rrm_e 1
D (1402) nvs: nvs_get sta.mbo_e 1
D (1402) nvs: nvs_get_str_or_blob ap.ssid
D (1412) nvs: nvs_get_str_or_blob ap.passwd
D (1412) nvs: nvs_get_str_or_blob ap.pmk
D (1422) nvs: nvs_get ap.chan 1
D (1422) nvs: nvs_get ap.authmode 1
D (1422) nvs: nvs_get ap.hidden 1
D (1432) nvs: nvs_get ap.max.conn 1
D (1432) nvs: nvs_get bcn.interval 2
D (1432) nvs: nvs_get ap.phym 1
D (1442) nvs: nvs_get ap.phybw 1
D (1442) nvs: nvs_get ap.sndchan 1
D (1442) nvs: nvs_get ap.pmf_e 1
D (1452) nvs: nvs_get ap.pmf_r 1
D (1452) nvs: nvs_get ap.p_cipher 1
D (1452) nvs: nvs_get lorate 1
D (1462) nvs: nvs_get_str_or_blob country
D (1462) nvs: nvs_get ap.ftm_r 1
D (1472) nvs: nvs_set ap.sndchan 1 1
I (1472) wifi:wifi firmware version: 8cb87ff
I (1472) wifi:wifi certification version: v7.0
I (1482) wifi:config NVS flash: enabled
I (1482) wifi:config nano formating: disabled
I (1482) wifi:Init data frame dynamic rx buffer num: 32
I (1492) wifi:Init management frame dynamic rx buffer num: 32
I (1492) wifi:Init management short buffer num: 32
I (1502) wifi:Init dynamic tx buffer num: 32
I (1502) wifi:Init static rx buffer size: 1600
I (1512) wifi:Init static rx buffer num: 10
I (1512) wifi:Init dynamic rx buffer num: 32
I (1522) wifi_init: rx ba win: 6
I (1522) wifi_init: tcpip mbox: 32
I (1522) wifi_init: udp mbox: 6
I (1532) wifi_init: tcp mbox: 6
I (1532) wifi_init: tcp tx win: 5744
I (1542) wifi_init: tcp rx win: 5744
I (1542) wifi_init: tcp mss: 1440
I (1542) wifi_init: WiFi IRAM OP enabled
I (1552) wifi_init: WiFi RX IRAM OP enabled
D (1562) nvs: nvs_open_from_partition lfsload 0

NodeMCU ESP32 build unspecified powered by Lua 5.3.5 [5.3-int32-singlefp] on IDF v4.4-dev-5344-g6407ecb3f8
cannot open init.lua: No such file or directory

> =file.list()
Failed to stat init.lc err=-1
Failed to stat _lfs-reload.lc err=-1
Failed to stat LFS.img err=-1
Failed to stat release err=-1
Failed to stat _lfs-init.lc err=-1
table: 0x3ffc2de0
> 
> =file.fsinfo()
865197	91364	956561
>
> f1=assert(io.open("release"))
Lua error: 	stdin:1: release: No such file or directory
stack traceback:
	[C]: in function 'ROM.assert'
	stdin:1: in main chunk
	[C]: in ?
	[C]: in ?
>
> f1=assert(io.open("/release"))
> =f1:read("*a")
4deb89786b7b8082802a1aa5e9d33a17  init.lc
9d48163659b6e1950a6583c734451495  _lfs-reload.lc
26d501e492db018c282a3aff2e1b7664  LFS.img
09fbf439ee4458a2dacdf0d51a9476c7  _lfs-init.lc

> f1:close()

if i use comprehensive spiffsgen.py options:

./sdk/esp32-esp-idf/components/spiffs/spiffsgen.py --aligned-obj-ix-table --page-size=256 --obj-name-len=32 --meta-len=4 --use-magic --use-magic-len 0x100000 local/fs build/spiffs.img

and verifying it by using mkspiffs, built with same settings, renders readable result:

./mkspiffs -l  ../nodemcu-firmware-esp32/build/spiffs.img
428	/init.lc
1133	/_lfs-reload.lc
55543	/LFS.img
1147	/release
1481	/_lfs-init.lc

is failing as in first comment.