Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rBoot partition support #2258

Merged
merged 21 commits into from
Mar 17, 2021

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Mar 10, 2021

This PR adds partition table support to the ESP8266 bootloader (rBoot). See #2254 #2251.

The ESP8266 flash layout has been reverted to the original Sming 4.2 layout, with the addition of the partition table in the sector before the RF calibration data at end of flash.

Update rBoot

Update bootloader to read ROM addresses from partition table on boot. These overwrite whatever values have been set in its own configuration, thus avoiding inconsistencies. rBoot has been forked to simplify management.

An additional partition subtype has been added for RF calibration data, so existing applications running off the develop branch will need re-building and re-flashing.

The partition table may now be freely relocated for the Esp8266 (+ Host) to allow compatibility with existing devices which must be upgrade OTA.

Methods have been added to OTA classes to allow update regions to be set using partitions; this is safer than working with raw flash addresses but the underlying mechanism hasn't changed.

TODO:

  • Look at OTA support
  • Update documentation

@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch 2 times, most recently from 1deffb7 to a248a0c Compare March 10, 2021 18:41
@slaff slaff added this to the 4.3.0 milestone Mar 11, 2021
@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch 8 times, most recently from 4d31392 to 787a900 Compare March 13, 2021 22:19
@mikee47 mikee47 changed the title [WIP] Add rBoot partition support Add rBoot partition support Mar 13, 2021
@mikee47
Copy link
Contributor Author

mikee47 commented Mar 13, 2021

OK, I've checked this out as follows on a nodeMCU with 4MByte flash memory:

  1. Build and flash Basic_rBoot with Sming 4.2 LTS develop branch
  2. Check it's all working - 'info' is a handy command
  3. Check out this PR and go to the Basic_rBoot project directory.
  4. Run:
make HWCONFIG=legacy/spiffs
make map

Check the map looks sensible. The partition table is at the end of flash; anywhere else and it could collide with SPIFFS, etc.

  1. Flash the partition map, then read it back again to verify it hasn't been overwritten. (This happened for me when I put the partition table at 0x100000 - that's where SPIFFS is so got written over.)
make flashmap readmap
  1. Finally, flash the new application:
make flashapp terminal

And we should now be running with Sming 4.3.

@mikee47
Copy link
Contributor Author

mikee47 commented Mar 13, 2021

The OTA stuff I haven't yet tested. Volunteers?!

@mikee47
Copy link
Contributor Author

mikee47 commented Mar 13, 2021

NB. This PR is on top of #2263 so I'll rebase once that's merged.

@slaff
Copy link
Contributor

slaff commented Mar 14, 2021

so I'll rebase once that's merged.

PR #2263 is merged. Feel free to rebase when you have time.

@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch 2 times, most recently from 8761077 to 6932420 Compare March 14, 2021 11:27
@mikee47
Copy link
Contributor Author

mikee47 commented Mar 14, 2021

Minor fix to #2263 required...

@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch 8 times, most recently from 62b57e5 to 736fb01 Compare March 15, 2021 13:01
Support ESP8266 partition table in any sector
Support calculated `partition_table_offset` and partition `address` values
@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch from 736fb01 to a27f59e Compare March 16, 2021 07:25
@@ -4,6 +4,7 @@
"devices": {
// Override default (conservative) flash settings for maximum performance
"spiFlash": {
// "mode": "qio", // This doesn't always work, depends on the flash chip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the comment // This doesn't always work, depends on the flash chip with // Make sure to set the mode according to your flash chip. Allowed SPI modes are listed here: https://sming.readthedocs.io/en/latest/_inc/Sming/Components/esptool/index.html#envvar-SPI_MODE.

@@ -6,5 +6,24 @@
"filename": "$(FLASH_INIT_DATA_VCC)"
}
}
},
"legacy": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikee47 Why we need a new memory layout for ESP8266 given the fact that now the partition table can be moved to a different location? Why not keep the current layout and not introduce a legacy layout?

  • OTA will function out of the box for ESP8266 applications
  • The firmware ROMs for big flashes can be as big as possible AND use the same entry point address

Doesn't work with regular paths or environment variables, has to be a URL.
This is important because schemas can be integrated into IDE to ease editing
of hardware profiles and IFS build configs.
"address": "0x008000",
"size": "992K",
"address": "0x002000",
"size": "0x0F8000",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikee47 Thanks a lot for the changes. Would it be possible to change the value here back to a human readable size in K? At least for me it is easier to see the max size without going to another tool to calculate the size in K.

@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch 2 times, most recently from 7001a29 to decff1d Compare March 16, 2021 17:10
@mikee47 mikee47 force-pushed the feature/rboot-partition-support branch from decff1d to 580dbd1 Compare March 16, 2021 17:11
@slaff slaff removed the 3 - Review label Mar 17, 2021
@slaff slaff merged commit fec464b into SmingHub:develop Mar 17, 2021
@slaff slaff mentioned this pull request Mar 17, 2021
5 tasks
@mikee47 mikee47 deleted the feature/rboot-partition-support branch March 29, 2021 16:55
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Mar 11, 2024
Layout changed with the introduction of partition tables in PR SmingHub#2258,
but reverted back to standard default layout in SmingHub#2332.
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Mar 12, 2024
Layout changed with the introduction of partition tables in PR SmingHub#2258,
but reverted back to standard default layout in SmingHub#2332.
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Mar 12, 2024
Layout changed with the introduction of partition tables in PR SmingHub#2258,
but reverted back to standard default layout in SmingHub#2332.
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Mar 12, 2024
Layout changed with the introduction of partition tables in PR SmingHub#2258,
but reverted back to standard default layout in SmingHub#2332.
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Mar 13, 2024
Layout changed with the introduction of partition tables in PR SmingHub#2258,
but reverted back to standard default layout in SmingHub#2332.
mikee47 pushed a commit to mikee47/Sming that referenced this pull request Mar 13, 2024
Layout changed with the introduction of partition tables in PR SmingHub#2258,
but reverted back to standard default layout in SmingHub#2332.
slaff pushed a commit that referenced this pull request Mar 14, 2024
…2729)

Leaving `blockErase` parameter at `false` when constructing a `PartitionStream` will result in corruption unless partition has already been erased. This is not always immediately apparent so can be difficult to diagnose.

- **Breaking change** Replacing `blockErase` with an enumerated `mode` parameter enforces read-only behaviour by default (new feature and a good thing), with write access more explicitly defined. It's a simple change to existing code and will ensure it gets manually checked to ensure correct behaviour.

- Update the `Basic_Ota` sample to check that an OTA update is not being attempted on the active running partition. This can happen with esp8266, for example, when running in temporary boot mode. (NB. Other checks may include active filing system partitions but that is application-specific.)

- Update notes on migrating from Sming 4.2 to include updating boot sector. (Learning points froim #2727.)

- Remove redundant flashsize calculation from rboot and update version string to `Sming v1.5` (from v1.4.2). Note this should have been done in #2258.

- Fix rboot README regarding use of slot 2, should correspond with subtype `ota_2` not `ota_1`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants