forked from M-Labs/artiq
config: impl flashing over mgmt
This commit is contained in:
parent
378d962edb
commit
86f692fe7b
|
@ -259,7 +259,33 @@ mod imp {
|
|||
}
|
||||
|
||||
pub fn write(key: &str, value: &[u8]) -> Result<(), Error> {
|
||||
match append(key, value) {
|
||||
fn flash_binary(origin: usize, payload: &[u8]) {
|
||||
let mut offset = 0;
|
||||
while offset < payload.len() {
|
||||
unsafe {
|
||||
spiflash::erase_sector(origin + offset);
|
||||
}
|
||||
offset += spiflash::SECTOR_SIZE;
|
||||
}
|
||||
unsafe {
|
||||
spiflash::write(origin, payload);
|
||||
}
|
||||
}
|
||||
|
||||
match key {
|
||||
"gateware" => {
|
||||
flash_binary(0, value);
|
||||
Ok(())
|
||||
}
|
||||
"bootloader" => {
|
||||
flash_binary(::mem::ROM_BASE, value);
|
||||
Ok(())
|
||||
}
|
||||
"firmware" => {
|
||||
flash_binary(::mem::FLASH_BOOT_ADDRESS, value);
|
||||
Ok(())
|
||||
}
|
||||
_ => match append(key, value) {
|
||||
Err(Error::SpaceExhausted) => {
|
||||
compact()?;
|
||||
append(key, value)
|
||||
|
@ -267,6 +293,7 @@ mod imp {
|
|||
res => res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_int(key: &str, value: u32) -> Result<(), Error> {
|
||||
let mut buf = [0; 16];
|
||||
|
|
Loading…
Reference in New Issue