Skip to content

Commit 87dc69b

Browse files
committed
Checking header field magic number (VID/PID) for occurence of right value
1 parent af46cef commit 87dc69b

File tree

4 files changed

+463
-440
lines changed

4 files changed

+463
-440
lines changed

libraries/SNU/extras/NiNaBoot/NiNaBoot.ino

+23
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,29 @@ int main() {
220220
goto boot;
221221
}
222222

223+
/* Thirdly verify via magic number if this application is intented for
224+
* MKR WIFI 1010 or NANO 33 IOT.
225+
*/
226+
#if defined(ARDUINO_SAMD_MKRWIFI1010)
227+
if (ota_header.header.magic_number != 0x23418054) /* 2341:8054 = VID/PID MKR WIFI 1010 */
228+
{
229+
update_file.close();
230+
update_file.erase();
231+
goto boot;
232+
}
233+
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
234+
if (ota_header.header.magic_number != 0x23418057) /* 2341:8057 = VID/PID NANO 33 IOT */
235+
{
236+
update_file.close();
237+
update_file.erase();
238+
goto boot;
239+
}
240+
#else
241+
update_file.close();
242+
update_file.erase();
243+
goto boot;
244+
#endif
245+
223246
/* Rewind to start of LZSS compressed binary. */
224247
update_file.seek(sizeof(ota_header.buf));
225248

0 commit comments

Comments
 (0)