STM32Nucleoボード調査(割り込みベクタ)

startup_stm32f303x8.s(スタートアップルーチン)では、以下のように割り込みベクタテーブルが指定されている。

/******************************************************************************
*
* The minimal vector table for a Cortex-M4.  Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
*
******************************************************************************/
    .section    .isr_vector,"a",%progbits
    .type   g_pfnVectors, %object
    .size   g_pfnVectors, .-g_pfnVectors


g_pfnVectors:
    .word   _estack
    .word   Reset_Handler
    .word   NMI_Handler
    .word   HardFault_Handler
    .word   MemManage_Handler
    .word   BusFault_Handler
    .word   UsageFault_Handler

STM32F303K8Tx_FLASH.ld(リンカスクリプト)では、以下のようなメモリ割り当てが指示されている。

/* Specify the memory areas */
MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 12K
CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 4K
FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 64K
}

/* Define output sections */
SECTIONS
{
  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

つまり、割り込みベクタテーブルは0x8000000番地から書き込まれている。そして、

f:id:babyron64:20180504201453p:plain Boot from main Flash memory: the main Flash memory is aliased in the boot memory space (0x0000 0000), but still accessible from its original memory space (0x0800 0000). In other words, the Flash memory contents can be accessed starting from address 0x0000 0000 or 0x0800 0000.
from: RM0316 Reference manual

からわかるように、BOOT0が0(ie. グラウンド)であるなら、0x8000000番地(ie. FLASHメモリの先頭)は0x0番地にマッピングされる。実際、回路図やボードを見ると、

f:id:babyron64:20180504202332p:plain f:id:babyron64:20180504202341p:plain
from: UM1956 User manual

f:id:babyron64:20180504201147p:plain

となっている。