Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

External VFS troubles


I'm trying to get an external Flash chip working: W25Q32FVSSIG (on an ESP32)
It's a 32MBit chip, I believe this is the data sheet: Sheets/Winbond PDFs/W25Q32FV.pdf

This what I did so far:
- Cloned an empty app.
- Added the following to mos.yml:

- ["spi.enable", true]
- ["sys.esp32_adc_vref", 3300] # ADC Vref is 3.3V
- ["spi.mosi_gpio", 23]
- ["spi.miso_gpio", 19]
- ["spi.sclk_gpio", 18]
- ["spi.freq", 20000000]
- ["spi.cs0_gpio", 15] # VFS Flash

- origin:
- origin:
- origin:
- origin:
- origin:
- origin:
- origin:
- origin:
- origin:
- origin:
- origin:
- origin:

I attached the chip as follows:

Pin 1: CS -> gpio15
Pin 2: SO -> gpio19
Pin 3: WP -> 3.3V
Pin 4: GND -> GND
Pin 5: SI -> gpio23
Pin 6: SCK -> gpio18
Pin 7: Hold -> 3.3V
Pin 8: VCC -> 3.3V

I leave main.c as is and can compile and flash the firmware.
When booting I can see:
esp32_spi_master.c:93 SPI3 init ok (MISO: 19, MOSI: 23, SCLK: 18; CS0/1/2: 15/-1/-1; native? yes)

From within the mos tool I then tried to create a filesystem using different commands I found in another forum post:

mos call FS.Mkfs '{"dev_type": "w25xxx", "dev_opts": "{\"freq\": 20000000, \"cs\": 0}", "fs_type": "SPIFFS", "fs_opts": "{\"size\": 1073741824}"}'
mos call FS.Mkfs '{"dev_type": "w25xxx", "dev_opts": "{\"freq\": 20000000, \"cs\": 0}", "fs_type": "LFS", "fs_opts": "{\"bs\": 131072, \"is\": 8192}"}' --logtostderr

And I get:
I0302 18:08:45.569889    8660 main.go:233] Version: 2.12.1
I0302 18:08:45.569889    8660 main.go:234] Build ID: 20190222-142855/2.12.1-g980a486
I0302 18:08:45.569889    8660 main.go:235] Update channel: release
Using port COM18
I0302 18:08:45.570882    8660 ourutil.go:16] Using port COM18
I0302 18:08:45.570882    8660 serial.go:67] Opening COM18...
I0302 18:08:45.580361    8660 serial.go:82] COM18 opened: &{0x1406e828 664 {0 0} {0 0} 0x14073240 0x14073260}, err: <nil>
I0302 18:08:45.586853    8660 serial.go:308] handshake complete
I0302 18:08:45.893861    8660 serial.go:262] closing serial COM18
I0302 18:08:46.095006    8660 mgrpc.go:308] devConn is disconnected, breaking out of the recvLoop (EOF)
I0302 18:08:46.595056    8660 main.go:282] Error: /go/src/ remote error 500: mkfs failed
/go/src/ call failed
Error: /go/src/ remote error 500: mkfs failed
/go/src/ call failed

I presume I'm doing something wrong, no idea what however...
Do I have to initialise the device or something?


  • Hi,

    Add to your yml file:

         MGOS_ENABLE_SPI_GPIO: 1 # for SPI flash

    Also it is a good idea to watch the console and issue RPC commands via wifi :)

  • You also don't need vfs-dev-w25xxx library, vfs-dev-spi-flash is enough. For dev_type use spi_flash and not w25xxx.

  • mamuespmamuesp Germany/Northern coast
    edited March 2

    Have you looked into this HowTo? Even it's a more extended theme, there are some hints in the right direction.

  • MisterAMisterA Belgium

    By adding that line to mos.yml, I could execute the following command in my test setup:

    mos call FS.Mkfs '{"dev_type": "spi_flash", "dev_opts": "{\"freq\": 20000000, \"cs\": 0,\"label\": \"fs_ext\"}", "fs_type": "LFS", "fs_opts": "{\"bs\": 131072, \"is\": 8192}"}' --logtostderr

    But then this fails:
    mos call FS.Mount '{"dev_type": "spi_flash", "dev_opts": "{\"label\": \"fs_ext\"}", "fs_type": "LFS", "path": "/mnt"}'

    But shouldn't I be seeing some log entries in the log window within the MOS tool? Nothing is being show, so I have no clue what's going on or what's wrong.

    I added the same line in mos.yml on my real project, but there the same fs.mkfs command fails. Don't know if the fact that I have two other SPI devices on the SPI bus has something to do with it.
    I have an ILI9341 screen on cs1, a touchscreen controller on cs2 and the VFS Flash on cs0.

  • I call mount like this:

    mos --port ws:// call FS.Mount '{"dev_type": "spi_flash", "fs_type": "LFS", "fs_opts": "{\"size\": 1048576}", "path": "/mnt", "dev_opts": "{\"freq\": 20000000, \"cs\": 0}"}'

    If you send commands via UART (eg. --port /dev/ttyUSB0 or --port COM3) then you won't see console because you can't have the same port poened twice.

    Thanked by 1MisterA
  • MisterAMisterA Belgium


    just wanted to thank you for your pointers. Got LFS created and mounted!

    Best regards,

Sign In or Register to comment.