• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

Проблема с LittleFS, Wemos D1 mini

Motobiker

Member
Всем привет.

Если монтирую LittleFS в программе с небольшим кодом, то всё OK.
В более менее крупном коде не получается смонтировать.
Судя по описанию устройства памяти в ESP8266 всё вписывается в рамки.
Есть ли у кого опыт?


Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [==== ] 36.0% (used 29472 bytes from 81920 bytes)
Flash: [=== ] 30.4% (used 318000 bytes from 1044464 bytes)
Configuring upload protocol...
AVAILABLE: espota, esptool
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM14
Uploading .pio\build\d1_mini_pro\firmware.bin
esptool.py v2.8
Serial port COM14
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 48:3f:da:48:ac:9c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0240
Compressed 322160 bytes to 234363...

Writing at 0x00000000... (6 %)
Writing at 0x00004000... (13 %)
Writing at 0x00008000... (20 %)
Writing at 0x0000c000... (26 %)
Writing at 0x00010000... (33 %)
Writing at 0x00014000... (40 %)
Writing at 0x00018000... (46 %)
Writing at 0x0001c000... (53 %)
Writing at 0x00020000... (60 %)
Writing at 0x00024000... (66 %)
Writing at 0x00028000... (73 %)
Writing at 0x0002c000... (80 %)
Writing at 0x00030000... (86 %)
Writing at 0x00034000... (93 %)
Writing at 0x00038000... (100 %)
Wrote 322160 bytes (234363 compressed) at 0x00000000 in 20.6 seconds (effective 124.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
================================================================================================== [SUCCESS] Took 36.98 seconds ==================================================================================================
--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on COM14 9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
␀��HP�<>dh��D:l��LittleFS format failed
Error while mounting LittleFS
 

Motobiker

Member
Нашел вероятную причину. После того как создается объект класса, то возникает проблема с FS.
Что тут не так?

Код:
//main.cpp

#include <Arduino.h>
#include <connections.h>
#include <config.h>
#include <game.h>

game player_1(1);
//game player_2(2);
/*player_3(3),
    player_4(4),
    player_5(5),
    player_6(6),
    player_7(7),
    player_8(8);*/

void setup()
{
  //LittleFS.format();
  Serial.begin(9600);
  FS_init();
  Config_init(); //конфигурация файловой системы  для чистого контроллера
  setup_wifi();
  MQTT_init();
}

void loop()
{
  check_connect_MQTT();
  /* if (game::state_game_for_player_1)
    player_1.Loop();
  if (game::state_game_for_player_2)
    player_2.Loop();
  if (game::state_game_for_player_3)
    player_3.Loop();
  if (game::state_game_for_player_4)
    player_4.Loop();
  if (game::state_game_for_player_5)
    player_5.Loop();
  if (game::state_game_for_player_6)
    player_6.Loop();
  if (game::state_game_for_player_7)
    player_7.Loop();
  if (game::state_game_for_player_8)
    player_8.Loop();*/
}
Код:
//game.h

#ifndef GAME_H
#define GAME_H
#include <Arduino.h>

class game
{
private:
    int ns[];
    int
        current_attempt,
        current_shot,
        score,
        shots,
        player_ID;
    boolean
        init_game_flag;
    unsigned long
        time_begin_game;

public:
    game(int);
    void Loop();
    void Play_game_mode_1();
    void Play_game_mode_2();
    void Play_game_mode_3();
    void Play_game_mode_4();
    void Activate_target(int);
    void Activate_target(String);
    void Load_taget(int);
    void Load_taget(String);
    void Init_game();
    void End_game(boolean);
    void Pour(int);
    boolean Check_hit();
    boolean Check_shot();
    //**************************************
    // загружается из файла
    static int
        game_mode,
        num_players,
        num_targets,
        num_shots_1,
        num_shots_2,
        num_shots_3,
        num_shots_4,
        num_shots_5,
        num_shots_6,
        num_shots_7,
        num_shots_8,
        num_attempts,
        attempt_time,
        min_beer,
        max_beer,
        brightnes_bg,
        brightnes_fr;
    static boolean
        bg_light,
        time_game,
        hited_light;
    static String
        p1_color,
        p2_color,
        p3_color,
        p4_color,
        p5_color,
        p6_color,
        p7_color,
        p8_color;
    //**************************

    // назначается по MQTT
    static String
        config_file_address;
    static boolean
        state_game_for_player_1,
        state_game_for_player_2,
        state_game_for_player_3,
        state_game_for_player_4,
        state_game_for_player_5,
        state_game_for_player_6,
        state_game_for_player_7,
        state_game_for_player_8,
        player_1_hit_flag,
        player_2_hit_flag,
        player_3_hit_flag,
        player_4_hit_flag,
        player_5_hit_flag,
        player_6_hit_flag,
        player_7_hit_flag,
        player_8_hit_flag,
        player_1_shot_flag,
        player_2_shot_flag,
        player_3_shot_flag,
        player_4_shot_flag,
        player_5_shot_flag,
        player_6_shot_flag,
        player_7_shot_flag,
        player_8_shot_flag;
};

#endif
Код:
#include <game.h>
#include <connections.h>

boolean game::state_game_for_player_1 = false;
boolean game::state_game_for_player_2 = false;
boolean game::state_game_for_player_3 = false;
boolean game::state_game_for_player_4 = false;
boolean game::state_game_for_player_5 = false;
boolean game::state_game_for_player_6 = false;
boolean game::state_game_for_player_7 = false;
boolean game::state_game_for_player_8 = false;

boolean game::player_1_hit_flag = false;
boolean game::player_2_hit_flag = false;
boolean game::player_3_hit_flag = false;
boolean game::player_4_hit_flag = false;
boolean game::player_5_hit_flag = false;
boolean game::player_6_hit_flag = false;
boolean game::player_7_hit_flag = false;
boolean game::player_8_hit_flag = false;

boolean game::player_1_shot_flag = false;
boolean game::player_2_shot_flag = false;
boolean game::player_3_shot_flag = false;
boolean game::player_4_shot_flag = false;
boolean game::player_5_shot_flag = false;
boolean game::player_6_shot_flag = false;
boolean game::player_7_shot_flag = false;
boolean game::player_8_shot_flag = false;

int game::game_mode = 0;
int game::num_players = 0;
int game::num_targets = 0;
int game::num_shots_1 = 0;
int game::num_shots_2 = 0;
int game::num_shots_3 = 0;
int game::num_shots_4 = 0;
int game::num_shots_5 = 0;
int game::num_shots_6 = 0;
int game::num_shots_7 = 0;
int game::num_shots_8 = 0;
int game::num_attempts = 0;
int game::attempt_time = 0;
int game::min_beer = 0;
int game::max_beer = 0;
int game::brightnes_bg = 0;
int game::brightnes_fr = 0;

boolean game::bg_light = false;
boolean game::hited_light = false;
boolean game::time_game = false;

String game::config_file_address = "";
String game::p1_color = "";
String game::p2_color = "";
String game::p3_color = "";
String game::p4_color = "";
String game::p5_color = "";
String game::p6_color = "";
String game::p7_color = "";
String game::p8_color = "";

game::game(int pl_id)
{
  player_ID = pl_id;
  init_game_flag = false;
  ns[1] = num_shots_1;
  ns[2] = num_shots_2;
  ns[3] = num_shots_3;
  ns[4] = num_shots_4;
  ns[5] = num_shots_5;
  ns[6] = num_shots_6;
  ns[7] = num_shots_7;
  ns[8] = num_shots_8;
}

void game::Loop()
{

  if (game_mode == 1)
    Play_game_mode_1();
  if (game_mode == 2)
    Play_game_mode_2();
  if (game_mode == 3)
    Play_game_mode_3();
  if (game_mode == 4)
    Play_game_mode_4();
}

..............................
code
..............................
 

Motobiker

Member
такое впечатление, что оперативка забивается и вылезает в адресное пространство файловой системы и при попытке обратится к памяти для монтирования фс ничего не выходит
 

EvgeniyS

Member
[QUOTE="в процессе свободня память не уменьшается.
[/QUOTE]
Возможно стек переполняется, его размер можно попробовать увеличить отредактировав в файле cont.h параметр CONT_STACKSIZE, если используете Platformio, то файл находится: C:\Users\Текущий пользователь\.platformio\packages\framework-arduinoespressif8266\cores\esp8266
 

Motobiker

Member
[QUOTE="в процессе свободня память не уменьшается.
Возможно стек переполняется, его размер можно попробовать увеличить отредактировав в файле cont.h параметр CONT_STACKSIZE, если используете Platformio, то файл находится: C:\Users\Текущий пользователь\.platformio\packages\framework-arduinoespressif8266\cores\esp8266
[/QUOTE]
со стеком все в порядке
 
Сверху Снизу