-
Notifications
You must be signed in to change notification settings - Fork 3k
Update SAML21J18A target to Mbed OS 5.12 #8658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f6d2322
0d6b4db
8891b85
a2c9a43
70712ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* mbed Microcontroller Library | ||
* CMSIS-style functionality to support dynamic vectors | ||
******************************************************************************* | ||
* Copyright (c) 2011 ARM Limited. All rights reserved. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. 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. | ||
* 3. Neither the name of ARM Limited 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 THE COPYRIGHT HOLDER OR 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. | ||
******************************************************************************* | ||
*/ | ||
#include "cmsis_nvic.h" | ||
|
||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash | ||
|
||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) | ||
{ | ||
uint32_t *vectors = (uint32_t*)SCB->VTOR; | ||
uint32_t i; | ||
|
||
// Copy and switch to dynamic vectors if the first time called | ||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) { | ||
uint32_t *old_vectors = vectors; | ||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; | ||
for (i=0; i<NVIC_NUM_VECTORS; i++) { | ||
vectors[i] = old_vectors[i]; | ||
} | ||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; | ||
} | ||
vectors[IRQn + 16] = vector; | ||
} | ||
|
||
uint32_t NVIC_GetVector(IRQn_Type IRQn) | ||
{ | ||
uint32_t *vectors = (uint32_t*)SCB->VTOR; | ||
return vectors[IRQn + 16]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,11 +57,20 @@ extern uint32_t _ezero; | |
extern uint32_t _sstack; | ||
extern uint32_t _estack; | ||
|
||
/** \cond DOXYGEN_SHOULD_SKIP_THIS */ | ||
#ifdef MBED_CONF_RTOS_PRESENT | ||
extern void __libc_init_array(void); | ||
extern int main(void); | ||
#else | ||
/** \cond DOXYGEN_SHOULD_SKIP_THIS */ | ||
int main(void); | ||
/** \endcond */ | ||
|
||
void __libc_init_array(void); | ||
#endif | ||
|
||
/* Reset entry point*/ | ||
void software_init_hook(void); | ||
void pre_main(void) __attribute__((weak)); | ||
|
||
/* Default empty handler */ | ||
void Dummy_Handler(void); | ||
|
@@ -258,14 +267,17 @@ void Reset_Handler(void) | |
pSrc = (uint32_t *) & _sfixed; | ||
SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk); | ||
|
||
/* Initialize the C library */ | ||
__libc_init_array(); | ||
|
||
/* Overwriting the default value of the NVMCTRL.CTRLB.MANW bit (errata reference 13134) */ | ||
NVMCTRL->CTRLB.bit.MANW = 1; | ||
|
||
/* Branch to main function */ | ||
SystemInit(); | ||
|
||
#ifdef MBED_CONF_RTOS_PRESENT | ||
software_init_hook(); | ||
#else | ||
__libc_init_array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't mbed_boot code file already provide these for Mbed OS 5 ? See mbed_boot.c file, See the comments in the file:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @0xc0170 How do I set the reset vector to behave like this then? Because I copied this behavior from some NXP targets (example) and it seems to properly boot in both RTOS and non-RTOS mode. I don't really get how other targets do it because it's all in .S files not in C. Also this code is in the reset handler already, so what's the difference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood, looks fine |
||
main(); | ||
#endif | ||
|
||
/* Infinite loop */ | ||
while (1); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the size need to be reduced for this target? Not enough storage space?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Only 256K flash and half is already taken by the binary, so too little to use bigger FlashIAP file system.