Skip to content

Take control over the environment#34

Merged
samueldr merged 19 commits intoTow-Boot:developmentfrom
samueldr:feature/env-fixes
Jun 26, 2021
Merged

Take control over the environment#34
samueldr merged 19 commits intoTow-Boot:developmentfrom
samueldr:feature/env-fixes

Conversation

@samueldr
Copy link
Contributor

This is a weird name. But saying it "fixes saveenv issues" is too diminutive. But hey, closes #19!


What this changes

Environment

Two broad strokes. For release 002 of Tow-Boot, we will only support environment in the SPI Flash for builds installed to the SPI Flash.

Firmware installed to a shared storage media, starting with 002 up to later will not allow saving the environment.

To reduce confusion, a Tow-Boot install will strictly only use the environment in the same storage it is installed into. This means that SPI-installed firmware will read/save to the SPI Flash. Not implemented yet, but using the shared storage strategy, only when installed to a protective partition will Tow-Boot read/save the environment.

Variants

Since we need to change how the firmware acts depending on where it is installed, it was deemed the easiest method to just build different binaries. So we're now producing "variants", which in turn affect the configuration slightly. These are somewhat different from "simple" feature flags, as we are changing a fundamental property of the firmware.

It's not expected we'll gain many more variants. In fact the only one I expect to add is mmc which (using the U-Boot nomenclature) will use the partition from the shared storage media to manage the environment.

In other words, variants right now are strictly dealing with where the environment is read and saved.

File names and structure

It was coming, but since we needed to change file names for variants, I'm implementing the changes here. All files now report as "Tow-Boot". It apparently caused mild confusion in some users that the files were named "u-boot". Additionally, files are now stored in directories, config for the variant configuraiotns, and binaries for the "irrlevant to most users" files.

The main stars, the disk images, are at the root of the result.


Future changes

Environment with shared storage

As stated previously "only when installed to a protective partition will Tow-Boot read/save the environment."

This requires some development. There are no environment saving strategies that allows this to work in a safe manner.

Since we want to save to the same partition Tow-Boot is installed into, we need the environment "in MMC". With that strategy, only an offset to a hardcoded mmc device is supported. This means that using Tow-Boot on an SD card would save the environment to an arbitrary offset on the internal MMC storage, which is likely to break things! So we'll need to track the mmc device the system booted from. Additionally, it would be better if we'd instead be able to work with partitions, and offsets internal to the partition, instead of raw device offsets. This way it is more likely we don't need to implement platform-specific differences.

Using the "in FAT" strategy for the Raspberry Pi family of hardware might work... Except that it is unclear what happens when booting from USB. It will require extensive testing.

@samueldr samueldr force-pushed the feature/env-fixes branch 2 times, most recently from e44da51 to b74b27e Compare June 23, 2021 02:06
@samueldr samueldr force-pushed the feature/env-fixes branch from b74b27e to eb50719 Compare June 23, 2021 21:52
@samueldr samueldr mentioned this pull request Jun 25, 2021
@samueldr
Copy link
Contributor Author

samueldr commented Jun 25, 2021

I think this breaks uBoot-qemuX86_64... need to check.

Looks like it needs environment

TODO

  • Look into uBoot-qemuX86_64

@samueldr samueldr force-pushed the feature/env-fixes branch from eb50719 to 5735bb6 Compare June 26, 2021 04:44
samueldr added 19 commits June 26, 2021 01:02
Seems there's no issues with the boards we target
This is because we'll be renaming the outputs. Serves no purpose to have
a step in `preInstall` just to rename inputs we'd list in
`filesToInstall. Additionally, not in this change, we'll be naming the
outputs according to a variant identifier. Harder to do nicely within
Nix.
The main difference is that it uses an area in the SPI Flash to save and
read the environment.
Main gotcha here is that the `spi` variant will, subtly, provide a
different binary!
@samueldr samueldr force-pushed the feature/env-fixes branch from 5735bb6 to bf59d67 Compare June 26, 2021 05:02
@samueldr samueldr merged commit bc56239 into Tow-Boot:development Jun 26, 2021
@samueldr samueldr deleted the feature/env-fixes branch June 26, 2021 05:03
@samueldr samueldr added this to the "next" milestone Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Performing saveenv when booting from SPI corrupts SPI

1 participant