[riot-notifications] [RIOT-OS/RIOT] sys/bit.h: missing distinction between SRAM (and full SRAM) and PERIPHERAL bitband (#15810)

Francisco notifications at github.com
Wed Jan 20 09:29:56 CET 2021

#### Description

Most (if not all) Kinetis CPUs with bit-banding capabilities have two SRAM (`SRAM_U` and `SRAM_L`) but only `SRAM_U` supports bit-banding.

So far only `CPU_HAS_BITBAND` exists to tell if there is `bit-band` support but this does not make a distinction between SRAM or peripheral bit-banding (both are not always available) and does not say if the whole SRAM supports it.

If `CPU_HAS_BITBAND` is set then its is used in https://github.com/RIOT-OS/RIOT/blob/master/sys/include/bit.h for bit manipulation. ATM there are not that many users of `bit.h` mainly:

- `kinetis/periph/*`: si for peripheral access
- `kw41zrf_xcvr` (its a cortexm-0 to uses kinetis BME)
- `boards/pba-d-01-kw2x`: used in modem clock initialization (peripheral access)
- `cpu/kinetis/isr_kinetis.c`: used for peripheral access

- `cpu/stm32/periph/ptp` (so peripheral access)

- `cpu/cortexm_common/include/atomic_utils_arch.h`: used for SRAM access

So wee see theat up until recently all uses of bit-banding where for peripheral access up until the `atomic_util` module was included, but this module requires ALL and not only part of the SRAM to have bit-banding.

Here are all possible cases to cover:

1. peripheral bit-band support
1. full SRAM bit-band support
1. partial SRAM bit-band support

ATM (3) has no users and IMO the use cases for this would be limited, please correct me if I'm wrong.

So I think it is needed to make a distinction at least between (1) and (2), I would think that adding a feature for this would be nice: `cortexm_sram_bitband` and `cortexm_peripheral_bitband`

Maybe the implementation for `sram` and `peripherals` bit-band would need to be split as well? Split `bit.h` into a `bitband_sram.h` and `bitband_periph.h`?

#### Steps to reproduce the issue

The current status can be seen to cause issue when testing `tests/sys_atomic_utils` on cortexm4 kinetis boards: e.g. `frdm-k64f`, `pba-d-01-kw-2x`

#### Expected results

All kinetis should be able to use  `sys_atomic_utils` and leverage bit-banding when possible.

#### Actual results

`OUTPUT="TEXT" RYOT_CI=1 BOARD=frdm-k64f make -C tests/sys_atomic_utils_unittests/ flash test`

main(): This is RIOT! (Version: 2021.04-devel-66-gbb82e-pr_bitband_feature)
- atomic_utils_tests
1) OK test_load_store
2) OK test_fetch_ops_u8
3) OK test_fetch_ops_u16
4) OK test_fetch_ops_u32
5) OK test_fetch_ops_u64
addres:: 536807368
*** RIOT kernel panic:
*** halted.

#### Related issues

Solution that addresses `sys_atomic_utils` https://github.com/RIOT-OS/RIOT/pull/15809, maybe this is enough?

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210120/d91842c4/attachment-0001.htm>

More information about the notifications mailing list