Skip to content

Commit d10df48

Browse files
c1728p9bulislaw
authored andcommitted
Fix crash on boot on MAX326XX devices
Properly align ram vector table on MAX326XX devices to fix crashes on boot. Also move the implementation of the vector table out of a header file and into the c file device_nvic.c to fix warnings.
1 parent 05375fa commit d10df48

File tree

10 files changed

+126
-15
lines changed

10 files changed

+126
-15
lines changed

targets/TARGET_Maxim/TARGET_MAX32600/device/cmsis_nvic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#ifndef MBED_CMSIS_NVIC_H
3535
#define MBED_CMSIS_NVIC_H
3636

37-
static void (*ramVectorTable[MXC_IRQ_COUNT])(void);
37+
extern void (*ramVectorTable[MXC_IRQ_COUNT])(void);
3838

3939
#define NVIC_NUM_VECTORS (MXC_IRQ_COUNT)
4040
#define NVIC_RAM_VECTOR_ADDRESS (ramVectorTable) // Vectors positioned at start of RAM
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "cmsis.h"
17+
#include "mbed_toolchain.h"
18+
19+
/* RAM vector_table needs to be aligned with the size of the vector table */
20+
/* TODO: Use MXC_IRQ_COUNT to automatically set this alignment per DUI0553A 4.3.4 */
21+
/* Vector Table Offset which requires the next-power-of-two alignment. This */
22+
/* can be calculated by 4*pow(2,ceil(log2(MXC_IRQ_COUNT))) */
23+
MBED_ALIGN(512)
24+
void (*ramVectorTable[MXC_IRQ_COUNT])(void);

targets/TARGET_Maxim/TARGET_MAX32610/device/cmsis_nvic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#ifndef MBED_CMSIS_NVIC_H
3535
#define MBED_CMSIS_NVIC_H
3636

37-
static void (*ramVectorTable[MXC_IRQ_COUNT])(void);
37+
extern void (*ramVectorTable[MXC_IRQ_COUNT])(void);
3838

3939
#define NVIC_NUM_VECTORS (MXC_IRQ_COUNT)
4040
#define NVIC_RAM_VECTOR_ADDRESS (ramVectorTable) // Vectors positioned at start of RAM
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "cmsis.h"
17+
#include "mbed_toolchain.h"
18+
19+
/* RAM vector_table needs to be aligned with the size of the vector table */
20+
/* TODO: Use MXC_IRQ_COUNT to automatically set this alignment per DUI0553A 4.3.4 */
21+
/* Vector Table Offset which requires the next-power-of-two alignment. This */
22+
/* can be calculated by 4*pow(2,ceil(log2(MXC_IRQ_COUNT))) */
23+
MBED_ALIGN(512)
24+
void (*ramVectorTable[MXC_IRQ_COUNT])(void);

targets/TARGET_Maxim/TARGET_MAX32620/device/cmsis_nvic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#ifndef MBED_CMSIS_NVIC_H
3535
#define MBED_CMSIS_NVIC_H
3636

37-
static void (*ramVectorTable[MXC_IRQ_COUNT])(void);
37+
extern void (*ramVectorTable[MXC_IRQ_COUNT])(void);
3838

3939
#define NVIC_NUM_VECTORS (MXC_IRQ_COUNT)
4040
#define NVIC_RAM_VECTOR_ADDRESS (ramVectorTable) // Vectors positioned at start of RAM
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "cmsis.h"
17+
#include "mbed_toolchain.h"
18+
19+
/* RAM vector_table needs to be aligned with the size of the vector table */
20+
/* TODO: Use MXC_IRQ_COUNT to automatically set this alignment per DUI0553A 4.3.4 */
21+
/* Vector Table Offset which requires the next-power-of-two alignment. This */
22+
/* can be calculated by 4*pow(2,ceil(log2(MXC_IRQ_COUNT))) */
23+
MBED_ALIGN(512)
24+
void (*ramVectorTable[MXC_IRQ_COUNT])(void);

targets/TARGET_Maxim/TARGET_MAX32625/device/cmsis_nvic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
#ifndef MBED_CMSIS_NVIC_H
3535
#define MBED_CMSIS_NVIC_H
3636

37-
static void (*ramVectorTable[MXC_IRQ_COUNT])(void);
37+
extern void (*ramVectorTable[MXC_IRQ_COUNT])(void);
3838

3939
#define NVIC_NUM_VECTORS (MXC_IRQ_COUNT)
4040
#define NVIC_RAM_VECTOR_ADDRESS (ramVectorTable) // Vectors positioned at start of RAM
4141

4242
#endif /* MBED_CMSIS_NVIC_H */
43+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "cmsis.h"
17+
#include "mbed_toolchain.h"
18+
19+
/* RAM vector_table needs to be aligned with the size of the vector table */
20+
/* TODO: Use MXC_IRQ_COUNT to automatically set this alignment per DUI0553A 4.3.4 */
21+
/* Vector Table Offset which requires the next-power-of-two alignment. This */
22+
/* can be calculated by 4*pow(2,ceil(log2(MXC_IRQ_COUNT))) */
23+
MBED_ALIGN(512)
24+
void (*ramVectorTable[MXC_IRQ_COUNT])(void);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "cmsis.h"
17+
#include "mbed_toolchain.h"
18+
19+
/* RAM vector_table needs to be aligned with the size of the vector table */
20+
/* TODO: Use MXC_IRQ_COUNT to automatically set this alignment per DUI0553A 4.3.4 */
21+
/* Vector Table Offset which requires the next-power-of-two alignment. This */
22+
/* can be calculated by 4*pow(2,ceil(log2(MXC_IRQ_COUNT))) */
23+
MBED_ALIGN(512)
24+
void (*ramVectorTable[MXC_IRQ_COUNT])(void);

targets/TARGET_Maxim/TARGET_MAX32630/mxc/nvic_table.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,7 @@
4343
#ifndef _NVIC_TABLE_H
4444
#define _NVIC_TABLE_H
4545

46-
/* RAM vector_table needs to be aligned with the size of the vector table */
47-
/* TODO: Use MXC_IRQ_COUNT to automatically set this alignment per DUI0553A 4.3.4 */
48-
/* Vector Table Offset which requires the next-power-of-two alignment. This */
49-
/* can be calculated by 4*pow(2,ceil(log2(MXC_IRQ_COUNT))) */
50-
#if defined ( __ICCARM__ )
51-
#pragma data_alignment = 512
52-
#define __isr_vector __vector_table
53-
#else
54-
__attribute__ ((aligned (512)))
55-
#endif
56-
static void (*ramVectorTable[MXC_IRQ_COUNT])(void);
46+
extern void (*ramVectorTable[MXC_IRQ_COUNT])(void);
5747

5848
#define NVIC_NUM_VECTORS (MXC_IRQ_COUNT)
5949
#define NVIC_RAM_VECTOR_ADDRESS (ramVectorTable) // Vectors positioned at start of RAM

0 commit comments

Comments
 (0)