Skip to content

Commit

Permalink
ports/stm32/boards/OPENMV: Implement bootloader entry function.
Browse files Browse the repository at this point in the history
  • Loading branch information
iabdalkader committed Jan 3, 2025
1 parent 3f42112 commit 38c1ae3
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 14 deletions.
8 changes: 8 additions & 0 deletions ports/stm32/boards/OPENMV2/board_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "py/mphal.h"
#define OMV_BOOTLOADER_MAGIC_ADDR (0x1000FFFCU)
#define OMV_BOOTLOADER_MAGIC_VALUE (0xB00710ADU)

void board_enter_bootloader(void) {
*((uint32_t *) OMV_BOOTLOADER_MAGIC_ADDR) = OMV_BOOTLOADER_MAGIC_VALUE;
NVIC_SystemReset();
}
5 changes: 3 additions & 2 deletions ports/stm32/boards/OPENMV2/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ typedef unsigned int mp_uint_t; // must be pointer size
#define MICROPY_HW_ENABLE_USB (1)
#define MICROPY_HW_ENABLE_SDCARD (1)
#define MICROPY_HW_TIM_IS_RESERVED(id) (id == 1 || id == 6)

#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0)
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) NVIC_SystemReset()

extern void board_enter_bootloader(void);
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) board_enter_bootloader()

#define MICROPY_HW_CLK_PLLM (6)
#define MICROPY_HW_CLK_PLLN (360)
Expand Down
8 changes: 8 additions & 0 deletions ports/stm32/boards/OPENMV3/board_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "py/mphal.h"
#define OMV_BOOTLOADER_MAGIC_ADDR (0x2001FFFCU)
#define OMV_BOOTLOADER_MAGIC_VALUE (0xB00710ADU)

void board_enter_bootloader(void) {
*((uint32_t *) OMV_BOOTLOADER_MAGIC_ADDR) = OMV_BOOTLOADER_MAGIC_VALUE;
NVIC_SystemReset();
}
5 changes: 3 additions & 2 deletions ports/stm32/boards/OPENMV3/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ typedef unsigned int mp_uint_t; // must be pointer size
#define MICROPY_HW_ENABLE_USB (1)
#define MICROPY_HW_ENABLE_SDCARD (1)
#define MICROPY_HW_TIM_IS_RESERVED(id) (id == 1 || id == 6)

#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0)
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) NVIC_SystemReset()

extern void board_enter_bootloader(void);
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) board_enter_bootloader()

#define MICROPY_HW_CLK_PLLM (12)
#define MICROPY_HW_CLK_PLLN (432)
Expand Down
8 changes: 8 additions & 0 deletions ports/stm32/boards/OPENMV4/board_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "py/mphal.h"
#define OMV_BOOTLOADER_MAGIC_ADDR (0x2001FFFCU)
#define OMV_BOOTLOADER_MAGIC_VALUE (0xB00710ADU)

void board_enter_bootloader(void) {
*((uint32_t *) OMV_BOOTLOADER_MAGIC_ADDR) = OMV_BOOTLOADER_MAGIC_VALUE;
NVIC_SystemReset();
}
5 changes: 3 additions & 2 deletions ports/stm32/boards/OPENMV4/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ typedef unsigned int mp_uint_t; // must be pointer size
#define MICROPY_HW_ENABLE_USB (1)
#define MICROPY_HW_ENABLE_SDCARD (1)
#define MICROPY_HW_TIM_IS_RESERVED(id) (id == 1 || id == 6)

#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0)
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) NVIC_SystemReset()

extern void board_enter_bootloader(void);
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) board_enter_bootloader()

// Note these are not used in top system.c.
#define MICROPY_HW_CLK_PLLM (3)
Expand Down
11 changes: 9 additions & 2 deletions ports/stm32/boards/OPENMV4P/board_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include "storage.h"
#include "sdram.h"

void board_low_power(int mode)
{
#define OMV_BOOTLOADER_MAGIC_ADDR (0x2001FFFCU)
#define OMV_BOOTLOADER_MAGIC_VALUE (0xB00710ADU)

void board_low_power(int mode) {
switch (mode) {
case 0: // Leave stop mode.
sdram_leave_low_power();
Expand All @@ -18,3 +20,8 @@ void board_low_power(int mode)
// Enable QSPI deepsleep for modes 1 and 2
mp_spiflash_deepsleep(&spi_bdev.spiflash, (mode != 0));
}

void board_enter_bootloader(void) {
*((uint32_t *) OMV_BOOTLOADER_MAGIC_ADDR) = OMV_BOOTLOADER_MAGIC_VALUE;
NVIC_SystemReset();
}
5 changes: 3 additions & 2 deletions ports/stm32/boards/OPENMV4P/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ typedef unsigned int mp_uint_t; // must be pointer size
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_ENABLE_SDCARD (1)
#define MICROPY_HW_TIM_IS_RESERVED(id) (id == 1 || id == 6)

#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0)
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) NVIC_SystemReset()

extern void board_enter_bootloader(void);
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) board_enter_bootloader()

// Note these are not used in top system.c.
#define MICROPY_HW_CLK_PLLM (3)
Expand Down
11 changes: 9 additions & 2 deletions ports/stm32/boards/OPENMVPT/board_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include "storage.h"
#include "sdram.h"

void board_low_power(int mode)
{
#define OMV_BOOTLOADER_MAGIC_ADDR (0x2001FFFCU)
#define OMV_BOOTLOADER_MAGIC_VALUE (0xB00710ADU)

void board_low_power(int mode) {
switch (mode) {
case 0: // Leave stop mode.
sdram_leave_low_power();
Expand All @@ -18,3 +20,8 @@ void board_low_power(int mode)
// Enable QSPI deepsleep for modes 1 and 2
mp_spiflash_deepsleep(&spi_bdev.spiflash, (mode != 0));
}

void board_enter_bootloader(void) {
*((uint32_t *) OMV_BOOTLOADER_MAGIC_ADDR) = OMV_BOOTLOADER_MAGIC_VALUE;
NVIC_SystemReset();
}
5 changes: 3 additions & 2 deletions ports/stm32/boards/OPENMVPT/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ typedef unsigned int mp_uint_t; // must be pointer size
#define MICROPY_HW_ENABLE_USB (1)
#define MICROPY_HW_ENABLE_SDCARD (1)
#define MICROPY_HW_TIM_IS_RESERVED(id) (id == 1 || id == 6)

#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0)
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) NVIC_SystemReset()

extern void board_enter_bootloader(void);
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) board_enter_bootloader()

// Note these are not used in top system.c.
#define MICROPY_HW_CLK_PLLM (3)
Expand Down

0 comments on commit 38c1ae3

Please sign in to comment.