@@ -63,6 +63,48 @@ const PAGE_SIZE: u32 = 256;
6363const BLOCK_ERASE_CMD : u8 = 0xd8 ;
6464const FLASH_BASE : u32 = 0x1000_0000 ;
6565
66+ #[ repr( C ) ]
67+ pub struct FlashDevice {
68+ pub version : u16 ,
69+ pub device_name : [ u8 ; 128 ] ,
70+ pub device_type : u16 ,
71+ pub device_address : u32 ,
72+ pub size_device : u32 ,
73+ pub size_page : u32 ,
74+ pub reserved : u32 ,
75+ pub val_empty : u8 ,
76+ pub timeout_program : u32 ,
77+ pub timeout_erase : u32 ,
78+ pub sectors : [ u32 ; 4 ] ,
79+ }
80+
81+ #[ cfg( feature = "device_description" ) ]
82+ #[ no_mangle]
83+ #[ link_section = ".DevDscr" ]
84+ pub static FlashDevice : FlashDevice = FlashDevice {
85+ version : 1 , // Version 1.01
86+ device_name : [
87+ 0x52 , 0x61 , 0x73 , 0x70 , 0x65 , 0x72 , 0x72 , 0x79 , 0x20 , 0x50 , 0x69 , 0x20 , 0x52 , 0x50 , 0x32 ,
88+ 0x30 , 0x34 , 0x30 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
89+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
90+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
91+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
92+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
93+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
94+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
95+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
96+ ] , // "Rasperry Pi RP2040"
97+ device_type : 5 , // External SPI
98+ device_address : FLASH_BASE , // Default device start address
99+ size_device : 16 * 1024 * 1024 , // Total Size of device (16 MiB)
100+ size_page : PAGE_SIZE , // Programming page size
101+ reserved : 0 , // Must be zero
102+ val_empty : 0xFF , // Content of erase memory
103+ timeout_program : 500 , // 500 ms
104+ timeout_erase : 5000 , // 5 s
105+ sectors : [ SECTOR_SIZE , FLASH_BASE , 0xFFFFFFFF , 0xFFFFFFFF ] ,
106+ } ;
107+
66108impl FlashAlgo for RP2040Algo {
67109 fn new ( _address : u32 , _clock : u32 , _function : u32 ) -> Result < Self , ErrorCode > {
68110 let funcs = ROMFuncs :: load ( ) ;
0 commit comments