Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add universal flashing script #713

Merged
merged 1 commit into from
Aug 14, 2024
Merged

Conversation

unbel13ver
Copy link
Contributor

@unbel13ver unbel13ver commented Aug 5, 2024

The 'flash.sh' script makes image flashing easy and hassle-free, both for compressed and uncompressed images.

Description of changes

These changes should fix the recent issue with ZFS, when the device does not boot after the storage media was reflashed.

Checklist for things done

  • Summary of the proposed changes in the PR description
  • More detailed description in the commit message(s)
  • Commits are squashed into relevant entities - avoid a lot of minimal dev time commits in the PR
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • PR linked to architecture documentation and requirement(s) (ticket id)
  • Test procedure described (or includes tests). Select one or more:
    • Tested on Lenovo X1 x86_64
    • Tested on Jetson Orin NX or AGX aarch64
    • Tested on Polarfire riscv64
  • Author has run nix flake check --accept-flake-config and it passes
  • All automatic Github Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing

Build an image, flash it to the media using flash.sh script and boot the device.

@humaidq-tii
Copy link
Member

humaidq-tii commented Aug 6, 2024

Do we need to change the ghaf-installer.sh script also?

And should the flash script be an application in the default devShell? This way we can put the scripts in one place and not clutter the root directory of the repository.

Copy link
Contributor

@leivos-unikie leivos-unikie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milva-unikie noticed that she had to replace #!/bin/bash with #!/run/current-system/sw/bin/bash in her nixos environment.

How about using #!/usr/bin/env bash ?

How universal should the script be? Is it meant that user modifies these

OUTPUT_DIR="result"
UNCOMPRESSED_NAME="nixos.img"
COMPRESSED_NAME="disk1.raw.zst"

Now it works fine for flashing lenovo-x1 image (result/disk1.raw.zst) or icicle-kit image (result/nixos.img). For using the script for other targets:

  • lenovo-x1 installer (e.g. result/iso/ghaf-24.11.20240802.c488d21-x86_64-linux.iso)
  • orin agx/nx (e.g. /result/sd-image/nixos-sd-image-24.11.20240802.c488d21-aarch64-linux.img.zst)
    one has to modify.

@milva-unikie
Copy link

Do we need to change the ghaf-installer.sh script also?

Lenovo-X1 images installed with the installer get stuck at boot, so it definitely should also be fixed.

Now it works fine for flashing lenovo-x1 image (result/disk1.raw.zst) or icicle-kit image (result/nixos.img). For using the script for other targets:

* lenovo-x1 installer (e.g. result/iso/ghaf-24.11.20240802.c488d21-x86_64-linux.iso)

* orin agx/nx (e.g. /result/sd-image/nixos-sd-image-24.11.20240802.c488d21-aarch64-linux.img.zst)
  one has to modify.

Also to add to this, builds made in Himalia and Jenkins produce their own output packages with different names. The latest Lenovo-X1 Himalia-image for example is: d1cnkzqcpd0rp92ifkgdlhszakjb8pjx-ghaf-host-disko-images-himalia-621/d1cnkzqcpd0rp92ifkgdlhszakjb8pjx-ghaf-host-disko-images/disk1.raw.zst

@humaidq-tii
Copy link
Member

humaidq-tii commented Aug 6, 2024

Since we have different paths depending on the target, maybe it is better to generate a flash script with the build, like the Orin:
https://github.com/tiiuae/ghaf/blob/main/lib/mk-flash-script/default.nix

@unbel13ver
Copy link
Contributor Author

Since we have different paths depending on the target, maybe it is better to generate a flash script with the build, like the Orin: https://github.com/tiiuae/ghaf/blob/main/lib/mk-flash-script/default.nix

I initially wanted to keep this flashing script as a separate independent entity and do not contaminate target files. So I've added the possibility to pass the image file name as an argument.

@leivos-unikie
Copy link
Contributor

For the Orin images on vedenemo.dev one just has to first uncompress the *.tar.xz and then the flash script is applicable.

@unbel13ver
Copy link
Contributor Author

For the Orin images on vedenemo.dev one just has to first uncompress the *.tar.xz and then the flash script is applicable.

This is expected since the script is used in the "Build and Run" section of the documentation. The vedenemo images are mentioned in "Release Notes", though. So I can add *.tar.xz support to the script, if you think it is needed.

@leivos-unikie
Copy link
Contributor

For the Orin images on vedenemo.dev one just has to first uncompress the *.tar.xz and then the flash script is applicable.

This is expected since the script is used in the "Build and Run" section of the documentation. The vedenemo images are mentioned in "Release Notes", though. So I can add *.tar.xz support to the script, if you think it is needed.

I think it's enough that flash script covers the 'run and build' case. No need to serve everything.

docs/src/ref_impl/build_and_run.md Outdated Show resolved Hide resolved
docs/src/ref_impl/build_and_run.md Outdated Show resolved Hide resolved
The 'flash.sh' script makes image flashing easy and hassle-free,
both for compressed and uncompressed images.

Signed-off-by: Ivan Nikolaenko <ivan.nikolaenko@unikie.com>
Co-authored-by: Valentin Kharin <valentin.kharin@unikie.com>
Copy link
Collaborator

@brianmcgillion brianmcgillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - improvements can come later, if needed

@brianmcgillion brianmcgillion merged commit 217e7a6 into tiiuae:main Aug 14, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants