Автоопределение JTAG
This commit is contained in:
parent
aa97b636ff
commit
c1dd1a2b19
53
APP/main.c
53
APP/main.c
|
|
@ -70,16 +70,11 @@ typedef struct {
|
|||
#define FMC0_BASE_V2 (0x4001e000u)
|
||||
#define FMC0_V2 ((FMC_Type_V2 *)FMC0_BASE_V2)
|
||||
|
||||
static void swap_bank(uint8_t eBank)
|
||||
{
|
||||
if (0U == (FMC0_V2->OTA_CTRL))
|
||||
{
|
||||
if (0 == eBank)
|
||||
{
|
||||
static void swap_bank(uint8_t eBank) {
|
||||
if (0U == (FMC0_V2->OTA_CTRL)) {
|
||||
if (0 == eBank) {
|
||||
FMC0_V2->OTA_CTRL &= (~(1u << 5u));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FMC0_V2->OTA_CTRL |= (1u << 5u);
|
||||
}
|
||||
FMC0_V2->OTA_CTRL |= 0xA;
|
||||
|
|
@ -87,9 +82,8 @@ static void swap_bank(uint8_t eBank)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void DefaultISR(void) {
|
||||
*((volatile unsigned int *)(0x40014030)) = 0x00000A55;
|
||||
// *((volatile unsigned int *)(0x40014030)) = 0x00000A55;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -99,8 +93,7 @@ void DefaultISR(void) {
|
|||
//void xPortPendSVHandler(void) __attribute__((naked));
|
||||
//void vPortSVCHandler(void) __attribute__((naked));
|
||||
|
||||
static void Boot2App(void)
|
||||
{
|
||||
static void Boot2App(void) {
|
||||
uint32_t u32StackAddr = *((uint32_t *) ((uint32_t) _FirmwareMainBegin));
|
||||
uint32_t u32ResetAddr = *((uint32_t *) (((uint32_t) _FirmwareMainBegin) + 4U));
|
||||
SCB->VTOR = (uint32_t) _FirmwareMainBegin;
|
||||
|
|
@ -114,41 +107,33 @@ static void Boot2App(void)
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
bool is_jtag_debug_active(void) {
|
||||
// Проверяем, включена ли отладка
|
||||
return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0;
|
||||
}
|
||||
|
||||
uint64_t NumberBank = 0;
|
||||
|
||||
int main(void) {
|
||||
Bsp_CLOCK_Init();
|
||||
|
||||
|
||||
// RGM_ResetEventType eReset = RGM_HWA_ReadAllResetFlagBeforePOR();
|
||||
|
||||
|
||||
/*
|
||||
if (RGM_SRS_JTAG_MASK == (RGM->SRS & RGM_SRS_JTAG_MASK)) {
|
||||
if (is_jtag_debug_active()) {
|
||||
D_bInternalFlashPage_Clear(0x04000000, NULL, NULL);
|
||||
NumberBank = 0;
|
||||
} else {
|
||||
D_sInternalFlashPage_Read(0x04000000, 0, (uint8_t * ) & NumberBank, 8);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
uint8_t ver0[30];
|
||||
uint8_t ver1[30];
|
||||
|
||||
memcpy(ver0, (uint8_t *)(0x01000000 + 0xFF00), 30);
|
||||
swap_bank(1);
|
||||
memcpy(ver1, (uint8_t *)(0x01000000 + 0xFF00), 30);
|
||||
*/
|
||||
D_sInternalFlashPage_Read(0x04000000, 0, (uint8_t * ) & NumberBank, 8);
|
||||
NumberBank = (*(__IO uint64_t *) (0x04000000));
|
||||
|
||||
if (NumberBank == 1) {
|
||||
if (NumberBank == 0x1122334455667788) {
|
||||
swap_bank(1);
|
||||
} else {
|
||||
swap_bank(0);
|
||||
}
|
||||
// swap_bank(0);
|
||||
|
||||
|
||||
BootFastJumpToAddress(_FirmwareMainBegin);
|
||||
// Boot2App();
|
||||
// BootJumpToAddress(_FirmwareMainBegin);
|
||||
// BootFastJumpToAddress(_FirmwareMainBegin);
|
||||
Boot2App();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ SET(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/MODULES/CmakeConfig_GCC_CortexM7/gc
|
|||
ENABLE_LANGUAGE(ASM)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O2")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
|
||||
|
||||
IF (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
MESSAGE(
|
||||
|
|
|
|||
Loading…
Reference in New Issue