Commit graph

7275 commits

Author SHA1 Message Date
Michael Hope a816eeba2f soc: sam0: add support for the BOSSA bootloader
This adds a new config option for SAM0 targets that use the BOSSA
bootloader.  If the CDC ACM driver is also enabled, then the
programmer can automatically reset the board into the bootloader for
programming.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-12 13:20:47 +02:00
Michael Hope 0d16a9a801 usb: cdc_acm: add a DTE rate changed callback
This is called when the USB host changes the virtual baud rate.

This is used by Arduino style boards to signal that the board should
reset into the bootloader.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-12 13:20:47 +02:00
Asbjørn Sæbø 1886cb4b4e Bluetooth: Shell: Add shell command to output the ATT MTU size
It is sometimes useful to know what the ATT MTU size is.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2020-07-10 13:14:30 +02:00
Oleg Zhurakivskyy fda94f7d06 net: tcp2: Fix dereference after null check in tcp_in()
Fix dereference after null check in tcp_in().

Coverity CID :210051

Fixes #25783

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-07-10 11:46:20 +02:00
Stephanos Ioannidis 3322489d22 config: Rename TEXT_SECTION_OFFSET to ROM_START_OFFSET
The `TEXT_SECTION_OFFSET` symbol is used to specify the offset between
the beginning of the ROM area and the address of the first ROM section.

This commit renames `TEXT_SECTION_OFFSET` to `ROM_START_OFFSET` because
the first ROM section is not always the `.text` section.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-07-09 14:02:38 -04:00
Marek Pieta 4e43e00c4c Bluetooth: controller: Safe default value of BT_CTLR_LLCP_CONN
Change sets default value of Kconfig option BT_CTLR_LLCP_CONN to
BT_MAX_CONN. The default value should properly handle the worst case.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2020-07-09 19:08:50 +02:00
Vinayak Kariappa Chettimada dc55538645 Bluetooth: controller: Fix missing skip value calculation
Fix missing recalculation of skip value of the ticker being
inserted into ordered list, when it collides and is being
attempted to be inserted at next periodic interval.
This fix is for ticker compatibility mode which is used as
default for nRF51 series.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-09 19:08:35 +02:00
Marcin Niestroj af0bb8835b net: l2: ppp: ipv6cp: remove wrong Configure-Rej handling
Currently there is a single function that handles both Configure-Ack and
Configure-Rej messages. This is obviously wrong for Configure-Rej,
because implementation applies options received in the message.

Remove Configure-Rej callback, so those frames are simply ignored for
the time no valid handling code exists.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-09 12:47:12 -04:00
Maureen Helm eb43207508 disk: Remove unused variables in nxp usdhc driver
Removes unused instances of struct usdhc_priv in the nxp usdhc driver.
The DISK_ACCESS_USDHC_INIT macro is responsible for instantiating these
variables.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-07-09 07:56:44 -05:00
Maureen Helm 04f2ab9af1 disk: Remove extra copy of config struct in nxp usdhc driver
Updates the nxp usdhc driver data structure to keep a reference instead
of a copy of the constant config structure.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-07-09 07:56:44 -05:00
Maureen Helm 6fa92fe7da disk: Move variable from config to data struct in nxp usdhc driver
Moves the source clock frequency variable in the nxp usdhc driver from
the config structure to the data structure in preparation for removing
the writable copy of the config structure.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-07-09 07:56:44 -05:00
Maureen Helm ec53518fa5 disk: Remove instance conditionals from nxp usdhc driver functions
Refactors the nxp usdhc driver to remove instance-specific conditionals
from driver functions. Now all instance-specific details, such as power
and card detect gpios, are contained in the driver config structure.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-07-09 07:56:44 -05:00
Maureen Helm 47463173c7 disk: Create device instance macro in nxp usdhc driver
Creates a new device instance macro in the nxp usdhc driver to use with
DT_INST_FOREACH.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-07-09 07:56:44 -05:00
Trond Einar Snekvik cb7835d18f Bluetooth: Mesh: Wait for proxy on node reset
Adds idle wait callback to proxy by counting the number of pending
notifications.

Ensures that all connected nodes have received messages before resetting
the mesh stack.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-07-09 13:49:26 +02:00
Marcin Niestroj 7996f527d5 net: l2: ppp: ipcp: clear options after protocol goes down
Clear negotiated options in protocol down handler. That way all
addresses are properly requested (by sending 0.0.0.0 in Configure-Req)
in the subsequent option negotiation phases.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-09 13:45:18 +02:00
Vinayak Kariappa Chettimada eb2a64989b drivers: flash: nrf: Fix flash operation timeout
Fix flash operation timeout due to incorrect use of
secondary ticker to abort any radio in use. Ticker id 0
is reserved for split controller's pipeline preempt timeout.
Using the same ticker id caused the secondary ticker to
not be started if controller is using the same ticker id
for pipeline preempt timeout.

Fixes #26333.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-09 07:17:41 -04:00
Flavio Ceolin c4f7faea10 random: Include header where it is used
Unit tests were failing to build because random header was included by
kernel_includes.h. The problem is that rand32.h includes a generated
file that is either not generated or not included when building unit
tests. Also, it is better to limit the scope of this file to where it is
used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-07-08 21:05:36 -04:00
Flavio Ceolin 6216c6cf5b random: Add syscalls for random subsystem
Create syscalls to make possible using random APIs from user mode
threads. These APIs can have different implementations, like using
entropy driver or Xoroshiro128. Some of these implementations also have
some globals to preserve state between calls.

Make it run entire in user space would require user adding these globals
to their memeory domains and/or grant access to entropy device. Syscalls
simplify its usage.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-07-08 21:05:36 -04:00
Michał Narajowski 67ab8a3173 Bluetooth: Mesh: Fix response to Provisioning PDU with invalid type
Reverse the order of these checks because invalid PDU type will
never be expected. If PDU type is invalid we should respond with
error 0x0002 - Invalid format.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-08 10:19:02 +02:00
Emil Obalski 4f42b4413b usb: Correct logging level in Audio class.
Configuration file was left unchanged after development
of USB Audio class. Deleted configs should never be present.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-07-07 19:28:14 -04:00
Simon Glass 84e9c7c63d shell: Export shell_hexdump_line()
This function is useful for other code. Export it along with the
default line length in bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-07 17:19:26 -04:00
Robert Lubos c5132aac18 net: lwm2m: Fix invalid logical and operator usage
Binary and should be used instead.

Fixes #26356.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-07-07 15:06:22 +02:00
Vinayak Kariappa Chettimada 2b45736f28 Bluetooth: controller: Add Periodic Advertising HCI integration
Add implementation to integrate the HCI Periodic Advertising
interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-07 15:04:51 +02:00
Robert Lubos 2eb633d12e net: lwm2m: Reset only messages owned by lwm2m context
The context should only clear messages it owns, not all of them. Since
both context (LwM2M and FOTA) share common message pool, they might
interrupt their operation otherwise (i. e. cancel retransmissions).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-07-06 18:01:31 -04:00
Robert Lubos 8b22521b6b net: lwm2m: Close FOTA socket when finished
The FOTA socket was not closed when download finished or an error
occured.

Additionally, fix the socket fd verification (it was assumed 0 is not a
valid fd which is not correct).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-07-06 18:01:31 -04:00
Alexandre Bourdiol 937482b4a7 net: ip: copy to wrong destination in z_vrfy_net_addr_pton()
In function z_vrfy_net_addr_pton(),
the final copy should be to 'dst' variable not to 'src'

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-07-06 18:00:07 -04:00
Robert Lubos 3ea5c2180a net: lwm2m: Prevent infinite loop in do_write_op_tlv function
In case unsopported TLV type or malformed packet is received, the
`do_write_op_tlv` function will end up in an infinite loop. Prevent that
by returning an error code in case it does not recognize TLV type.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-07-06 17:57:40 -04:00
Marcin Niestroj 03c774e58c net: l2: ppp: drop ppp_context's is_network_up
There is already a variable 'network_protos_up', which stores number of
network protocols being up. Additionally each network protocol has its
own state represented by is_ip{,v6}cp_up. Use the latter in FSM up() and
down() callbacks.

This fixes a case when both IPCP and IPv6CP protocols are going
down. When using ctx->is_network_up only one of them (the first) was
deinitialized correctly, second stayed always up (at least partially,
e.g. not calling ppp_network_down()).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-06 17:55:44 -04:00
Marcin Niestroj 16542e1642 net: l2: ppp: fix packet length for sending Term-Req and Term-Ack
Each PPP packet sent on wire needs to have at least 4 bytes length. Set
that length for outgoing Term-Req and Term-Ack packets. Also update
length validation to check for at least 4 bytes instead of at least 1
byte.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-06 16:50:54 +02:00
Joakim Andersson c3308275f6 Bluetooth: GATT: Turn GATT notify multiple feature default off
Turn the GATT notify multiple feature off as default value.
This feature changes the behavior of the bt_gatt_notify API in a way
that might not be backwards-compatible.
This is because the notify multiple header is larger, and therefore
limits the amount of bytes that could otherwise have been sent in a
normal notify PDU for a given ATT MTU.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-06 16:50:36 +02:00
Joakim Andersson 1d27450954 Bluetooth: host: Fix conn_handle in LE Advertising Set Terminated evt
Fix use of conn_handle in LE Advertising Set Terminated event not
converting from serial Little Endian to native CPU endianness.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-06 16:49:28 +02:00
Vinayak Kariappa Chettimada 6adfc9bfba Bluetooth: controller: Fix Periodic Adv Data Set parameter list
Fix the parameter list of Periodic Advertising Data Set
interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-06 16:49:19 +02:00
Joakim Andersson 4f7505cb10 Bluetooth: host: Unspecified disconnect reason for no pending conn
Use an unspecified reason when disconnecting a connection that did not
have a pending connection in the host.
We don't allocate connection objects in the connection complete anymore
so using memory-capacity-exceeded is misleading.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-06 14:39:30 +02:00
Joakim Andersson 52f9c0dd46 Bluetooth: host: Fix resume advertiser race condition
This patch fixes an issue with the advertiser not resuming connectable
advertiser if the last bt_conn_unref happens from something other
than the disconnected callback.
In this case this last bt_conn_unref was from gatt.c notify_cb called
from application main thread.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-06 11:15:39 +02:00
Joakim Andersson 4be66bd33d Bluetooth: Fix host RX thread deadlock
Fix host RX thread being deadlocked. The deadlock occurs because the
RX thread is stuck waiting in conn_tx_alloc with K_FOREVER but if the
connection is disconnected only the RX thread can unblock it in the
handling of the disconnect event.

This commit fixes this deadlock by splitting the processing of the
disconnected event into two parts.
The part needed to unblock the RX is to release resources held by
unack'ed TX packets and mark the connection state as not connected
anymore.
The RX thread waiting for free_tx fifo and the TX thread waiting for
the bt_dev.le.pkts semaphore will both check the connected state after
having acquired them and will abort if disconnected.
The rest of the processing will be handled at normal RX thread
priority like normal.

Move the bt_recv_prio handling to the Bluetooth host when the host
has defined its own RX thread (CONFIG_BT_RECV_IS_RX_THREAD=n).
If the HCI driver has the RX thread (CONFIG_BT_RECV_IS_RX_THREAD=y),
then the responsibility to call bt_recv and bt_recv_prio correctly
falls to the HCI driver.
The helper function bt_hci_evt_is_prio() is replaced with
bt_hci_evt_get_flags() so that the HCI driver can do this correctly.
This decision to replace was made so that existing HCI drivers
maintained out-of-tree will fail at compile time with the new system.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>

Bluetooth: host: Move bt_recv_prio to host when RX thread is defined

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-06 11:15:39 +02:00
Dominik Ermel a5b3e86339 subsys/fs: Fix fs_* operations crashing when file closed
Attempt to perform fs_read, fs_write, fs_seek, fs_tell, fs_truncate
and fs_sync on file that has been closed, prior to attempt, would cause
NULL pointer dereference.
With this fix, such operations would instead return -EBADF.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-03 12:16:11 -04:00
Dominik Ermel 54492c2748 subsys/fs: Fix fs_close on closed file causing NULL dereference
If fs_close gets invoked on closed file (e.g. double close) it would
cause NULL dereference and system crash. Instead now it will just
return with success, as the file is already closed anyway.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-03 12:16:11 -04:00
ZhongYao Luo ddf5152bb8 Bluetooth: br/edr: store link key
Save link key to settings_subsys, no need to re-pair after restart.
Overwrite old pairing records with aging counts.

Signed-off-by: ZhongYao Luo <LuoZhongYao@gmail.com>
2020-07-02 16:32:41 +03:00
Andries Kruithof 2bfb128463 Bluetooth: shell: allow multiple parameters for bt hci-cmd
The hci-cmd currently accepts only a 1 byte parameter. This
disables use of commands that requires more than 1 byte,
for ex. the feature exchange that requires a 16 bit parameter.

This commit allows a datafield parameter up to 65 bytes long.
65 bytes comes from the nr. of parameters for the
HCI_LE_Generate_DHKey command

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-07-02 16:32:04 +03:00
Michał Narajowski 91761767dd mesh: Ignore Friend Request from local interface
Friend Request is also transmitted over local queue and
if both Friend and LPN features are enabled then we would
try to establish friendship with ourselves.

Fixes MESH/NODE/FRND/LPN testcases.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski 1e29b2dceb mesh: Replace hardcoded duplicate cache size
The hardcoded value was arbitrary and interfered with message cache
mechanism causing invalid behavior and PTS test to fail.

Fixes MESH/NODE/RLY/BV-02-C.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski cc6d9f1072 mesh: Do not ignore message with DST as RFU group address
According to Mesh Profile Test Specification we should still
relay messages with DST address that is RFU.

Fixes MESH/NODE/RLY/BV-01-C.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski 3e7c64dda9 mesh: Fix net_buf leak in advertising provisioning bearer
Unsegmented buffer in bearer_ctl_send was not unrefed causing
a memory leak.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski 73e1cccdbb mesh: Fix Vendor Model Subscription Get procedure
Invalid argument was passed to bt_mesh_model_tree_walk.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski addbdb0d00 mesh: Fix key refresh procedure
Key refresh procedure was ignored on non-primary subnet.

Mesh Profile Specification v1.0.1:
3.10.4 Key Refresh procedure
"This procedure is used when the security of one or more network
keys and/or one or more of the application keys has been compromised
or could be compromised."

"It is possible to update each NetKey independently of all other
NetKeys. A Key Refresh procedure for one NetKey can be in a different
phase to another Key Refresh procedure for other NetKeys."

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski 9a0602417a mesh: Add reset link functionality to provisioning bearers
Reset provisioning bearers when bt_mesh_reset() is called. Accept
another provisioning attempt after link close.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski 5e543a2366 mesh: Add a define representing max transaction id
This value was used quite often in the file so adding a
descriptive name should improve readability.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski ebabba3684 mesh: Start protocol timer on send message in advertising bearer
Protocol timer was not started when sending a control message
in advertising bearer.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Michał Narajowski df426abe53 mesh: Fix resending provisioning link ack
The comparison of a current tx link transaction id caused
us to not send ack and in effect fail provisioning.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Francois Ramu fd5ce64db4 soc: arm: st_stm32 add low power to stm32wb series
This patch introduces the support of low power modes
for the STM32WBxx from STMicroelectronics based on the lptim
Here, the power modes are sleep modes have lptimer as wakeup source.
The sleep modes are configured by the SYS_POWER_MANAGEMENT.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-07-02 08:45:40 -04:00