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
899592ac
Commit
899592ac
authored
Mar 13, 2024
by
Damien George
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/boards/LEGO_HUB_NO6: Move robust logic to mboot.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
9651046e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
13 deletions
+8
-13
ports/stm32/boards/LEGO_HUB_NO6/appupdate.py
ports/stm32/boards/LEGO_HUB_NO6/appupdate.py
+0
-12
ports/stm32/boards/LEGO_HUB_NO6/board_init.c
ports/stm32/boards/LEGO_HUB_NO6/board_init.c
+8
-1
No files found.
ports/stm32/boards/LEGO_HUB_NO6/appupdate.py
View file @
899592ac
...
...
@@ -7,9 +7,6 @@ import struct, machine, fwupdate, spiflash, pyb
_IOCTL_BLOCK_COUNT
=
const
(
4
)
_IOCTL_BLOCK_SIZE
=
const
(
5
)
_SPIFLASH_UPDATE_KEY_ADDR
=
const
(
1020
*
1024
)
_SPIFLASH_UPDATE_KEY_VALUE
=
const
(
0x12345678
)
_FILESYSTEM_ADDR
=
const
(
0x8000_0000
+
1024
*
1024
)
# Roundabout way to get actual filesystem size from config.
...
...
@@ -26,9 +23,6 @@ def update_app(filename):
if
not
elems
:
return
# Create the update key.
key
=
struct
.
pack
(
"<I"
,
_SPIFLASH_UPDATE_KEY_VALUE
)
# Create a SPI flash object.
spi
=
machine
.
SoftSPI
(
sck
=
machine
.
Pin
.
board
.
FLASH_SCK
,
...
...
@@ -41,11 +35,5 @@ def update_app(filename):
# We can't use pyb.Flash() because we need to write to the "reserved" 1M area.
flash
=
spiflash
.
SPIFlash
(
spi
,
cs
)
# Write the update key and elements to the SPI flash.
flash
.
erase_block
(
_SPIFLASH_UPDATE_KEY_ADDR
)
flash
.
write
(
_SPIFLASH_UPDATE_KEY_ADDR
,
key
+
elems
)
# Enter mboot with a request to do a filesystem-load update.
# If there is a power failure during the update (eg battery removed) then
# mboot will read the SPI flash update key and elements and retry.
machine
.
bootloader
(
elems
)
ports/stm32/boards/LEGO_HUB_NO6/board_init.c
View file @
899592ac
...
...
@@ -194,7 +194,14 @@ int board_mboot_get_reset_mode(uint32_t *initial_r0) {
}
void
board_mboot_state_change
(
int
state
,
uint32_t
arg
)
{
if
(
state
==
MBOOT_STATE_FSLOAD_END
)
{
if
(
state
==
MBOOT_STATE_FSLOAD_START
)
{
// The FS-load update is about to start. Program the update key and FS-load elements
// into the flash so they can be retrieved if there is a power failure during the update.
mp_spiflash_erase_block
(
MBOOT_SPIFLASH_SPIFLASH
,
SPIFLASH_UPDATE_KEY_ADDR
);
uint32_t
key
=
SPIFLASH_UPDATE_KEY_VALUE
;
mp_spiflash_write
(
MBOOT_SPIFLASH_SPIFLASH
,
SPIFLASH_UPDATE_KEY_ADDR
,
4
,
(
const
uint8_t
*
)
&
key
);
mp_spiflash_write
(
MBOOT_SPIFLASH_SPIFLASH
,
SPIFLASH_UPDATE_KEY_ADDR
+
4
,
ELEM_DATA_SIZE
,
ELEM_DATA_START
);
}
else
if
(
state
==
MBOOT_STATE_FSLOAD_END
)
{
// The FS-load update completed (either with success or failure), so erase the
// update key and write the result of the FS-load operation into flash.
mp_spiflash_erase_block
(
MBOOT_SPIFLASH_SPIFLASH
,
SPIFLASH_UPDATE_KEY_ADDR
);
...
...
xpstem
@xpstem
mentioned in commit
64f28dc1
·
May 06, 2024
mentioned in commit
64f28dc1
mentioned in commit 64f28dc1eb542c90e38e89cd55b5452ed59290d0
Toggle commit list
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