skorpyon1992
Posts: 1
Joined: Fri May 24, 2019 5:59 am

Issue: Barebox bootchooser state RAUC Integration RPi 3

Fri May 24, 2019 6:09 am

Hello guys,

I have an issue regarding barebox bootchooser/state integration for Raspberry Pi 3 (used for multiple rootfs + RAUC software update).
I am using the following: Yocto Pyro 2.3.2, barebox 2018.12.0 meta-barebox layer developed by Menschel Dennis . I have successfully configured barebox, I can see the output on the debug console.

As I understood and seen on the device tree, Rpi 3 does not have any other non-volatile memory (except SD card). How can I store the barebox state on SD card?
For other boards, the barebox state is stored on EEPROM/onboard eMMC/NAND (even SD card) which is already described in the Device Tree Source. The SD card for RPI (mci0) is detected at barebox startup, and it is not described in the DTS (see devinfo output below):

Code: Select all

  [email protected] 3 Model B:/ devinfo
`-- global
`-- nv
`-- platform
   `-- soc
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
         `-- wdog0
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
         `-- mci0
            `-- 0x00000000-0x76e47ffff (  29.7 GiB): /dev/disk0
            `-- 0x00001000-0x022c1fff (  34.8 MiB): /dev/disk0.0
            `-- 0x022c2000-0xfbc5bbff (   3.9 GiB): /dev/disk0.1
            `-- 0xfbc5c000-0x1f55f5bff (   3.9 GiB): /dev/disk0.2
            `-- 0x1f55f5c00-0x2149f5fff (   500 MiB): /dev/disk0.3
            `-- 0x1f55f5e00-0x1fb9f5dff (   100 MiB): /dev/disk0.4
            `-- 0x1fb9f6000-0x2149f5fff (   400 MiB): /dev/disk0.5
            `-- fat0
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- [email protected]
      `-- soc:gpu
      `-- [email protected]
      `-- soc:firmware
         `-- soc:firmware:gpio
      `-- soc:power
      `-- [email protected]
   `-- clocks
      `-- clocks:[email protected]
      `-- clocks:[email protected]
   `-- phy
   `-- arm-pmu
   `-- timer
   `-- leds
   `-- wifi-pwrseq
   `-- regulator-bcm2835
   `-- mem0
      `-- 0x00000000-0x3b3fffff (   948 MiB): /dev/ram0
   `-- mem1
      `-- 0x00000000-0xfffffffe (     4 GiB): /dev/mem
   `-- bcm2835_fb0
`-- amba
   `-- [email protected]
      `-- cs0
         `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs0
`-- spi
`-- fs
   `-- ramfs0
   `-- devfs0

In addition, barebox documentation states the following (regarding SD card state storage) : "Note that currently there is no support for on-disk partition tables. Instead, an ofpart partition description must be used. You have to make sure that this partition does not conflict with any other partition in the partition table."

Would it be okay if I define the mci0 node in the device tree source? How should I do it? Somehow I have to access a location of the sd card where no partitions are written...

Barebox provides a simple example for SD/MMC barebox state , but it didn't help too much:

Code: Select all

backend_state_sd: [email protected] {
        label = "state";
        reg = <0x100000 0x20000>;
};


aliases {
        state = &state_sd;
};

state_sd: state_memory {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "barebox,state";
        magic = <0xab67421f>;
        backend-type = "raw";
        backend = <&backend_state_sd>;
        backend-stridesize = <0x40>;

        [email protected] {
                reg = <0x0 0x1>;
                type ="uint8";
                default = <0x1>;
        };
};

Many Thanks!

Regards, Vali.

epoch1970
Posts: 2809
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Issue: Barebox bootchooser state RAUC Integration RPi 3

Fri May 24, 2019 11:10 am

In case your question is about the general principle and not barebox specifically.

You can find an example of how this actually works in buildroot/uboot (the opposites of your environment, sorry...). At built time you get everything compiled and an uboot environment binary file gets created to hold state variables.
Then the toolchain runs genimage (another pengutronix contrib) and creates a partitioned image from the elements that just got generated. In a genimage configuration file you can specify option "in-partition-table: false" for a partition.
To include the env in the right place, your genimage config file has to have an out-of-partition-table partition with the generated uboot env copied into it. The offset and size you specify for that partition in your genimage config file have to match variables you defined prior to making uboot.
In the end you get an SD with an MBR, some sectors used for the env, then the start of the FAT boot partition.

Hopefully you can translate that to yocto and barebox.

(I don't like genimage particularly. If your toolchain uses it, I would advise you fsck the generated SD image before burning it to an SD.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Advanced users”