pub fn run(mut self) -> ! {
        self.verify_bank_correctness();
        duprintln!(self.serial, "");
        duprintln!(self.serial, "{}", self.greeting);
        if let Some(image) = self.latest_bootable_image() {
            duprintln!(self.serial, "Attempting to boot from default bank.");
            match self.boot(image).unwrap_err() {
                Error::BankInvalid => {
                    info!("Attempted to boot from invalid bank. Restoring image...")
                }
                Error::BankEmpty => {
                    info!("Attempted to boot from empty bank. Restoring image...")
                }
                Error::SignatureInvalid => {
                    info!("Signature invalid for stored image. Restoring image...")
                }
                _ => info!("Unexpected boot error. Restoring image..."),
            };
        }

        match self.restore() {
            Ok(image) => self.boot(image).expect("FATAL: Failed to boot from verified image!"),
            Err(e) => {
                info!("Failed to restore. Error: {:?}", e);

                if self.recovery_enabled {
                    self.recover();
                } else {
                    panic!("FATAL: Failed to boot, and serial recovery is not supported.");
                }
            }
        }
    }
/// Main bootloader routine.
///
/// In case the MCU flash's main bank contains a valid image, an update is attempted.
/// (Any valid image with a different signature in the top occupied external bank is
/// considered "newer" for the purposes of updating). The golden image, if available,
/// is *never* considered newer than the current MCU image, as it exists only as a final
/// resort fallback.
///
/// After attempting or skipping the update process, the bootloader attempts to boot
/// the current MCU image. In case of failure, the following steps are attempted:
///
/// * Verify each bank in ascending order. If any is found to contain a valid
/// image, copy it to bootable MCU flash bank and attempt to boot it.
/// * Verify golden image. If valid, copy to bootable MCU flash bank and attempt to boot.
/// * If golden image not available or invalid, proceed to recovery mode.
Main bootloader routine.
In case the MCU flash's main bank contains a valid image, an update is attempted.
(Any valid image with a different signature in the top occupied external bank is
considered "newer" for the purposes of updating). The golden image, if available,
is *never* considered newer than the current MCU image, as it exists only as a final
resort fallback.

After attempting or skipping the update process, the bootloader attempts to boot
the current MCU image. In case of failure, the following steps are attempted.

Verify each bank in ascending order. If any is found to contain a valid
image, copy it to bootable MCU flash bank and attempt to boot it.
Verify golden image. If valid, copy to bootable MCU flash bank and attempt to boot.
If golden image not available or invalid, proceed to recovery mode.
Main bootloader routine . In case the MCU flash ' s main bank contains a valid image an update is attempted . ( Any valid image with a different signature in the top occupied external bank is considered " newer " for the purposes of updating ) . The golden image if available is * never * considered newer than the current MCU image as it exists only as a final resort fallback . After attempting or skipping the update process the bootloader attempts to boot the current MCU image . In case of failure the following steps are attempted . Verify each bank in ascending order . If any is found to contain a valid image copy it to bootable MCU flash bank and attempt to boot it . Verify golden image . If valid copy to bootable MCU flash bank and attempt to boot . If golden image not available or invalid proceed to recovery mode .
pub fn run(mut self) -> ! {
        self.verify_bank_correctness();
        duprintln!(self.serial, "");
        duprintln!(self.serial, "{}", self.greeting);
        if let Some(image) = self.latest_bootable_image() {
            duprintln!(self.serial, "Attempting to boot from default bank.");
            match self.boot(image).unwrap_err() {
                Error::BankInvalid => {
                    info!("Attempted to boot from invalid bank. Restoring image...")
                }
                Error::BankEmpty => {
                    info!("Attempted to boot from empty bank. Restoring image...")
                }
                Error::SignatureInvalid => {
                    info!("Signature invalid for stored image. Restoring image...")
                }
                _ => info!("Unexpected boot error. Restoring image..."),
            };
        }
        match self.restore() {
            Ok(image) => self.boot(image).expect("FATAL: Failed to boot from verified image!"),
            Err(e) => {
                info!("Failed to restore. Error: {:?}", e);
                if self.recovery_enabled {
                    self.recover();
                } else {
                    panic!("FATAL: Failed to boot, and serial recovery is not supported.");
                }
            }
        }
    }
pub fn run ( mut self ) -> ! { self . verify_bank_correctness ( ) ; duprintln ! ( self serial " " ) ; duprintln ! ( self serial " " self greeting ) ; if let Some ( image ) = self . latest_bootable_image ( ) { duprintln ! ( self serial " " ) ; match self . boot ( image ) . unwrap_err ( ) { Error :: BankInvalid => { info ! ( " " ) } Error :: BankEmpty => { info ! ( " " ) } Error :: SignatureInvalid => { info ! ( " " ) } _ => info ! ( " " ) , } ; } match self . restore ( ) { Ok ( image ) => self . boot ( image ) . expect ( " " ) , Err ( e ) => { info ! ( " " e ) ; if self . recovery_enabled { self . recover ( ) ; } else { panic ! ( " " ) ; } } } }
Main bootloader routine.
Main bootloader routine .
mut self
mut self