Skip to content
Snippets Groups Projects

Reboot to bootloader

Open Nikolay Amiantov requested to merge abbradar/firmware:reboot-to-bootloader into master
1 unresolved thread
Files
23
+ 20
2
@@ -2,6 +2,7 @@
#include "card10-version.h"
#include "card10.h"
#include "card10-platform.h"
#include "led.h"
#include "pb.h"
#include "pmic.h"
@@ -29,6 +30,11 @@
#define PARTITION_START (0x10000000 + 64 * 1024)
#define PARTITION_END (0x10000000 + 1024 * 1024 - 1)
struct bootloader_version __attribute__((section(".bootloader_version"))) __bootloader_version = {
.magic = BOOTLOADER_MAGIC,
.version = BOOTLOADER_VERSION,
};
DIR dir;
FATFS FatFs;
@@ -68,6 +74,18 @@ int mount(void)
return 0;
}
int get_msc_flag(void)
{
// We use the API call memory to store a magic value there.
uint32_t* flag = API_CALL_MEM_ADDRESS;
if (*flag == MSC_MAGIC) {
*flag = 0;
return 1;
} else {
return 0;
}
}
int check_integrity(void)
{
FIL file;
@@ -242,8 +260,8 @@ int main(void)
bootloader_display_init();
// If the button is pressed, we go into MSC mode.
if (PB_Get(3)) {
// If the button is pressed or a flag in memory is detected, we go into MSC mode.
if (PB_Get(3) || get_msc_flag()) {
msc();
}
Loading