edison-fw / meta-intel-edison

Here is the meta-intel-edison that builds, tries to stay up to date. Master is based on Yocto Poky Gatesgarth LTS 5.10.yy vanilla kernels. It builds a 32bit kernel (Gatesgarth branch 64bit) with ACPI enabled and corresponding rootfs. Telegram group: https://t.me/IntelEdison Web-site:
https://edison-fw.github.io/meta-intel-edison/
MIT License
60 stars 37 forks source link

boot environment not updated on ota #68

Closed razvan-becheriu closed 4 years ago

razvan-becheriu commented 4 years ago

the flashall script does flash the u-boot-envs/*.bin files but the boot environment does not define such action (do_ota, etc...), so doing ota to a different version which might have a different boot environment might not work, as the old environment is preserved

also thud ota is not working, even from/to the same version

razvan-becheriu commented 4 years ago

I believe this can be achieved by either modifying ./utils/flash/ota_update.cmd which is the upgrade script run on ota, or by modifying meta-intel-edison-bsp/recipes-bsp/u-boot/files/edison.env, or both.

htot commented 4 years ago

I think Intel gave up on ota at a certain point when the partition to hold the ota became to small. Or when the root partition became to small so they had to sacrifice the ota partition. Correct me if I'm wrong. I'm not even sure how the ota is supposed to work. IIUC the binary is booted instead of the kernel. I don't think we have the sources of the binary. My long term plan was to create a 2nd kernel and use that to install the rootfs ota. But if you have a better solution I would be happy to take your patches.

razvan-becheriu commented 4 years ago

Hi,

Here is a patch. You can test it. Please let me know if you find any issue with it.

patch.txt

It does write the u-boot-env0 and u-boot-env1 partitions just as flashall would do, and then loads the content using 'env import' and saves it as current env using 'saveenv'.

razvan-becheriu commented 4 years ago

To test this, I use the old (official) intel edison image and do ota to thud.

razvan-becheriu commented 4 years ago

It seems that the ota is broken in thud version. So you can upgrade from pocky to thud, but you can not upgrade from thud to thud. Not all commands in ota_update.cmd are supported by the new u-boot. I'll provide a patch to fix this as well.

htot commented 4 years ago

I see. I wanted to ask you that.

I think I removed ota when adding reboot usb and reboot sdhc.

I think we could use a doc page explaining how the ota mechanism works.

razvan-becheriu commented 4 years ago

no. it is not related. the new uboot has 'part' command with different sintax.

old syntax: part find mmc 0 label:${u_part_lbl} u_part_num part info mmc 0:${u_part_num} u_part_start u_part_sz u_part_blksz

new sintax: part start mmc 0 ${u_part_num} u_part_start part size mmc 0 ${u_part_num} u_part_sz

where ${u_part_num} is ${u_part_lbl} not sure if the conversion function is still needed.

I'll try to add support for both old and new syntax (maybe somebody wants to do downgrade to an old uboot, so the script should support both)

htot commented 4 years ago

That would be very nice.

razvan-becheriu commented 4 years ago

I believe that doing downgrade won’t work as the script on the old image has to be modified also to support the new syntax. so doing an OTA to an older version will use the new ‘part’ syntax, but the commands from the old script (within the image) with old ‘part’ syntax...so the best I can do is add support for OTA from old to new and from new to new versions.

razvan-becheriu commented 4 years ago

another way to do this is to actually modify the ‘part’ command to support both ‘syntax’ so we can leave the scripts as they are and have full compatibility between versions

htot commented 4 years ago

From old to new, and new to new sounds good enough to me. To go back to factory state, people can better flashall (which doesn't work well on win10 I hear) or Flash Tool Lite.

Does OTA work even I you prepare that partition for usb/sdhc booting? https://edison-fw.github.io/meta-intel-edison/2.2-Building-and-installing-the-kernel.html#installing-the-kernel

razvan-becheriu commented 4 years ago

Hi,

I have a working ota script. The script allows old (pocky) version to be upgraded to thud and also supports update from thud to thud. As I have described, it is not compatible with pocky when it comes to downgrading because:

  1. the pocky version does not have the update script with compatibility of 'part' command running in u-boot on the thud board
  2. the pocky version does not have the update script which updates the environment from u-boot-envs/*.bin files

I am not really happy with the fix, as it hardcodes the partition numbers and block size (512 bytes/block). However, there are many things hardcoded in the boot environment, like: 'root=/dev/mmcblk0p8'. Also the partitioning is hardcoded, but I believe we can work with this approach for now.

A better solution would be to modify the 'part' command to retrieve the same way it did on pocky, but there will still be a need to fix item 2. I am not sure (sincerely I don't think so) if we can change the thud image to boot with the environment on pocky, which concludes that a change on the pocky image (upgrade script and maybe even more files) to make it work with OTA from thud.

patch.txt

I'll investigate item 1 for a better solution. Until then, you can experiment with this.

razvan-becheriu commented 4 years ago

I have modified the part command to support 'block' and 'id' which return the partition block size and partition id respectively.

I have also modified the dfu to support either mmc or raw type (both act like default raw type).

add files: meta-intel-edison-bsp/recipes-bsp/u-boot/files/dfu-add-mmc-support.diff meta-intel-edison-bsp/recipes-bsp/u-boot/u-boot-fw-utils_2019.04.bbappend meta-intel-edison-bsp/recipes-bsp/u-boot/u-boot_2019.04.bbappend

I guess we should find a better name for the files.

Now we can modify the utils/flash/ota_update.cmd to use runtime (not hard coded) values for partition id and block size (update ota_find_partition_alternative and ota_get_partition_attributes_alternative functions).

u-boot-fw-utils_2019.04.bbappend.txt u-boot_2019.04.bbappend.txt

I'll update the utils/flash/ota_update.cmd and come back with a patch.

htot commented 4 years ago

You can patch u-boot files directly (no need bbappend). They are ours meta-intel-edison/meta-intel-edison-bsp/recipes-bsp/u-boot/

razvan-becheriu commented 4 years ago

ok.

here is the patch for the OTA upgrade script (without any harcoded value):

ota_update.cmd.diff.txt

enjoy!

razvan-becheriu commented 4 years ago

you can put these changes in their respective repo. I only have a fork from meta-intel-edison, os this is the reason I put everything relative to it.

razvan-becheriu commented 4 years ago

Ups.. I did a mistake.. reloading the patch

dfu-add-mmc-support.diff.txt

razvan-becheriu commented 4 years ago

I have tested on my side and everything seems fine. Please let me know what you think.

razvan-becheriu commented 4 years ago

If I come to think about it, we can leave drivers/dfu/dfu_mmc.c unmodified, as we will not try to resolve issue 2. So you can just delete the modifications related to that file in dfu-add-mmc-support.diff.txt

dfu-add-mmc-support.diff.txt

I am not going to rename the file as you will include the changes in the repo directly.

htot commented 4 years ago

you can put these changes in their respective repo. I only have a fork from meta-intel-edison, os this is the reason I put everything relative to it.

I see. You are right, adding the patch to the u-boot recipe is more future proof then adding to u-boot fork. Unless you get @andy-shev to take your patch (is our upstream).

If you rebase to current meta-intel-edison/master (or warrior) and commit your changes then push your local branch, you can send me a PR. That would prevent me from making mistakes and also takes care of the attribution of your work. Would do you think?

razvan-becheriu commented 4 years ago

Ok. I'll try to do that but I am busy with something else right now. Will try to do this at the end of the week.

Another thing, it seems that the modification in drivers/dfu/dfu_mmc.c are necessary. If you flash a board with the new thud image and try to do flashall.sh using an pocky image, it won't work unless you also add the modification in drivers/dfu/dfu_mmc.c to the thud image.

The flashall will overwrite the old dfu, but it uses the currently installed dfu on the board (the thud version), so if it does not support mmc (which is equivalent to raw), it won't work.

can you please also specify the upstream git repository address. Thank you.

andy-shev commented 4 years ago

@htot, my branch is merely an intermittent place for patches to go to U-Boot upstream. So, if the patch could fit pure upstream U-Boot, I can take it. Otherwise I wouldn't touch U-Boot repository for that.

htot commented 4 years ago

@andy-shev understood, we will apply patches through u-boot recipe.

razvan-becheriu commented 4 years ago

Hi,

I havecreated 2 PR:

u-boot: Add part command support for block size and partition number: https://github.com/edison-fw/u-boot/pull/1

meta-intel-edison: Fixed OTA upgrade script to update environment and to use alternative syntax to support upgrade from both pocky or thud: https://github.com/edison-fw/meta-intel-edison/pull/70

Regards, Razvan

On Mon, Sep 23, 2019 at 9:55 PM Ferry Toth notifications@github.com wrote:

@andy-shev https://github.com/andy-shev understood, we will apply patches through u-boot recipe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/edison-fw/meta-intel-edison/issues/68?email_source=notifications&email_token=AEURNW3Q5O5LV5RWLS7XK5LQLEGIHA5CNFSM4IX7KPIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7L4SRI#issuecomment-534235461, or mute the thread https://github.com/notifications/unsubscribe-auth/AEURNW6K2EF6TK562WT4UMDQLEGIHANCNFSM4IX7KPIA .

razvan-becheriu commented 4 years ago

I believe that you have to update some hashes/commit ids if you are going to use the new HEAD (after merge) on https://github.com/edison-fw/u-boot

If you prefer to use (just as I did) bbappend, then I'll create another PR for meta-intel-edison.

I can also try to apply the patch to https://github.com/andy-shev/u-boot

Please let me know.

Razvan

On Mon, Sep 30, 2019 at 9:43 AM razvan becheriu razvan.becheriu@gmail.com wrote:

Hi,

I havecreated 2 PR:

u-boot: Add part command support for block size and partition number: https://github.com/edison-fw/u-boot/pull/1

meta-intel-edison: Fixed OTA upgrade script to update environment and to use alternative syntax to support upgrade from both pocky or thud: https://github.com/edison-fw/meta-intel-edison/pull/70

Regards, Razvan

On Mon, Sep 23, 2019 at 9:55 PM Ferry Toth notifications@github.com wrote:

@andy-shev https://github.com/andy-shev understood, we will apply patches through u-boot recipe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/edison-fw/meta-intel-edison/issues/68?email_source=notifications&email_token=AEURNW3Q5O5LV5RWLS7XK5LQLEGIHA5CNFSM4IX7KPIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7L4SRI#issuecomment-534235461, or mute the thread https://github.com/notifications/unsubscribe-auth/AEURNW6K2EF6TK562WT4UMDQLEGIHANCNFSM4IX7KPIA .

razvan-becheriu commented 4 years ago

Moved https://github.com/edison-fw/meta-intel-edison/pull/70 to https://github.com/edison-fw/meta-intel-edison/pull/71

fixed typo in branch name

On Mon, Sep 30, 2019 at 9:49 AM razvan becheriu razvan.becheriu@gmail.com wrote:

I believe that you have to update some hashes/commit ids if you are going to use the new HEAD (after merge) on https://github.com/edison-fw/u-boot

If you prefer to use (just as I did) bbappend, then I'll create another PR for meta-intel-edison.

I can also try to apply the patch to https://github.com/andy-shev/u-boot

Please let me know.

Razvan

On Mon, Sep 30, 2019 at 9:43 AM razvan becheriu razvan.becheriu@gmail.com wrote:

Hi,

I havecreated 2 PR:

u-boot: Add part command support for block size and partition number: https://github.com/edison-fw/u-boot/pull/1

meta-intel-edison: Fixed OTA upgrade script to update environment and to use alternative syntax to support upgrade from both pocky or thud: https://github.com/edison-fw/meta-intel-edison/pull/70

Regards, Razvan

On Mon, Sep 23, 2019 at 9:55 PM Ferry Toth notifications@github.com wrote:

@andy-shev https://github.com/andy-shev understood, we will apply patches through u-boot recipe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/edison-fw/meta-intel-edison/issues/68?email_source=notifications&email_token=AEURNW3Q5O5LV5RWLS7XK5LQLEGIHA5CNFSM4IX7KPIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7L4SRI#issuecomment-534235461, or mute the thread https://github.com/notifications/unsubscribe-auth/AEURNW6K2EF6TK562WT4UMDQLEGIHANCNFSM4IX7KPIA .

htot commented 4 years ago

I'll try it, but need a bit of time. Hold on :-)

htot commented 4 years ago

I believe it is fixed in warrior in my repo https://github.com/htot/meta-intel-edison/tree/warrior. Eventually this will land in edison-fw/master. Closing for now.