commit 2c71246c93af20c368515e95024018980dc0c3d2 Author: cfif Date: Wed Dec 4 13:10:48 2024 +0300 Init diff --git a/Inc/BootJump.h b/Inc/BootJump.h new file mode 100644 index 0000000..66265ad --- /dev/null +++ b/Inc/BootJump.h @@ -0,0 +1,12 @@ +// +// Created by xemon on 02.11.22. +// + +#ifndef UVEOS_ON_NATION_BOOTLOADER_JUMP_H +#define UVEOS_ON_NATION_BOOTLOADER_JUMP_H + +#include "stdint.h" + +void BootJumpToAddress(const uint32_t address); + +#endif //UVEOS_ON_NATION_BOOTLOADER_JUMP_H diff --git a/Src/BootJump.c b/Src/BootJump.c new file mode 100644 index 0000000..df5f3d7 --- /dev/null +++ b/Src/BootJump.c @@ -0,0 +1,51 @@ +// +// Created by xemon on 02.11.22. +// +#include "n32g45x.h" + +typedef void (*pFunction)(void); + +#pragma GCC push_options +#pragma GCC optimize ("O0") + +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 +} + +#pragma GCC pop_options \ No newline at end of file diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..0ba0c0b --- /dev/null +++ b/modular.json @@ -0,0 +1,17 @@ +{ + "dep": [ + { + "type": "git", + "provider": "NAVIGATOR_UVEOS_NATION_TELIT", + "repo": "PeripheralDriver_NATION_N32G45X" + } + ], + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file