Commit 0efa0b54 authored by Damien George's avatar Damien George

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: default avatarDamien George <damien@micropython.org>
parent c1eb2929
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -43,6 +43,7 @@ enum {
ELEM_TYPE_END = 1,
ELEM_TYPE_MOUNT,
ELEM_TYPE_FSLOAD,
ELEM_TYPE_STATUS,
};
enum {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment