Skip to main content
RComa.1
Associate II
Jul 26, 2022 3:43 PM UTC
Question

Shared RAM memory from boot to firmware

Hello everye one, i have a customized bootloader and firmware, i need pass som argument from the first one to the last one, in both project, at linker scripr file i have the following:

MEMORY
{
 RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 12K
 SHARED	(xrw)	: ORIGIN = 0x20002000, LENGTH = 8K
 FLASH (rx) : ORIGIN = 0x8009C00, LENGTH = 25K
}
SECTIONS
{
 
 .shared_mem :
 {
 . = ALIGN(4);
 __shared_mem_start__ = .;
 	*(.shared_mem.key)
 	*(.shared_mem.ID)
 *(.shared_mem*)
 __shared_mem_end__ = .;
 } > SHARED

as you can see i created a SHARED area and shared_mem into, and the application project has the same defined area, and then in the main.c files has thes two lines

__attribute__((section(".shared_mem.key"))) volatile uint32_t VERSION[20];
__attribute__((section(".shared_mem.ID"))) volatile uint32_t ID[20];

if i compile, everything is okay, but when i try to write something in VERSION from the bootloader, the file's size step up a lot, like 300Kb, so if i code the following:

VERSION[0] = 1;

it makes file.bin increase its size a lot and then i cannot flash the MCU because of its size.

Do know someone what's going on?

thanks a lot in advance.

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
Jul 26, 2022 3:48 PM UTC

add the (NOLOAD) attribute to .shared_mem output section

.shared_mem (NOLOAD):

{

[...]

}

JW

RComa.1
RComa.1Author
Associate II
Jul 26, 2022 4:03 PM UTC

Hello, nice the problem has been solved, now the problem is, when bootloader jumps to app, HAL_Delay seems doesn't work, at the begin i put:

SCB->VTOR = 0x8009C00;

__enable_irq();

but it doesn't work yet i am not sure whether new memory are has nothing to do with this problem...

Tesla DeLorean
Guru
Jul 26, 2022 10:13 PM UTC

Do you transfer control from an interrupt or callback routine?

Check that the Systick interrupt has been enabled and that it's being called.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
RComa.1
RComa.1Author
Associate II
Jul 27, 2022 7:36 AM UTC

Hi there, i hope you fine! i use this code to jump from the boot to the app:

typedef void (*pFunction)(void);
 
 
void jumpApp(){
 
 uint32_t jumpAddress;
	pFunction jump_to_app;
 
	jumpAddress = *(uint32_t*) (FLASH_APP_ADDR + 4);
	jump_to_app = (pFunction)jumpAddress;
 
 __HAL_RCC_GPIOC_CLK_DISABLE();
 __HAL_RCC_GPIOD_CLK_DISABLE();
 __HAL_RCC_GPIOB_CLK_DISABLE();
 __HAL_RCC_GPIOA_CLK_DISABLE();
	HAL_RCC_DeInit();
	HAL_DeInit();
	SysTick->CTRL = 0;
	SysTick->LOAD = 0;
	SysTick->VAL = 0;
 
	 __disable_irq();
	 __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
 
	__set_MSP(*(uint32_t*)FLASH_APP_ADDR); //Stack
	jump_to_app();
}

How can i enable the systick interrupt?