Completing the partition table re-work.

I think our current target arrangement is pretty good:

Label            Type Subtype         Address Size
nvs              data nvs          0x00009000 16 KB
otadata          data ota          0x0000d000 8 KB
phy_init         data phy          0x0000f000 4 KB
ota_0            app  ota_0        0x00010000 7 MB
ota_1            app  ota_1        0x00710000 7 MB
store            data fat          0x00e10000 1984 KB
Digest:          520877a00f2b1f7506844246b950ab23 pass

But we have a number of things to resolve before ready for production. The ones I can think of are:

1) Making it simple
   1.1) Automate the steps
   1.2) Provide a user interface
   1.3) Module informing servers of status (so we can see progress)

2) 4MB vs 7MB firmware
   2.1) Server support builds
   2.2) Module downloads correct build
   2.3) Firmware fitting in the partition

3) Notifying users
   3.1) Developers
   3.2) End users

4) Versioning
   4.1) Firmware versions

5) Factory
   5.1) Factory production support

So let's look at each of these, and I make a proposal how to solve.

1) Making it simple
1.1) Automate the steps

The current approach is overly complex for non-technical end-users. They simply either won't do it, or will mess it up.

My suggestion here is to:

a) Introduce a new 'ovms partitions upgrade auto -noconfirm' command. This command will initiate a fully automatic upgrade.

b) At the ovms_partitions.{h,cpp} level, introduce a 'ovms_partition_table_upgrade' command that will look at the current state, perform the required actions, and reboot as necessary.

c) Extend boot.{h,cpp} to support a new BR_PartitionUpgrade boot state (used by ovms_partition_table_upgrade during reboot).

d) Extend the initial boot code so that if the BR_PartitionUpgrade flag is set then re-run ovms_partition_table_upgrade and only continue with the system init if that indicates failure.

I think in that way we can reduce the boot time (by not initialising modem, etc) and also avoid the SD CARD mounting issue. It would be one command the user runs, and monitors the output on USB console (or not).

1.2) Provide a user interface

Presumably this could simply be done by the admin web interface. If the ovms_partition_table_get_type() is not OVMS_FlashPartition_35 (or perhaps introduce a new ovms_partition_table_isuptodate() call), then prompt to update.

1.3) Module informing servers of status (so we can see progress)

In OvmsOTA::AutoFlash() we build the URL as api.openvehicles.com/firmware/ota + GetOVMSProduct() + tag + ovms3.bin. That GetOVMSProduct() is in ovms_utils.{h,cpp} and returns v3.0, v3.1, or v3.3.

In ovms_version.{h,cpp} it uses GetOVMSVersion() + " (build " + GetOVMSBuild() + ")" to build the version and set as m.version.

It seems that we can quite simply:

a) Change GetOVMSProduct() to return v3.5 for a v3.3 hardware running the upgraded partition layout.

b) Change ovms_version to add "product " + GetOVMSProduct() before the build in the version string.

The server would then receive that in the version string, and we could use it for status and statistical deployment purposes. I don't think it affects the buildverscmp() comparison.

2) 4MB vs 7MB firmware
2.1) Server support builds

We would need to add a v3.5 directory to the servers, and presumably do new nightly 7MB builds as well as a cut-down 4MB builds. These presumably would be simple and only have different sdkconfig files (plus perhaps a sanity check to ensure that the 4MB file is <4MB before deployment).

2.2) Module downloads correct build

The GetOVMSProduct() change in 1.3(a) above should resolve this.

2.3) Firmware fitting in the partition

This seems to have already been resolved in Michael's a5843037a503a61ec116e4ab46e05883545f7a48 commit.

3) Notifying users
3.1) Developers

I suggest we prioritise developers to get this tested. Once the firmware is ready we can push on ovmsdev mailing list to deploy for wider testing.

3.2) End users

I can think of two approaches:

a) A pop-up on web interface main screen if partition table upgrade is available.

b) Push notifications when they connect using the App.

4) Versioning
4.1) Firmware versions

If we follow the approach in 1.3 above, no change to current versioning scheme is needed.

There was a suggestion that once this is ready for production deployment we make that the 3.3-006 version.

5) Factory
5.1) Factory production support

Once this is in production we would need to change the default partitions.csv to reflect the new arrangement, build new production firmware, and release to factory.

I am happy to do 1.1, 1.3, 2.1 (for api.openvehicles.com), 2.2, 3.1, 4.1, and 5.1.

Feedback appreciated. Is this an acceptable approach?

Regards, Mark