Problem with "Wemos D1 Mini" and the Flash library.

Posted on
  • Hello,

    it's my first try with Espruino. Im using a "Wemos D1 Mini".

    At first I erased the flash from the "Wemos D1 Mini".

    esptool.py --port /dev/ttyUSB0 --baud 115200 erase_flash
    

    Then I flashed the firmware.

    esptool.py --port /dev/ttyUSB0 --baud 115200 \ 
    write_flash --flash_freq 80m --flash_mode qio \
     --flash_size 32m \
    0x0000 "boot_v1.6.bin" \
    0x1000 espruino_esp8266_user1.bin \
    0x3FC000 esp_init_data_default.bin \
    0x3FE000 blank.bin
    

    Then I wrote following code:

    var flash = require("Flash");
    
    function writeTestValues() {
      var password_string = "password";
      var id = new Uint8Array([0x11, 0x22, 0x33, 0x44]);
      var password = E.toUint8Array(password_string);
      flash.write(id, 0x077000);
      flash.write(password, 0x077004);
      console.log("Test values written:");
      console.log("ID =" + " 0x" + id[0].toString(16)
                          + " 0x" + id[1].toString(16) 
                          + " 0x" + id[2].toString(16) 
                          + " 0x" + id[3].toString(16));
      console.log("Password = " + password_string);
    }
    
    function readTestValues() {
      var id = flash.read(4, 0x077000);
      var password = flash.read(8, 0x077004);
      var password_string = E.toString(password);
      console.log("Test values read:");
      console.log("ID =" + " 0x" + id[0].toString(16)
                          + " 0x" + id[1].toString(16) 
                          + " 0x" + id[2].toString(16) 
                          + " 0x" + id[3].toString(16));
      console.log("Password = " + password_string);
    }
    
    writeTestValues();
    readTestValues();
    

    And the console delivered this:

    >
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v95 Copyright 2017 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0x5e chip 0x4016
    
    >Test values written:
    ID = 0x11 0x22 0x33 0x44
    Password = password
    Test values read:
    ID = 0x1 0x0 0x0 0x0
    Password = ! 
    =undefined
    > 
    

    The ID and Password, what I saved before, isn't the same.
    On http://www.espruino.com/EspruinoESP8266 you can see, that the EEPROM emulation is addressed to "0x077000".

    Start Start Length Function
    0x000000 0 4KB Bootloader with flash type/size header
    0x001000 4KB 468KB Espruino firmware, first partition
    0x076000 472KB 4KB SDK RF calibration save area on 512KB modules
    0x077000 476KB 4KB EEPROM emulation
    0x078000 480KB 12KB Espruino save() area
    0x07B000 492KB 4KB Espruino system and wifi settings
    0x07C000 496KB 16KB 512KB flash: Espressif SDK system params, else unused
    0x080000 512KB 4KB SDK RF calibration save area on 1MB and larger modules
    0x081000 516KB 472KB Espruino firmware, second partition
    0x0F7000 988KB 4KB Unused
    0x0F8000 992KB 16KB Unused
    0x0FC000 996KB 16KB 1MB flash: Espressif SDK system params, else unused
    0x100000 1MB approx 1MB-3MB flash unused on 2MB-4MB modules
    0x1FC000 2032KB 16KB 2MB flash: Espressif SDK system params, else unused
    0x3FC000 4080KB 16KB 4MB flash: Espressif SDK system params, else unused

    I don't know what I did wrong. Hope you can help me.

  • Hi clausinus,

    use require("ESP8266").getFreeFlash(); to get a array of objects with addr and length like this

    // sample output 
    require("ESP8266").getFreeFlash()
    =[
      { "area": 487424, "length": 4096 },
      { "area": 524288, "length": 4096 },
      { "area": 1011712, "length": 36864 }
     ]
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Problem with "Wemos D1 Mini" and the Flash library.

Posted by Avatar for clausius @clausius

Actions