8000 stm32/modmachine: Add ability to pass through user data to mboot. · lolsborn/micropython@65b1fef · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 65b1fef

Browse files
committed
stm32/modmachine: Add ability to pass through user data to mboot.
1 parent 3669198 commit 65b1fef

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ports/stm32/modmachine.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "modmachine.h"
3131
#include "py/gc.h"
3232
#include "py/runtime.h"
33+
#include "py/objstr.h"
3334
#include "py/mperrno.h"
3435
#include "py/mphal.h"
3536
#include "extmod/machine_mem.h"
@@ -273,6 +274,20 @@ STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args)
273274
__set_MSP(*(volatile uint32_t*)0x08000000);
274275
((void (*)(uint32_t)) *((volatile uint32_t*)(0x08000000 + 4)))(0x70ad0000);
275276
}
277+
278+
if (n_args == 1 && mp_obj_is_str_or_bytes(args[0])) {
279+
// With a string/bytes given, pass its data to the custom bootloader
280+
size_t len;
281+
const char *data = mp_obj_str_get_data(args[0], &len);
282+
void *mboot_region = (void*)*((volatile uint32_t*)0x08000000);
283+
memmove(mboot_region, data, len);
284+
#if __DCACHE_PRESENT == 1
285+
SCB_DisableICache();
286+
SCB_DisableDCache();
287+
#endif
288+
__set_MSP(*(volatile uint32_t*)0x08000000);
289+
((void (*)(uint32_t)) *((volatile uint32_t*)(0x08000000 + 4)))(0x70ad0080);
290+
}
276291
#endif
277292

278293
#if defined(STM32F7) || defined(STM32H7)

0 commit comments

Comments
 (0)
0