raburton / rboot-sample

Sample ESP 8266 SDK project demonstrating rBoot OTA
MIT License
23 stars 11 forks source link

How do you determine which Flash sectors/address should be selected? #8

Open dipendra77 opened 4 years ago

dipendra77 commented 4 years ago

Hi, Can you tell me how do you determine which flash sector should be flashed with binary and booted from after update ?. Where is the structure variable "bootconf.roms[upgrade->rom_slot]" is getting the rom address. I am asssuming this example is for 1 MB Flash size. I am using a 2MB flash and my ota partitions are at address 0x1000 (OTA0) and 0x81000 (OTA1), each around 430 KB. Do we have to change something to get the OTA working on 2MB flash ? I read somewhere that we need to modify th elinker script to support OTA for different sizes.Can you tell ,me what should i change and which files for 2MB flash support. I have these following linker files in my project.
ota_ld_files

Thank you in advance.

raburton commented 4 years ago

Not sure where you've got those linker files from, so no idea what's in them. The rBoot config structure is stored in the second sector of flash. If it doesn't exist on first boot rBoot it will create a sensible default for you using the code here: https://github.com/raburton/rboot/blob/master/rboot.c#L258 Basically the default is to have 2 roms, the first will start on the third sector of flash (rBoot lives in the first and it's config lives in the second), so your rom will be flashed to 0x2000 (not 0x1000 as you mentioned). Depending on if you are using bigflash mode or not then the position of the second rom will differ. Without bigflash mode it will be 0x82000, with bigflash mode it will be half the flash size + 0x2000. I assume from what you've said you are not using bigflash, which limits a two rom layout to a bit less than 512k each (so your rom should fit), but requires you to link two different versions, one with org = 0x40202010 and the second with org = 0x40282010 (note the extra 0x10 for header on these values), and flash these to the lower and higher regions respectively. There is a non-bigflash example in this repository, which you can use as a basis for your rom. I'd suggest getting this example running first, then you'll be able to compare it to your linker stuff and see what what's going on. In order for rBoot to generate a default config correctly for you, you must set the flash size correctly when flashing rBoot and any other initial stuff to the device.

dipendra77 commented 4 years ago

I am not using rboot bootloader binary as in my project. I am using the boootloader provided in ESP8266_NONOS_SDK , here https://github.com/espressif/ESP8266_NONOS_SDK I have only ported your sample code from here: https://github.com/raburton/rboot-sample I am not using big flash mode. Here is the two linker scripts generated after compilation of my project. eagle.app.v6.new.1024.app1.ld.txt eagle.app.v6.new.1024.app2.ld.txt

I am able to do an upgrade. But on boot it fails to fetch the right address it should boot to and goes into fatal exception. I tried hardcoding the address as per the rom_slot variable returned by the rboot_get_config().

NOTE : My OTA address are 0x1000 and 0x81000 as per the espressif documentation here, ref. section 4.2.1. https://www.espressif.com/sites/default/files/2a-esp8266-sdk_getting_started_guide_en_0.pdf

raburton commented 4 years ago

I have no idea what you are trying to do then. If you aren't using rBoot, why are you calling rBoot APIs? What do you expect to happen?