Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

esp32 W25N01 VFS Usage

diridiridiridiri Daejeon
edited October 21 in Mongoose OS

Hi, I'm trying to connect W25N01 as my vfs using SPI protocal to esp32,

But I can't acquire W25N01 with command

mos call FS.Mkfs '{"dev_type": "w25xxx", "dev_opts": "{\"freq\": 48000000, \"cs\": 0}", "fs_type": "SPIFFS", "fs_opts": "{\"size\": 1073741824}"}'

I'm using mos 2.6, with command line tool version 201810191116.

and my mos.yml looks like

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}~~~~

tags:
  - c
  - js
  - aws
  - arduino
  - vfs
  - docs:drivers:VFS (SPI NOR Flash)

sources:
  - src

filesystem:
  - fs

config_schema:
  - ["wifi.ap.enable", true]
  - ["wifi.ap.ssid", "test-esp-ap"]
  - ["wifi.ap.pass", "test-esp-ap"]

  - ["wifi.sta.enable", false]
  - ["wifi.sta.ssid", "test-esp"]
  - ["wifi.sta.pass", "test-esp"]

  - ["i2c.enable", true]
  - ["sntp.enable", "b", true, {title: "Enable SNTP"}]
  - ["spi.enable", true]

  - ["device.owner", "s", "", {title: "owner id"}]

libs:
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-uart
  - origin: https://github.com/mongoose-os-libs/dht
  - origin: https://github.com/mongoose-os-libs/mjs
  - origin: https://github.com/mongoose-os-libs/http-server
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/pwm
  - origin: https://github.com/mongoose-os-libs/adc
  - origin: https://github.com/mongoose-os-libs/sntp
  - origin: https://github.com/mongoose-os-libs/ds3231
  - origin: https://github.com/mongoose-os-libs/spi
  - origin: https://github.com/mongoose-os-libs/vfs-dev-w25xxx

manifest_version: 2017-09-29

when I run the firmware, It says
mgos_spi_create SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 5/-1/-1; native? yes)

when I call command above,

Error message is like
[Oct 22 05:43:49.943] mg_rpc_handle_reques FS.Mkfs via UART UART0
[Oct 22 05:43:49.943] vfs_dev_w25xxx_detec Failed to read JEDEC ID
[Oct 22 05:43:49.949] mgos_vfs_dev_create_ Dev w25xxx {"freq": 48000000, "cs": 0} open failed: -7

Can you help me with connecting to W25N01 please?

Thanks!

Comments

  • rojerrojer Dublin, Ireland
    edited October 24

    how do you connect w25n01 to the esp32? which pins do you connect to which?
    also please post full boot log.

    Thanked by 1diridiri
  • diridiridiridiri Daejeon
    edited October 29

    Sorry for late response,

    I've changed W25Q256FV to W25N01 pin settings are all same

    miso : 19
    mosi : 23
    sclk : 18
    cs0 : 5
    

    full boot log is as below.

    [Oct 30 00:27:05.262] ets Jun  8 2016 00:22:57
    [Oct 30 00:27:05.262] 
    [Oct 30 00:27:05.262] rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    [Oct 30 00:27:05.267] configsip: 0, SPIWP:0xee
    [Oct 30 00:27:05.267] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    [Oct 30 00:27:05.272] mode:DIO, clock div:2
    [Oct 30 00:27:05.277] load:0x3fff0018,len:4
    [Oct 30 00:27:05.277] load:0x3fff001c,len:5788
    [Oct 30 00:27:05.283] load:0x40078000,len:8252
    [Oct 30 00:27:05.283] ho 0 tail 12 room 4
    [Oct 30 00:27:05.283] load:0x40080400,len:6716
    [Oct 30 00:27:05.290] entry 0x40080760
    [Oct 30 00:27:05.290] [0;32mI (30) boot: ESP-IDF v3.1-r3 2nd stage bootloader[0m
    [0;32mI (30) boot: compi[Oct 30 00:27:05.300] le time 14:48:25[0m
    [Oct 30 00:27:05.300] [0;32mI (30) boot: Enabling RNG early entropy source...[0m
    [0;32mI (35) boot: SPI Speed      : 40MHz[0m
    [Oct 30 00:27:05.311] [0;32mI (39) boot: SPI Mode       : DIO[0m
    [Oct 30 00:27:05.311] [0;32mI (43) boot: SPI Flash Size : 4MB[0m
    [Oct 30 00:27:05.317] [0;32mI (47) boot: Partition Table:[0m
    [Oct 30 00:27:05.322] [0;32mI (51) boot: ## Label            Usag[Oct 30 00:27:05.327] e          Type ST Offset   Length   Flags[0m
    [Oct 30 00:27:05.327] [0;32mI (59) boot:  0 nvs              WiFi data        01 02 00009000 00004000 00000000[0m
    [Oct 30 00:27:05.338] [0;32mI (67) boot:  1 otadata          OTA data         01 00 0000d000 00002000 00000000[0m
    [0;32mI (75) boot:  2 app_0            OTA app          00 10 00010000 00180000 00000000[0m
    [Oct 30 00:27:05.354] [0;32mI (83) boot:  3 fs_0             SPIFFS           01 82 00190000 00040000 00000000[0m
    [Oct 30 00:27:05.360] [0;32mI (92) boot:  4 app_1            OTA app          00 11 001d0000 00180000 00000000[0m
    [Oct 30 00:27:05.370] [0;32mI (100) boot:  5 fs_1             SPIFFS           01 82 00350000 00040000 00000000[0m
    [Oct 30 00:27:05.376] [0;32mI (108) boot: End of partition table[0m
    [Oct 30 00:27:05.381] [0;32mI (112) boot: OTA data 0: seq 0x00000001, st 0x10, CRC 0x157a2b85, valid? 1[0m
    [Oct 30 00:27:05.392] [0;32mI (120) boot: OTA data 1: seq 0x00000000, st 0x00, CRC 0x00000000, valid? 0[0m
    [Oct 30 00:27:05.397] [0;32mI (128) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2785c (161884) map[0m
    [Oct 30 00:27:05.450] [0;32mI (192) esp_image: segment 1: paddr=0x00037884 vaddr=0x3ffb0000 size=0x02bb0 ( 11184) load[0m
    [Oct 30 00:27:05.461] [0;32mI (196) esp_image: segment 2: paddr=0x0003a43c vaddr=0x3ffb2bb0 size=0x00000 (     0) load[0m
    [Oct 30 00:27:05.471] [0;32mI (199) esp_image: segment 3: paddr=0x0003a444 vaddr=0x40080000 size=0x00400 (  1024) load[0m
    [Oct 30 00:27:05.477] [0;32mI (208) esp_image: segment 4: paddr=0x0003a84c vaddr=0x40080400 size=0x057c[Oct 30 00:27:05.488] 4 ( 22468) load[0m
    [Oct 30 00:27:05.488] [0;32mI (225) esp_image: segment 5: paddr=0x00040018 vaddr=0x400d0018 size=0xbb494 (767124) map[0m
    [Oct 30 00:27:05.748] [0;32mI (487) esp_image: segment 6: paddr=0x000fb4b4 vaddr=0x40085bc4 size=0x0c784 ( 51076) load[0m
    [Oct 30 00:27:05.764] [0;32mI (507) esp_image: segment 7: paddr=0x00107c40 vaddr=0x400c0000 size=0x00034 (    52) load[0m
    [Oct 30 00:27:05.775] [0;32mI (507) esp_image: segment 8: paddr=0x00107c7c vaddr=0x50000000 size=0x00000 (     0) load[0m
    [Oct 30 00:27:05.786] [0;32mI (524) boot: Loaded app from partition at offset 0x10000[0m
    [0;32mI (525) boot: Disabling RNG early entropy source...[0m
    [Oct 30 00:27:05.796] [0;32mI (526) cpu_start: Pro cpu up.[0m
    [Oct 30 00:27:05.802] [0;32mI (529) cpu_start: Single core mode[0m
    [Oct 30 00:27:05.802] [0;32mI (534) heap_init: Initializing. RAM available for dynamic allocation:[0m
    [Oct 30 00:27:05.813] [0;32mI (541) heap_init: At 3FFAE6E0 len 00001920 ([Oct 30 00:27:05.818] 6 KiB): DRAM[0m
    [Oct 30 00:27:05.818] [0;32mI (547) heap_init: At 3FFB8CB8 len 00027348 (156 KiB): DRAM[0m
    [Oct 30 00:27:05.823] [0;32mI (553) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
    [Oct 30 00:27:05.829] [0;32mI (559) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
    [Oct 30 00:27:05.834] [0;32mI (566) heap_init: At 40092348 len 0000DCB8 (55 KiB): IRAM[0m
    [Oct 30 00:27:05.839] [0;32mI (572) cpu_start: Pro cpu start user code[0m
    [Oct 30 00:27:05.847] [0;32mI (254) cpu_start: Starting scheduler on PRO CPU.[0m
    [Oct 30 00:27:05.861] mgos_init2           MOGG_FW 1.0 (20181029-144923)
    [Oct 30 00:27:05.866] mgos_init2           Mongoose OS 201810291449 (20181029-144921)
    [Oct 30 00:27:05.872] mgos_init2           CPU: 160 MHz, heap: 295632 total, 255440 free
    [Oct 30 00:27:05.877] mgos_init2           Newlib 2.2.0
    [Oct 30 00:27:05.882] mgos_hal_freertos_pr ESP-IDF v3.1-r3
    [Oct 30 00:27:05.888] mgos_hal_freertos_pr Boot partition: app_0; flash: 4M
    [Oct 30 00:27:05.888] mg_lwip_if_init      Mongoose 6.13, LwIP 2.0.3
    [Oct 30 00:27:05.894] mg_ssl_if_init       mbed TLS 2.13.1-cesanta2
    [Oct 30 00:27:05.901] mgos_vfs_dev_create_ fs_0: esp32part ({"label": "fs_0"}), size 262144
    [Oct 30 00:27:05.907] mgos_vfs_dev_create_ fs_1: esp32part ({"label": "fs_1"}), size 262144
    [Oct 30 00:27:05.913] mgos_vfs_mount_dev   /:[Oct 30 00:27:05.928]  SPIFFS @ fs_0, opts {"bs": 4096, "ps": 256, "es": 4096}
    mgos_vfs_print_fs_in /: size 233681, used: 109938, free: 123743
    [Oct 30 00:27:06.110] mgos_sys_config_init MAC: 240AC49EACD8
    mgos_sys_config_init WDT: 30 seconds
    [Oct 30 00:27:06.119] mgos_i2c_create      I2C0 init ok (SDA: 32, SCL: 33, freq: 100000)
    [Oct 30 00:27:06.125] mgos_wifi_setup      WiFi mode: AP
    esp32_wifi_set_mode  WiFi mode: AP
    I (817) wifi: wifi driver task: 3ffc214c, prio:23, stack:3584, core=0
    [Oct 30 00:27:06.138] I (817) wifi: wifi firmware version: d8b211c
    [Oct 30 00:27:06.144] I (827) wifi: config NVS flash: enabled
    [Oct 30 00:27:06.144] I (827) wifi: config nano formating: disabled
    I (837) wifi: Init dynamic tx buffer num: 32
    [Oct 30 00:27:06.163] I (847) wifi: Init data frame dynamic[Oct 30 00:27:06.168]  rx buffer num: 64
    [Oct 30 00:27:06.168] I (847) wifi: Init management frame dynamic rx buffer num: 64
    I (857) wifi: Init static rx buffer size: 1[Oct 30 00:27:06.179] 600
    [Oct 30 00:27:06.180] I (857) wifi: Init static rx buffer num: 10
    [Oct 30 00:27:06.180] I (867) wifi: Init dynamic rx buffer num: 0
    [Oct 30 00:27:06.243] [0;32mI (927) phy: phy_version: 4000, b6198fa, Sep  3 2018, 15:11:06, 0, 0[0m
    [Oct 30 00:27:06.248] I (927) wifi: mode : softAP (24:0a:c4:9e:ac:d9)
    [Oct 30 00:27:06.256] I (937) wifi: Set ps type: 0
    [Oct 30 00:27:06.256] 
    [Oct 30 00:27:06.256] mgos_wifi_dev_ap_set WiFi AP: SSID test-esp-ap, channel 6
    [Oct 30 00:27:07.110] mgos_wifi_dev_ap_set WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP range 192.168.4.2 - 192.168.4.100
    [Oct 30 00:27:07.117] mgos_wifi_dev_ap_set WiFi AP: SSID test-esp-ap, channel 6
    mgos_http_server_ini HTTP server started on [80]
    [Oct 30 00:27:07.135] mg_rpc_channel_uart  0x3ffc[Oct 30 00:27:07.142] 98b0 UART0
    [Oct 30 00:27:07.142] mgos_spi_create      SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 5/-1/-1; native? yes)
    [Oct 30 00:27:07.148] mgos_init            Init done, RAM: 294948 total, 220856 free, 220856 min free
    [Oct 30 00:27:08.012] mongoose_poll        New heap free LWM: 175956
    

    Thanks for reply, rojer

  • rojerrojer Dublin, Ireland

    SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 5/-1/-1; native? yes) ok, so assuming that matches... i noticed that you use high clock speed, 48 mhz. ESP32 SPI is a bit tricky at >= 40 mhz, i'm not sure it's set up correctly. try "freq": 20000000.

    Thanked by 1diridiri
  • It's not working yet but I think it progressed!

    previously it was

    [Oct 30 01:20:29.259] mg_rpc_handle_reques FS.Mkfs via UART UART0
    [Oct 30 01:20:29.259] vfs_dev_w25xxx_detec Failed to read JEDEC ID
    [Oct 30 01:20:29.265] mgos_vfs_dev_create_ Dev w25xxx {"freq": 48000000, "cs": 0} open failed: -7
    [Oct 30 01:20:29.272] 
    [Oct 30 01:20:29.272] 
    [Oct 30 01:20:29.272] 
    [Oct 30 01:20:29.293] 
    Server Error: {"error":"remote error 500: mkfs failed"}
    

    but now debug text is like

    [Oct 30 01:18:53.834] mg_rpc_handle_reques FS.Mkfs via UART UART0
    [Oct 30 01:18:53.834] vfs_dev_w25xxx_det[Oct 30 01:18:53.839] ec Invalid chip ID (got 00 00 00)
    [Oct 30 01:18:53.839] mgos_vfs_dev_create_ Dev w25xxx {"freq": 20000000, "cs": 0} open failed: -7
    [Oct 30 01:18:53.846] 
    [Oct 30 01:18:53.846] 
    [Oct 30 01:18:53.846] 
    [Oct 30 01:18:53.867] 
    Server Error: {"error":"remote error 500: mkfs failed"}
    

    so it tries to read ID (not JEDEC ID)
    but it reads 00 00 00

    Thanks rojer

  • rojerrojer Dublin, Ireland

    hardly a progress, really :)
    actually, looking at your schematics again - you ground both /wp and /hold pins, which are active-low. you are write-proceting your device and blocking spi communications. you need to pull these pins up.

  • Thanks rojer,

    That must be the reason! I'll try it right away and reply soon

Sign In or Register to comment.