Commit graph

71 commits

Author SHA1 Message Date
Joakim Andersson f756b79124 Bluetooth: controller: Use NRF RNG entropy device
Use the NRF RNG entropy device as the entropy device for bt_rand and
controller internal functions when LLL is Nordic.
Using an entropy source with a significant increase in stack usage
will invalidate all stack size configurations in the system and lead
to stack overflow issues.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-06-16 19:09:55 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Carles Cufi b67a31e411 Bluetooth: controller: Remove legacy LL
Remove the legacy Link Layer implementation.

Closes #24187.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-08 15:07:00 +02:00
Joakim Andersson 9e8a30203f Bluetooth: log: Add BT_ASSERT_MSG that matches __ASSERT
Add BT_ASSERT_MSG assert mechanism that can print assertion messages
when verbose bluetooth asserts are enabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-08 17:58:32 +03:00
Joakim Andersson 7b2f9d929f bluetooth: fix signed and unsigend comparison warnings
Fix instances of:
warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-03 18:06:59 -04:00
Oleg Zhurakivskyy b1e1f64d14 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Carles Cufi 4b37a8f3a4 Revert "global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()"
This reverts commit 8739517107.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 8739517107 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Joakim Andersson ac05ae3d25 Bluetooth: Fix controller RPA calling into host with host-based crypto
In a combined build where bt_rand functions is implemented in the host
the RPA module should not use the bluetooth rand function since the RPA
module is common for host and controller.
Having the controller call the the host only to go through HCI back into
the controller would not be a good idea.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-31 18:33:06 +01:00
Joakim Andersson 8b98231e4f Bluetooth: HCI: Fix allow Zephyr VS HCI commands in host-only build
Fix unable to select the Zephyr Vendor-Specific HCI commands support in
host-only build. Set VS HCI support as default on if it is known that
the controller supports it. Otherwise set it to off, this means that
VS HCI support will be default off in host-only builds.

Fixes: #21996

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-17 13:55:56 +02:00
Joakim Andersson 08168f60f7 Bluetooth: assert: Change printed expression to printing line and file
Change assertion messaged printed from printing expression to printing
the line and file name. This provides more context as the same
expression could be asserted upon multiple times and would then not
provide enough clarity in the message.

Also using a formatted string would save code space as we can use the
same string for all messages instead of creating a unique one for each
condition.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Joakim Andersson b30b480c7c Bluetooth: UUID: Expose bt_uuid_to_str to application
Expose the bt_uuid_to_str function as an API to the application.
This aligns this function with the bt_addr_to_str function call. This
allows the application to use this function without having to enable
the BT_DEBUG option.

Move the in-place bt_uuid_str to internal logging, this is mainly done
due to the limitation in the log_strdup that shouldn't be exposed to the
application.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-12-09 17:15:05 +02:00
Alex Li 198013ad9f Bluetooth: Fix BT log level config won't take effect
BT log module should be registered as user configured level,
instead of using default log level

Signed-off-by: Alex Li <lizhiqin46783937@live.com>
2019-11-26 09:11:06 +02:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Ulf Magnusson ac9fe11f2f Kconfig: Remove copy-pasted comments on some promptless symbols
Remove the

    # Omit prompt to signify a "hidden" option

comments that appear on some symbols. They seem to have been copy-pasted
at random, as there are lots of promptless symbols that don't have them
(that's confusing in itself, because it might give the idea that the
ones with comments are special in some way).

I suspect those comments wouldn't have helped me much if I didn't know
Kconfig either. There's a lot more Kconfig documentation now too, e.g.
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.

Keep some comments that give more information than the symbol having no
prompt.

Also do some minor drive-by cleanup.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-17 13:05:24 -05:00
Carles Cufi cd9b940756 Bluetooth: common: Statically check for immediate logging
Immediate logging is not compatible with the software-based controller
due to the additional ISR latency that it introduces. Ensure that
deferred logging is in use whenever using the software-based LL.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-10-01 19:11:16 +02:00
Joakim Andersson 3920844842 Bluetooth: Host: Fix usage of re-using Bluetooth log buffers
Fix calling bt_hex and bt_addr_le_str multiple times in the same logging
call could result in string overwritten since log_strdup is not
guaranteed to duplicate the string buffer in all logging configurations.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-09-30 17:47:43 +02:00
Kumar Gala 8ce0cf0126 kconfig: Convert device tree chosen properties to new kconfigfunctions
Convert how we get the various chosen properties like "zephyr,console"
to use the new kconfig functions like dt_chosen_to_label.

Because of how kconfig parses things we define a set of variables of the
form DT_CHOSEN_Z_<PROP> since comma's are parsed as field seperators in
macros.

This conversion allows us to remove code in gen_defines.py for the
following chosen properties:

zephyr,console
zephyr,shell-uart
zephyr,bt-uart
zephyr,uart-pipe
zephyr,bt-mon-uart
zephyr,uart-mcumgr
zephyr,bt-c2h-uart

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-13 11:42:34 -05:00
Carles Cufi aa960c9d6e Bluetooth: log: Rework BT_ASSERT
Rework the BT_ASSERT infrastructure with the following changes:

- Transition from LOG() macros to printk()
- Allow the BT_ASSERT() macro to map directly to stancard __ASSERT()
- Allow printing of the assert reason to be disabled
- Switch from k_oops() to k_panic() configurable

There are 2 reasons for using printk() instead of LOG():

- BT_ERR uses deferred logging by default, which is problematic with
ASSERTs
- The __ASSERT() macro in Zephyr uses printk()

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-09-07 15:50:23 +03:00
Peter Bigot 5412409781 include/bluetooth: rearrange for standard use of extern "C"
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

Background from issue #17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-13 18:00:31 +02:00
Anas Nashif efb8df5366 cleanup: include/: move misc/stack.h to debug/stack.h
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif e1e05a2eac cleanup: include/: move atomic.h to sys/atomic.h
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Carles Cufi bae9f1967b samples: Bluetooth: hci_uart: Implement NOP Command Complete
Implement the Controller counterpart to CONFIG_BT_WAIT_NOP so that it
issues a NOP Command Complete event after booting up, to signal to the
Host that it is ready to receive HCI traffic.

Fixes #15333

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-04-11 14:54:37 +02:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Thomas Stenersen caa4f7baae kconfig: bluetooth: Let BT_HCI_VS be configurable from controller
This moves the vendor-specific HCI command/event configuration
definitions out of bluetooth/common into bluetooth. This allows
the controller itself to indicate its support for vendor-specific
commands/events.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Ulf Magnusson b34b2c5a94 Bluetooth: kconfig: Remove redundant dependencies
subsys/bluetooth/common/Kconfig and subsys/bluetooth/host/Kconfig are
'source'd within 'if BT' and 'if BT_HCI', in subsys/bluetooth/Kconfig,
so there's no need to add those dependencies within them.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 10:03:06 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Kumar Gala ff70b3444f dts: Convert CONFIG_ to DT_ symbols for chosen props
Replace generating CONFIG_ symbols with DT_ symbols for chosen
properties like 'zephyr,console' or 'zephyr,bt-mon-uart'.  We now use a
kconfigfunctions (dt_str_val) to extract the info from dts into Kconfig.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 11:41:26 -06:00
Vinayak Kariappa Chettimada 254a97af93 Bluetooth: controller: Preliminary work in progress mesh ext.
Preliminary work done towards Mesh extensions on the old LL
architecture implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-23 09:45:06 +01:00
Jiahao Li 5b9d5a217c Bluetooth: Fixes length limit in bt_hex_real
Since `str` is the output buffer, `bt_hex_real` should limit its output
length according to the `str` size, not the `hex` size.

Signed-off-by: Jiahao Li <reg@ljh.me>
2019-01-13 23:19:30 +02:00
Krzysztof Chruscinski dc2ab4d74f bluetooth: Simplifying log macros
Function name prefix is now configurable (by default only debug
messages are prefixed) and log macros can be simplified.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-12-13 14:21:25 +01:00
Andrzej Puzdrowski c2e7847daa bluetooth: common: Add BT hexdump
Added BT alisa for dumping binary data to the logg.
The macro will be useful for BT as reworked settings supports r/w of
raw data - which will be widely leveraged in bluetooth storage alignment
to reworked settings.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-12-11 11:22:16 +01:00
Olivier Martin 58245cd02f Bluetooth: Define log level at bluetooth subsystem level
This commit defines a default log level at bluetooth subsystem
level when module log level is not defined.

Prior to this change, the bluetooth subsystem would use
the firmware default log level.

Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
2018-11-28 13:52:35 -06:00
David B. Kinder ee47f7fb7a doc: fix kconfig misspellings
Fix misspellings in Kconfig files that show up in the configuration
documentation (and make menuconfig screens).

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-11-02 17:58:16 -04:00
Johan Hedberg 9f18ff9baf Bluetooth: Convert monitor protocol to a logger backend
Convert the monitor protocol to a proper logger backend. This also
means that our log.h headerfile gets greatly simplified.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Johan Hedberg cd4cf4e580 Bluetooth: Convert string helpers to use log_strdup
This reduces the multiple buffer requirement to a single buffer.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Johan Hedberg 251d99132d Bluetooth: Remove custom stack macros
Now that log processing happens in a separate thread, the
BT_STACK_EXTRA macro is not needed (since there's no significant
overhead), and therefore the BT_STACK macros become unnecessary as
well.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Johan Hedberg 343c53e841 Bluetooth: Switch from SYS_LOG to logger-based logging
Initial conversion to use syslog instead of logger.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Johan Hedberg 5bd6bc4bed Bluetooth: log: Make address helpers more robust
Use irq_lock (same way as bt_hex does it) and increase the number of
static buffers to reduce the risk of reuse before a buffer gets
processed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Johan Hedberg 6a68b29f41 Bluetooth: Only build bt_hex() if BT_DEBUG is enabled
bt_hex() should be included in the same block as the address helpers.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Joakim Andersson 773b21ac38 bluetooth: config: Fix bluetooth config dependencies
Fix bluetooth config dependencies where the definitions depend on other
definitions.
BT_RX_PRIO is not always defined in a controller only build.
BT_CTLR_TX_BUFFER_SIZE does not depend on BT_CTLR, but BT_LL_SW.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2018-10-05 11:15:27 -04:00
Szymon Janc e76224d038 Bluetooth: Controller: Add CONFIG_BT_HCI_VS option
This allows to fully disable HCI VS commands support.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2018-09-19 13:03:56 +02:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Ulf Magnusson 1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Sebastian Bøe d62117e5b8 kconfig: Change how BT affects SYSTEM_WORKQUEUE_PRIORITY
Invalid configurations should be detected during configuration instead
of during compilation whenever possible.

This patch replaces a BUILD_ASSERT on CONFIG_SYSTEM_WORKQUEUE_PRIORITY
with what is intended to be an equivalent Kconfig restriction.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-06-14 16:49:50 -04:00
Sebastian Bøe f8dc4b6b50 net: bluetooth: Enforce the minimum user_data size at Kconfig
Invalid configurations should be detected during configuration instead
of during compilation whenever possible.

This patch replaces a BUILD_ASSERT on CONFIG_NET_BUF_USER_DATA_SIZE
with what is intended to be an equivalent Kconfig restriction.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-06-13 15:13:18 +02:00