From e89bb3c822eac18d0ca4d1e523d8e78f5845d400 Mon Sep 17 00:00:00 2001 From: cfif Date: Tue, 11 Mar 2025 12:05:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E=20=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inc/BootJump.h | 12 ++++++++++++ Src/BootJump.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ modular.json | 10 ++++++++++ 3 files changed, 70 insertions(+) create mode 100755 Inc/BootJump.h create mode 100755 Src/BootJump.c create mode 100755 modular.json diff --git a/Inc/BootJump.h b/Inc/BootJump.h new file mode 100755 index 0000000..65d598c --- /dev/null +++ b/Inc/BootJump.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 02.11.22. +// + +#ifndef UVEOS_ON_ARTERY_BOOTLOADER_JUMP_H +#define UVEOS_ON_ARTERY_BOOTLOADER_JUMP_H + +#include "stdint.h" + +void BootJumpToAddress(const uint32_t address); + +#endif //UVEOS_ON_ARTERY_BOOTLOADER_JUMP_H diff --git a/Src/BootJump.c b/Src/BootJump.c new file mode 100755 index 0000000..a9be601 --- /dev/null +++ b/Src/BootJump.c @@ -0,0 +1,48 @@ +// +// Created by xemon on 02.11.22. +// +#include CMSIS_device_header + +typedef void (*pFunction)(void); + +void BootJumpToAddress(const uint32_t address) { + + uint32_t appStack; + pFunction appEntry; + + // get the application stack pointer (1st entry in the app vector table) + appStack = (uint32_t) *((__IO + uint32_t *) address); + + // Get the app entry point (2nd entry in the app vector table + appEntry = (pFunction) *(__IO + uint32_t *) (address + 4); + +// HAL_RCC_DeInit(); +// HAL_DeInit(); + + SysTick->CTRL = 0; + SysTick->LOAD = 0; + SysTick->VAL = 0; + uint32_t i = SCB->VTOR; + i++; + +// Reconfigure vector table offset to match the app location +//#if (SET_VECTOR_TABLE) +// SCB->VTOR = address; +//#endif +// +//// __disable_irq(); // disable interrupt +//// __enable_irq(); +//// __set_PRIMASK(1); +//// __set_MSP(appStack); // Set app stack pointer + + __disable_irq(); + __set_MSP(appStack); + SCB->VTOR = address; + __enable_irq(); + + appEntry(); // Start the app + + while (1); // never reached +} \ No newline at end of file diff --git a/modular.json b/modular.json new file mode 100755 index 0000000..71971cd --- /dev/null +++ b/modular.json @@ -0,0 +1,10 @@ +{ + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file