SuperHouse / esp-open-rtos

Open source FreeRTOS-based ESP8266 software framework
BSD 3-Clause "New" or "Revised" License
1.52k stars 491 forks source link

fix http ota #661

Closed apiel closed 5 years ago

apiel commented 5 years ago

I had some issue to flash my esp8266 (sonoff) with http client ota.

sdk_spi_flash_write requires a word aligned Assuming size is always a multiple of 4 bytes.

See ./extras/rboot-ota/ota-tftp.c

apiel commented 5 years ago

I try to upload another firmware on the rboot_config.roms[1] -> 0x102000

esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 16m -fm dout -ff 40m 0x102000 ./firmware/firmware.bin

And it does like I upload it on 0x2000 It reboot on this new firmware, but rboot_config.current_rom is 0 and the address is 0x2000 even if I uploaded it to 0x102000

Any idea?

AndreaGreco commented 5 years ago

This is a wdog Reset, that means that your IDLE Task does not ping wdog. The perfect is a API for manually ping wdog but at now is not available. Checkout that you do not remove delay. Or consider increase delay.

apiel commented 5 years ago

I actually wonder if it is not a problem with rboot. I try to change the flashsize setting to 0x80000, 0x40000 even 0x20000 but none of them work.

esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 2m -fm dout -ff 40m 0x0 ../esp-open-rtos/bootloader/firmware/rboot.bin 0x1000 ../esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/firmware156.bin 0x42000 ./firmware/firmware157.bin

I have to stop for today cause my head is explading :p Hopefully, I will find the solution soon. I will try to take in consideration your comments to make it work :D

AndreaGreco commented 5 years ago

Do you make a sleep before reset ESP. Make a large sleep before reset is important for ping wdog.

apiel commented 5 years ago

Actually, it's even more a question of OTA or not, I just have to find the right setting for flashing my ROMs. I tried so much different setting but I don't manage to get it work :-/

esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 8m -fm dout -ff 40m 0x0 ../esp-open-rtos/bootloader/firmware/rboot.bin 0x1000 ../esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/firmware.bin 0x82000 ./firmware/firmware164.bin

Here, I manage to upload the 2 firmwares correctly but when I switch to the second room, the boot fails.

apiel commented 5 years ago

I spent the whole day on my issue. I even made a new version of rBoot, I start to understand more and more all the logic of this booting system. But it seem that there is an issue when we boot from another address than 0x2000. I cleaned up all the flash and then I run the following command (with original rBoot). I took care to leave 0x2000 that rBoot switch to the next rom address. Everything is fine, but when it come to boot, nothing happen, no error, nothing, just stuck there.

 #:~/dev/esp/sonoff$ esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 8m -fm dout 0x0 ../esp-open-rtos/bootloader/firmware/rboot.bin 0x82000 ./firmware/firmware.bin && cu -l /dev/ttyUSB0 -s 115200
esptool.py v1.2
Connecting...
Running Cesanta flasher stub...
Flash params set to 0x0320
Writing 4096 @ 0x0... 4096 (100 %)
Wrote 4096 bytes at 0x0 in 0.4 seconds (89.6 kbit/s)...
Leaving...
Connected.
load 0x40100000, len 2412, room 16 
tail 12
chksum 0xf0
ho 0 tail 12 room 4
load 0x3ffe8000, len 800, room 12 
tail 4
chksum 0xdc
csum 0xdc

rBoot v1.4.0 - richardaburton@gmail.com
Flash Size: 8 Mbit
Flash Mode:   DOUT
Flash Speed:  40 MHz
rBoot Option: Big flash
rBoot Option: RTC data

Rom 0 at 2000 is bad.
Booting rom 1 from 82000, run at ram c0620.

Any idea?

oremic commented 5 years ago

hi resolve problem ??

apiel commented 5 years ago

Long time I didn't touch sonoff and especially OTA, but from what I remember I had lot of issue with erasing the flash before to write the new rom. So the best way was to prepare the flash when the sonoff start. Also I had some issue to make the sonoff boot at the second rom position, so to solve this issue I wrote my own booting system. However, OTA with esp-open-rtos is a pain and if you really need OTA, I would highly recommand you to use Arduino.