@@ -97,65 +97,75 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
97
97
match FromPrimitive :: from_usize ( msg. body . id ( ) ) {
98
98
#[ cfg( feature="dbg-ecupdate" ) ]
99
99
Some ( UpdateOp :: UpdateGateware ) => { // blocking scalar
100
- netmgr. connection_manager_stop ( ) . unwrap ( ) ;
101
- com. wlan_leave ( ) . ok ( ) ;
102
- ticktimer. sleep_ms ( 4000 ) . unwrap ( ) ; // give a few seconds for any packets/updates to clear so we don't tigger panics as the EC is about to disappear...
103
-
104
100
let package = unsafe { core:: slice:: from_raw_parts ( ec_package. as_ptr ( ) as * const u8 , xous:: EC_FW_PKG_LEN as usize ) } ;
105
101
if !validate_package ( package, PackageType :: Ec ) {
106
102
log:: error!( "firmware package did not pass validation" ) ;
107
103
modals. show_notification (
108
104
& format ! ( "{} gateware" , t!( "ecup.invalid" , xous:: LANG ) ) , None ) . unwrap ( ) ;
109
105
} else {
106
+ log:: info!( "updating GW" ) ;
107
+ netmgr. connection_manager_stop ( ) . ok ( ) ;
108
+ llio. com_event_enable ( false ) . ok ( ) ;
110
109
susres. set_suspendable ( false ) . unwrap ( ) ; // block suspend/resume operations
111
- do_update ( & mut com, & modals, package, CTRL_PAGE_LEN , EC_GATEWARE_BASE , EC_GATEWARE_LEN , "gateware" ) ;
110
+ if !do_update ( & mut com, & modals, package, CTRL_PAGE_LEN , EC_GATEWARE_BASE ,
111
+ EC_GATEWARE_LEN ,
112
+ "gateware" ) {
113
+ xous:: return_scalar ( msg. sender , UpdateResult :: Abort . to_usize ( ) . unwrap ( ) ) . unwrap ( ) ;
114
+ continue ;
115
+ }
112
116
susres. set_suspendable ( true ) . unwrap ( ) ; // resume suspend/resume operations
113
117
}
114
118
xous:: return_scalar ( msg. sender , 0 ) . unwrap ( ) ;
115
119
} ,
116
120
#[ cfg( feature="dbg-ecupdate" ) ]
117
121
Some ( UpdateOp :: UpdateFirmware ) => { // blocking scalar
118
- netmgr. connection_manager_stop ( ) . unwrap ( ) ;
119
- com. wlan_leave ( ) . ok ( ) ;
120
- ticktimer. sleep_ms ( 4000 ) . unwrap ( ) ; // give a few seconds for any packets/updates to clear so we don't tigger panics as the EC is about to disappear...
121
-
122
122
let package = unsafe { core:: slice:: from_raw_parts ( ec_package. as_ptr ( ) as * const u8 , xous:: EC_FW_PKG_LEN as usize ) } ;
123
- let mut temp: [ u8 ; 4 ] = Default :: default ( ) ;
124
- temp. copy_from_slice ( & package[ 0x28 ..0x2c ] ) ;
125
- let length = u32:: from_le_bytes ( temp) ; // total length of package
126
-
127
123
if !validate_package ( package, PackageType :: Ec ) {
128
124
log:: error!( "firmware package did not pass validation" ) ;
129
125
modals. show_notification (
130
126
& format ! ( "{} firmware" , t!( "ecup.invalid" , xous:: LANG ) ) , None ) . unwrap ( ) ;
131
127
} else {
128
+ let length = u32:: from_le_bytes ( package[ 0x28 ..0x2c ] . try_into ( ) . unwrap ( ) ) ;
129
+ if length == 0xffff_ffff { // nothing was staged at all
130
+ xous:: return_scalar ( msg. sender , UpdateResult :: PackageInvalid . to_usize ( ) . unwrap ( ) ) . unwrap ( ) ;
131
+ continue ;
132
+ }
133
+ log:: info!( "updating FW" ) ;
134
+ netmgr. connection_manager_stop ( ) . unwrap ( ) ;
135
+ llio. com_event_enable ( false ) . ok ( ) ;
132
136
susres. set_suspendable ( false ) . unwrap ( ) ; // block suspend/resume operations
133
- do_update ( & mut com, & modals, package, EC_GATEWARE_LEN + CTRL_PAGE_LEN ,
134
- EC_FIRMWARE_BASE , length - ( EC_GATEWARE_LEN ) , "firmware" ) ;
137
+ if !do_update ( & mut com, & modals, package, EC_GATEWARE_LEN + CTRL_PAGE_LEN ,
138
+ EC_FIRMWARE_BASE , length - ( EC_GATEWARE_LEN ) ,
139
+ "firmware" ) {
140
+ xous:: return_scalar ( msg. sender , UpdateResult :: Abort . to_usize ( ) . unwrap ( ) ) . unwrap ( ) ;
141
+ continue ;
142
+ }
135
143
susres. set_suspendable ( true ) . unwrap ( ) ; // resume suspend/resume operations
136
144
}
137
145
xous:: return_scalar ( msg. sender , 0 ) . unwrap ( ) ;
138
146
} ,
139
147
#[ cfg( feature="dbg-ecupdate" ) ]
140
148
Some ( UpdateOp :: UpdateWf200 ) => { // blocking scalar
141
- netmgr. connection_manager_stop ( ) . unwrap ( ) ;
142
- com. wlan_leave ( ) . ok ( ) ;
143
- ticktimer. sleep_ms ( 4000 ) . unwrap ( ) ; // give a few seconds for any packets/updates to clear so we don't tigger panics as the EC is about to disappear...
144
-
145
149
let package = unsafe { core:: slice:: from_raw_parts ( wf_package. as_ptr ( ) as * const u8 , xous:: EC_WF200_PKG_LEN as usize ) } ;
146
- let mut temp: [ u8 ; 4 ] = Default :: default ( ) ;
147
- temp. copy_from_slice ( & package[ 0x28 ..0x2c ] ) ;
148
- let length = u32:: from_le_bytes ( temp) ; // total length of package
149
-
150
- if !validate_package ( package, PackageType :: Wf200 ) {
151
- log:: error!( "WF200 firmware package did not pass validation" ) ;
152
- modals. show_notification (
153
- & format ! ( "{} wf200" , t!( "ecup.invalid" , xous:: LANG ) ) , None ) . unwrap ( ) ;
154
- } else {
150
+ if validate_package ( package, PackageType :: Wf200 ) {
151
+ log:: info!( "updating Wf200" ) ;
152
+ netmgr. connection_manager_stop ( ) . unwrap ( ) ;
153
+ llio. com_event_enable ( false ) . ok ( ) ;
154
+ let length = u32:: from_le_bytes ( package[ 0x28 ..0x2c ] . try_into ( ) . unwrap ( ) ) ;
155
155
susres. set_suspendable ( false ) . unwrap ( ) ; // block suspend/resume operations
156
- do_update ( & mut com, & modals, package, CTRL_PAGE_LEN ,
157
- WF200_FIRMWARE_BASE , length, "wf200" ) ;
156
+ if !do_update ( & mut com, & modals, package, CTRL_PAGE_LEN ,
157
+ WF200_FIRMWARE_BASE , length,
158
+ "WF200" ) {
159
+ xous:: return_scalar ( msg. sender , UpdateResult :: Abort . to_usize ( ) . unwrap ( ) ) . unwrap ( ) ;
160
+ continue ;
161
+ }
158
162
susres. set_suspendable ( true ) . unwrap ( ) ; // resume suspend/resume operations
163
+ } else {
164
+ log:: error!( "wf200 package did not pass validation" ) ;
165
+ modals. show_notification (
166
+ & format ! ( "{} WF200" , t!( "ecup.invalid" , xous:: LANG ) ) , None ) . unwrap ( ) ;
167
+ xous:: return_scalar ( msg. sender , UpdateResult :: PackageInvalid . to_usize ( ) . unwrap ( ) ) . unwrap ( ) ;
168
+ continue ;
159
169
}
160
170
161
171
xous:: return_scalar ( msg. sender , 0 ) . unwrap ( ) ;
0 commit comments