======================================================
===== Workflow tests                            ======
======================================================

Needed:
 * Ensure the HC flasher works correctly within installer on rk3399 box:
   Should since the flashing code and other main bits were taken from rk3399 code.
 * Ensure HC flasher works properly on a HoneyComb LX2!


1. No known version of firmware on either boot source:
   =================================================================
   Status: PASS

a) SPI flash empty

   Execute:
  * Flash the RockPro64 firmware to the SPI
    or empty it

b) SD card empty
   Execute:
  * dd over the first 100K of the SD card, since that's all we check
     dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=1

Expected result:
  * No Hardware Config profile detected
  * Flashing is mandated

2. Known PACKAGED versions of firmware on either one of the devices:
   =================================================================
   Status: PASS

 a) SPI has nothing recognisable.
    SD card has a recognised image

   Execute:
   * empty/flash rockpro64 image to it
   * write SD card image to SD
   cd platform/aarch64/bootware/recovery/lx2160acex7
   xzcat lx2160acex7_2000_700_3200_8_5_2.img.xz | dd of=/dev/mmcblk1 bs=4M iflag=fullblock status=progress

Expected result:
   * Hardware profile is populated
   * Firmware file is recognised and surfaced
     Flashing MANDATED

 b) SPI flash contains known version that IS PACKAGED:
   Execute:
   * Use the tool to flash one of them
   * Re-run tool

Expected result:
   Hardware profile is populated
   Firmware file is recognised and surfaced.
   Flashing is NOT recommended.


3. Known UNPACKAGED versions of firmware on either one of the devices:
   ===================================================================
   STATUS: pass

 a) SPI flash contains an 'OLD' version that is known in the checksum inventory but
    not packaged.

Execute:
  https://images.solid-run.com/LX2k/lx2160a_uefi
  wget https://solid-run-images.sos-de-fra-1.exo.io/LX2k/lx2160a_uefi/lx2160acex7_2000_700_2900_8_5_2_flexspi_nor_2466e62.img.xz
  xzcat lx2160acex7_2000_700_2900_8_5_2_flexspi_nor_2466e62.img.xz > /tmp/firmware-bin
  Flash to SPI
  flashcp -vA /tmp/firmware-bin /dev/mtd0

  Run tool

Expected results:
  * Hardware profile and file name is populated.
    Flashing SUGGESTED

 b) SD card contains an OLD version, ditto above.

Execute:
   * Restore Rockpro64 firmware so it has nothing recognisable

   * Write old version of SD card image to sd card
    wget https://solid-run-images.sos-de-fra-1.exo.io/LX2k/lx2160a_uefi/lx2160acex7_2000_700_2900_8_5_2_sd_2466e62.img.xz
    xzcat lx2160acex7_2000_700_2900_8_5_2_sd_2466e62.img.xz | dd of=/dev/mmcblk1 bs=4M iflag=fullblock status=progress

   * Run tool.


======================================================
===== Basic requirements: situations & workflow ======
======================================================

Inform:
SPI , SD check - determine hardware profile
SPI check to see if pkg'd version = spi hash

Scenarios to handle

Within installer:

Fresh install
 - no SPi
 - SD card present, flashed with one of the known firmwares

 Reinstall:
 - SPI contains known firmware
 - potentially no SD

Installed OS
 - Scan only SPI?


Only package the LATEST firmwares.
 Option to include others should they be required.

Work flow:

Initialisation
----------------

 * Sanity check - can we read SPI?
   bail out if not.

   Sanity code exists within the rk3399 flashing tool.
   Use first 100K. SPI is slow & 100K is more than sufficient to identify
   a unique FW file.

   The check also determines the existing HW profile if possible from
   either the SPI or SD card. -- sets variable.

   Scoping the query of devices for hardware profile discovery:
   ```````````````````````````````````````````````````````````
    Check both SD and SPI in both environments.
old idea:
#   If within the installer,check SPI then SD card.
#   Within the OS, only query the SPI -- this is because the SD card might be in use
#   and the Slackware installation mandates firmware lives on SPI - that's our scope of support.

Decide whether to flash or not
------------------------------

 * Determine if SPI flash contains one of the packaged firmware versions
  * If it does, offer flashing:
     Msg: if you want to change hardware profile, you'll need to reflash then
     power off.
     Surface: firmware file name AND hardware profile type     
     Otherwise, suggest not flashing.

Flashing
---------

   If unable to determine HW profile, curate a list of PROFILES based on the packaged versions.
   (there are 3?)

   If known, default the menu to the EXISTING profile.
   if unknown, note in the message box that we don't know and you need to choose it yourself.

Flash.



