Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
714a59ab
Commit
714a59ab
authored
Jan 03, 2017
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
esp8266/modesp: Make check_fw() work with OTA firmware.
parent
f5750e88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
esp8266/modesp.c
esp8266/modesp.c
+19
-7
No files found.
esp8266/modesp.c
View file @
714a59ab
...
...
@@ -628,10 +628,12 @@ STATIC mp_obj_t esp_flash_size(void) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
esp_flash_size_obj
,
esp_flash_size
);
// If there's just 1 loadable segment at the start of flash,
// we assume there's a yaota8266 bootloader.
#define IS_OTA_FIRMWARE() ((*(uint32_t*)0x40200000 & 0xff00) == 0x100)
STATIC
mp_obj_t
esp_flash_user_start
(
void
)
{
if
((
*
(
uint32_t
*
)
0x40200000
&
0xff00
)
==
0x100
)
{
// If there's just 1 loadable segment at the start of flash,
// we assume there's a yaota8266 bootloader.
if
(
IS_OTA_FIRMWARE
())
{
return
MP_OBJ_NEW_SMALL_INT
(
0x3c000
+
0x90000
);
}
else
{
return
MP_OBJ_NEW_SMALL_INT
(
0x90000
);
...
...
@@ -641,10 +643,20 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_user_start_obj, esp_flash_user_start)
STATIC
mp_obj_t
esp_check_fw
(
void
)
{
MD5_CTX
ctx
;
uint32_t
*
sz_p
=
(
uint32_t
*
)
0x40208ffc
;
printf
(
"size: %d
\n
"
,
*
sz_p
);
char
*
fw_start
=
(
char
*
)
0x40200000
;
if
(
IS_OTA_FIRMWARE
())
{
// Skip yaota8266 bootloader
fw_start
+=
0x3c000
;
}
uint32_t
size
=
*
(
uint32_t
*
)(
fw_start
+
0x8ffc
);
printf
(
"size: %d
\n
"
,
size
);
if
(
size
>
1024
*
1024
)
{
print
(
"Invalid size
\n
"
);
return
mp_const_false
;
}
MD5Init
(
&
ctx
);
MD5Update
(
&
ctx
,
(
char
*
)
0x40200004
,
*
sz_p
-
4
);
MD5Update
(
&
ctx
,
fw_start
+
4
,
size
-
4
);
unsigned
char
digest
[
16
];
MD5Final
(
digest
,
&
ctx
);
printf
(
"md5: "
);
...
...
@@ -652,7 +664,7 @@ STATIC mp_obj_t esp_check_fw(void) {
printf
(
"%02x"
,
digest
[
i
]);
}
printf
(
"
\n
"
);
return
mp_obj_new_bool
(
memcmp
(
digest
,
(
void
*
)(
0x40200000
+
*
sz_p
)
,
sizeof
(
digest
))
==
0
);
return
mp_obj_new_bool
(
memcmp
(
digest
,
fw_start
+
size
,
sizeof
(
digest
))
==
0
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
esp_check_fw_obj
,
esp_check_fw
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment