38 Commits

Author SHA1 Message Date
Karl Palsson
c6743f9ecd vector: make common linker definitions available to users
_data_loadaddr, _data, _edata, _ebss, _stack and vector_table all now
available in vector.h.

Suggested on IRC
2017-10-18 20:05:14 +00:00
Anatol Pomozov
ae41782e1a Fix misspellings using codespell tool 2016-03-08 08:52:54 -08:00
Ondřej Hruška
fb410a403d cm3/sync: Fix broken mutex_trylock()
Fails when the mutex was already locked.

Implemented zyp's fix for broken mutex. If it's 1 (= failure) by default, the function works fine.

irc log for reference
```
<zyp> strex returns 1 if it fails, 0 if it's successful
<zyp> but if the mutex is already locked, line 57 skips the status update and status gets remains at the initial value which means successful, which is wrong
<zyp> changing line 54 to status = 1 should do the trick
```
2016-01-06 14:36:30 +00:00
Jim Paris
01f08c4638 Remove WEAK from handler prototypes
These prototypes affect functions defined by application code.  Only
the implementations in libopencm3 are supposed to be weak; the
functions in application code should definitely not be.  Otherwise,
you'll end up with two weak symbols being linked together, and
it's luck as to which one the linker picks.
2015-11-24 09:55:27 +00:00
Forrest Voight
4a21730bb6 startup: Explicitly enable STKALIGN for all parts.
SCB.CCR.STKALIGN enables the automatic aligning of the stack pointer to 8 bytes
on interrupt entry.  Per ARM recommendations, and for AAPCS compliance, this
bit should be enabled at all times.  ARMv6M has this hardcoded to 1. Cortex M3
has this broken in rev 0, optional (default off) in rev 1, and optional
(default on) in rev 2 and later. M4(f) has optional (default on) for all
revisions, M7 has hardcoded to 1.

See Section 2.3.3 in ARM document IHI0046B:
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0046b/IHI0046B_ABI_Advisory_1.pdf

To ensure that all parts behave correctly, we make sure that we hardcode the
feature on, for all parts.  While not _required_ for anything other than rev1
cm3, inserting it into the common reset handler ensures no-one gets any
surprises.

Fixes Github issue #516
2015-08-14 01:14:01 +00:00
Oliver Meier
f52a39cc48 [cm3/sync] mutex_lock now calls mutex_trylock repeatedly 2014-12-11 09:59:22 +00:00
Oliver Meier
a2fe6c49a8 [cm3/sync] Add mutex_trylock()
Allows non-blocking use in user code.
2014-12-11 09:58:34 +00:00
Stefan Agner
0d5dac515a init: call pre_main before C++ constructors
This moves the platform specific initialization function pre_main
in front of C++ constructors. This is especially necessary for
platforms which need to setup the stack pointer (pre_main itself
is inline, hence no stack needed for this function).
2014-10-07 11:31:36 +00:00
Karl Palsson
34ed0a740b sync: use matching #ifdefs in source as in header
Fixes github issue #298
2014-04-04 20:19:37 +00:00
Karl Palsson
5b6e97732b cm0 doesn't support sync operations
So remove the warning, the sync code is already left out of the cm0
builds.

Fixes #291
2014-03-12 09:40:03 +00:00
Frantisek Burian
5ba8b10428 Add method to clear the systick value, that is undefined at startup. 2014-01-15 22:37:45 +01:00
Piotr Esden-Tempski
a909b5ca9e [Style] Global style fix run. 2014-01-03 01:07:30 +01:00
Frantisek Burian
d541c14110 [CM3] Systick Add helper function to easily set the desired frequency 2014-01-02 22:09:16 +01:00
Frantisek Burian
7ccc0d053e [CM3] Add register definitions for Debug Watch Trace point.
Add provision functions for the use of CPU counter as a high-resolution timer for code benchmarking purposes
2014-01-02 21:25:26 +01:00
BuFran
8c8592e2b6 [CM3] Fix the set clksource, found and described by ksarkies. 2013-10-06 19:04:41 +00:00
BuFran
efc2489d2c [Stylecheck] Code cleaned to current stylecheck script 2013-08-22 17:18:41 -07:00
BuFran
e1ebcc9da8 [Cortex] Add preliminary support for core-dependent defines ARMv6m / ARMv7m, ARMv7em 2013-08-22 17:18:35 -07:00
Piotr Esden-Tempski
b72a3640b3 [CM0] Disabled sync for LPC43xx/M0.
We are currently using the same code for CM0 CM3 and CM4 cores. This
patch is a bodge that disables sync on the LPC43xx/M0 core, it would be
nicer to probably implement a dispatch system similar to the one used in
stm32 peripheral support so that we can accomodate the different
features of the cortex cores. I (esden) assume we will run into more
incompatibilities in the future between the cortex cores.
2013-07-07 13:58:00 -07:00
Ben Gamari
11ea9b090c sync: Add comment 2013-07-07 13:52:16 -07:00
Piotr Esden-Tempski
34de1e776e Changed to use stdint types. 2013-06-12 19:11:22 -07:00
Piotr Esden-Tempski
7df63fcae0 First coarse run to fix coding style in locm3.
Added --terse and --mailback options to the make stylecheck target. It
also does continue even if it enounters a possible error.

We decided on two exceptions from the linux kernel coding standard:
- Empty wait while loops may end with ; on the same line.
- All blocks after while, if, for have to be in brackets even if they
  only contain one statement. Otherwise it is easy to introduce an
  error.

Checkpatch needs to be adapted to reflect those changes.
2013-06-12 18:22:56 -07:00
Fergus Noble
4d15da995e Adding basic support for v7m sync primatives and mutex convenience functions. 2013-05-10 14:30:17 -07:00
Nicolas Schodet
b2df978eae Add support for static constructors and destructors 2013-04-24 22:49:25 +02:00
Piotr Esden-Tempski
8545d9d565 Using while(1) instead of exit.
The exit function can significantly increase code size, and adds
dependency on stdlibc.
2013-04-21 19:13:35 -07:00
Andrey Smirnov
6cb7d8abf3 Add a "noreturn" attribute to 'scb_reset_system'
Adding this attribute allows to avoid warnings issued by GCC in cases
when 'scb_reset_system' is used as a last call in a function with
"noreturn" attribute set(usually reset handler of some sorts)
2013-04-16 16:57:58 -07:00
Piotr Esden-Tempski
3d3ddc7014 Fixed all warnings for examples. 2013-02-26 19:33:42 -08:00
Felix Ruess
3ef44bff54 [cm3] fix doxygen for systick_get_value, add systick_get_reload
Fix the reload value in the examples:
to get a SysTick interrupt every N clock pulses: set reload to N-1
see http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/BGBEEJHC.html#BABGACGG
2013-02-19 19:22:49 +01:00
Karl Palsson
22d8891fee Remove assembly forcing stack.
Fixes #51

There should be no reason for manually trying to load the stack.  Cortex
devices can be programmed with only C, and any code that needed this
would indicate broken vectors.
2013-01-16 20:41:26 +00:00
Norbert Braun
569ebfdffb Add __attribute__ ((naked)) to reset_handler() 2012-11-28 15:28:42 +01:00
chrysn
bc5146b710 unified systick handling
the only change this results in in the example binaries is in the
hackrf-jellybean/systick example, where the the check in
systick_set_clocksource for overflowing from the stm32 area gets used.
2012-10-18 22:48:14 +02:00
chrysn
e20f1c0d8f unify scb (system control block)
these register definitions are common to all cortex mcus. some of the
registers might not be implemented everywhere (especially the floating
point registers), but defining them does no harm.

this modification does not result in any changes in the example
binaries.
2012-10-18 21:45:20 +02:00
chrysn
0548317683 fix bug resulting from equally named files
the local vector.o files shadowed the ../cm3/vector.c from VPATH,
resulting in empty reset vectors.
2012-10-18 18:54:52 +02:00
chrysn
c69916ffb6 integrate irq2nvic_h script in buildprocess 2012-10-18 17:58:12 +02:00
chrysn
ae832b4ee8 split irq.yaml output in nvic.h and vector_nvic.h
the weak pragmas need to be used in the very compilation unit where
their target is defined, requiring another dispatch
2012-10-18 17:33:20 +02:00
chrysn
5afa53f01a drop two-line vector.c dispatchers in favor of central dispatch 2012-10-18 16:29:58 +02:00
chrysn
9c13299f25 unified nvic.c 2012-10-18 13:22:12 +02:00
chrysn
a69d83d312 unified vector table initialization
the cortex generic interrupts get moved to lib/cm3/vector.c, the
platorms' individual irq names, initialization and handler prototypes go
to platoform specific irq.h files.

as the vector.c file heavily depends on platoform specific headers, it
can't be built once-and-for-all in lib/cm3/, so there are inclusion
stubs in the various architecture dirs; this might be better solved with
Makefile / include path handling.

one particular file is lib/lpc43xx/vector.c; that platform's
initialization code contains an additional section to copy everything
from flash to ram (which probably performs better there). that code
still resides in the inclusion stub, and gets mashed in using defines.
would need a cleaner implementation together with the Makefile solution.

this commit contains some files of the upcoming efm32 branch, from which
it was cherry-picked.

the .bin files produced from before and after this commit only differ in
lpc43xx, where the startup sequence was subtly modified.
2012-10-05 00:55:24 +02:00
Tomaz Solc
fc4047e4b4 Add assert macros to aid in debugging.
Adds libopencm3/cm3/assert.h header that provides assertion check macros
similar to those provided by the standard C library.

Thanks to Nicolas Schodet for help.
2012-10-02 08:48:45 +02:00