forked from M-Labs/artiq
1
0
Fork 0

runtime: fix some final flash storage issues.

This commit is contained in:
whitequark 2017-12-26 14:09:09 +00:00
parent 188764693e
commit 71eca5ad61
2 changed files with 12 additions and 5 deletions

View File

@ -8,6 +8,7 @@ mod imp {
mod lock { mod lock {
use core::slice; use core::slice;
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use board;
static LOCKED: AtomicUsize = ATOMIC_USIZE_INIT; static LOCKED: AtomicUsize = ATOMIC_USIZE_INIT;
@ -24,14 +25,20 @@ mod imp {
pub fn data(&self) -> &'static [u8] { pub fn data(&self) -> &'static [u8] {
extern { extern {
static _ftext: u8;
static _fstorage: u8; static _fstorage: u8;
static _estorage: u8; static _estorage: u8;
} }
unsafe { unsafe {
let begin = &_fstorage as *const u8; let base = &_ftext as *const _ as usize;
let end = &_estorage as *const u8; let begin = &_fstorage as *const _ as usize;
slice::from_raw_parts(begin, end as usize - begin as usize) let end = &_estorage as *const _ as usize;
let ptr = board::mem::FLASH_BOOT_ADDRESS + (begin - base);
let len = end - begin;
slice::from_raw_parts(ptr as *const u8, len)
} }
} }
} }
@ -71,7 +78,7 @@ mod imp {
if record_size == !0 /* all ones; erased flash */ { if record_size == !0 /* all ones; erased flash */ {
return None return None
} else if record_size < 4 || record_size > data.len() { } else if record_size < 4 || record_size > data.len() {
error!("offset {}: invalid record size", self.offset); error!("offset {}: invalid record size {}", self.offset, record_size);
return Some(Err(())) return Some(Err(()))
} }

View File

@ -69,8 +69,8 @@ SECTIONS
.storage : .storage :
{ {
/* Keep in sync with artiq_flash.py */ /* Keep in sync with artiq_flash.py */
_fstorage = .;
. = _ftext + 0x100000; . = _ftext + 0x100000;
_fstorage = .;
. += /*SPIFLASH_SECTOR_SIZE*/ 0x10000; . += /*SPIFLASH_SECTOR_SIZE*/ 0x10000;
_estorage = .; _estorage = .;
} > runtime } > runtime