Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Rare behavior - ESP32 board fails when encrypting

bs_alexbs_alex Barcelona

Hi there,

I am trying to flash a piece of firmware on a ESP32 board (4MB) that is already encrypted. The flashing is successful but when it starts to re-encrypt the board, it fails when trying to encrypt ca.pem file.
I am using the latest version of mos tool and the encryption key is correct. This is what appears on my logs:

[Jun  8 10:13:56.415] mgos_vfs_fs_spiffs_e ca.pem: write failed: -10001 
[Jun  8 10:13:56.415] mgos_vfs_fs_spiffs_m SPIFFS mount failed
[Jun  8 10:13:56.424] mgos_vfs_mount       FS SPIFFS {"encr": true}: mount failed
[Jun  8 10:13:56.424] mgos_task            MGOS init failed: -5
[Jun  8 10:13:56.933] mgos_vfs_umount_all  Unmounting filesystems
[Jun  8 10:13:56.937] /opt/Espressif/esp-idf/components/freertos/queue.c:620 (xQueueTakeMutexRecursive)- assert failed!

[Jun  8 10:13:56.946] abort() was called at PC 0x4008efd3 on core 0

[Jun  8 10:13:56.950] 

[Jun  8 10:13:56.950] Backtrace: 0x4009149b 0x4009159b 0x4008efd3 0x40082f65 0x400ea888 0x400eaedf 0x400e350a 0x40082d7e

[Jun  8 10:13:56.959] --- BEGIN CORE DUMP ---
[Jun  8 10:13:56.961] {"arch": "ESP32", "cause":29,
[Jun  8 10:13:56.964] "REGS": {"addr": 1073545568, "data": "
[Jun  8 10:13:56.967] mxQJQJ4VCYCgJf4/LwAAAC8AAAAMAAAA/////wAAAAD+////AAAAAIAl/j8AAAAAMSX+P98k/j8wAAAAAAAAAOkk/j/vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd6sNghAtjYIQAAAAAAFAAAAAAAAAAEAAADvvq3e776t3iALBgDEMvk/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},
[Jun  8 10:13:57.016] "DRAM": {"addr": 1073405952, "data": "

That said, if I try to **flash the demo-js ** firmware, it works and the board is encrypted well. So, it obviously depends on the firmware I am trying to flash. This is the mos.yml file of the app I want to flash:

version: 1.0
manifest_version: 2017-05-18
libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}


config_schema:
  - ["mqtt.server", "iot.eclipse.org:1883"]
  - ["i2c.enable", true]
  - ["claim", "o", {"title": "Hello app settings"}]
  - ["claim.code", "s", "0", {"title": "Hello app settings"}]
  - ["shadow.ota_enable", "b", true, {title: "Enable OTA via shadow"}]
  - ["shadow.autocommit", "b", true, {title: "Autocommit OTA if the shadow connection is successful"}]

tags:
  - js

filesystem:
  - fs

libs:
  - origin: https://github.com/mongoose-os-libs/js-demo-bundle
  - origin: https://github.com/mongoose-os-libs/neopixel
  - origin: https://github.com/mongoose-os-libs/dash
  - origin: https://github.com/mongoose-os-libs/shadow


sources:
  - src

ffi_symbols:
  - mqttUnsubscribe

build_vars:
  MGOS_ENABLE_UPDATER: 1

If anyone has an idea of what it could be I would be very appreciated.
Thanks in advance.

Comments

  • tripflextripflex Orlando, FL

    I'm having the same issue as well:

    [Aug 10 17:40:26.884] esp32_fs_crypt_init  FS encryption key set up, seed @ 0x0
    [Aug 10 17:40:26.890] mgos_vfs_dev_create_ fs_0: esp32part ({"label": "fs_0"}), size 262144
    [Aug 10 17:40:26.897] mgos_vfs_dev_create_ fs_1: esp32part ({"label": "fs_1"}), size 262144
    [Aug 10 17:40:26.904] mgos_vfs_dev_create_ data: esp32part ({"label": "data"}), size 262144
    [Aug 10 17:40:26.911] mgos_vfs_mount_dev   /: SPIFFS @ fs_0, opts {"encr": true}
    [Aug 10 17:40:27.011] mgos_vfs_fs_spiffs_e Encrypting zone.js (id 56, size 2476) -> XXXXXX
    [Aug 10 17:40:27.024] mgos_vfs_fs_spiffs_e zone.js: update_meta failed: -10001
    [Aug 10 17:40:27.029] mgos_vfs_fs_spiffs_m SPIFFS mount failed
    [Aug 10 17:40:27.033] mgos_vfs_mount_dev   FS SPIFFS {"encr": true}: mount failed
    [Aug 10 17:40:27.038] mgos_core_init       FS init error
    [Aug 10 17:40:27.042] mgos_deps_init       core init failed
    [Aug 10 17:40:27.045] mgos_task            MGOS init failed: -32
    

    Tried freeing up some space and it now throws errors on different files, but same issue as above regardless .... any help would be appreciated!

  • bs_alexbs_alex Barcelona

    Hi @tripflex . Did you manage to fix it?
    Any insight?

  • SergeySergey Dublin, Ireland

    @bs_alex could you show the backtrace of your coredump please?

  • bs_alexbs_alex Barcelona

    Sure.

    [Sep 10 10:47:48.081] mgos_init2           empty 1.0 (20180908-075427)
    [Sep 10 10:47:48.081] mgos_init2           Mongoose OS 201809080754 (20180908-075425)
    [Sep 10 10:47:48.081] mgos_init2           CPU: 160 MHz, heap: 188272 total, 148612 free
    [Sep 10 10:47:48.081] mgos_init2           Newlib 2.2.0
    [Sep 10 10:47:48.081] mgos_hal_freertos_pr ESP-IDF v3.0-r11
    [Sep 10 10:47:48.082] mgos_hal_freertos_pr Boot partition: app_0; flash: 4M
    [Sep 10 10:47:48.085] mg_lwip_if_init      Mongoose 6.12, LwIP 1.5.0
    [Sep 10 10:47:48.089] mg_ssl_if_init       mbed TLS 2.8.0
    [Sep 10 10:47:48.095] esp32_fs_crypt_init  FS encryption key set up, seed @ 0x0
    [Sep 10 10:47:48.102] mgos_vfs_dev_create_ fs_0: esp32part ({"label": "fs_0"}), size 262144
    [Sep 10 10:47:48.116] mgos_vfs_dev_create_ fs_1: esp32part ({"label": "fs_1"}), size 262144
    [Sep 10 10:47:48.116] mgos_vfs_dev_create_ fs_ext: esp32part ({"label": "fs_ext"}), size 262144
    [Sep 10 10:47:48.121] mgos_vfs_mount_dev   /: SPIFFS @ fs_0, opts {"encr": true}
    [Sep 10 10:47:48.253] mgos_vfs_fs_spiffs_e Encrypting api_file.js (id 1, size 2105) -> pGAJfdEruerVEJzlpM1X9I2kwI//ci5hFrQmiYvYcKw=
    [Sep 10 10:47:48.462] mgos_vfs_fs_spiffs_e Encrypting ca.pem (id 2, size 18826) -> HKh/in9whWnhvXe1LwvTLI2kwI//ci5hFrQmiYvYcKw=
    [Sep 10 10:47:53.540] mgos_vfs_fs_spiffs_e ca.pem: write failed: -10001
    [Sep 10 10:47:53.543] mgos_vfs_fs_spiffs_m SPIFFS mount failed
    [Sep 10 10:47:53.549] mgos_vfs_mount_dev   FS SPIFFS {"encr": true}: mount failed
    [Sep 10 10:47:53.552] mgos_core_init       FS init failed
    [Sep 10 10:47:53.555] mgos_deps_init       core init failed
    [Sep 10 10:47:53.559] mgos_task            MGOS init failed: -32
    [Sep 10 10:47:54.063] mgos_vfs_umount_all  Unmounting filesystems
    [Sep 10 10:47:54.066] mgos_system_restart  Restarting
    [Sep 10 10:47:54.097] ets Jun  8 2016 00:22:57
    [Sep 10 10:47:54.097] 
    [Sep 10 10:47:54.097] rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    [Sep 10 10:47:54.097] configsip: 0, SPIWP:0xee
    [Sep 10 10:47:54.097] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    [Sep 10 10:47:54.097] mode:DIO, clock div:2
    [Sep 10 10:47:54.098] load:0x3fff0018,len:4
    [Sep 10 10:47:54.098] load:0x3fff001c,len:5576
    [Sep 10 10:47:54.098] load:0x40078000,len:0
    [Sep 10 10:47:54.098] ho 12 tail 0 room 4
    [Sep 10 10:47:54.144] [0;32mI (30) boot: ESP-IDF v3.0-r11 2nd stage bootloader[0m
    [Sep 10 10:47:54.144] [0;32mI (30) boot: compile time 07:54:18[0m
    [Sep 10 10:47:54.144] [0;32mI (30) boot: Enabling RNG early entropy source...[0m
    [Sep 10 10:47:54.144] [0;32mI (35) boot: SPI Speed      : 40MHz[0m
    [Sep 10 10:47:54.144] [0;32mI (39) boot: SPI Mode       : DIO[0m
    [Sep 10 10:47:54.145] [0;32mI (43) boot: SPI Flash Size : 4MB[0m
    [Sep 10 10:47:54.145] [0;32mI (47) boot: Partition Table:[0m
    [Sep 10 10:47:54.145] [0;32mI (51) boot: ## Label            Usage          Type ST Offset   Length   Flags[0m
    [Sep 10 10:47:54.145] [0;32mI (59) boot:  0 nvs              WiFi data        01 02 00009000 00004000 00000000[0m
    [Sep 10 10:47:54.188] [0;32mI (67) boot:  1 otadata          OTA data         01 00 0000d000 00002000 00000000[0m
    [Sep 10 10:47:54.188] [0;32mI (75) boot:  2 app_0            OTA app          00 10 00010000 00180000 00000000[0m
    [Sep 10 10:47:54.188] [0;32mI (84) boot:  3 fs_0             SPIFFS           01 82 00190000 00040000 00000000[0m
    [Sep 10 10:47:54.188] [0;32mI (92) boot:  4 app_1            OTA app          00 11 001d0000 00180000 00000000[0m
    [Sep 10 10:47:54.188] [0;32mI (100) boot:  5 fs_1             SPIFFS           01 82 00350000 00040000 00000000[0m
    [Sep 10 10:47:54.188] [0;32mI (109) boot:  6 fs_ext           SPIFFS           01 82 00390000 00040000 00000000[0m
    [Sep 10 10:47:54.224] [0;32mI (117) boot: End of partition table[0m
    [Sep 10 10:47:54.224] [0;32mI (121) boot: OTA data 0: seq 0x00000001, st 0x10, CRC 0x157a2b85, valid? 1[0m
    [Sep 10 10:47:54.225] [0;32mI (129) boot: OTA data 1: seq 0x00000000, st 0x00, CRC 0x00000000, valid? 0[0m
    [Sep 10 10:47:54.225] [0;32mI (136) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x40974 (264564) map[0m
    [Sep 10 10:47:54.345] [0;32mI (241) esp_image: segment 1: paddr=0x0005099c vaddr=0x3ffc0000 size=0x03688 ( 13960) load[0m
    [Sep 10 10:47:54.345] [0;32mI (247) esp_image: segment 2: paddr=0x0005402c vaddr=0x3ffc3688 size=0x00000 (     0) load[0m
    [Sep 10 10:47:54.345] [0;32mI (248) esp_image: segment 3: paddr=0x00054034 vaddr=0x40080000 size=0x00400 (  1024) load[0m
    [Sep 10 10:47:54.345] [0;32mI (257) esp_image: segment 4: paddr=0x0005443c vaddr=0x40080400 size=0x0bbd4 ( 48084) load[0m
    [Sep 10 10:47:54.362] [0;32mI (286) esp_image: segment 5: paddr=0x00060018 vaddr=0x400d0018 size=0x10a390 (1090448) map[0m
    [Sep 10 10:47:54.757] [0;32mI (681) esp_image: segment 6: paddr=0x0016a3b0 vaddr=0x4008bfd4 size=0x0ac50 ( 44112) load[0m
    [Sep 10 10:47:54.785] [0;32mI (699) esp_image: segment 7: paddr=0x00175008 vaddr=0x400c0000 size=0x00034 (    52) load[0m
    [Sep 10 10:47:54.785] [0;32mI (700) esp_image: segment 8: paddr=0x00175044 vaddr=0x50000000 size=0x00000 (     0) load[0m
    [Sep 10 10:47:54.831] [0;32mI (719) boot: Loaded app from partition at offset 0x10000[0m
    [Sep 10 10:47:54.832] [0;32mI (719) boot: Disabling RNG early entropy source...[0m
    [Sep 10 10:47:54.832] [0;32mI (720) cpu_start: Pro cpu up.[0m
    [Sep 10 10:47:54.832] [0;32mI (723) cpu_start: Single core mode[0m
    [Sep 10 10:47:54.832] [0;32mI (728) heap_init: Initializing. RAM available for dynamic allocation:[0m
    [Sep 10 10:47:54.832] [0;32mI (735) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM[0m
    [Sep 10 10:47:54.832] [0;32mI (741) heap_init: At 3FFD1808 len 0000E7F8 (57 KiB): DRAM[0m
    [Sep 10 10:47:54.832] [0;32mI (747) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
    [Sep 10 10:47:54.850] [0;32mI (753) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
    [Sep 10 10:47:54.850] [0;32mI (760) heap_init: At 40096C24 len 000093DC (36 KiB): IRAM[0m
    [Sep 10 10:47:54.850] [0;32mI (766) cpu_start: Pro cpu start user code[0m
    [Sep 10 10:47:54.857] [0;32mI (113) cpu_start: Starting scheduler on PRO CPU.[0m
    [Sep 10 10:47:54.891] mgos_init2           empty 1.0 (20180908-075427)
    [Sep 10 10:47:54.891] mgos_init2           Mongoose OS 201809080754 (20180908-075425)
    [Sep 10 10:47:54.891] mgos_init2           CPU: 160 MHz, heap: 188272 total, 148612 free
    [Sep 10 10:47:54.891] mgos_init2           Newlib 2.2.0
    [Sep 10 10:47:54.891] mgos_hal_freertos_pr ESP-IDF v3.0-r11
    [Sep 10 10:47:54.891] mgos_hal_freertos_pr Boot partition: app_0; flash: 4M
    [Sep 10 10:47:54.895] mg_lwip_if_init      Mongoose 6.12, LwIP 1.5.0
    [Sep 10 10:47:54.898] mg_ssl_if_init       mbed TLS 2.8.0
    [Sep 10 10:47:54.905] esp32_fs_crypt_init  FS encryption key set up, seed @ 0x0
    [Sep 10 10:47:54.913] mgos_vfs_dev_create_ fs_0: esp32part ({"label": "fs_0"}), size 262144
    [Sep 10 10:47:54.919] mgos_vfs_dev_create_ fs_1: esp32part ({"label": "fs_1"}), size 262144
    [Sep 10 10:47:54.926] mgos_vfs_dev_create_ fs_ext: esp32part ({"label": "fs_ext"}), size 262144
    [Sep 10 10:47:54.931] mgos_vfs_mount_dev   /: SPIFFS @ fs_0, opts {"encr": true}
    [Sep 10 10:47:55.064] mgos_vfs_fs_spiffs_e Encrypting conf0.json (id 3, size 2762) -> oDcQMHLKXYhXtHc97IasYY2kwI//ci5hFrQmiYvYcKw=
    [Sep 10 10:47:56.747] mgos_vfs_fs_spiffs_e Encrypting api_events.js (id 29, size 3398) -> ekXeGsYZ209AtIPG3uW89I2kwI//ci5hFrQmiYvYcKw=
    
  • Do you start mos console immediately after mos flash?
    If yes, try to wait 30-60 seconds before running mos console to allow the encryption process to finish.

  • bs_alexbs_alex Barcelona

    Nope. Actually, I first open MOS UI, and run the mos flash command from the Command Line embedded in the MOS UI.
    The strange thing is that, a code that is fully working and can be flashed and encrypted, if I just add a 'print("test");' then it build correctly, but fails in encrypting and isseus the same error I copied before.

  • Try to use only the command line of the operating system, not the Web UI.

  • bs_alexbs_alex Barcelona

    Tried to do so, and get same results.

  • Well, it happened to me too while encrypting about 240k filesystem. I waited more than 5 minutes before launching mos console...

Sign In or Register to comment.