Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

VFS SPI Flash issue.

siftd106siftd106 United States
edited May 2018 in Mongoose OS

Hello,

I am having some issus getting an external spi flash chip to work with an esp32. We have a 32MB flash chip (IS25LP256D-JLLE) connected to a SPI mux (MAX14662ETI+).

I add this to my mos.yml

build_vars: 
  ESP_IDF_EXTRA_PARTITION: fs_ext,data,spiffs,,256K

If I change the 256K to anything larger I get the following error in the console.

[May 25 14:10:30.845]      x  x  x x x x    ets Jun  8 2016 00:22:57
[May 25 14:10:30.845] 
[May 25 14:10:30.851] rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
[May 25 14:10:30.856] configsip: 0, SPIWP:0xee
[May 25 14:10:30.862] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[May 25 14:10:30.862] mode:DIO, clock div:2
[May 25 14:10:30.862] load:0x3fff0018,len:4
[May 25 14:10:30.867] load:0x3fff001c,len:5508
[May 25 14:10:30.867] load:0x40078000,len:0
[May 25 14:10:30.871] load:0x40078000,len:12764
[May 25 14:10:30.871] entry 0x400785a4
[May 25 14:10:30.883] I (28) boot: ESP-IDF v3.0-rc1-r9 2nd stage bootloader
[May 25 14:10:30.883] I (28) boot: compile time 18:09:21
[May 25 14:10:30.889] I (40) boot: Enabling RNG early entropy source...
[May 25 14:10:30.895] I (40) boot: SPI Speed      : 40MHz
[May 25 14:10:30.900] I (40) boot: SPI Mode       : DIO
[May 25 14:10:30.906] I (44) boot: SPI Flash Size : 4MB
[May 25 14:10:30.911] E (48) flash_parts: partition 6 invalid - offset 0x390000 size 0x80000 exceeds flash chip size 0x400000
[May 25 14:10:30.917] E (58) boot: Failed to verify partition table
[May 25 14:10:30.924] E (63) boot: load partition table error!
[May 25 14:10:30.924] user code done

The above issue may be related to the following issues as well.

In order to get console output during the mkfs and mount commands, I have implemented them in code, as follows.

MAX14662E.selectSpiSwitch(2); // tell the mux I want to communicate with the flash chip.
RPC.call(RPC.LOCAL, 'FS.Mkfs', {dev_type: "spi_flash", dev_opts: "{\"label\": \"fs_ext\", \"freq\":10000000, \"cs\":1, \"mode\":0, \"size\": \"256\"}", fs_type: "SPIFFS", fs_opts: "{\"force\": true}" }, function (resp, ud) {
  print('Mkfs Response:', JSON.stringify(resp));
  RPC.call(RPC.LOCAL, 'FS.Mount', {dev_type: "spi_flash", dev_opts: "{\"label\": \"fs_ext\", \"freq\":10000000, \"cs\":1, \"mode\":0, \"size\": \"256\"}", fs_type: "SPIFFS", path: "/mnt"}, function (resp, ud) {
    print('Mount Response:', JSON.stringify(resp));
    print("Writing file");
    print(File.write("hello world", "/mnt/hello.txt"));
  }, null);
}, null);

Using this code gives me the following output.

...
[May 25 14:20:25.181] mongoose_poll        New heap free LWM: 107944
[May 25 14:20:25.195] mgos_vfs_dev_open    spi_flash ({"label": "fs_ext", "freq":10000000, "cs":1, "mode":0, "size": "256"}) -> 0x3ffb9030
[May 25 14:20:25.203] mgos_vfs_dev_spi_fla Chip ID: 9d 60, size: 256
[May 25 14:20:25.210] mgos_vfs_mkfs        Create SPIFFS (dev 0x3ffb9030, opts {"force": true})
[May 25 14:20:25.253] Mkfs Response: null 
[May 25 14:20:25.311] mgos_vfs_dev_open    spi_flash ({"label": "fs_ext", "freq":10000000, "cs":1, "mode":0, "size": "256"}) -> 0x3ffbd9d8
[May 25 14:20:25.319] mgos_vfs_dev_spi_fla Chip ID: 9d 60, size: 256
[May 25 14:20:25.326] mgos_vfs_mount       Mount SPIFFS @ /mnt (dev 0x3ffbd9d8, opts ) -> 0x3ffb9030
[May 25 14:20:25.334] mgos_vfs_mount       /mnt: size 4294960017, used: 0, free: 4294960017
[May 25 14:20:25.347] Mount Response: null 
[May 25 14:20:25.347] Writing file 
[May 25 14:20:25.354] 0

If I do not specify the size in the dev_opts I as shown here...

MAX14662E.selectSpiSwitch(2); // tell the mux I want to communicate with the flash chip.
RPC.call(RPC.LOCAL, 'FS.Mkfs', {dev_type: "spi_flash", dev_opts: "{\"label\": \"fs_ext\", \"freq\":10000000, \"cs\":1, \"mode\":0}", fs_type: "SPIFFS", fs_opts: "{\"force\": true}" }, function (resp, ud) {
  print('Mkfs Response:', JSON.stringify(resp));
  RPC.call(RPC.LOCAL, 'FS.Mount', {dev_type: "spi_flash", dev_opts: "{\"label\": \"fs_ext\", \"freq\":10000000, \"cs\":1, \"mode\":0}", fs_type: "SPIFFS", path: "/mnt"}, function (resp, ud) {
    print('Mount Response:', JSON.stringify(resp));
    print("Writing file");
    print(File.write("hello world", "/mnt/hello.txt"));
  }, null);
}, null);

...I get the following error.

...
[May 25 14:24:06.434] mongoose_poll        New heap free LWM: 108056
[May 25 14:24:06.447] mgos_vfs_dev_open    spi_flash ({"label": "fs_ext", "freq":10000000, "cs":1, "mode":0}) -> 0x3ffb42e4
[May 25 14:24:06.455] mgos_vfs_dev_spi_fla Chip ID: 9d 60, size: 33554432
[May 25 14:24:06.462] mgos_vfs_mkfs        Create SPIFFS (dev 0x3ffb42e4, opts {"force": true})
[May 25 14:24:36.444] Task watchdog got triggered. The following tasks did not reset the watchdog in time:
[May 25 14:24:36.461]  - mgos (CPU 0/1), backtrace: 0x401028be 0x40102977 0x40102d11 0x40102eed 0x400e4a6d 0x401049b6 0x401030c5 0x400e4ca4 0x400e3de3 0x40100ca0 0x400f2335 0x400f258f 0x4010019d 0x40082d8e
[May 25 14:24:36.461] 
[May 25 14:24:36.461] Tasks currently running:
[May 25 14:24:36.461] CPU 0: mgos
[May 25 14:24:36.466] Aborting.
[May 25 14:24:36.466] abort() was called at PC 0x400d0b84 on core 0
[May 25 14:24:36.467] 
[May 25 14:24:36.472] Backtrace: 0x4009147b 0x4009157b 0x400d0b84 0x4008166e 0x401028bb
[May 25 14:24:36.478] --- BEGIN CORE DUMP ---
[May 25 14:24:36.478] mos: catching core dump

I also had issues with the spi frequency, which lowing down to 1000000 seemed to resolve it.

So my questions are...
1) How can I partition and format using the full 32MB?
2) Why does the mount fail and/or the mkfs
3) Any idea why I need to use a lower frequency (20000 - 1000000)

Thanks in advance for your help!

-Joel

Comments

Sign In or Register to comment.