1
0
Fork 0

Load PL: simplify logic by using fatfs find_file directly.

This commit is contained in:
pca006132 2020-06-18 11:32:23 +08:00
parent 228c0c813d
commit 2b1b0dc49f
1 changed files with 5 additions and 10 deletions

View File

@ -161,16 +161,11 @@ pub fn load_bitstream_from_sd() -> Result<(), PlLoadingError> {
let fs = reader.mount_fatfs(sd_reader::PartitionEntry::Entry1)?; let fs = reader.mount_fatfs(sd_reader::PartitionEntry::Entry1)?;
let root_dir = fs.root_dir(); let root_dir = fs.root_dir();
for entry in root_dir.iter() { let mut file = root_dir.open_file("/BOOT.BIN").map_err(|_| PlLoadingError::BootImageNotFound)?;
if let Ok(entry) = entry {
if entry.is_file() && entry.short_file_name() == "BOOT.BIN" {
info!("Found boot image!"); info!("Found boot image!");
return load_bitstream(&mut entry.to_file()); load_bitstream(&mut file)
}
}
}
} else { } else {
info!("SD card not inserted. Bitstream cannot be loaded.") info!("SD card not inserted. Bitstream cannot be loaded.");
}
Err(PlLoadingError::BootImageNotFound) Err(PlLoadingError::BootImageNotFound)
}
} }