@@ -36,6 +36,18 @@ pub fn list_serial_ports() -> Result<Vec<SerialPortInfo>, TockloaderError> {
3636 tokio_serial:: available_ports ( ) . map_err ( TockloaderError :: SerialInitializationError )
3737}
3838
39+ // TODO(george-cosma): These functions can all be turned into traits (Listable,
40+ // Installable, etc.) and be implemented on the Connection enum. Or, if we also
41+ // split Connection into trait + structs for each type of connection type, we
42+ // can implement these traits on the individual connections types, and not have
43+ // this mega-massive file.
44+
45+ // TODO(george-cosma): Examine if we need to split these functions into smaller
46+ // parts (reading - processing - writing) for mocking. Could also involve adding
47+ // functions to the proposed 'Connection' trait.
48+
49+ // TODO(george-cosma): General housekeeping in these functions.
50+
3951pub async fn list (
4052 connection : & mut Connection ,
4153 settings : & BoardSettings ,
@@ -107,12 +119,12 @@ pub async fn install_app(
107119 . core ( info. core )
108120 . map_err ( |e| TockloaderError :: CoreAccessError ( info. core , e) ) ?;
109121
110- // TODO: extract these informations without bootloader
111- // TODO: extract board name and kernelr version to verify app compatability
122+ // TODO(george-cosma) : extract these informations without bootloader
123+ // TODO(george-cosma) : extract board name and kernel version to verify app compatability
112124
113125 let mut address = settings. start_address ;
114126
115- // TODO: double-check/rework this
127+ // TODO(george-cosma) : double-check/rework this
116128
117129 // Read a block of 200 8-bit words// Loop to check if there are another apps installed
118130 loop {
@@ -141,7 +153,7 @@ pub async fn install_app(
141153 "No architecture found." . to_owned ( ) ,
142154 ) ) ?;
143155
144- let mut binary = tab_file. extract_binary ( & arch. clone ( ) ) ?;
156+ let mut binary = tab_file. extract_binary ( & arch) ?;
145157 let size = binary. len ( ) as u64 ;
146158
147159 // Make sure the app is aligned to a multiple of its size
@@ -155,12 +167,18 @@ pub async fn install_app(
155167 ( address, 0 )
156168 } ;
157169
158- // No more need of core
170+ // TODO(george-cosma): This point MIGHT mark a good point to split
171+ // this function (for probe-rs).
172+
173+ // At this point we no longer need to hold the probe-rs connection
174+ // to the core, as the flashing is done without it.
159175 drop ( core) ;
160176
161177 // Make sure the binary is a multiple of the page size by padding 0xFFs
162- // TODO(Micu Ana): check if the page-size differs
163- // TODO: also use page_size given or known. This works for now
178+
179+ // TODO(george-cosma): check if the page-size differs + support
180+ // multiple types of page sizes. Possibly make page size a board
181+ // setting.
164182 let page_size = 512 ;
165183 let needs_padding = binary. len ( ) % page_size != 0 ;
166184
@@ -186,14 +204,16 @@ pub async fn install_app(
186204 }
187205 }
188206
189- // If there are no pages valid, all pages would have been removed, so we write them all
207+ // If there are no pages valid, all pages would have been removed,
208+ // so we write them all
190209 if valid_pages. is_empty ( ) {
191210 for i in 0 ..( size as usize / page_size) {
192211 valid_pages. push ( i. try_into ( ) . unwrap ( ) ) ;
193212 }
194213 }
195214
196- // Include a blank page (if exists) after the end of a valid page. There might be a usable 0 on the next page
215+ // Include a blank page (if exists) after the end of a valid page.
216+ // There might be a usable 0 on the next page
197217 let mut ending_pages: Vec < u8 > = Vec :: new ( ) ;
198218 for & i in & valid_pages {
199219 let mut iter = valid_pages. iter ( ) ;
@@ -208,8 +228,8 @@ pub async fn install_app(
208228
209229 for i in valid_pages {
210230 println ! ( "Writing page number {}" , i) ;
211- // Create the packet that we send to the bootloader
212- // First four bytes are the address of the page
231+ // Create the packet that we send to the bootloader. First four
232+ // bytes are the address of the page
213233 let mut pkt = Vec :: new ( ) ;
214234
215235 // Then the bytes that go into the page
0 commit comments