-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-45 extract raspberry specific to seperate module
This task it the first in the sequence that provides the flashing feature for RK1 compute modules. In this commit raspberry specific code is moved to a seperate file. Secondly the runway is implemented to support multiple "drivers" that enable read/write to internal storage of compute modules. e.g. Writing new firmware to eMMC storage of a module see: turing-machines/BMC-Firmware#45
- Loading branch information
1 parent
f1fec6e
commit 274d8d7
Showing
8 changed files
with
358 additions
and
169 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use futures::future::BoxFuture; | ||
use tokio::{ | ||
io::{AsyncRead, AsyncWrite}, | ||
sync::mpsc::Sender, | ||
}; | ||
|
||
pub use super::usbboot::FlashingError; | ||
use super::{rk1_fwudate::Rk1FwUpdateDriver, rpi_fwupdate::RpiFwUpdate, usbboot::FlashProgress}; | ||
|
||
pub const SUPPORTED_MSD_DEVICES: [(u16, u16); 1] = [RpiFwUpdate::VID_PID]; | ||
pub const SUPPORTED_DEVICES: [(u16, u16); 2] = [RpiFwUpdate::VID_PID, Rk1FwUpdateDriver::VID_PID]; | ||
|
||
pub trait FwUpdate: AsyncRead + AsyncWrite + std::marker::Unpin + Send {} | ||
|
||
pub type FactoryItem = BoxFuture<'static, Result<Box<dyn FwUpdate>, FlashingError>>; | ||
|
||
pub fn fw_update_factory( | ||
vid_pid: (u16, u16), | ||
logging: Sender<FlashProgress>, | ||
) -> Option<FactoryItem> { | ||
if vid_pid == RpiFwUpdate::VID_PID { | ||
Some(Box::pin(async { | ||
RpiFwUpdate::new(logging) | ||
.await | ||
.map(|u| Box::new(u) as Box<dyn FwUpdate>) | ||
})) | ||
} else if vid_pid == Rk1FwUpdateDriver::VID_PID { | ||
Some(Box::pin(async { | ||
Rk1FwUpdateDriver::new(logging).map(|u| Box::new(u) as Box<dyn FwUpdate>) | ||
})) | ||
} else { | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#![allow(unused_variables)] | ||
|
||
use super::{ | ||
firmware_update_usb::FwUpdate, | ||
usbboot::{FlashProgress, FlashingError}, | ||
}; | ||
use tokio::{ | ||
io::{AsyncRead, AsyncWrite}, | ||
sync::mpsc::Sender, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct Rk1FwUpdateDriver {} | ||
|
||
impl Rk1FwUpdateDriver { | ||
pub const VID_PID: (u16, u16) = (0x2207, 0x350b); | ||
pub fn new(logging: Sender<FlashProgress>) -> Result<Self, FlashingError> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl FwUpdate for Rk1FwUpdateDriver {} | ||
|
||
impl AsyncRead for Rk1FwUpdateDriver { | ||
fn poll_read( | ||
self: std::pin::Pin<&mut Self>, | ||
cx: &mut std::task::Context<'_>, | ||
buf: &mut tokio::io::ReadBuf<'_>, | ||
) -> std::task::Poll<std::io::Result<()>> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl AsyncWrite for Rk1FwUpdateDriver { | ||
fn poll_write( | ||
self: std::pin::Pin<&mut Self>, | ||
cx: &mut std::task::Context<'_>, | ||
buf: &[u8], | ||
) -> std::task::Poll<Result<usize, std::io::Error>> { | ||
todo!() | ||
} | ||
|
||
fn poll_flush( | ||
self: std::pin::Pin<&mut Self>, | ||
cx: &mut std::task::Context<'_>, | ||
) -> std::task::Poll<Result<(), std::io::Error>> { | ||
todo!() | ||
} | ||
|
||
fn poll_shutdown( | ||
self: std::pin::Pin<&mut Self>, | ||
cx: &mut std::task::Context<'_>, | ||
) -> std::task::Poll<Result<(), std::io::Error>> { | ||
todo!() | ||
} | ||
} |
Oops, something went wrong.