Skip to content

Initialise RAM interrupt vector tables in SystemInit() for UBLOX_C030 platform #4539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
*/


#include "ublox_low_level_api.h"
#include "stm32f4xx.h"
#include "hal_tick.h"

Expand Down Expand Up @@ -122,9 +123,7 @@

/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
#define VECT_TAB_SRAM
/******************************************************************************/

/**
Expand Down Expand Up @@ -215,10 +214,16 @@ void SystemInit(void)
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */

/* Configure the Vector Table location add offset address ------------------*/
SCB->VTOR = FLASH_BASE; /* Vector Table Relocation in Internal FLASH */

#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
int *vectors = (int *)SCB->VTOR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this result in copying nvic 2x ? I replied the the issue. Why is HalInit part of SystemInit. Can it be delayed and what would be the implications. We are reviewing this currently

cc @c1728p9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I suppose it would mean that, but an extra copy step is worth it to have my platform boot and I can't see anything wrong with the platform initialising its interrupt vector table in SystemInit(). If there is a proper/tested answer I'm happy for this PR to be dropped; I'm happy to wait a few days for that answer to come about. If anyone wants working code for the UBLOX_C030 platform I will point them to my fix branch in the meantime.

int *old_vectors = vectors;
vectors = (int *)NVIC_RAM_VECTOR_ADDRESS;
for (int i = 0; i < NVIC_NUM_VECTORS; i++) {
vectors[i] = old_vectors[i];
}
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
#endif

/* Configure the Cube driver */
Expand All @@ -232,7 +237,10 @@ void SystemInit(void)

/* Reset the timer to avoid issues after the RAM initialization */
TIM_MST_RESET_ON;
TIM_MST_RESET_OFF;
TIM_MST_RESET_OFF;

// Initialise the board
ublox_board_init();
}

/**
Expand Down Expand Up @@ -309,7 +317,6 @@ void SystemCoreClockUpdate(void)
SystemCoreClock = pllvco/pllp;
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
/* Compute HCLK frequency --------------------------------------------------*/
Expand Down Expand Up @@ -877,4 +884,4 @@ void SetSysClock(void)
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/