SmingHub / Sming

Sming - powerful open source framework simplifying the creation of embedded C++ applications.
https://sming.readthedocs.io
GNU Lesser General Public License v3.0
1.47k stars 347 forks source link

HttpServer_FirmwareUpload upgrade fails with error No suitable ROM image found #2146

Closed jafal99 closed 3 years ago

jafal99 commented 3 years ago

HttpServer_FirmwareUpload doesn't work on ESP-12 with 4MB flash. After uploading firmware.ota Error: No suitable ROM image found is displayed.

16217102 Build timestamp of current firmware: 4127964447ll
16217449 Build timestamp of OTA upgrade file: 4131565346ll
16217607 Starting firmware upgrade, receive 1 image(s)
16221603 Skip ROM image for [0x00002000..0x00058da0)
17683728 ROM update complete
17684027 Error: No suitable ROM image found

It looks like firmware.ota contains only one image - for slot0, image for slot1 is not included.

I suspect problem with dependencies between rboot and OtaUpgrade components. OtaUpgrade includes image for slot1 only if RBOOT_ROM_1_BIN is defined but rboot eliminates this entry if the same image is used for both slots

in OtaUpgrade/component.mk existence of RBOOT_ROM_1_BIN is checked

    $(Q) $(OTATOOL) mkfile \
        $(OTA_CRYPTO_FEATURES_IMAGE) \
        $(if $(OTA_CRYPTO_FEATURES_IMAGE),--key=$(OTA_KEY_IMAGE)) \
        --rom=$(RBOOT_ROM_0_BIN)@$(RBOOT_ROM0_ADDR) \
        $(if $(RBOOT_ROM_1_BIN),--rom=$(RBOOT_ROM_1_BIN)@$(RBOOT_ROM1_ADDR)) \
        --output=$@

and in rboot/component.mk there is

# multiple roms per 1mb block?
ifeq ($(RBOOT_TWO_ROMS),1)
    # set a define so ota code can choose correct rom
    APP_CFLAGS          += -DRBOOT_TWO_ROMS
else
    # eliminate the second rBoot target
    RBOOT_ROM_1_BIN     :=
endif

In my opinion the best strategy will be to update OtaUpgrade operation to follow rboot behavior - if the same image is used for both slots add some marking to header that allows load included image in to currently not used slot

jafal99 commented 3 years ago

After checking config I found bug - there flashconfig was done with wrongly set RBOOT_ROM1_ADDR