configuring state framework for x86/EFI

Ahmad Fatoum a.fatoum at pengutronix.de
Wed May 19 03:39:17 PDT 2021


Hi Laszlo,

On 19.05.21 11:47, Laszlo Sitzer wrote:
> Hello,
> 
> I have a x86/EFI system with barebox running (without state framework).
> I noticed using the nv command persists values but I can't seem to
> understand where these physically get stored. Is there a way I could
> determine that?

EFI variables; You should see something like:
environment load /efivars/barebox-env-5b91f69c-8b88-4a2b-9269-5f1d802b5175: No such file or directory

first time you boot when you have no environment stored yet.

> I  would like to use the state framework (in order to be able to use
> barebox-state to reset bootchooser counters). In order to do so I have
> to write my state.dts, but I don't know which backend to choose in
> order to use the same location as nv used before.

If you have atomic EFI variables, you could use those directly for
next boot slot selection without involving barebox-state.

If they aren't atomic, you will likely not want them as backing
store for barebox-state either. For such cases you can create a
partition and use that as backend.
> I am not asking to use nv and state at the same time but rather have
> state framework use the location that nv used. Does that make sense?

It does. Here's an example:

/ {
	aliases {
		state = &state;
	};

	state: state {
		magic = <0xDEADBEEF>;
         	backend-type = "raw";
         	backend = <&state_part>;
         	backend-stridesize = <4096>; /* partition must be at least 3x this */
		
		/* your variables */
	};

	partitions {
        	compatible = "fixed-partitions";

	        state_part: state {
                	partuuid = "your-part-uuid";
        	};
	};
};

Adjust your partitioning accordingly, compile the DT, store it
in /boot/EFI/barebox/state.dtb and use the most recent
version of the barebox-state userspace utility and you should be good to go.

If you think the documentation here can be improved, patches are always
welcome :-)

Cheers,
Ahmad

> 
> Best, Lazlo
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list