flash/nor: add support for TI MSP432 devices
[openocd.git] / contrib / loaders / flash / msp432 / startup_msp432e4.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 ******************************************************************************/
34
35 #include <stdint.h>
36
37 /* Entry point for the application. */
38 extern int main();
39
40 /* Reserve space for the system stack. */
41 extern uint32_t __stack_top;
42
43 typedef void(*pFunc)(void);
44
45 /* Interrupt handler prototypes */
46 void default_handler(void);
47 void reset_handler(void);
48
49 /*
50 * The vector table. Note that the proper constructs must be placed on this to
51 * ensure that it ends up at physical address 0x0000.0000 or at the start of
52 * the program if located at a start address other than 0.
53 */
54 void (* const intr_vectors[])(void) __attribute__((section(".intvecs"))) = {
55 (pFunc)&__stack_top, /* The initial stack pointer */
56 reset_handler, /* The reset handler */
57 default_handler, /* The NMI handler */
58 default_handler, /* The hard fault handler */
59 default_handler, /* The MPU fault handler */
60 default_handler, /* The bus fault handler */
61 default_handler, /* The usage fault handler */
62 0, /* Reserved */
63 0, /* Reserved */
64 0, /* Reserved */
65 0, /* Reserved */
66 default_handler, /* SVCall handler */
67 default_handler, /* Debug monitor handler */
68 0, /* Reserved */
69 default_handler, /* The PendSV handler */
70 default_handler /* The SysTick handler */
71 };
72
73 /*
74 * The following are constructs created by the linker, indicating where the
75 * the "data" and "bss" segments reside in memory. The initializers for the
76 * for the "data" segment resides immediately following the "text" segment.
77 */
78 extern uint32_t __bss_start__;
79 extern uint32_t __bss_end__;
80
81 /*
82 * This is the code that gets called when the processor first starts execution
83 * following a reset event. Only the absolutely necessary set is performed,
84 * after which the application supplied entry() routine is called. Any fancy
85 * actions (such as making decisions based on the reset cause register, and
86 * resetting the bits in that register) are left solely in the hands of the
87 * application.
88 */
89 __attribute__((section(".reset"))) __attribute__((naked))
90 void reset_handler(void)
91 {
92 /* Set stack pointer */
93 __asm(" MOVW.W r0, #0x1700\n"
94 " MOVT.W r0, #0x2000\n"
95 " mov sp, r0\n");
96
97 /* Zero fill the bss segment. */
98 __asm(" ldr r0, =__bss_start__\n"
99 " ldr r1, =__bss_end__\n"
100 " mov r2, #0\n"
101 " .thumb_func\n"
102 "zero_loop:\n"
103 " cmp r0, r1\n"
104 " it lt\n"
105 " strlt r2, [r0], #4\n"
106 " blt zero_loop");
107
108 /* Call the application's entry point. */
109 main();
110 }
111
112 /*
113 * This is the code that gets called when the processor receives an unexpected
114 * interrupt. This simply enters an infinite loop, preserving the system state
115 * for examination by a debugger.
116 */
117 void default_handler(void)
118 {
119 /* Enter an infinite loop. */
120 while (1)
121 ;
122 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)