Skip to content

Commit

Permalink
2.0.3
Browse files Browse the repository at this point in the history
2.0.3

Overhaul of 3rd_party startup code, added STM32C031xx target

2.0.3

2.0.3
  • Loading branch information
quantum-leaps committed Feb 13, 2023
1 parent d54613a commit 3a1a810
Show file tree
Hide file tree
Showing 104 changed files with 33,606 additions and 1,445 deletions.
291 changes: 130 additions & 161 deletions 3rd_party/ek-tm4c123gxl/arm/startup_TM4C123GH6PM.s

Large diffs are not rendered by default.

123 changes: 27 additions & 96 deletions 3rd_party/ek-tm4c123gxl/gnu/startup_TM4C123GH6PM.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* File: startup_TM4C123GH6PM.c
/* File: startup_TM4C123GH6PM.c for GNU-ARM
* Purpose: startup file for TM4C123GH6PM Cortex-M4 device.
* Should be used with GCC 'GNU Tools ARM Embedded'
* Version: CMSIS 5.0.1
* Date: 2017-09-13
*
* Modified by Quantum Leaps:
* Added assert_failed() and DBC_fault_handler()
* Added relocating of the Vector Table to free up the 256B region at 0x0
* for NULL-pointer protection by the MPU.
* - Added relocating of the Vector Table to free up the 256B region at 0x0
* for NULL-pointer protection by the MPU.
* - Modified all exception handlers to branch to assert_failed()
* instead of locking up the CPU inside an endless loop.
*
* Created from the CMSIS template for the specified device
* Quantum Leaps, www.state-machine.com
Expand All @@ -19,32 +20,6 @@
* assembly to re-set the stack pointer, in case it is corrupted by the
* time assert_failed is called.
*/
/* Copyright (c) 2011 - 2014 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/

/* start and end of stack defined in the linker script ---------------------*/
/*extern int __stack_start__;*/
Expand All @@ -66,8 +41,6 @@ void assert_failed(char const *module, int loc);
void Default_Handler(void); /* Default empty handler */
void Reset_Handler(void); /* Reset Handler */
void SystemInit(void); /* CMSIS system initialization */
__attribute__ ((noreturn))
void DBC_fault_handler(char const *module, int loc);

/*----------------------------------------------------------------------------
* weak aliases for each Exception handler to the Default_Handler.
Expand Down Expand Up @@ -428,91 +401,49 @@ void Reset_Handler(void) {
}

/* the previous code should not return, but assert just in case... */
assert_failed("Reset_Handler", __LINE__);
assert_failed("Reset_Handler", 1U);
}


/* fault exception handlers ------------------------------------------------*/
__attribute__((naked)) void NMI_Handler(void);
void NMI_Handler(void) {
__asm volatile (
" ldr r0,=str_nmi \n"
" mov r1,#1 \n"
" b assert_failed \n"
"str_nmi: .asciz \"NMI\" \n"
" .align 2 \n"
);
}
/*..........................................................................*/
__attribute__((naked)) void MemManage_Handler(void);
void MemManage_Handler(void) {
__asm volatile (
" ldr r0,=str_mem \n"
" mov r1,#1 \n"
" b assert_failed \n"
"str_mem: .asciz \"MemManage\"\n"
" .align 2 \n"
);
/* reset the SP to the initial value in case of stack overflow */
__asm volatile (" MOV sp,%0" : : "r" (&__stack_end__));
assert_failed("NMI_Handler", 1U);
}
/*..........................................................................*/
__attribute__((naked)) void HardFault_Handler(void);
void HardFault_Handler(void) {
__asm volatile (
" ldr r0,=str_hrd \n"
" mov r1,#1 \n"
" b assert_failed \n"
"str_hrd: .asciz \"HardFault\"\n"
" .align 2 \n"
);
/* reset the SP to the initial value in case of stack overflow */
__asm volatile (" MOV sp,%0" : : "r" (&__stack_end__));
assert_failed("HardFault_Handler", 1U);
}
/*..........................................................................*/
__attribute__((naked)) void MemManage_Handler(void);
void MemManage_Handler(void) {
/* reset the SP to the initial value in case of stack overflow */
__asm volatile (" MOV sp,%0" : : "r" (&__stack_end__));
assert_failed("MemManage_Handler", 1U);
}
/*..........................................................................*/
__attribute__((naked)) void BusFault_Handler(void);
void BusFault_Handler(void) {
__asm volatile (
" ldr r0,=str_bus \n"
" mov r1,#1 \n"
" b assert_failed \n"
"str_bus: .asciz \"BusFault\"\n"
" .align 2 \n"
);
/* reset the SP to the initial value in case of stack overflow */
__asm volatile (" MOV sp,%0" : : "r" (&__stack_end__));
assert_failed("MemManage_Handler", 1U);
}
/*..........................................................................*/
__attribute__((naked)) void UsageFault_Handler(void);
void UsageFault_Handler(void) {
__asm volatile (
" ldr r0,=str_usage \n"
" mov r1,#1 \n"
" b assert_failed \n"
"str_usage: .asciz \"UsageFault\"\n"
" .align 2 \n"
);
/* reset the SP to the initial value in case of stack overflow */
__asm volatile (" MOV sp,%0" : : "r" (&__stack_end__));
assert_failed("BusFault_Handler", 1U);
}
/*..........................................................................*/
__attribute__((naked)) void Default_Handler(void);
void Default_Handler(void) {
__asm volatile (
" ldr r0,=str_dflt \n"
" mov r1,#1 \n"
" b assert_failed \n"
"str_dflt: .asciz \"Default\"\n"
" .align 2 \n"
);
}

/*--------------------------------------------------------------------------*/
/* The function assert_failed() provides a low-level handler for assertion
* failures. It ultimately transfers control to DBC_fault_handler(), which
* defines the error/assertion handling policy for the application.
*
* assert_failed() re-sets the stack pointer (MSP) to the original setting.
* This is necessary to avoid cascading exceptions in case the stack was
* OVERFLOWN.
*/
__attribute__ ((naked, noreturn))
void assert_failed(char const *module, int loc) {
/* re-set the SP in case of stack overflow */
/* reset the SP to the initial value in case of stack overflow */
__asm volatile (" MOV sp,%0" : : "r" (&__stack_end__));
DBC_fault_handler(module, loc); /* application-specific DBC handler */
for (;;) { /* should not be reached, but just in case loop forever... */
}
assert_failed("Default_Handler", 1U);
}
Loading

0 comments on commit 3a1a810

Please sign in to comment.