STMicroelectronics / STM32CubeL1

Full Firmware Package for the STM32L1 series: HAL+LL drivers, CMSIS, BSP, MW, plus a set of Projects (examples and demos) running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits).
Other
37 stars 24 forks source link

FW_L1 V1.10.3 does not set VTOR in SystemInit() by default, which causes HardFault. #11

Closed popons closed 2 years ago

popons commented 2 years ago

Caution In v1.10.3, SCB->VTOR is not set by default and remains at 0x00000000. Nevertheless, g_pfnVectors will be placed at 0x08000000. So if you run the default project in STM32CubeIDE, you will get a HardFault from SysTick Exception.

Describe the set-up

Describe the bug In the project's default configuration, USER_VECT_TAB_ADDRESS is not defined and VTOR remains at 0x00000000, resulting in a HardFault. Is this intended?

How To Reproduce

  1. Open STM32CubeIDE 1.6.1(or 1.7.0)

  2. Create New STM32 Project

  3. Select STM32L151CB-A

  4. Select V1.10.3 Firmware

  5. Build and Program and Run

Additional context

Screenshotsimage

ALABSTM commented 2 years ago

Hi @popons,

As you are using a custom board, would you mind checking that pin BOOT0 is connected to the GND? In case, it is, would you please ensure you application is not modifying the MEM_MODE field of the SYSCFG_MEMRMP register?

If both checks are OK, then maybe you wanted to relocate the vector table without defining USER_VECT_TAB_ADDRESS whether at IDE- or Makefile-level.

As for what you are observing, not setting the SCB->VOTR register is not likely to be the root-cause. Indeed:

Since address 0x08000000 is by default aliased 0x00000000, access to the vector table will be correctly performed in case of interrupt. This is very likely to be the case as, on the screenshot above, both SysTick and HardFault exceptions are recognized. This would not have been the case in case of an incorrect access to the vector table.

I hope this helps. Waiting for you reply to know how things have progressed.

With regards,

popons commented 2 years ago

Thank you for your reply. I checked and BOOT0 was in OPEN state. I shorted it to GND and it booted normally. Thank you for your time responding to my inquiries.

ALABSTM commented 2 years ago

Hi @popons,

Glad to know you could solve this point. Please allow me to close this issue in this case.

With regards,