2014-01-09 07:14 PM
Working on STM32F051.
The bootloader works fine but the interrupt vectors in application file doesn't work even after locating vector table to SRAM. Any solution will be appreciated.2014-01-09 07:45 PM
The bootloader works fine but the interrupt vectors in application file doesn't work even after locating vector table to SRAM.
Evaluate careful what the vectors actually point too. Look at things like the .MAP file, and perhaps a disassembly listing. With the information provided it's going to be a bit hard to remotely debug it. Suggest you reframe with enough data that someone could evaluate what you've created. Have you used a debugger? What did you learn about what is actually happening in the system in this failing state?2014-01-17 03:12 AM
...
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define APPLICATION_ADDRESS (uint32_t)0x08003000
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static __IO uint32_t TimingDelay;
#if (defined ( __CC_ARM ))
__IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
#elif (defined (__ICCARM__))
#pragma location = 0x20000000
__no_init __IO uint32_t VectorTable[48];
#elif defined ( __GNUC__ )
__IO uint32_t VectorTable[48] __attribute__((section(''.RAMVectorTable'')));
#elif defined ( __TASKING__ )
__IO uint32_t VectorTable[48] __at(0x20000000);
#endif
/* Private function prototypes -----------------------------------------------*/
void Delay(__IO uint32_t nTime);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
uint32_t i = 0;
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f0xx.c file
*/
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
/* Copy the vector table from the Flash (mapped at the base of the application
load address 0x08003000) to the base address of the SRAM at 0x20000000. */
for(i = 0; i < 48; i++)
{
VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}
/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Remap SRAM at 0x00000000 */
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
i have done the same settings in both Coocox project and Keil project
but keil application layer works fine and coocox application hangs in the interrupt.2014-01-17 03:45 AM
Hi
Apparently, there are issues with coocox. Certainly does not support all STM32 processors - check carefully if your one is supported. You could try : http://www.emblocks.org/web/ (not a recommendation from me - I have not tried it yet - just a suggestion if you are looking for a free tool chain - at least it looks like a free one). Otherwise - why are you not using Keil if you have it?2014-03-12 05:21 AM
You have to use custom linker file when developing your own IAP application.
Below is detailed information about how to solove your problem
1) Open ''project configuration page'' --> ''link'' tab, Unselect ''use memory layout from memory window'' option
At this time, CoIDE will product an gcc scatter file <arm-gcc-link.ld> in your project directory
2) Open <arm-gcc-link.ld> file, Modify Flash/RAM content according to your MCU
rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x00010000
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00002000
3) Find ''_eram'' symbol in <arm-gcc-link.ld> file, then modify stack size
Generally, we let it point to the end of RAM section, shown below
_eram = 0x20000000 + 0x00002000;
4) Find the code listed below
.data : AT (_etext)
{
_sdata = .;
*(.data .data.*)
. = ALIGN(4);
_edata = . ;
} > ram
Then rewrite it with following code, so that CoIDE can allocate RAM interrupt vector table at the beginning of RAM(0x20000000)
.data : AT (_etext)
{
_sdata = .;
KEEP(*(.RAMVectorTable .RAMVectorTable.*))
*(.data .data.*)
. = ALIGN(4);
_edata = . ;
} > ram
5) Rebuild your project, everything should be ok
Hope this helps!2015-06-17 06:25 AM
Hi tech_that,
I am using an STM32F030 and Coocox, and what to implement an IAP. The linker file produced by Coocox is different to that shown in your example. The .data section is shown below. /* _sidata is used in coide startup code */ _sidata = __etext; .data : AT (__etext) { __data_start__ = .; /* _sdata is used in coide startup code */ _sdata = __data_start__; *(vtable) *(.data*) . = ALIGN(4); /* preinit data */ PROVIDE_HIDDEN (__preinit_array_start = .); KEEP(*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); . = ALIGN(4); /* init data */ PROVIDE_HIDDEN (__init_array_start = .); KEEP(*(SORT(.init_array.*))) KEEP(*(.init_array)) PROVIDE_HIDDEN (__init_array_end = .); . = ALIGN(4); /* finit data */ PROVIDE_HIDDEN (__fini_array_start = .); KEEP(*(SORT(.fini_array.*))) KEEP(*(.fini_array)) PROVIDE_HIDDEN (__fini_array_end = .); KEEP(*(.jcr*)) . = ALIGN(4); /* All data end */ __data_end__ = .; /* _edata is used in coide startup code */ _edata = __data_end__; } > ram What do I need to change to get the vector table to work? Ian2015-06-17 06:40 AM
What do I need to change to get the vector table to work?
Not a CooCox user.Key things you need to do, the base of you application image needs to hold the vector table. You need space at the base of RAM to hold a copy of the vector table. You need to copy the table to the base of RAM, and have the core map the RAM at address ZERO.I would do this be creating a normal FLASH image for the new address. I would shrink the RAM available, advancing the base the linker can use by 0x100 or 0x200 byte. Then in main() I'd copy the vectors over, and remap.The concepts here are not overly complicated.Joseph Yiu has a good book on the Cortex-M0 parts.2015-06-17 06:44 AM
int main(void)
{ uint32_t i = 0; /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/ /* Copy the vector table from the Flash (mapped at the base of the application load address 0x08003000) to the base address of the SRAM at 0x20000000. */ for(i = 0; i < 48; i++) { VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2)); } /* Enable the SYSCFG peripheral clock*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // Clock not Reset /* Remap SRAM at 0x00000000 */ SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM); // ... }2015-06-18 07:36 AM
Hi Clive1,
Thanks for a prompt reply.
I now have the code working. If the linker script is modified as shown below the bootloader works.
/* *(vtable) */
KEEP(*(.RAMVectorTable .RAMVectorTable.*)) *(.data*)However I was slightly thrown by the statement
/* Remap SRAM at 0x00000000 */
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);In my code SYSCFG_MemoryRemap_SRAM is defined as 0x03 in stm32f0xx_syscfg.h. If this is set to 0x00 the bootloader
fails. Do you know why this is? Ian2015-06-18 08:24 AM
However I was slightly thrown by the statement
/* Remap SRAM at 0x00000000 */
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
In my code SYSCFG_MemoryRemap_SRAM is defined as 0x03 in stm32f0xx_syscfg.h. If this is set to 0x00 the bootloader fails. Do you know why this is?
I'm not saying you set the value to zero, writing SYSCFG_MemoryRemap_SRAM shadows the RAM at address zero, it appears in the processors memory map at 0x00000000 and 0x20000000