Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite33d238

Browse files
committed
esp8266/modesp: Add check_fw() function to check integrity of the firmware.
Requires firmware generated by the latest makeimg.py (which stores sizeand md5 of the firmware together with the firmware itself).
1 parentbf47b71 commite33d238

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎esp8266/etshal.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ void ets_timer_arm_new(os_timer_t *tim, uint32_t millis, bool repeat, bool is_mi
2020
voidets_timer_setfn(os_timer_t*tim,ETSTimerFunccallback,void*cb_data);
2121
voidets_timer_disarm(os_timer_t*tim);
2222

23+
// Opaque structure
24+
typedefcharMD5_CTX[64];
25+
26+
voidMD5Init(MD5_CTX*context);
27+
voidMD5Update(MD5_CTX*context,constvoid*data,unsignedintlen);
28+
voidMD5Final(unsignedchardigest[16],MD5_CTX*context);
29+
2330
// These prototypes are for recent SDKs with "malloc tracking"
2431
void*pvPortMalloc(unsignedsz,constchar*fname,intline);
2532
voidvPortFree(void*p,constchar*fname,intline);

‎esp8266/modesp.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,24 @@ STATIC mp_obj_t esp_flash_size(void) {
633633
}
634634
STATICMP_DEFINE_CONST_FUN_OBJ_0(esp_flash_size_obj,esp_flash_size);
635635

636+
STATICmp_obj_tesp_check_fw(void) {
637+
MD5_CTXctx;
638+
uint32_t*sz_p= (uint32_t*)0x40208ffc;
639+
printf("size: %d\n",*sz_p);
640+
MD5Init(&ctx);
641+
MD5Update(&ctx, (char*)0x40200004,*sz_p-4);
642+
unsignedchardigest[16];
643+
MD5Final(digest,&ctx);
644+
printf("md5: ");
645+
for (inti=0;i<16;i++) {
646+
printf("%02x",digest[i]);
647+
}
648+
printf("\n");
649+
returnmp_obj_new_bool(memcmp(digest, (void*)(0x40200000+*sz_p),sizeof(digest))==0);
650+
}
651+
STATICMP_DEFINE_CONST_FUN_OBJ_0(esp_check_fw_obj,esp_check_fw);
652+
653+
636654
STATICmp_obj_tesp_neopixel_write_(mp_obj_tpin,mp_obj_tbuf,mp_obj_tis800k) {
637655
mp_buffer_info_tbufinfo;
638656
mp_get_buffer_raise(buf,&bufinfo,MP_BUFFER_READ);
@@ -703,6 +721,7 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = {
703721
{MP_OBJ_NEW_QSTR(MP_QSTR_dht_readinto), (mp_obj_t)&dht_readinto_obj },
704722
{MP_OBJ_NEW_QSTR(MP_QSTR_freemem), (mp_obj_t)&esp_freemem_obj },
705723
{MP_OBJ_NEW_QSTR(MP_QSTR_meminfo), (mp_obj_t)&esp_meminfo_obj },
724+
{MP_OBJ_NEW_QSTR(MP_QSTR_check_fw), (mp_obj_t)&esp_check_fw_obj },
706725
{MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&pyb_info_obj },// TODO delete/rename/move elsewhere
707726
{MP_OBJ_NEW_QSTR(MP_QSTR_malloc), (mp_obj_t)&esp_malloc_obj },
708727
{MP_OBJ_NEW_QSTR(MP_QSTR_free), (mp_obj_t)&esp_free_obj },

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp