mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update bootloader to support M7.
This commit is contained in:
parent
d0ae48d3a6
commit
53df7fed4f
@ -30,7 +30,7 @@
|
|||||||
#define __USBD_CONF_H
|
#define __USBD_CONF_H
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f4xx_hal.h"
|
#include STM32_HAL_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@ -24,9 +24,13 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stm32f4xx_hal.h>
|
#include STM32_HAL_H
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
|
#if defined(STM32F769xx)
|
||||||
|
#define FLASH_FLAG_PGSERR (FLASH_FLAG_ERSERR)
|
||||||
|
#endif
|
||||||
|
|
||||||
extern void __fatal_error();
|
extern void __fatal_error();
|
||||||
|
|
||||||
void flash_erase(uint32_t sector)
|
void flash_erase(uint32_t sector)
|
||||||
@ -38,7 +42,7 @@ void flash_erase(uint32_t sector)
|
|||||||
|
|
||||||
// Clear pending flags (if any)
|
// Clear pending flags (if any)
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
|
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
|
||||||
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
|
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||||
|
|
||||||
// erase the sector(s)
|
// erase the sector(s)
|
||||||
FLASH_EraseInitTypeDef EraseInitStruct;
|
FLASH_EraseInitTypeDef EraseInitStruct;
|
||||||
|
|||||||
@ -1,34 +1,29 @@
|
|||||||
#include <stm32f4xx_hal.h>
|
#include STM32_HAL_H
|
||||||
|
#include "usbd_cdc.h"
|
||||||
#include "usbd_desc.h"
|
#include "usbd_desc.h"
|
||||||
#include "usbd_cdc.h"
|
#include "omv_boardconfig.h"
|
||||||
|
|
||||||
#define LED_RED GPIO_PIN_0
|
|
||||||
#define LED_GREEN GPIO_PIN_2
|
|
||||||
#define LED_BLUE GPIO_PIN_1
|
|
||||||
|
|
||||||
#define APP_ADDR (0x08010000)
|
|
||||||
|
|
||||||
USBD_HandleTypeDef USBD_Device;
|
USBD_HandleTypeDef USBD_Device;
|
||||||
extern USBD_CDC_ItfTypeDef USBD_CDC_fops;
|
extern USBD_CDC_ItfTypeDef USBD_CDC_fops;
|
||||||
|
|
||||||
void __flash_led(uint16_t led)
|
void __flash_led()
|
||||||
{
|
{
|
||||||
HAL_GPIO_TogglePin(GPIOC, led);
|
HAL_GPIO_TogglePin(OMV_BOOTLDR_LED_PORT, OMV_BOOTLDR_LED_PIN);
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
HAL_GPIO_TogglePin(GPIOC, led);
|
HAL_GPIO_TogglePin(OMV_BOOTLDR_LED_PORT, OMV_BOOTLDR_LED_PIN);
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((noreturn)) __fatal_error()
|
void __attribute__((noreturn)) __fatal_error()
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
__flash_led(LED_RED);
|
__flash_led();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Override main app interrupt vector offset (set in system_stm32f4xx.c)
|
// Override main app interrupt vector offset (set in system_stm32fxxx.c)
|
||||||
SCB->VTOR = FLASH_BASE | 0x0;
|
SCB->VTOR = FLASH_BASE | 0x0;
|
||||||
|
|
||||||
HAL_Init();
|
HAL_Init();
|
||||||
@ -47,14 +42,13 @@ int main()
|
|||||||
|
|
||||||
// Wait for IDE to connect
|
// Wait for IDE to connect
|
||||||
uint32_t start = HAL_GetTick();
|
uint32_t start = HAL_GetTick();
|
||||||
while (!USBD_IDE_Connected() &&
|
while (!USBD_IDE_Connected() && (HAL_GetTick() - start) < 500) {
|
||||||
(HAL_GetTick() - start) < 500) {
|
__flash_led();
|
||||||
__flash_led(LED_GREEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for new firmware image
|
// Wait for new firmware image
|
||||||
while (USBD_IDE_Connected()) {
|
while (USBD_IDE_Connected()) {
|
||||||
__flash_led(LED_GREEN);
|
__flash_led();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deinit USB
|
// Deinit USB
|
||||||
@ -64,5 +58,5 @@ int main()
|
|||||||
__disable_irq(); __DSB(); __ISB();
|
__disable_irq(); __DSB(); __ISB();
|
||||||
|
|
||||||
// Jump to main app
|
// Jump to main app
|
||||||
((void (*)(void))(*((uint32_t*) (APP_ADDR+4))))();
|
((void (*)(void))(*((uint32_t*) (MAIN_APP_ADDR+4))))();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,13 +6,10 @@
|
|||||||
* HAL MSP.
|
* HAL MSP.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <stm32f4xx_hal.h>
|
#include STM32_HAL_H
|
||||||
|
#include "omv_boardconfig.h"
|
||||||
|
|
||||||
#define LED_RED GPIO_PIN_0
|
extern void SystemClock_Config();
|
||||||
#define LED_GREEN GPIO_PIN_2
|
|
||||||
#define LED_BLUE GPIO_PIN_1
|
|
||||||
|
|
||||||
void SystemClock_Config();
|
|
||||||
|
|
||||||
void HAL_MspInit()
|
void HAL_MspInit()
|
||||||
{
|
{
|
||||||
@ -22,27 +19,27 @@ void HAL_MspInit()
|
|||||||
// Config Systick
|
// Config Systick
|
||||||
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
||||||
|
|
||||||
|
/* Enable GPIO clocks */
|
||||||
__GPIOA_CLK_ENABLE();
|
__GPIOA_CLK_ENABLE();
|
||||||
__GPIOB_CLK_ENABLE();
|
__GPIOB_CLK_ENABLE();
|
||||||
__GPIOC_CLK_ENABLE();
|
__GPIOC_CLK_ENABLE();
|
||||||
__GPIOD_CLK_ENABLE();
|
__GPIOD_CLK_ENABLE();
|
||||||
__GPIOE_CLK_ENABLE();
|
__GPIOE_CLK_ENABLE();
|
||||||
|
#if defined (STM32F769xx)
|
||||||
|
__GPIOF_CLK_ENABLE();
|
||||||
|
__GPIOG_CLK_ENABLE();
|
||||||
|
__GPIOH_CLK_ENABLE();
|
||||||
|
__GPIOI_CLK_ENABLE();
|
||||||
|
__GPIOJ_CLK_ENABLE();
|
||||||
|
__GPIOK_CLK_ENABLE();
|
||||||
|
#endif
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
||||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
|
||||||
GPIO_InitStructure.Pin = LED_RED;
|
GPIO_InitStructure.Pin = OMV_BOOTLDR_LED_PIN;
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
HAL_GPIO_Init(OMV_BOOTLDR_LED_PORT, &GPIO_InitStructure);
|
||||||
|
HAL_GPIO_WritePin(OMV_BOOTLDR_LED_PORT, OMV_BOOTLDR_LED_PIN, GPIO_PIN_SET);
|
||||||
GPIO_InitStructure.Pin = LED_GREEN;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
GPIO_InitStructure.Pin = LED_BLUE;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOC, LED_RED, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOC, LED_GREEN, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOC, LED_BLUE, GPIO_PIN_SET);
|
|
||||||
}
|
}
|
||||||
@ -36,8 +36,8 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stm32f4xx_it.h"
|
#include STM32_HAL_H
|
||||||
#include <stm32f4xx_hal.h>
|
#include <stm32fxxx_it.h>
|
||||||
|
|
||||||
extern PCD_HandleTypeDef hpcd;
|
extern PCD_HandleTypeDef hpcd;
|
||||||
/**
|
/**
|
||||||
@ -1,8 +1,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <usbd_cdc.h>
|
#include <usbd_cdc.h>
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
#include "omv_boardconfig.h"
|
||||||
|
|
||||||
#define MAIN_FW_ADDR 0x08010000
|
|
||||||
#define APP_RX_DATA_SIZE 2048
|
#define APP_RX_DATA_SIZE 2048
|
||||||
#define APP_TX_DATA_SIZE 2048
|
#define APP_TX_DATA_SIZE 2048
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ static int8_t CDC_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
|||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case BOOTLDR_START:
|
case BOOTLDR_START:
|
||||||
flash_offset = MAIN_FW_ADDR;
|
flash_offset = MAIN_APP_ADDR;
|
||||||
ide_connected = 1;
|
ide_connected = 1;
|
||||||
// Send back the START command as an ACK
|
// Send back the START command as an ACK
|
||||||
CDC_Tx(Buf, 4);
|
CDC_Tx(Buf, 4);
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include <stm32f4xx_hal.h>
|
#include STM32_HAL_H
|
||||||
#include "usbd_core.h"
|
#include "usbd_core.h"
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
|||||||
@ -10,46 +10,55 @@
|
|||||||
/* Entry Point */
|
/* Entry Point */
|
||||||
ENTRY(Reset_Handler)
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
#ifdef OPENMV1
|
#if defined(OPENMV1)
|
||||||
#define HEAP_MEMORY CCM
|
#define FLASH_ORIGIN 0x08000000
|
||||||
#define FLASH_ORIGIN 0x08000000
|
#define FLASH_LENGTH 512K
|
||||||
#define FLASH_LENGTH 512K
|
|
||||||
|
#define TEXT_ORIGIN 0x08000000
|
||||||
|
#define TEXT_LENGTH 16K
|
||||||
|
|
||||||
|
#define RAM_ORIGIN 0x20000000
|
||||||
|
#define RAM_LENGTH 128K
|
||||||
|
|
||||||
|
#define CCM_ORIGIN 0x10000000
|
||||||
|
#define CCM_LENGTH 64K
|
||||||
|
#elif defined(OPENMV2)
|
||||||
|
#define FLASH_ORIGIN 0x08000000
|
||||||
|
#define FLASH_LENGTH 1024K
|
||||||
|
|
||||||
|
#define TEXT_ORIGIN 0x08000000
|
||||||
|
#define TEXT_LENGTH 16K
|
||||||
|
|
||||||
|
#define RAM_ORIGIN 0x20000000
|
||||||
|
#define RAM_LENGTH 192K
|
||||||
|
|
||||||
|
#define CCM_ORIGIN 0x10000000
|
||||||
|
#define CCM_LENGTH 64K
|
||||||
|
#elif defined(OPENMV7)
|
||||||
|
#define FLASH_ORIGIN 0x08000000
|
||||||
|
#define FLASH_LENGTH 1920K
|
||||||
|
|
||||||
|
#define TEXT_ORIGIN 0x08000000
|
||||||
|
#define TEXT_LENGTH 32K
|
||||||
|
|
||||||
|
#define CCM_ORIGIN 0x20000000
|
||||||
|
#define CCM_LENGTH 128K
|
||||||
|
|
||||||
#define TEXT_ORIGIN 0x08000000
|
#define RAM_ORIGIN 0x20020000
|
||||||
#define TEXT_LENGTH 16K
|
#define RAM_LENGTH 384K
|
||||||
|
|
||||||
#define RAM_ORIGIN 0x20000000
|
|
||||||
#define RAM_LENGTH 128K
|
|
||||||
|
|
||||||
#define CCM_ORIGIN 0x10000000
|
|
||||||
#define CCM_LENGTH 64K
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define HEAP_MEMORY CCM
|
|
||||||
#define FLASH_ORIGIN 0x08000000
|
|
||||||
#define FLASH_LENGTH 1024K
|
|
||||||
|
|
||||||
#define TEXT_ORIGIN 0x08000000
|
|
||||||
#define TEXT_LENGTH 16K
|
|
||||||
|
|
||||||
#define RAM_ORIGIN 0x20000000
|
|
||||||
#define RAM_LENGTH 192K
|
|
||||||
|
|
||||||
#define CCM_ORIGIN 0x10000000
|
|
||||||
#define CCM_LENGTH 64K
|
|
||||||
#endif //OPENMV1
|
#endif //OPENMV1
|
||||||
|
|
||||||
/* Specify the memory areas */
|
/* Specify the memory areas */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH_TEXT (rx) : ORIGIN = TEXT_ORIGIN, LENGTH = TEXT_LENGTH
|
|
||||||
RAM (xrw) : ORIGIN = RAM_ORIGIN, LENGTH = RAM_LENGTH
|
|
||||||
CCM (xrw) : ORIGIN = CCM_ORIGIN, LENGTH = CCM_LENGTH
|
CCM (xrw) : ORIGIN = CCM_ORIGIN, LENGTH = CCM_LENGTH
|
||||||
|
RAM (xrw) : ORIGIN = RAM_ORIGIN, LENGTH = RAM_LENGTH
|
||||||
|
FLASH_TEXT (rx) : ORIGIN = TEXT_ORIGIN, LENGTH = TEXT_LENGTH
|
||||||
}
|
}
|
||||||
|
|
||||||
_estack = 0x10010000; /* Stack is allocated on CCM block */
|
_estack = ORIGIN(CCM) + LENGTH(CCM);
|
||||||
_ram_end = 0x10010000; /* 64KB CCM */
|
_ram_end = ORIGIN(CCM) + LENGTH(CCM);
|
||||||
_stack_size = 0xC00; /* minimum amount of stack */
|
_stack_size = (4K); /* minimum amount of stack */
|
||||||
|
|
||||||
/* Define output sections */
|
/* Define output sections */
|
||||||
SECTIONS
|
SECTIONS
|
||||||
@ -103,7 +112,7 @@ SECTIONS
|
|||||||
} >CCM
|
} >CCM
|
||||||
|
|
||||||
/* Make sure there is enough RAM the stack and FS cache */
|
/* Make sure there is enough RAM the stack and FS cache */
|
||||||
._user_heap_stack :
|
.stack :
|
||||||
{
|
{
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
. = . + _stack_size;
|
. = . + _stack_size;
|
||||||
Loading…
Reference in New Issue
Block a user