1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

339 Commits

Author SHA1 Message Date
Jean Pierre Dudey
ffff68deaf
Merge pull request #16813 from jeandudey/doc1
cpu: fix doxygen grouping warnings
2021-09-13 11:30:27 +02:00
Jean-Pierre De Jesus DIAZ
51bab0a5a9 cpu/cortexm_common: fix doxygen grouping warnings
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2021-09-11 12:45:15 +02:00
MrKevinWeiss
636c6c4cdb
cpu/cortexm: Use DEVELHELP to add stack guard 2021-09-08 12:40:30 +02:00
Hauke Petersen
65b7f84568 cpu/cortexm_common: implement irq_is_enabled() 2021-08-25 08:01:05 +02:00
8f10f22b1f cpu/cortexm: ldscripts: bkup-ram -> bkup_ram
Fixes this error with binutils 2.37:

```
/usr/lib/gcc/arm-none-eabi/11.2.0/../../../../arm-none-eabi/bin/ld:cortexm_base.ld:217: warning: memory region `bkup' not declared
/usr/lib/gcc/arm-none-eabi/11.2.0/../../../../arm-none-eabi/bin/ld:cortexm_base.ld:217: syntax error
```
2021-08-18 10:29:38 +02:00
Jan Romann
4384795cb9
treewide: Remove excessive newlines 2021-08-13 19:50:38 +02:00
Benjamin Valentin
6d42c9fcfe cpu: make newlib_nano a DEFAULT_MODULE
This allows to disable nanospecs with

    DISABLE_MODULE += newlib_nano

if a full-features version of newlib is desired.
2021-05-04 12:12:36 +02:00
Sebastiaan de Schaetzen
e3c9b0c4ca cortexm: initialise fpu early 2021-04-29 13:19:47 +02:00
Hauke Petersen
899fe63fe2 cpu/cortexm_common/kconfig: add dbgpin feature 2021-02-26 11:34:52 +01:00
Hauke Petersen
47a031e483 cpu/cortexm_common: add dbgpin initialization 2021-02-26 11:34:52 +01:00
4dc8895093
cpu/cortexm_common: always add jlink as supported programmer 2021-02-24 13:27:04 +01:00
858b5ca6ed xfa: remove obsolete empty xfa.ld 2021-02-18 10:46:08 +01:00
d8d34e033c cpu/cortexm_common: add XFA handling to linkerscript
The global core/ldscripts/xfa.ld doesn't match our cortexm_base.ld.
This commit directly adds the two XFA lines to cortexm_base.ld.
In addition to that, a dummy (empty) xfa.ld is added, which the linker will pick
instead of core/ldscripts/xfa.ld, effectingly not using it.
2021-02-18 10:46:08 +01:00
Francisco Molina
63a2a6ce1b
treewide: model newlib as a FEATURE 2021-01-27 09:24:25 +01:00
benpicco
4c403d6559
Merge pull request #15788 from bergzand/pr/core/inline_thread_yield_higher
core/thread: Allow for inline thread_yield_higher
2021-01-22 20:25:11 +01:00
Marian Buschsieweke
716441d0c3
cpu/cortexm_common: fix atomic_utils_arch.h
Only use bit-banding if all of SRAM supports bit-banding
2021-01-20 09:19:33 +01:00
0129e73ec0
cpu/cortexm_common: Inline thread_yield_higher function 2021-01-19 11:03:21 +01:00
6d3d067443
cpu/cortexm_common: Do not use SVC for cpu_switch_context_exit
Directly use the pendsv interrupt instead of chaining through the SVC
interrupt
2021-01-18 16:27:17 +01:00
dylad
9d02efb4ea cpu/cortexm_common: increase RIOTBOOT_LEN size when usbus_dfu is used 2021-01-12 11:34:22 +01:00
Marian Buschsieweke
277ddcb108
cpu/cortexm_common: fix select in Kconfig
Only select MODULE_MALLOC_THREAD_SAFE if TEST_KCONFIG is true.
2020-12-18 12:50:33 +01:00
Marian Buschsieweke
c8d16d21f7
Merge pull request #15606 from maribu/malloc-newlib-picolibc
sys/malloc_thread_safe: new module
2020-12-17 19:55:32 +01:00
Marian Buschsieweke
09b41d2e1e
cpu/cortexm_common: use malloc_thread_safe module 2020-12-17 15:39:05 +01:00
8f1a42cbbf
cpu/cortexm_common: fix r12 clobber in pendsv for Cortex-M0 2020-12-15 13:16:02 +01:00
benpicco
c5b5788eb7
Merge pull request #15570 from benpicco/sys/bit.h
sys/bit: move bit.h header to sys/
2020-12-11 08:36:36 +01:00
Benjamin Valentin
e300dfe47e sys/bit: move bit.h from cortexm_common/ to sys/
The bit access functions are not tied to Cortex-M CPUs, here they only
provide optimisations via bit-banding.

But the functions are generally useful - so move them to an arch independent
location.
2020-12-08 17:07:41 +01:00
04ca147f59 cpu/cortexm_common: fix r12 clobber in pendsv for Cortex-M3+ 2020-12-08 13:29:54 +01:00
977f0dfd70 cpu/cortexm_common: split isr_pendsv() 2020-12-08 10:14:45 +01:00
Marian Buschsieweke
dd48ced151
cpu/*/atomic_utils_arch.h: Add volatile qualifier 2020-11-24 14:00:52 +01:00
benpicco
1f7fdbc97a
Merge pull request #15099 from maribu/cortexm-common-cast-align
cpu/cortexm_common: Silence -Wcast-align false positives
2020-11-18 00:38:03 +01:00
792e031a95
Merge pull request #14331 from maribu/atomic_utils
sys/atomic_utils: Functions for atomic access
2020-11-12 21:44:53 +01:00
Marian Buschsieweke
a3e2d27799
cpu/cortexm_common: Add atomic_utils_arch.h 2020-11-10 10:55:13 +01:00
Bas Stottelaar
22243aec7a cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
Benjamin Valentin
c48b331051 cpu/cortexm_common: flush pipeline before disabling interrupts in idle
When enabling & disabling interrupts back-to-back pending interrupts
are not serviced on Cortex-M23/M33.

Flush the pipeline to give interrupts a chance of executing in `sched_arch_idle()`.

This fixes `no_idle_thread` on Cortex-M23.
2020-10-16 15:36:28 +02:00
160d9a53b9
cpu/cortexm_common: also check for picolibc in USEMODULE 2020-10-15 18:52:51 +02:00
8df645cfe9
Merge pull request #15011 from benpicco/picolobc_feature
picolibc: model as a feature
2020-10-14 17:02:04 +02:00
Leandro Lanzieri
4d7ea1b50a
makefiles/kconfig: always allow to use KCONFIG_ADD_CONFIG 2020-10-13 09:53:00 +02:00
benpicco
c979fda1f3
Merge pull request #14367 from basilfx/feature/cortex_m33
cpu/cortex: add initial support for Cortex-M33
2020-10-08 22:55:06 +02:00
Bas Stottelaar
0f8cecb50b cpu/cortexm_common: add support for Cortex-M33 2020-10-06 17:11:26 +02:00
2609dc1aa7
cpu/cortexm_common: fix typo 'occured' -> 'occurred' 2020-10-02 07:56:27 +02:00
e5ca237318
cpu/cortexm_common: fix typo 'pre-empt' -> 'preempt'
Also fix typo 'efficency' -> 'efficiency'
2020-10-02 07:53:54 +02:00
Marian Buschsieweke
30bebdb3ff
cpu/cortexm_common: Add architecture_arch.h 2020-09-29 12:34:00 +02:00
Marian Buschsieweke
0e097b54a4
cpu/cortexm_common: Silence -Wcast-align false positives
Verified that each warning generated by -Wcast-align is indeed a false positive
and used an (intermediate) cast to `uintptr_t` to silence the warnings.
2020-09-28 10:45:50 +02:00
Marian Buschsieweke
49f3d1056d
cpu/cortexm_common: Code style
Fix code alignment
2020-09-25 13:58:25 +02:00
Marian Buschsieweke
304f4ec7d4
cpu/cortexm_common: flush pipeline after PendSV
https://interrupt.memfault.com/blog/arm-cortex-m-exceptions-and-nvic#pendsv-example
2020-09-25 13:58:06 +02:00
eb73515e2c
cortexm_common: Enable no_thread_idle for all architectures 2020-09-23 11:02:01 +02:00
ba58273b04
cortexm_common: Enable using pendsv IRQ at lower priority
This modifies the cortex-m thread specifics to allow running the PendSV
interrupt continuously at lower priority and removes the priority
modifications during the interrupt itself. Interrupts are disabled
during the scheduling itself, but enabled briefly after the sleep to
ensure that they are handled if activated during the scheduling or the
sleep.
2020-09-23 11:01:29 +02:00
Benjamin Valentin
cff8e862b8 picolibc: model as a feature 2020-09-15 22:11:21 +02:00
Marian Buschsieweke
f5398cf57b
Merge pull request #14940 from benpicco/cpu/cortexm_common-puf_sram
cpu/cortexm_common: advertise puf_sram feature
2020-09-15 10:58:41 +02:00
Benjamin Valentin
d9116684e5 cpu/cortexm_common: advertise puf_sram feature
`puf_sram` is a feature of the linker script, it does not need vendor
specific hardware support.
2020-09-11 16:30:45 +02:00
5db55360cc
cortexm_common: Determine next thread before unscheduling 2020-09-10 20:42:55 +02:00
22252337b6
cortexm_common: simplify FPU guards
The FPU is only enabled on platforms where it is available. The extra
checks for these platforms are redundant and removed here
2020-09-03 21:00:40 +02:00
Leandro Lanzieri
2e79e00ca7
treewide: change Kconfig prefix for module symbols
This changes the prefix used for the symbols that reprensent modules
(not the ones generated from USEMODULE).

MOD_ => MODULE_
2020-08-31 09:57:28 +02:00
Francisco
f963089b28
Merge pull request #14718 from bergzand/pr/cortexm_common/hard_fault_add_thread_info
cortexm_common: Add thread info to hard fault handler
2020-08-26 12:40:25 +02:00
0d484f4d3a
cortexm_common: Add thread info to hard fault handler
While the hard fault handler prints the offending program counter, it
does not print information about the context triggering the hard fault.
This commit adds a line printing the thread ID and name that triggered
the hard fault. If the hard fault is triggered during an ISR, it only
prints that the hard fault happened during ISR context, not which ISR
triggered it.
2020-08-26 11:42:07 +02:00
Keith Packard
e215261ced picolibc: Use most NEWLIB code with picolibc
In most places, picolibc and newlib are the same, so use
the existing newlib code when compiling with picolibc.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-08-24 08:26:16 -07:00
Keith Packard
531050ada2 picolibc: Enable TLS support [v4]
Allocate and initialize a thread-local block for each thread at the
top of the stack.

Set the tls base when switching to a new thread.

Add tdata/tbss linker instructions to cortex_m and risc-v scripts.

Signed-off-by: Keith Packard <keithp@keithp.com>

---

v2:
	Squash fixes

v3:
	Replace tabs with spaces

v4:
	Add tbss to fe310 linker script
2020-08-24 08:26:16 -07:00
ff3bee24b9 picolibc: Provide integration into the build system [v3]
Support for picolibc as alternative libc implementation is added with
this commit. For now only cortex-m CPU's are supported.

Enable via PICOLIBC=1

---
v2:
	squash fixes in

v3:
	Remove picolibc integer printf/scanf stuff from sys/Makefile.include,
	it gets set in makefiles/libc/picolibc.mk

fixup for dependency
2020-08-23 13:12:57 -07:00
e2d8d40792
cortexm_common: Enable MPU after configuring regions
Reordering this ensures that the MPU regions are configured before
enabling the MPU and restricting the memory access.
2020-08-21 13:38:59 +02:00
2f30aaaf06 cpu/cortexm_common: use mpu stack guard if DEVELHELP is enabled 2020-08-18 10:26:21 +02:00
Marian Buschsieweke
aeedb3ad16
cpu/cortexm_common: Don't access sched_active_*
Replaced accesses to sched_active_* with API calls in C files
2020-08-17 11:27:52 +02:00
Leandro Lanzieri
7dc6639f59
cpu/cortexm_common: add default Kconfig configuration 2020-08-12 12:22:43 +02:00
Leandro Lanzieri
b98527ef53
cpu: Add 'periph' module to Kconfig
Select it from cortexm_common module as it is always needed.
2020-08-12 12:22:39 +02:00
Leandro Lanzieri
2d53003ee2
cpu/cortexm_common: Model cortexm_common modules
This models cortexm_common and cortexm_common_periph modules.
2020-08-12 12:22:39 +02:00
Marian Buschsieweke
234a720571
Merge pull request #14516 from benpicco/bitband_hw
cortexm_common: fix check for bitbanding feature
2020-08-08 14:26:49 +02:00
Martine Lenders
b1bf8ab981
Merge pull request #14565 from bergzand/pr/sched/fix_retrigger
sched: Prevent retriggering the scheduler interrupt during idle sleep
2020-07-28 22:11:25 +02:00
d59233baf1
Merge pull request #14556 from benpicco/bitarithm_test_and_clear
core/bitarithm: add bitarithm_test_and_clear()
2020-07-28 10:11:47 +02:00
benpicco
f3bce19646
Merge pull request #14503 from maribu/cpp-feature
build system: Add libstdcpp feature and doc
2020-07-23 19:05:10 +02:00
Benjamin Valentin
a8904edd7d core/bitarithm: add bitarithm_test_and_clear() 2020-07-21 16:03:59 +02:00
fc1d642113
cpu/cortexm_init: add specific case for stm32g0 svcall irq 2020-07-21 12:45:25 +02:00
0b549c6e0c
Merge pull request #14152 from aabadie/pr/pkg/stm32cube
pkg/stm32cmsis: retrieve STM32 CMSIS header from a package
2020-07-21 12:27:19 +02:00
0eb66a429f
cortexm_common: Clear PendSV request after idle sleep
The PendSV interrupt is used to request a scheduling operation. An
interrupt during the idle sleep can re-request the PendSV interrupt,
while the PendSV is still busy scheduling the next thread. This clears
the request after sleep to prevent triggering an extra PendSV interrupt
after the current PendSV handler finished.
2020-07-21 11:23:49 +02:00
Leandro Lanzieri
c71c2b79a7
cpu/arm7_common: Add Kconfig symbols
HAS_ARCH_ARM features now is moved to Kconfig.features as it is being
used by multiple architectures.
2020-07-16 19:03:38 +02:00
1f0a3a6bae
cpu/cortexm_common: add special case for SVC interrupt configuration
by default stm32f0/l0/l1 families simply call the interrupt enum SVC_IRQn
2020-07-16 17:35:48 +02:00
Benjamin Valentin
95ec5890b0 cortexm_common: fix bit-banding check
Not all MCUs ≥ Cortex-M3 provide the Bit-Banding feature.
It is up to the manufacturer to implement it.

Instead, rely on the CPU_HAS_BITBAND being set in `periph_cpu.h`.
2020-07-16 14:44:28 +02:00
eec7aa2e42
cortexm_common: disable IRQ during thread_sched_idle
A race condition is present where an IRQ is serviced between the
priority increase of the PENDSV and the sleep. When the IRQ
is serviced before the WFI sleep, the core will sleep until the next
IRQ and the thread activated by the IRQ will not be scheduled until
a new IRQ triggers.

This commit wraps an IRQ disable and restore around the priority
modification and sleep to prevent interrupts from being serviced until
the WFI call returns.
2020-07-16 11:11:15 +02:00
Marian Buschsieweke
cf482c5d46
build system: Add libstdcpp feature and doc
- Add libstdcpp feature to indicate a platform is providing a libstdc++
  implementation ready for use
- The existing cpp feature now only indicates a working C++ toolchain without
  libstdc++. (E.g. still useful for the Arduino compatibility layer.)
- Added libstdcpp as required feature were needed
- Added some documentation on C++ on RIOT
2020-07-15 11:45:22 +02:00
Marian Buschsieweke
91a294aa45
cpu/cortexm_common: Drop LTO workaround for Cortex M thread_arch.c
The `ldr    r1, =sched_active_thread` instruction couldn't be assembled with
LTO, as the no immediate offset could be found to construct the address of
`sched_active_thread`. This commit instructs the assembler to generate a
literate pool which can be used to construct the address. While this issue
was only triggered during LTO, it theoretically could also pop up without LTO
due to unrelated changes. Thus, it is a good idea to create the literate pool
even without LTO enabled.
2020-07-15 10:37:15 +02:00
Marian Buschsieweke
0feebcb094
cpu/cortexm_common: Drop #7776's LTO workaround
The workaround from #7776 is no longer needed with recent toolchains, e.g. such
as the toolchain in the riot/riotbuild docker image.
2020-07-15 10:37:15 +02:00
Marian Buschsieweke
056100c1ca
cpu/cortexm_common: Fix cpu_switch_context_exit()
- Use `irq_enable()` over `bl irq_enable`, as `irq_enable()` is an inline
  function and not a C function any more
- Drop `__attribute__((naked))` qualifier
    - It must be used with the declaration of the function, but there it is
      missing. (And it cannot be added there, as this function would need to
      be implemented as "naked" by every platform; which is impossible for
      platforms not supporting `__attribute__((naked))`.)
    - Only functions consisting completely of basic asm may be marked as naked.
      But both the assembly used to trigger the SVC interrupt as well as the
      assembly used in `irq_enable()` are extended asm, not basic asm
- Use ` UNREACHABLE();` over a custom asm construct
2020-07-03 12:48:42 +02:00
0ff9e554eb cpu/cortexm: implement sched_arch_idle() and disable idle thread 2020-06-25 16:02:28 +02:00
d7c1510b0f
cortexm_common: Remove read in ICSR register operations
All bits in the ICSR register in the cortexm system control block are
either read-only or don't have an effect when writing a zero. A
read-modify-write cycle is thus not required when writing bit flags in
the register. This commit removes the reads in the read-modify-store
patterns for this register.
2020-06-23 11:53:53 +02:00
Leandro Lanzieri
2c4c04d11b
cpu/cortexm_common: Unify Kconfig and Makefile arch identifiers 2020-06-16 12:05:41 +02:00
Leandro Lanzieri
649017f0b2
cpu/cortexm_common: Rename arch_cortexm feature to cpu_core_cortexm 2020-06-16 12:05:41 +02:00
Leandro Lanzieri
4d65bc8e0a
cpu: Rename CPU_ARCH to CPU_CORE 2020-06-16 12:05:40 +02:00
8466946ea1 cpu/cortexm_common/Kconfig: add cortexm_svc feature 2020-06-10 23:13:43 +02:00
dbe7331d10 cpu/cortexm: "free" SVC 2020-06-10 23:12:58 +02:00
Jean Pierre Dudey
fea44e8b35
cpu/cortexm_common: add HAS_CORTEX_MPU feature
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2020-06-04 22:16:43 -05:00
José Alamos
917cc66e48
Merge pull request #14162 from jia200x/pr/kconfig/cortex
Kconfig/armv7_m/cortexm: declare CPU_ARCH and CPU_CORE symbols
2020-05-28 14:59:37 +02:00
Leandro Lanzieri
be8289bd8d cpu/cortexm_common: Add Kconfig symbols
This declares the architecture and core specific Kconfig symbols and the
features provided by it are selected.
2020-05-28 14:11:21 +02:00
Francisco Molina
b5e4224a6f
cpu/cortexm_common: remove special cortexm_sleep handle for stm32l152re
__set_PRIMASK(state) had been directly inlined to avoid a hardfault that
occured when branching after waking up from sleep with DBG_STANDBY,
DBG_STOP or DBG_SLEEP set in DBG_CR.

The hardfault occured when returning from the branch to irq_restore,
since the function is now inlined the branch does not happen either.

Refer to #14015 for more details.
2020-05-12 16:37:34 +02:00
Francisco Molina
4ad3164599
cpu/cortexm_common/irq_arch: fix irq_enable return type 2020-05-12 16:37:34 +02:00
Francisco Molina
cb5cbe7431
cpu/cortexm_common: add inlined header only def for irq_%
irq_% are not inlined by the compiler which leads to it branching
to a function that actually implement a single machine instruction.

Inlining these functions makes the call more efficient as well as
saving some bytes in ROM.
2020-05-12 16:37:34 +02:00
iosabi
7e7b6e1cfe Allow to define reserved fields in CortexM vector table.
The ARM CortexM vector table has some reserved fields which are used by
some manufacturers to store their custom image information. In
particular, NXP QN908X stores the checksum, Code Read Protection, image
type and boot block pointer in this region.

This patch allows the cpu and board modules to define the value of these
fields at build time by defining a macro.
2020-04-10 10:37:41 +00:00
Pekka Nikander
4534e9b773
cpu/cortexm_common: add irq sub-priorities
This commit enables Cortex-M CPU interrupt sub-priorities
and allows the PendSV interrupt to have a priority different
from the default one.  Together these two preprocessor
defines can be used to have PendSV always run as the last interrupt
before returning from the interrupt stack back to the user space.

Running PendSV as the last interrupt before returning to the
user space is recommended by ARM, as it increases efficiency.
Furthermore, that change enhances stability a lot with the
new nRF52 SoftDevice support, currently being worked in
PR #9473.

This commit merely enables sub-priorities and a separate
PendSV priority to be used without changing the default
RIOT behaviour.
2020-04-03 17:49:31 +02:00
Leandro Lanzieri
ea2f963302
cpu/cortexm: Add 'cortexm_fpu' as a DEFAULT_MODULE if possible
This adds cortexm_fpu to the DEFAULT_MODULE list when the feature
cortexm_fpu is provided by the architecture. It also moves the
dependency resolution of this module to the architecture-specific
Makefile.dep file.
2020-04-01 09:46:29 +02:00
Leandro Lanzieri
64552a3b9a
cpu/cortexm_common: Move common modules to Makefile.dep
This moves the following modules to a architecture-specific Makefile.dep
file:
- cortexm_common
- cortexm_common_periph
- newlib
- newlib_nano
- periph
2020-04-01 09:46:21 +02:00
Benjamin Valentin
a11bcdcd5c cpu/cortexm_common: define BACKUP_RAM attribute 2020-03-19 13:37:58 +01:00
Sören Tempel
59676a1f5e Make sure the mpu_noexec_ram regions has the lowest priority
From the ARMv7-M ARM section B3.5.3:

	Where there is an overlap between two regions, the register with
	the highest region number takes priority.

We want to make sure the mpu_noexec_ram region has the lowest
priority to allow the mpu_stack_guard region to overwrite the first N
bytes of it.

This change fixes using mpu_noexec_ram and mpu_stack_guard together.
2020-03-10 11:16:22 +01:00
Sören Tempel
2c1a627118 Add mpu_noexec_ram pseudomodule 2020-03-07 13:09:55 +01:00
Gunar Schorcht
f688f84a15
Merge pull request #12928 from benpicco/newlib-multiheap
sys/newlib: enable multiple heaps in _sbrk_r()
2020-02-25 19:16:42 +01:00