Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Programming ESP-01

I am currently working on a project where I use oldschool esp-01 modules. I'm using a usb adapter for those.
Few weeks ago I already succeeded to flash the firmware using the ui.. it seems that that was luck since I fail in the newer versions.
However, Arduino IDE has no problems flashing the device. So all connections are correct.
My intention is, that the UI kills the initial flash state of the device by constantly trying to reach it before it starts to flash.
The ESP-01 does not have a reset button so it depends on beeing left in the state when powered up.

There seems to be a way to use the mos tool in command line using the flash option... but I can't find any documentation.
what would be an easy way to flash it

(I'm using windows)

Comments

  • by the way.. when I get the timing right this is the result:

    [Aug 16 16:40:52.530] Fetching https://mongoose-os.com/downloads/mos-esp8266-latest.zip...
    [Aug 16 16:40:53.957] Loaded default/esp8266 version 1.0 (20170816-102708/???)
    [Aug 16 16:40:53.957] Opening COM3 @ 115200...
    [Aug 16 16:40:53.958] Connecting to ESP8266 ROM, attempt 1 of 10...
    [Aug 16 16:40:54.511] Connecting to ESP8266 ROM, attempt 2 of 10...
    [Aug 16 16:40:55.065] Connecting to ESP8266 ROM, attempt 3 of 10...
    [Aug 16 16:40:55.624] Connecting to ESP8266 ROM, attempt 4 of 10...
    [Aug 16 16:40:56.455] Connecting to ESP8266 ROM, attempt 5 of 10...
    [Aug 16 16:40:56.619] Connected
    [Aug 16 16:40:56.619] Running flasher @ 460800...
    [Aug 16 16:40:57.718] Flasher is running
    [Aug 16 16:40:57.719] Flash size: 1048576, params: 0x0220 (dio,8m,40m)
    [Aug 16 16:41:00.732] E0816 16:41:00.732107 13244 ui.go:494] Calling: Sys.GetInfo
    [Aug 16 16:41:05.778] E0816 16:41:05.777300 13244 ui.go:518] Call complete, error: context deadline exceeded
    [Aug 16 16:41:05.778] E0816 16:41:05.778298 13244 reconnect_wrapper.go:72] [reconnectWrapperCodec to COM3; connecting...] Connection closed

    what I would expect is:

    [Aug 16 16:21:21.661] Fetching https://mongoose-os.com/downloads/mos-esp8266-latest.zip...
    [Aug 16 16:21:22.259] Loaded default/esp8266 version 1.0 (20170816-102708/???)
    [Aug 16 16:21:22.260] Opening COM6 @ 115200...
    [Aug 16 16:21:22.260] Connecting to ESP8266 ROM, attempt 1 of 10...
    [Aug 16 16:21:22.627] Connected
    [Aug 16 16:21:22.627] Running flasher @ 460800...
    [Aug 16 16:21:23.726] Flasher is running
    [Aug 16 16:21:23.727] Flash size: 4194304, params: 0x0240 (dio,32m,40m)
    [Aug 16 16:21:23.730] Deduping...
    [Aug 16 16:21:24.461] 128 @ 0x3fc000 -> 0
    [Aug 16 16:21:24.461] Writing...
    [Aug 16 16:21:24.461] 4096 @ 0x0
    [Aug 16 16:21:24.522] 4096 @ 0x7000
    [Aug 16 16:21:24.573] 262144 @ 0x8000
    [Aug 16 16:21:26.323] 757760 @ 0x100000
    [Aug 16 16:21:38.929] 4096 @ 0x3fb000
    [Aug 16 16:21:38.980] Wrote 1029680 bytes in 14.52 seconds (554.06 KBit/sec)
    [Aug 16 16:21:38.981] Verifying...
    [Aug 16 16:21:38.981] 2656 @ 0x0
    [Aug 16 16:21:38.988] 4096 @ 0x7000
    [Aug 16 16:21:38.993] 262144 @ 0x8000
    [Aug 16 16:21:39.109] 756688 @ 0x100000
    [Aug 16 16:21:39.438] 4096 @ 0x3fb000
    [Aug 16 16:21:39.442] 128 @ 0x3fc000
    [Aug 16 16:21:39.445] Booting firmware...
    [Aug 16 16:21:39.498] All done!

  • rojerrojer Dublin, Ireland

    default fw build requires at least 2M of flash, your ESP-01 has 1M

  • wow.. thanks.. that's helpful.. the esp-01 I used before might have been another batch. I'll try another..
    still would like to know a reliable way to flash it if possible :)

  • Hi
    I succeeded to flash my ESP-01, yesterday. you need to prepare ESP before flashing:
    Hardware
    CH_PD => High
    GPIO => LOW
    RST => LOW => High
    (if you already can flash, then no need for above steps)

    Software:
    make sure that your board has 1MB (chip no. W25Q80).
    1. you must build with the following parameters (add the following lines to mos.yml file):

    build_vars:
      FLASH_SIZE: 1048576
    

    this is because the default RAM is 4MB
    2. mos build
    3. use "mos flash" or "--esp-flash-params "dio,8m,40m"

    Thanked by 1bitluni
  • rojerrojer Dublin, Ireland

    we added a 1M flash build to the standard set, mos flash mos-esp8266-1M-latest should now work.

    Thanked by 1bitluni
  • I checked now with an esp-01 of same batch with an identical flash chip.. it was also 1M.. did the size of the image increase recently?

  • rojerrojer Dublin, Ireland

    yes, we increased size of the filesystem to 256K and had to change flash layout to make room for code and larger FS

    Thanked by 1mjhram
  • Wow! this is great. it is working. I checked the UI, I changed init.js "led = 1" (built in led=1 in ESP-01), I put WIFI. all configurations are saved. I used "mos put".
    Thanks a lot Rojer.

    There are some issues when saving from the UI, but I used the command instead. But when I try to upload my init.js using mos put init.js, I got Error: (400) failed to open file "init.js".
    following is Sys.GetInfo:

    {
        "app": "default",
        "fw_version": "1.0",
        "fw_id": "20170816-154837/???",
        "mac": "1AFE34982B1C",
        "arch": "esp8266",
        "uptime": 66,
        "ram_size": 52184,
        "ram_free": 42304,
        "ram_min_free": 32568,
        "fs_size": 113201,
        "fs_free": 8785,
        "wifi": {
        "sta_ip": "192.168.0.106",
        "ap_ip": "",
        "status": "got ip",
        "ssid": "MJH_MIFI"
      }
    }
    

    Also what is the flags to build my app? "mos build ....."

  • Tahnk you very much for providing that image.. it's working now. I almost had to drop my complete project which is based on ESP-01

  • SergeySergey Dublin, Ireland

    @mjhram you are getting failures cause you have no space left in the FS.
    9k means it's over. Clean it up - remote cruft you're not using.

  • SergeySergey Dublin, Ireland

    @bitluni what you're doing on esp-01, btw? why not esp-12?

  • My next video is about "worlds smallest" WiFi-button :D ESP-01 is a bit smaller than esp-12 and the initial programming of it is easier with a chap programmer than desoldering an esp-12 off of a wemos or so.... regardless the the other complications.
    esp-01 is not really my preference and I think I wont use it except for a grid project where the cost matters.
    When I started the recording few weeks ago, it worked so I did all my shots and now doing so missing scenes... But it might also be useful to others having a small image since there are still so many of the esp-01 modules out there

  • rojerrojer Dublin, Ireland

    one important thing is that OTA is not supported on flash < 2M. so it's not really viable for production deployments.

  • Thanks Surgey, I will try to remove some files.
    I am working on Smart Door Sensor IoT with AWS shadow. I already used NodeMCU (on Li-ion battery with deep sleep). Now I am trying ESP-01 to reduce power as possible. It is successful also, but needs some touches.
    Question: If I used the following build_vars, would I get the same binary as "mos flash mos-esp8266-1M-latest"?

    build_vars:
      FLASH_SIZE: 1048576
    
  • rojerrojer Dublin, Ireland

    yes, this is the only difference in the 1M build.

  • Hi All i have successfully flashed the mongoose to esp 01 then i get this

    mos  --esp-baud-rate=115200 flash esp8266-1M
    Fetching https://github.com/mongoose-os-apps/demo-js/releases/download/1.25/demo-js-esp8266-1M.zip...
    Loaded demo-js/esp8266 version 1.0 (20180125-013314/???)
    Using port /dev/ttyACM0
    Opening /dev/ttyACM0 @ 115200...
    Connecting to ESP8266 ROM, attempt 1 of 10...
      Connected, chip: ESP8266EX
    Running flasher @ 115200...
      Flasher is running
    Flash size: 1048576, params: 0x0220 (dio,8m,40m)
    Deduping...
         2736 @ 0x0 -> 0
         4096 @ 0x7000 -> 0
       778512 @ 0x8000 -> 0
       131072 @ 0xdb000 -> 0
         4096 @ 0xfb000 -> 0
          128 @ 0xfc000 -> 0
    Verifying...
         2736 @ 0x0
         4096 @ 0x7000
       778512 @ 0x8000
       131072 @ 0xdb000
         4096 @ 0xfb000
          128 @ 0xfc000
    Booting firmware...
    All done!

    then when i tried to set the wifi data using the wifi command it failed .i tried both "mos --esp-baud-rate=115200 wifi WIFINAME WIFIPASS" and "mos wifi WIFINAME WIFIPASS"

    Using port /dev/ttyACM0
    Getting configuration...
    Error: write /dev/ttyACM0: file already closed

    So i opened the serial console using "mos console" following exception appears.
    [Feb  4 18:33:07.449] Fatal exception (28): 
    [Feb  4 18:33:07.449] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000

    any idea how to fix this ?
  • ArruelahArruelah Brazil

    I have the exact same problem

Sign In or Register to comment.