Commit graph

21541 commits

Author SHA1 Message Date
Emil Obalski
e288fb9d34 net: Do not depend timeout on AUTO_INIT.
CONFIG_NET_CONFIG_INIT_TIMEOUT should not only be available if
CONFIG_NET_CONFIG_AUTO_INIT=y. If *_AUTO_INIT=n then application
may wish to initialize net manually and still use configured
timeout.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-06 12:12:10 -05:00
Jukka Rissanen
bef54aff3e net: config: Allow initialization from application
If the CONFIG_NET_CONFIG_AUTO_INIT is not set, then let application
to do the initialization manually. In that case the app should call
net_config_init_app() when it is ready to setup the network.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-06 12:12:10 -05:00
Trond Einar Snekvik
0221853386 Bluetooth: Mesh: Silence proxy not connected log
When performing node reset over a proxy connection, the disconnection is
asynchronous, and will finish after the reset callback goes to the
application. If the application restarts provisioning in this callback,
the disconnected-event is triggered after PB GATT is reactivated, and
this error is printed without any faults actually occurring.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-08-06 12:56:54 +03:00
Joakim Andersson
97ec4a775e Bluetooth: Host: Notify L2CAP that security change failed
Notify L2CAP when pairing procedure fails during SMP pairing
process. L2CAP needs to be notified so that it can cancel
ongoing connection-oriented channel requests.

Rename bt_l2cap_encrypt_change to bt_l2cap_security_changed and
call it from bt_conn_security_changed always, so that L2CAP
is informed when changing security fails.

This also fixes security_changed conn callback not called when
auth_complete returns an error.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
42b4719947 Bluetooth: ATT: Avoid warning when no ATT request is pending
Avoid warning in att_handle_rsp, only call this when there is a
pending ATT request. This avoids a warning happens when elevating
security fails but higher security had not been requested by an
ATT request.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>

squash! Bluetooth: ATT: Remove warning when no ATT process pending
2020-08-06 11:47:03 +02:00
Joakim Andersson
53435fdd8f Bluetooth: shell: Add sec_level argument to l2cap connect command
Add argument to set required security level when connection
an L2CAP channel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
521034c63d Bluetooth: L2CAP: Release channel when connect request fails
Release the l2cap channel when sending the l2cap connect request
fails.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
5f00ee1e88 Bluetooth: L2CAP: Elevate security level if requested by application
Elevate the security level before sending the connection request if
the application has set a required security level on the channel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
9c3d006471 Bluetooth: L2CAP: Elevate security level when connect request denied
Elevate the security level of the connection when the l2cap channel
connect request is denied with encryption or authentication error
code.
The l2cap channel required_sec_level was used, but this is not
correct as this is set by the user of the API. This resulted in
the call to bt_conn_set_security seeing that the current security
level was already set, decide there is nothing to be done and return
success.

Fixes: #27220

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
81e297aa88 Bluetooth: L2CAP: Use safe for-each loop where channel can be removed
Use safe for-each loop in bt_l2cap_encrypt_change since dynamic
channels with pending connection-oriented channel requests will
be canceled and removed from the list if the encryption change
failed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
1d66c1e491 Bluetooth: host: Use CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU
Remove dependency on CONFIG_BT_ACL_FLOW_CONTROL and use
CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU.
The ATT MTU is set from two different KConfig options depending
on if CONFIG_BT_ACL_FLOW_CONTROL is enabled, which makes it
a confusing option and hard to provide a conf file that
supports multiple board configurations.

This changes the behavior when CONFIG_BT_ACL_FLOW_CONTROL and
CONFIG_BT_BUF_RX_LEN was used to set the L2CAP RX MTU, and by
extension the ATT MTU.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:46:48 +02:00
Andrew Boie
d0e4b24453 bluetooth: use kernel stacks
These threads don't run in user mode, save some memory if
userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-05 21:30:32 -04:00
Andrew Boie
039c5f62ee usb: use kernel stacks
These threads don't run in user mode. Save some memory
if userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-05 15:21:51 -04:00
Jett Rink
63283621ea ztest: clean up comments, strings, and interface
Clean up comment typos and wording for expect data functions.

Add a cast to (void *) to match convention set in expect value;
this allows the caller to avoid casting on every single call.

Signed-off-by: Jett Rink <jettrink@google.com>
2020-08-05 15:05:44 -04:00
Jett Rink
03c0990275 ztest: fix failure when exceeding mock parameter count
If you tried to use more mock parameters than were set in
CONFIG_ZTEST_PARAMETER_COUNT, you would get a random seg fault somewhere
unrelated to the mocking parameter as we would use memory past an array
bounds.

Signed-off-by: Jett Rink <jettrink@google.com>
2020-08-05 15:05:44 -04:00
Jett Rink
a6e1706269 ztest: increase default mock parameter count
If one enables mocking, then they most likely want more than 1 mockable
or verifiable parameter by default. Bump the default number of mockable
parameters to 10 to handle most cases without needing to touch an
additional Kconfig option.

Signed-off-by: Jett Rink <jettrink@google.com>
2020-08-05 15:05:44 -04:00
Kamil Kasperczyk
e5c65ebe2e net: openthread: Added config for OpenThread version selection.
Config options used for selecting OpenThread stack version
were added.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-08-05 15:20:52 +02:00
Torsten Rasmussen
bb3946666f cmake: fix include directories to work with out-of-tree arch
Include directories for ${ARCH} is not specified correctly.
Several places in Zephyr, the include directories are specified as:
${ZEPHYR_BASE}/arch/${ARCH}/include
the correct line is:
${ARCH_DIR}/${ARCH}/include
to correctly support out of tree archs.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Andrew Boie
9598a5fbff ztest: use kernel stack for cpuhold
These threads don't run in user mode, save some memory if
userspace is not enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-05 13:21:38 +02:00
Dag Bjarvin
e93963b719 Bluetooth: controller: Add ll_adv_aux_set_clear function
Add ll_adv_aux_set_clear, add to bsim test

Signed-off-by: Dag Bjarvin <Dag.Bjarvin@nordicsemi.no>
2020-08-05 12:52:42 +02:00
Vinayak Kariappa Chettimada
77b820a9ea Bluetooth: controller: Fix incorrect use of ticker user id
Fix incorrect use of LLL ticker user id in ULL_LOW execution
context.

Regression introduced in commit 23ef75f6d9 ("Bluetooth:
controller: split: Fix Low Latency Prepare Done").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-08-05 12:02:05 +02:00
Jukka Rissanen
e73e932153 net: tcp2: Check data length properly
The original return type of tcp_data_get() was unsigned and the
return value <0 was not checked properly.

Fixes #25723
Coverity-CID: 210559

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-05 08:50:42 +03:00
Carles Cufi
c8bc3753aa mgmt: mcumgr: Consolidate Kconfig into a single file
For some reason, MCUMgr used to consist of two separate Kconfig
files, likely due to the fact that the author's original intention was
to split the "management" and "mcumgr-specific" options in order to
integrate additional libraries. In practice this never worked out, so
coalesce them into a single file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-08-04 15:16:35 -04:00
Andrew Boie
8da93b136c logging: use kernel stack
The logging thread runs in supervisor mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-04 09:45:50 -05:00
Andrew Boie
1452ca4edc mgmt: use kernel stack
This doesn't run in user mode, save some memory if
userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-04 09:44:37 -05:00
Robert Lubos
ab9f8bac28 net: lwm2m: Update lifetime on Register Update event
The LwM2M server might modify the lifetime value while the device is
registered, hence it's needed to obtain the value directly from the
Server object instance, before each Register Update.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-08-04 16:29:40 +02:00
Robert Lubos
b9caaf217e net: lwm2m: Fix Security and Server object instance matching
A proper way to match a Security object instance with a Server object
instance is via Short Server ID resource. Both coupled object instances
should carry the same value of this resource in order to me considered
matched.

This was not implemented in the LwM2M library and it was incorrectly
assumed that the Security object instance index corresponds to the
Server object instance index. While such apporach works is simple
scenario, it might yield incorrect results when bootstrap is used.

Fix this, by verifyng the Short Server ID resource in the Secuirty
instance used, and finding a matching Server instance. The server object
instance is stored for future use in the engine.

Additionally, remove an extra Server object instance that was created
when the bootstrap procedure was used. Since the boostrap Security
object instance does not have the corresponding Server object, it's
enough to have a single Server instance.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-08-04 16:29:40 +02:00
Jukka Rissanen
9e8c1b0bbf net: tcp2: Verify that options are read correctly
Remove the static buffer for TCP options. Make sure that the
options were read properly to temp buffer.

Fixes: #25729
Coverity-CID: 210056

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-04 16:18:18 +02:00
Marcin Niestroj
5b12c23b44 mgmt: smp: shell: remove useless data->end member
Value of this member was never assigned, so it was always 0. Remove it
to simplify code a little bit.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-08-04 16:18:06 +02:00
chao an
5328adcff5 Bluetooth: Mesh: Fix tx seg buffer with NULL pointer reference
Fix tx seg buffer with NULL pointer reference if enable mesh friendly

Signed-off-by: chao an <anchao@xiaomi.com>
2020-08-04 12:47:05 +03:00
Luiz Augusto von Dentz
6c7a387e9f Bluetooth: ATT: Fix handling to EATT channels
EATT channels use bt_l2cap_chan_send which does return the number of
bytes sent on success not 0 as bt_l2cap_send.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-08-04 10:38:27 +03:00
Gerson Fernando Budke
29544a1ceb updatehub: Move from lib to subsys:mgmt folder
Zephyr introduced subsys/mgmt folder for MCU management. Move UpdateHub
to this newly and dedicated space.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-08-03 16:33:06 +02:00
chao an
9e64d379f0 Bluetooth: Mesh: configurable advertiser stack size
Add a configurable Kconfig option for advertiser thread stack size

Change-Id: Ia59a03311706de929d1833fa46cff66652620e7a
Signed-off-by: chao an <anchao@xiaomi.com>
2020-08-03 13:50:21 +02:00
Andrew Boie
8b531aa996 canbus: use kernel stacks
These threads don't run in user mode, save some memory
if userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-02 10:50:12 -04:00
Andrew Boie
c0d3ed0d1c net: use kernel stacks
These threads don't run in user mode, save some memory if
userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-01 08:13:15 -04:00
Andrew Boie
99c211dbc6 shell: fix irq stack extern declaration
This is a kernel stack now.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-01 08:12:47 -04:00
Carles Cufi
244f826e3c cmake: remove _if_kconfig() functions
This set of functions seem to be there just because of historical
reasons, stemming from Kbuild. They are non-obvious and prone to errors,
so remove them in favor of the `_ifdef()` ones with an explicit
`CONFIG_` condition.

Script used:

git grep -l _if_kconfig | xargs sed -E -i
"s/_if_kconfig\(\s*(\w*)/_ifdef(CONFIG_\U\1\E \1/g"

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-08-01 12:35:20 +02:00
Vinayak Kariappa Chettimada
dc48999ee1 Bluetooth: controller: Fill event counter in sync info
Fill the referenced event counter of the Periodic
Advertising SYNC_IND PDU into the sync info struct in the
Common Extended Advertising Header Format.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-31 19:04:23 +02:00
Jukka Rissanen
dea5b74a2c net: Separate net_pkt priority from traffic class
User can always set the network packet priority as it is not
related to traffic class.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-31 18:11:51 +02:00
Carles Cufi
c200b1c5e6 mgmt: Move mcumgr into its own folder
In order to be able to add more entries under 'subsys/mgmt', move the
current contents of it, which relate exclusively to MCUMgr, to its own
folder.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-07-31 08:46:53 -05:00
Jakub Rzeszutko
b83e4224e0 shell: correct build-in commands definition
The definition of the help command has been changed
so that it does not accept the arguments.
Thanks to this it cannot be marked by the "select" command.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-07-31 11:54:34 +02:00
Jakub Rzeszutko
5aaac4b72e shell: update select command help message
Added information that a command must accept arguments to be selected.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-07-31 11:54:34 +02:00
Jakub Rzeszutko
e76cd05e18 shell: fix select command
If the command buffer is empty the shell was trying to read a string
from a random memory location. Added a condition checking "argc" value
when the select command is executed.

Fixes: #27227

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-07-31 11:54:34 +02:00
Andrew Boie
8b4b0d6264 kernel: z_interrupt_stacks are now kernel stacks
This will save memory on many platforms that enable
user mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-30 21:11:14 -04:00
Andrew Boie
b0c155f3ca kernel: overhaul stack specification
The core kernel computes the initial stack pointer
for a thread, properly aligning it and subtracting out
any random offsets or thread-local storage areas.
arch_new_thread() no longer needs to make any calculations,
an initial stack frame may be placed at the bounds of
the new 'stack_ptr' parameter passed in. This parameter
replaces 'stack_size'.

thread->stack_info is now set before arch_new_thread()
is invoked, z_new_thread_init() has been removed.
The values populated may need to be adjusted on arches
which carve-out MPU guard space from the actual stack
buffer.

thread->stack_info now has a new member 'delta' which
indicates any offset applied for TLS or random offset.
It's used so the calculations don't need to be repeated
if the thread later drops to user mode.

CONFIG_INIT_STACKS logic is now performed inside
z_setup_new_thread(), before arch_new_thread() is called.

thread->stack_info is now defined as the canonical
user-accessible area within the stack object, including
random offsets and TLS. It will never include any
carved-out memory for MPU guards and must be updated at
runtime if guards are removed.

Available stack space is now optimized. Some arches may
need to significantly round up the buffer size to account
for page-level granularity or MPU power-of-two requirements.
This space is now accounted for and used by virtue of
the Z_THREAD_STACK_SIZE_ADJUST() call in z_setup_new_thread.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-30 21:11:14 -04:00
Dominik Ermel
babc322e09 native_posix: Add flags argument to fs_open invocations
Now fs_open supports open flags and the fuse requires update.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-30 16:33:18 +02:00
Dominik Ermel
cac07629bf subsys/fs: Add open flags parameter to fs_open
The fs_open has been extended with support for open flags.
Currently supported flags are:
  FS_O_READ -- open for read
  FS_O_WRITE -- open for write
  FS_O_CREATE -- create file if it does not exist
  FS_O_APPEND -- move to the end of file before each write

The FAT FS and LittleFS front-ends within the Zephyr has also been
modified to utilize the flags.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-30 16:33:18 +02:00
Anas Nashif
988433f086 power: remove unused inclusion of soc.h
Inclusion of soc.h not needed in this file

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-30 08:00:03 -04:00
Peter A. Bigot
68b561c4a7 settings: avoid null pointer invocation in runtime read
If a setting read is attempted from a store that doesn't support
reading return an error rather than faulting.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-07-30 12:22:41 +02:00
Tomasz Bursztyka
7d1af02410 uart: Fix uart_irq_callback_set usage
It was already using uart_irq_callback_user_data_set below, now it also
uses uart_irq_callback_user_data_t as callback type, so let's normalize
the callbacks.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00