Hi Roman,
On 14/08/2017 23:34, Roman Kalashnikov wrote:
> Hi all.
>
> I'm using *swupdate* as standalone service for updating my system:
> * Intel Atom x86_64
> * Ubuntu 16.04
I've never thought when I started this project that it could be used to
update a standard Linux distro, too. Life is surprising....
> With partition schema:
> *|* EFI *|* rootfs1-/dev/sda2*| *rootfs2-/dev/sda3 *|* swap*|* USER DATA *|*
ok
>
> Building *swupdate* with needed params has no problems for me. But i can
> not understand how exactly realised grub support in *swupdate*.
> As i know grub boot sequence splitted into several stages for me:
> 1 EFI starts with script: ln -s /boot/efi/EFI/BOOT/ubuntu/grubx64.efi
> /boot/startup.nsh - grub microprogram
> 2 Grub microprogram using 1st config-file:
> /boot/efi/EFI/BOOT/ubuntu/grub.cfg - contains parition's UUID for
> continue loading (this directory can contains *grubenv*, but not out of
> the box, should use 'grub-editenv create' before)
The structure of grubenv file is very simple. It can generate in a lot
of ways.
> 3 Then grub loads 2nd config : rootfsX-EXT4/boot/grub/grub.cfg -
> contains menu entries and *grubenv*
It is required that grub.cfg calls load_env
> 4 Now the kernel loaded
>
> So, in case *swupdate* i use simple, RAW, gzipped image for partition
> /dev/sda3. *sw-description* contains simple code:
> software =
> {
> version = "0.1";
> hardware-compatibility = [ "1.0" ];
> stable:
> {
> main:
> {
> images: (
> {
> filename = "rootfs.img.gz";
> device = "/dev/sda2";
> compressed = true;
> }
> );
> };
> alt:
> {
> images: (
> {
> filename = "rootfs.img.gz";
> device = "/dev/sda3";
> compressed = true;
> }
> );
> };
> };
> }
you need to add a bootloader entry for each of them where you set the
variable to be processed by Grub. For example, you can set "next_entry"
or "default". Of course, it could be you have to change grub.cfg for
your needs. See example with bootloader or U-Boot in examples directory.
>
> Command for install it:
> swupdate -e "stable,alt" -v -i update_image.swu
>
> And all works fine, my image delivered into /dev/sda3, BUT grub have no
> any information for boot from new partitions (f.e. failsafe flags or
> UUID for new partition).
Well. you have not added any information to sw-description. You need
also to add Grub support to SWUpdate CONFIG_BOOTLOADER_GRUB) and check
if grubev is in the correct path (CONFIG_GRUBENV_PATH).
> As i can understand from source codes, *swupdate* uses *grubenv* for
> configuration grub for next boot.
Right.
> How can i put my own or automatically
> generated grub-boot-scripts through *swupdate *into grub.cfg/grubenv?
See above. Please note they are not scripts, but just variables.
> If I am trying put boot-options into grub using grub-editenv 'just by
> hands' - *grub* ignores grubenv variables and use old config
This is maybe caused by "standard" grub.cfg installed with Ubuntu.
Ubuntu has different goals and uses variables in a different way - see
grub.cfg.
> (i was
> trying to check grubenv from grub command line while boot and it show me
> expected grubenv variables) O_o
>
The whole logic is inside grub.cfg, and Ubuntu installed a script that
well fits the distro. You could simplify it with just two "menuentry" (A
/B) and setting default with a variable read from grubenv.
> Best regards, Roman.
> P.S. Sorry for my english :)
Never mind.
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone:
+49-8142-66989-53 Fax:
+49-8142-66989-80 Email:
sba...@denx.de
=====================================================================