Hello all, I have a board that currently supports an SD card successfully, but I have decided to replace the SD card with a Winbond W25N 1Gb NAND chip. I have wired the W25N to an Adafruit Huzzah32 (ESP32 WROOM) board and using some simple Arduino code I can write to and read from the flash chip.
I am now trying to make the W25N work with Mongoose and the provided VFS driver
https://mongoose-os.com/docs/mongoose-os/api/drivers/vfs-dev-w25xxx.md
and LFS, as described here (but with the Winbond driver):
https://mongoose-os.com/docs/mongoose-os/api/misc/fstab.md
The hardware is wired:
miso -> 19
mosi -> 18
clk -> 5
cs -> 21
I have tried many configurations, but what keeps happening is that the “fstab init failed” and so MGOS init failed: -32".
Ultimately I want a 1gb partition, but for now I can’t even make a 4MB partition for this chip.
I do notice in the last 5 lines of the output:
[Mar 15 22:25:32.546] esp32_spi_master.c:94 SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 5/-1/-1; native? yes)
[Mar 15 22:25:32.553] mgos_deps_init.c:72 Init fstab 1.0...
[Mar 15 22:25:32.558] mgos_vfs_dev_spi_fl:370 Failed to read JEDEC ID
[Mar 15 22:25:32.565] mgos_vfs_dev.c:66 Dev spi_flash {"cs": 21, "freq": 10000000} open failed: -7
[Mar 15 22:25:32.569] mgos_deps_init.c:74 fstab init failed
[Mar 15 22:25:32.573] mgos_freertos.c:184 MGOS init failed: -32
It thinks CS is 0/1/2 even though i specified 21.
I have stripped everything out of the code and mos.yml except what’s needed for this, and I’ll post the code and the output. If someone could tell me what I’m doing wrong I would really appreciate it. Thanks very much.
mos.yml:
author: mongoose-os
description: A Mongoose OS app skeleton
version: 1.0
libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}
# Optional. List of tags for online search.
tags:
- c
# List of files / directories with C sources. No slashes at the end of dir names.
sources:
- src
# List of dirs. Files from these dirs will be copied to the device filesystem
filesystem:
- fs
build_vars:
ESP_IDF_EXTRA_PARTITION: spif0,data,spiffs,,256K
config_schema:
- ["spi.enable", true]
# Other SPI interface options go here.
- ["sd_spi.pin_miso", 19]
- ["sd_spi.pin_mosi", 18]
- ["sd_spi.pin_clk", 5]
- ["sd_spi.pin_cs", 21]
- ["devtab.dev0.name", "spif0"]
- ["devtab.dev0.type", "spi_flash"]
- ["devtab.dev0.opts", '{"cs": 21, "freq": 10000000}']
- ["fstab.fs0.dev", "spif0"]
- ["fstab.fs0.type", "LFS"]
# I have tried it both with and without this line since I think these are auto detected
- ["fstab.fs0.opts", '{"bs": 4096}']
- ["fstab.fs0.path", "/spif0"]
- ["fstab.fs0.create", true]
- ["debug.level", 3]
libs:
- origin: https://github.com/mongoose-os-libs/vfs-dev-w25xxx
# These from fstab documentation
- origin: https://github.com/mongoose-os-libs/fstab
- origin: https://github.com/mongoose-os-libs/vfs-dev-spi-flash
- origin: https://github.com/mongoose-os-libs/vfs-fs-lfs
# Used by the mos tool to catch mos binaries incompatible with this file format
manifest_version: 2017-09-29
Code:
#include "mgos.h"
#include "mgos_vfs_dev_w25xxx.h"
#define LED_PIN 13
static void timer_cb(void *arg)
{
#ifdef LED_PIN
mgos_gpio_toggle(LED_PIN);
#endif
(void) arg;
}
enum mgos_app_init_result mgos_app_init(void)
{
mgos_gpio_set_mode(LED_PIN, MGOS_GPIO_MODE_OUTPUT);
mgos_set_timer(1000, MGOS_TIMER_REPEAT, timer_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}
Output:
[Mar 15 22:25:31.853] rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[Mar 15 22:25:31.858] configsip: 0, SPIWP:0xee
[Mar 15 22:25:31.858] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[Mar 15 22:25:31.864] mode:DIO, clock div:1
[Mar 15 22:25:31.870] load:0x3fff0030,len:4
[Mar 15 22:25:31.870] load:0x3fff0034,len:6868
[Mar 15 22:25:31.870] load:0x40078000,len:13428
[Mar 15 22:25:31.875] ho 0 tail 12 room 4
[Mar 15 22:25:31.875] load:0x40080400,len:5064
[Mar 15 22:25:31.879] entry 0x400806d4
[Mar 15 22:25:31.885] e[0;32mI (31) boot: ESP-IDF 4.2-r1 2nd stage bootloadere[0m
[Mar 15 22:25:31.885] e[0;32mI (31) boot: compile time 02:24:14e[0m
[Mar 15 22:25:31.890] e[0;32mI (31) boot: chip revision: 1e[0m
[Mar 15 22:25:31.896] e[0;32mI (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0e[0m
[Mar 15 22:25:31.906] e[0;32mI (41) qio_mode: Enabling default flash chip QIOe[0m
[Mar 15 22:25:31.910] e[0;32mI (46) boot.esp32: SPI Speed : 80MHze[0m
[Mar 15 22:25:31.921] e[0;32mI (51) boot.esp32: SPI Mode : QIOe[0m
[Mar 15 22:25:31.921] e[0;32mI (55) boot.esp32: SPI Flash Size : 4MBe[0m
[Mar 15 22:25:31.933] e[0;32mI (60) boot: Enabling RNG early entropy source...e[0m
[Mar 15 22:25:31.933] e[0;32mI (65) boot: Partition Table:e[0m
[Mar 15 22:25:31.933] e[0;32mI (69) boot: ## Label Usage Type ST Offset Lengthe[0m
[Mar 15 22:25:31.940] e[0;32mI (76) boot: 0 nvs WiFi data 01 02 00009000 00004000 00000000e[0m
[Mar 15 22:25:31.950] e[0;32mI (84) boot: 1 otadata OTA data 01 00 0000d000 00002000 00000000e[0m
[Mar 15 22:25:31.952] e[0;32mI (93) boot: 2 app_0 OTA app 00 10 00010000 00180000 00000000e[0m
[Mar 15 22:25:31.963] e[0;32mI (101) boot: 3 fs_0 FS 01 82 00190000 00040000 00000000e[0m
[Mar 15 22:25:31.968] e[0;32mI (109) boot: 4 app_1 OTA app 00 11 001d0000 00180000 00000000e[0m
[Mar 15 22:25:31.979] e[0;32mI (117) boot: 5 fs_1 FS 01 82 00350000 00040000 00000000e[0m
[Mar 15 22:25:31.985] e[0;32mI (126) boot: 6 spif0 FS 01 82 00390000 00040000 00000000e[0m
[Mar 15 22:25:31.996] e[0;32mI (134) boot: End of partition tablee[0m
[Mar 15 22:25:32.002] e[0;32mI (138) boot: OTA data 0: seq 0x00000001, st 0x10, CRC 0x157a2b85, valid? 1e[0m
[Mar 15 22:25:32.007] e[0;32mI (146) boot: OTA data 1: seq 0x00000000, st 0x00, CRC 0x00000000, valid? 0e[0m
[Mar 15 22:25:32.013] e[0;32mI (154) boot_comm: chip revision: 1, min. application chip revision: 0e[0m
[Mar 15 22:25:32.024] e[0;32mI (161) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x16e38 ( 93752) mape[0m
[Mar 15 22:25:32.050] e[0;32mI (197) esp_image: segment 1: paddr=0x00026e60 vaddr=0x3ffb0000 size=0x01afc ( 6908) loade[0m
[Mar 15 22:25:32.057] e[0;32mI (200) esp_image: segment 2: paddr=0x00028964 vaddr=0x40080000 size=0x00400 ( 1024) loade[0m
[Mar 15 22:25:32.067] e[0;32mI (204) esp_image: segment 3: paddr=0x00028d6c vaddr=0x40080400 size=0x072ac ( 29356) loade[0m
[Mar 15 22:25:32.072] e[0;32mI (223) esp_image: segment 4: paddr=0x00030020 vaddr=0x400d0020 size=0x5bcf0 (376048) mape[0m
[Mar 15 22:25:32.186] e[0;32mI (333) esp_image: segment 5: paddr=0x0008bd18 vaddr=0x400876ac size=0x02afc ( 11004) loade[0m
[Mar 15 22:25:32.197] e[0;32mI (343) boot: Loaded app from partition at offset 0x10000e[0m
[Mar 15 22:25:32.203] e[0;32mI (343) boot: Disabling RNG early entropy source...e[0m
[Mar 15 22:25:32.208] e[0;32mI (345) cpu_start: Pro cpu up.e[0m
[Mar 15 22:25:32.208] e[0;32mI (348) cpu_start: Application information:e[0m
[Mar 15 22:25:32.214] e[0;32mI (353) cpu_start: Project name: winbond-w25n-teste[0m
[Mar 15 22:25:32.220] e[0;32mI (359) cpu_start: App version: 0be6836e[0m
[Mar 15 22:25:32.225] e[0;32mI (364) cpu_start: Compile time: Mar 16 2021 02:24:14e[0m
[Mar 15 22:25:32.231] e[0;32mI (370) cpu_start: ELF file SHA256: 6e1e225c163c5e3a...e[0m
[Mar 15 22:25:32.240] e[0;32mI (376) cpu_start: ESP-IDF: 4.2-r1e[0m
[Mar 15 22:25:32.242] e[0;32mI (381) cpu_start: Single core modee[0m
[Mar 15 22:25:32.247] e[0;32mI (385) heap_init: Initializing. RAM available for dynamic allocation:e[0m
[Mar 15 22:25:32.253] e[0;32mI (392) heap_init: At 3FF80000 len 00002000 (8 KiB): RTCRAMe[0m
[Mar 15 22:25:32.258] e[0;32mI (398) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAMe[0m
[Mar 15 22:25:32.264] e[0;32mI (405) heap_init: At 3FFB5770 len 0002A890 (170 KiB): DRAMe[0m
[Mar 15 22:25:32.275] e[0;32mI (411) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAMe[0m
[Mar 15 22:25:32.280] e[0;32mI (417) heap_init: At 40078000 len 00008000 (32 KiB): IRAMe[0m
[Mar 15 22:25:32.286] e[0;32mI (423) heap_init: At 4008A1A8 len 00015E58 (87 KiB): IRAMe[0m
[Mar 15 22:25:32.292] e[0;32mI (430) cpu_start: Pro cpu start user codee[0m
[Mar 15 22:25:32.301] e[0;32mI (446) spi_flash: detected chip: generice[0m
[Mar 15 22:25:32.301] e[0;32mI (447) spi_flash: flash io: qioe[0m
[Mar 15 22:25:32.306] e[0;32mI (447) cpu_start: Starting scheduler on PRO CPU.e[0m
[Mar 15 22:25:32.324]
[Mar 15 22:25:32.324]
[Mar 15 22:25:32.324] mgos_freertos.c:155 winbond-w25n-test 1.0 (20210316-022430)
[Mar 15 22:25:32.329] mgos_freertos.c:157 Mongoose OS 0be6836 (20210316-022430/g0be6836-master)
[Mar 15 22:25:32.335] mgos_freertos.c:161 CPU: 160 MHz, FreeRTOS 8.2.0, heap: 318368 total, 287376 free
[Mar 15 22:25:32.340] mgos_freertos.c:163 Newlib 3.0.0
[Mar 15 22:25:32.345] esp32_main.c:65 ESP-IDF 4.2-r1
[Mar 15 22:25:32.350] esp32_main.c:68 Boot partition: app_0; flash: 4M
[Mar 15 22:25:32.355] mongoose.c:15666 Mongoose 6.18, LwIP 2.1.3
[Mar 15 22:25:32.359] mongoose.c:4928 mbed TLS 2.16.6-cesanta1
[Mar 15 22:25:32.366] mgos_vfs_dev.c:73 fs_0: esp32part ({"label": "fs_0"}), size 262144
[Mar 15 22:25:32.372] mgos_vfs_dev.c:73 fs_1: esp32part ({"label": "fs_1"}), size 262144
[Mar 15 22:25:32.379] mgos_vfs_dev.c:73 spif0: esp32part ({"label": "spif0"}), size 262144
[Mar 15 22:25:32.386] mgos_vfs.c:174 /: SPIFFS @ fs_0, opts {"bs":4096,"ps":256,"es":4096}
[Mar 15 22:25:32.466] mgos_vfs.c:347 /: size 233681, used: 1004, free: 232677
[Mar 15 22:25:32.533] mgos_sys_config.c:368 MAC: 24:6f:28:1e:93:70
[Mar 15 22:25:32.536] mgos_sys_config.c:376 WDT: 30 seconds
[Mar 15 22:25:32.540] mgos_deps_init.c:72 Init spi 1.0...
[Mar 15 22:25:32.546] esp32_spi_master.c:94 SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 5/-1/-1; native? yes)
[Mar 15 22:25:32.553] mgos_deps_init.c:72 Init fstab 1.0...
[Mar 15 22:25:32.558] mgos_vfs_dev_spi_fl:370 Failed to read JEDEC ID
[Mar 15 22:25:32.565] mgos_vfs_dev.c:66 Dev spi_flash {"cs": 21, "freq": 10000000} open failed: -7
[Mar 15 22:25:32.569] mgos_deps_init.c:74 fstab init failed
[Mar 15 22:25:32.573] mgos_freertos.c:184 MGOS init failed: -32