UnknownCommand = 1,
InvalidArgument,
ChecksumMismatch,
+ PermissionDenied,
}
extern {
}
}
- pub fn run(&mut self) {
+ pub fn run(&mut self) -> bool {
if self.command_bytes < 4 {
if let Some(b) = try_read_u8() {
self.command >>= 8;
}
}
- if self.command_bytes == 4 {
+ if self.command_bytes != 4 {
+ true
+ } else {
self.command_bytes = 0;
self.process_command();
+
+ self.command != COMMAND_START_APP
}
}
if sector > 0xff {
Err(Error::InvalidArgument)
+ } else if sector == 0x01 {
+ // The second sector contains the flash configuration field,
+ // and keeping it in the erased state has the potential
+ // to brick the device.
+ Err(Error::PermissionDenied)
} else {
flash::erase(sector);