Master is now using the same FW_Update Methode as the Slaves
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "BSP_POWER.h"
|
||||
#include "BSP_GPIO.h"
|
||||
#include "BSP_ADC.h"
|
||||
#include "ram_loader.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -73,13 +74,12 @@ static void MPU_Config(void);
|
||||
void MX_FREERTOS_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
void ULOG_SendLPUART(ulog_level_t level, char *msg);
|
||||
void JumpToBootloader_system(void);
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
const uint32_t OS_BOOTFLAG_ADDRESS = 0x38000000;
|
||||
const uint32_t OS_BOOTFLAG_MAGIC = 0xDEADBEFF;
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@@ -90,19 +90,6 @@ int main(void)
|
||||
{
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
// Check if the bootloader magic number is set at the given address
|
||||
volatile uint32_t * ptr = (uint32_t *)OS_BOOTFLAG_ADDRESS;
|
||||
if (*ptr == OS_BOOTFLAG_MAGIC) {
|
||||
// Jump to the bootloader
|
||||
*ptr = 0;
|
||||
JumpToBootloader_system();
|
||||
}
|
||||
|
||||
if (*ptr == 0) {
|
||||
*ptr = 2;
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -302,58 +289,8 @@ void ULOG_SendLPUART(ulog_level_t level, char *msg) {
|
||||
HAL_UART_Transmit(&hlpuart1, (const uint8_t*)ulog_send_buffer, send_length, LOG_TIMEOUT);
|
||||
}
|
||||
|
||||
void JumpToBootloader(void)
|
||||
{
|
||||
|
||||
// Set the magic number to the given address
|
||||
volatile uint32_t * ptr = (uint32_t *)OS_BOOTFLAG_ADDRESS;
|
||||
*ptr = OS_BOOTFLAG_MAGIC;
|
||||
|
||||
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void JumpToBootloader_system(void)
|
||||
{
|
||||
#define conBootloadAddress 0x1FF09800
|
||||
|
||||
void (*SysMemBootJump)(void);
|
||||
uint8_t i;
|
||||
|
||||
__disable_irq();
|
||||
// Reset USB
|
||||
//USBD_DeInit(&hUsbDeviceHS);
|
||||
|
||||
//De-init all peripherals
|
||||
//HAL_ADC_DeInit(&hadc1);
|
||||
|
||||
// Disable Systick
|
||||
SysTick->CTRL = 0;
|
||||
SysTick->LOAD = 0;
|
||||
SysTick->VAL = 0;
|
||||
|
||||
// Reset clock to default
|
||||
HAL_RCC_DeInit();
|
||||
|
||||
// Clear all interrupt bits
|
||||
for (i = 0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]); i++)
|
||||
{
|
||||
NVIC->ICER[i] = 0xFFFFFFFF;
|
||||
NVIC->ICPR[i] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
__enable_irq();
|
||||
|
||||
SysMemBootJump = (void (*)(void)) (*((uint32_t *) (conBootloadAddress + 4)));
|
||||
__set_MSP(*(uint32_t *)conBootloadAddress);
|
||||
SysMemBootJump();
|
||||
|
||||
while (1); // Just in case...
|
||||
}
|
||||
|
||||
|
||||
void DataClbk_cls_usb_JumpToBootloader(void* msg, uint32_t length) {
|
||||
JumpToBootloader();
|
||||
RamLoader_LoadApplication();
|
||||
}
|
||||
/* USER CODE END 4 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user