diff options
author | Damien George <damien@micropython.org> | 2021-01-28 15:46:02 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-01-29 15:02:55 +1100 |
commit | 0efa0b54374e3ea0cbaf455c41945800479b5bc8 (patch) | |
tree | c1b2a3636b851d01b298f699eb03a58a3065fb37 | |
parent | c1eb2929279fdcf7f89adeb013290e7c45e24fb7 (diff) |
stm32/mboot: Add ELEM_TYPE_STATUS element so application can get status.
This new element takes the form: (ELEM_TYPE_STATUS, 4, <address>). If this
element is present in the mboot command then mboot will store to the given
address the result of the filesystem firmware update process. The address
can for example be an RTC backup register.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/stm32/boards/stm32f4xx_hal_conf_base.h | 1 | ||||
-rw-r--r-- | ports/stm32/boards/stm32f7xx_hal_conf_base.h | 1 | ||||
-rw-r--r-- | ports/stm32/boards/stm32h7xx_hal_conf_base.h | 1 | ||||
-rw-r--r-- | ports/stm32/mboot/main.c | 9 | ||||
-rw-r--r-- | ports/stm32/mboot/mboot.h | 1 |
5 files changed, 12 insertions, 1 deletions
diff --git a/ports/stm32/boards/stm32f4xx_hal_conf_base.h b/ports/stm32/boards/stm32f4xx_hal_conf_base.h index 91f064835..057a9e81e 100644 --- a/ports/stm32/boards/stm32f4xx_hal_conf_base.h +++ b/ports/stm32/boards/stm32f4xx_hal_conf_base.h @@ -54,6 +54,7 @@ #include "stm32f4xx_hal_usart.h" #include "stm32f4xx_hal_wwdg.h" #include "stm32f4xx_ll_adc.h" +#include "stm32f4xx_ll_pwr.h" #include "stm32f4xx_ll_rtc.h" // Enable various HAL modules diff --git a/ports/stm32/boards/stm32f7xx_hal_conf_base.h b/ports/stm32/boards/stm32f7xx_hal_conf_base.h index 1a3fca3ac..6e7dff304 100644 --- a/ports/stm32/boards/stm32f7xx_hal_conf_base.h +++ b/ports/stm32/boards/stm32f7xx_hal_conf_base.h @@ -54,6 +54,7 @@ #include "stm32f7xx_hal_usart.h" #include "stm32f7xx_hal_wwdg.h" #include "stm32f7xx_ll_adc.h" +#include "stm32f7xx_ll_pwr.h" #include "stm32f7xx_ll_rtc.h" // Enable various HAL modules diff --git a/ports/stm32/boards/stm32h7xx_hal_conf_base.h b/ports/stm32/boards/stm32h7xx_hal_conf_base.h index 231f1ac7f..a451cfde7 100644 --- a/ports/stm32/boards/stm32h7xx_hal_conf_base.h +++ b/ports/stm32/boards/stm32h7xx_hal_conf_base.h @@ -54,6 +54,7 @@ #include "stm32h7xx_hal_usart.h" #include "stm32h7xx_hal_wwdg.h" #include "stm32h7xx_ll_adc.h" +#include "stm32h7xx_ll_pwr.h" #include "stm32h7xx_ll_rtc.h" // Enable various HAL modules diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c index 0846d97cf..1395949f2 100644 --- a/ports/stm32/mboot/main.c +++ b/ports/stm32/mboot/main.c @@ -1443,7 +1443,14 @@ enter_bootloader: // Application passed through elements, validate then process them const uint8_t *elem_end = elem_search(ELEM_DATA_START, ELEM_TYPE_END); if (elem_end != NULL && elem_end[-1] == 0) { - fsload_process(); + int ret = fsload_process(); + // If there is a valid ELEM_TYPE_STATUS element then store the status in the given location. + const uint8_t *elem_status = elem_search(ELEM_DATA_START, ELEM_TYPE_STATUS); + if (elem_status != NULL && elem_status[-1] == 4) { + uint32_t *status_ptr = (uint32_t *)get_le32(&elem_status[0]); + LL_PWR_EnableBkUpAccess(); // In case status_ptr points to backup registers + *status_ptr = ret; + } } // Always reset because the application is expecting to resume led_state_all(0); diff --git a/ports/stm32/mboot/mboot.h b/ports/stm32/mboot/mboot.h index e4ed3cecc..853a86968 100644 --- a/ports/stm32/mboot/mboot.h +++ b/ports/stm32/mboot/mboot.h @@ -43,6 +43,7 @@ enum { ELEM_TYPE_END = 1, ELEM_TYPE_MOUNT, ELEM_TYPE_FSLOAD, + ELEM_TYPE_STATUS, }; enum { |