MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mccibootloaderplatform_startapp.c
Go to the documentation of this file.
1
/*
2
3
Module: mccibootloaderplatform_startapp.c
4
5
Function:
6
McciBootloaderPlatform_startApp()
7
8
Copyright and License:
9
This file copyright (C) 2021 by
10
11
MCCI Corporation
12
3520 Krums Corners Road
13
Ithaca, NY 14850
14
15
See accompanying LICENSE file for copyright and license information.
16
17
Author:
18
Terry Moore, MCCI Corporation March 2021
19
20
*/
21
22
#include "
mcci_bootloader_platform.h
"
23
24
#include "
mcci_bootloader_bits.h
"
25
#include "
mcci_arm_cm0plus.h
"
26
#include <stdint.h>
27
␌
28
/****************************************************************************\
29
|
30
| Manifest constants & typedefs.
31
|
32
\****************************************************************************/
33
34
35
/****************************************************************************\
36
|
37
| Read-only data.
38
|
39
\****************************************************************************/
40
41
42
43
/****************************************************************************\
44
|
45
| Variables.
46
|
47
\****************************************************************************/
48
49
␌
50
/*
51
52
Name: McciBootloaderPlatform_startApp()
53
54
Function:
55
Launch application from bootloader.
56
57
Definition:
58
void McciBootloaderPlatform_startApp(
59
const void *pAppBase
60
);
61
62
Description:
63
pAppBase points to the base of the application image in memory, which
64
is assumed to conform to any platform-specific requirements. The
65
application is launched. If the launch fails,
66
McciBootloaderPlatform_fail() is invoked. This function does not
67
return to the caller.
68
69
Returns:
70
No explicit result.
71
72
Notes:
73
On a Cortex M0+ or similar processor, pAppBase points to the vectors
74
of the app being invoked. The first dword is the stack pointer, and
75
the second dword is the start address.
76
77
In a full implementation, the bootloader should shutdown all
78
peripherals it has setup, and establish a default condition for
79
launching the app. In principal, the app should be entered as if
80
it had received control from a reset. This is to some degree a
81
matter of taste and design rather than a logical requirement.
82
83
*/
84
85
#define FUNCTION "McciBootloaderPlatform_startApp"
86
87
void
88
McciBootloaderPlatform_startApp
(
89
const
void
*pAppBase
90
)
91
{
92
const
Mcci_CortexAppEntryContents_t
*
const
pAppVectors = pAppBase;
93
const
uint32_t stack = pAppVectors->
stack
;
94
const
uint32_t pc = pAppVectors->
entry
;
95
96
// Oddly, interrupts are enabled on launch, so we have to
97
// deal with that below.
98
McciArm_disableInterrupts();
99
100
// Do the SOC-specific things to get us ready;
101
McciBootloaderPlatform_prepareForLaunch
();
102
103
// set the stack pointer
104
McciArm_setMSP(stack);
105
106
// set the vector address
107
McciArm_putReg
(
108
MCCI_CM0PLUS_SCB_VTOR
,
109
(uint32_t) pAppVectors &
MCCI_CM0PLUS_SCB_VTOR_TBLOFF
110
);
111
112
// go to the app: enable interrupts and jump.
113
__asm
volatile
(
"cpsie i"
:::
"memory"
);
114
__asm
volatile
(
"bx %0"
::
"r"
(pc));
115
__builtin_unreachable();
116
}
117
118
#undef FUNCTION
119
120
121
/**** end of mccibootloaderplatform_startapp.c ****/
mcci_arm_cm0plus.h
MCCI_CM0PLUS_SCB_VTOR
#define MCCI_CM0PLUS_SCB_VTOR
Definition
mcci_arm_cm0plus.h:104
McciArm_putReg
static uint32_t McciArm_putReg(uint32_t reg, uint32_t val)
write a 32-bit value to a cm0plus register
Definition
mcci_arm_cm0plus.h:256
MCCI_CM0PLUS_SCB_VTOR_TBLOFF
#define MCCI_CM0PLUS_SCB_VTOR_TBLOFF
Definition
mcci_arm_cm0plus.h:188
mcci_bootloader_bits.h
mcci_bootloader_platform.h
McciBootloaderPlatform_prepareForLaunch
static void McciBootloaderPlatform_prepareForLaunch(void)
Definition
mcci_bootloader_platform.h:80
McciBootloaderPlatform_startApp
void McciBootloaderPlatform_startApp(const void *pAppBase)
Definition
mccibootloaderplatform_startapp.c:88
Mcci_CortexAppEntryContents_t
application entry contents
Definition
mcci_arm_cm0plus.h:476
Mcci_CortexAppEntryContents_t::entry
uint32_t entry
Definition
mcci_arm_cm0plus.h:478
Mcci_CortexAppEntryContents_t::stack
uint32_t stack
Definition
mcci_arm_cm0plus.h:477
platform
arch
cm0plus
src
mccibootloaderplatform_startapp.c
Generated on Thu Feb 19 2026 18:47:32 for MCCI Trusted Bootloader by
1.9.8