fn verify(&mut self, data: &[u8]) {
        let result = (|| {
            let word_size = 4;
            let mut errors = 0;
            let words = data.len() / 4;
            for (word_count, word_bytes) in data.chunks(word_size).enumerate() {
                let firmware_word = Cursor::new(word_bytes).read_u32::<BigEndian>().unwrap();
                let address = IFLASH0_ADDR + (word_count * word_size) as u32;
                let sam_word = self.read_word(address)?;
                trace!("Verifying word {:04} of {:04} at address 0x{:08X}", word_count, words, address);
                let _ = self.sender.send(Progress::Verifying(word_count));

                // Compare the top 2 bytes of every word
                let mask = 0xFFFF0000;
                if sam_word & mask != firmware_word & mask {
                    errors += 1;
                }
            }
            Ok(errors)
        })();

        let _ = match result {
            Ok(num) => self.sender.send(Progress::VerifyComplete(num)),
            Err(e) => self.sender.send(Progress::Failed(e)),
        };
    }
/// Verifies that the data from the given buffer matches the data on the ATSAM
/// beginning at the base Flash address of the device. This is used to check that
/// a firmware image was uploaded correctly.
Verifies that the data from the given buffer matches the data on the ATSAM
beginning at the base Flash address of the device. This is used to check that
a firmware image was uploaded correctly.
Verifies that the data from the given buffer matches the data on the ATSAM beginning at the base Flash address of the device . This is used to check that a firmware image was uploaded correctly .
fn verify(&mut self, data: &[u8]) {
        let result = (|| {
            let word_size = 4;
            let mut errors = 0;
            let words = data.len() / 4;
            for (word_count, word_bytes) in data.chunks(word_size).enumerate() {
                let firmware_word = Cursor::new(word_bytes).read_u32::<BigEndian>().unwrap();
                let address = IFLASH0_ADDR + (word_count * word_size) as u32;
                let sam_word = self.read_word(address)?;
                trace!("Verifying word {:04} of {:04} at address 0x{:08X}", word_count, words, address);
                let _ = self.sender.send(Progress::Verifying(word_count));
                // Compare the top 2 bytes of every word
                let mask = 0xFFFF0000;
                if sam_word & mask != firmware_word & mask {
                    errors += 1;
                }
            }
            Ok(errors)
        })();
        let _ = match result {
            Ok(num) => self.sender.send(Progress::VerifyComplete(num)),
            Err(e) => self.sender.send(Progress::Failed(e)),
        };
    }
fn verify ( & mut self , data : & [ u8 ] ) { let result = ( | | { let word_size = 4 ; let mut errors = 0 ; let words = data . len ( ) / 4 ; for ( word_count , word_bytes ) in data . chunks ( word_size ) . enumerate ( ) { let firmware_word = Cursor :: new ( word_bytes ) . read_u32 :: < BigEndian > ( ) . unwrap ( ) ; let address = IFLASH0_ADDR + ( word_count * word_size ) as u32 ; let sam_word = self . read_word ( address ) ? ; trace ! ( " " word_count words address ) ; let _ = self . sender . send ( Progress :: Verifying ( word_count ) ) ; // Compare the top 2 bytes of every word let mask = 0xFFFF0000 ; if sam_word & mask != firmware_word & mask { errors += 1 ; } } Ok ( errors ) } ) ( ) ; let _ = match result { Ok ( num ) => self . sender . send ( Progress :: VerifyComplete ( num ) ) , Err ( e ) => self . sender . send ( Progress :: Failed ( e ) ) , } ; }
Verifies that the data from the given buffer matches the data on the ATSAM
beginning at the base Flash address of the device.
Verifies that the data from the given buffer matches the data on the ATSAM beginning at the base Flash address of the device .
&mut self
data
&[u8]
&mut self
data
&[u8]