Compare commits

..

179 Commits

Author SHA1 Message Date
Johan Hedberg
2bd062c258 release: bump version to Zephyr 2.2.1
Update version to 2.2.1

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-29 11:50:11 +03:00
Johan Hedberg
d2160cbf4a doc: releases: Add release notes for Zephyr 2.2.1
Add the release notes for Zephyr 2.2.1.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-29 11:50:11 +03:00
David Brown
9a3aa3c9c3 updatehub: Require peer verification with DTLS
DTLS without peer verification offers no security whatsoever (and is
arguably worse than not using DTLS in the first place).

Change the verification option to require this peer verification.  To
use this, it may be necessary to install and use a root certificate.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-05-28 22:28:36 +03:00
François Delawarde
137ebbc43f bluetooth: host: fix wrong bt/cf settings loading
This commits fixes the loading of bt/cf settings into memory. Only data
was loaded and not the address.

Signed-off-by: François Delawarde <fnde@demant.com>
2020-05-27 12:37:37 +03:00
Andries Kruithof
a520506076 Bluetooth: controller: split: Update feature exchange to BTCore V5.0
The existing feature exchange procedure does not give the proper
response as specified in the BT core spec 5.0.
The old behaviour is that the feature-response returns the logical and
of the features for both peers.
The behaviour implemented here is that the feature-response returns the
featureset of the peer, except for octet 0 which is the logical and of
the supported features.
Tested by using the bt shell, and having different featuresets
on the 2 peers.

This fixes #25483

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-05-27 12:37:04 +03:00
Vinayak Kariappa Chettimada
2758c33e39 Bluetooth: controller: split: Fix slave latency cancel race
Fix missing transmit buffer demutiplexing before checking if
slave latency needs to be maintained or cancelled.

This bug was detected when new transmit buffer was enqueued
overlapping with on-air radio transmission of empty PDU
preceding the handling of radio event done.

Symptoms of this bug being data transmission latency of upto
slave latency plus one times connection interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-05-22 16:47:57 +03:00
Morten Priess
2fa7a7e977 Bluetooth: controller: Added support for vendor ticker nodes
With BT_CTLR_USER_TICKER_ID_RANGE it is possible for vendors to add a
number of ticker nodes for proprietary purposes. The feature depends on
BT_CTLR_USER_EXT.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-05-18 13:05:17 +03:00
Johan Hedberg
dbfc2ebc6b Bluetooth: Fix NULL pointer dereference when bt_send() fails
The last parameter to hci_cmd_done() is expected to be a valid net_buf
since the function immediately tries to dereference it. Fix this by
passing the appropriate buffer reference to the function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-06 11:56:34 +03:00
Trond Einar Snekvik
82083a90cc Bluetooth: Mesh: net_key_status only pull one key idx
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.

Fixes #24601.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-28 21:31:18 +03:00
Gerson Fernando Budke
341681f312 lib: updatehub: Improve probe security
Improve buffer overflow security on probe_cb. This ensures that socket
buffer have fixed lenght and content received by COAP fills properly on
metadata buffer. After that, ensures that metadata content is a valid
string with length lower than metadata size.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
3f4221db6f lib: updatehub: Refact to use bin2hex
Use bin2hex instead inline conversion.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
4d949eebef lib: updatehub: Fix variable-size string copy
A malformed JSON payload that is received from an UpdateHub server
may trigger memory corruption in the Zephyr OS. This could result
in a denial of service in the best case, or code execution in the
worst case.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-04-22 14:37:28 +03:00
Otavio Salvador
8e8ba2396c CODEOWNERS: Update UpdateHub owners
This replaces @chtavares592 with @nandojve as he will contributing to it
from now on.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit a3d6b627b7)
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
0e51f8bd79 lib: updatehub: Add missing do upgrade request call
After a success image download, UpdateHub needs inform MCUboot that
must test new image and then, on success, commit this new image. This
add missing upgrade request call step and fixes the upgarde flow.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit d1e2d345fb)
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
3e91120f2b lib: updatehub: Fix download block error
The current version aborts update when found last transfer block. Now,
system checks only at end of coap block transfer total size and install
if download is ok.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit 1128eab3f2)
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
fb244f7542 lib: updatehub: Extract sha256 final method
Extract finish sha256 calc method.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit 1fe1b0eec6)
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
f7ac49efe6 lib: updatehub: Fix buffer sizes
The MAX_PAYLOAD_SIZE must reflect the size of COAP_BLOCK_x. This is
necessary becase BLOCK size represents max payload size. The current
value create inconsistencies for coap lib. The same way,
MAX_DOWNLOAD_DATA must allocate sufficient space for MAX_PAYLOAD_SIZE
plus all space for coap header etc.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit 5f5919a900)
2020-04-22 14:37:28 +03:00
Gerson Fernando Budke
fce4c9e317 lib: updatehub: Fix build warnings
Fix all build warnings.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit 92f9cd9f85)
2020-04-22 14:37:28 +03:00
Flavio Ceolin
385f88242e net: coap: Fix possible overflow
Fix possible integer overflow when parsing a CoAP packet.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-04-22 13:02:46 +03:00
Flavio Ceolin
4e8e72bd4c math: extras: Add overflow functions to u16
Add functions to addition and multiplication for u16_t.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-04-22 13:02:46 +03:00
Vinayak Kariappa Chettimada
eee10e9aff Bluetooth: controller: split: Fix DLE duplicate requests
Fix implementation to handle back-to-back and duplicate
LENGTH_REQ PDU reception.

Relates to #23707.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-22 13:00:50 +03:00
Vinayak Kariappa Chettimada
b7e7153b95 Bluetooth: controller: split: Simplify DLE state checks
Simplify the Data Length Update Procedure state check when
processing incoming LENGTH_REQ/RSP PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-22 13:00:50 +03:00
Vinayak Kariappa Chettimada
525500123a Bluetooth: controller: split: Validate chan map and hop value
Add validation of channel map and hop increment value
received in CONNECT_IND PDU.

Zero bit count leads to controller assert or divide-by-zero
fault.

Hop increment shall be between 5 and 16 by BT Specification.

Relates to #23705.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-22 13:00:29 +03:00
Vinayak Kariappa Chettimada
ff39065ed4 Bluetooth: controller: Fix ticker ticks_current value
Update the ticks_current value on last stopped ticker
instance, so that when a new ticker instance is started
the anchor ticks calculation uses the correct current tick
with respect to supplied anchor ticks.

Fixes #23805.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-22 13:00:03 +03:00
Vinayak Kariappa Chettimada
1b253c2dba Bluetooth: controller: split: Fix slave latency during conn update
Fix regression in cancelling slave latency during Connection
Update Procedure.

Slave latency should not be applied between the ack of a
Connection Update Indication PDU and until the instant.
When caching was introduced, implementation missed this
consideration.

Relates to #23813.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-22 12:59:43 +03:00
Vinayak Kariappa Chettimada
37c46e3cf5 Bluetooth: controller: split: Fix regression in handling invalid pkt seq
Fix regression in handling invalid packet sequence in the
first packet in a connection.

This relates to commit 62c1e1a52b ("Bluetooth: controller:
split: Fix assert on invalid packet sequence")

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-22 12:59:20 +03:00
Andries Kruithof
c5f9a2d2bc [Backport-v2.2-branch] Bluetooth: controller: legacy: DLE timing
Fixes #23482.

There is a bug in calculation of time for the DLE procedure:
the preamble size is incorrect for the 2M phy

This is for the legacy code, see PR #23570 for the split controller

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-04-22 12:58:52 +03:00
Joakim Andersson
7e4bcff791 Bluetooth: SMP: Fix bond lost on pairing failure.
Fix an an issue where established bonding information in the peripheral
are deleted when the central does not have the bond information.
This could be because the central has removed the bond information, or
this is in fact not the central but someone spoofing it's identity, or
an accidental RPA match.

This is a regression from: a3e89e84a8

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-22 12:58:19 +03:00
Vinayak Kariappa Chettimada
ee4006e42e Bluetooth: controller: nRF: Revert use of ticker compat mode as default
Ticker is now fixed to avoid catch up of periodic timeout under
large ISR latencies.

Revert commit a749e28d98 ("Bluetooth: controller: split:
nRF: Use ticker compat mode as default").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-20 21:46:38 +03:00
Vinayak Kariappa Chettimada
bec2a497b9 Bluetooth: controller: Consider must_expire while avoiding catchup
If must_expire is set for a ticker instance, then ticker
expiry shall still perform catchup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-20 21:46:38 +03:00
Vinayak Kariappa Chettimada
2295af0f05 Bluetooth: controller: Fix ticks_slot_previous calculation
Fix ticks_slot_previous calculation in the ticker_job when
tickers are skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-20 21:46:38 +03:00
Vinayak Kariappa Chettimada
8e12b42af2 Bluetooth: controller: Fix ticker state on skipped
Reset ticker state in ticker_job for ticker instances that
have been skipped in the ticker_worker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-20 21:46:38 +03:00
Vinayak Kariappa Chettimada
a3c2a72c6c Bluetooth: controller: Remove lazy handling in ticker_worker
Removed lazy handling from ticker_worker as it is now taken
care in ticker_job.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-20 21:46:38 +03:00
Vinayak Kariappa Chettimada
c2e829ba8c Bluetooth: controller: Fix ticker catch up on ISR latency
Fix ticker to avoid catch up of periodic timeouts in case of
large ISR latencies like in case of flash erase scenarios.

Relates to #23815.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-04-20 21:46:38 +03:00
Andries Kruithof
b83d9a5eea Bluetooth: controller: split: correct timing calculation in PKT_US
A bug in the PKT_US resulted in wrong calculations for the 2M phy.
Fixes the bug, verified on EBQ.
Also adds some defines for improved readability.

Fixes #23482

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-04-12 11:54:29 +03:00
Carles Cufi
a69cdb31ca ci: do not use latest sphinx/breathe releases for docs
Sphinx version 3.0.0 release recently break doc build, lock version
of sphinx to something compatible while we upgrade dependencies...

breathe v4.15.0 was just released and fixes some compatibility issues
with latest sphinx, the combo works, however with many warnings that we
still need to either fix or whitelist. This is temporary until we are
able to use those new versions.

Backport of #24109 and #24166

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-04-08 17:14:25 +02:00
Dan Erichsen
d39cb42d09 bluetooth: host: Do not send unwanted SC indicate
Fixes #23485

When we create a GATT table dynamically, we also create a hash
identifying this table. This hash can be stored in persistent memory and
we can thus determine after recreating the GATT table whether the
services have changed or not from before the reboot.

When these hashes are identical, it implies that the table has not
changed, wherefore a service changed indication should not be sent to
any bonded clients. The method for achieving this was to remove the
gatt_sc.work entry from the work queue. This work queue entry was to
send an indication to the clients when the table had been allocated.
If the final entry then caused the hashes to match, the indication
would be cancelled.

On unit testing this behaviour in simulation and in practice, we found
that the indication was sent nonetheless, and the issue was located to
be tied to the SERVICE_RANGE_CHANGED flag which is set when the services
are changed and is cleared when the indications are being sent out.

It was the job of the work queue entry to clear this flag, and as the
entry was never serviced, the flag was never cleared, and when
sc_commit() is called at the end of the process, it believes that there
is a new service change pending and therefore starts the job over, thus
creating a redundant indication to the clients.

This commit fixes the issue by clearing the flag when the work entry
is removed due to a hash match. This has been unittested in a live
environment, in a simulation environment, and sanitycheck has been run
on it.

Signed-off-by: Dan Erichsen <daee@demant.com>
2020-03-17 18:16:57 +01:00
Wolfgang Puffitsch
9d83a7cd27 Bluetooth: controller: split: Fix response to unexpected LL_FEATURE_RSP
Fix response to unexpected LL_FEATURE_RSP for the case that
BT_CTLR_SLAVE_FEAT_REQ is disabled. Fixes LL/PAC/SLA/BV-01 for such a
configuration.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-03-17 18:16:47 +01:00
Johan Hedberg
9518bd19b7 release: Zephyr 2.2.0
Bump version to 2.2.0 final.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-10 10:49:52 +02:00
Johan Hedberg
883f1aede0 doc: Update generated version list for 2.2.0
Add 2.2.0 to the version pick list. Also remove old versions so that
the oldest one is the LTS release.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-10 10:49:52 +02:00
Johan Hedberg
ee4a28e127 doc: release notes: Update contents for 2.2.0
Finalize the release notes for Zephyr 2.2.0.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-10 10:49:52 +02:00
Anas Nashif
497fe4267a release: update sanitycheck footprint file
Update for latest release.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-09 23:40:45 +02:00
Carles Cufi
dad082d170 doc: gsg: Link to the gatekeeper section from the toolchains
Add a warning about the Gatekeeper issues that Catalina introduces in
the section about GNU Arm Embedded.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-09 21:56:58 +02:00
Carles Cufi
4a45ceaf62 doc: gsg: Remove duplicate information for Windows
The GSG already includes the setup instructions. Remove the
duplicate that existed in installation_win.rst.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-09 21:56:58 +02:00
Carles Cufi
e35f86aae6 doc: gsg: Remove duplicate information for macOS
The GSG already includes the setup instructions. Remove the duplicate
that existed in installation_mac.rst.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-09 21:56:58 +02:00
Carles Cufi
a997a803a3 doc: gsg: Minor macOS clarification
The check for updates sequence applies to Mojave and later versions.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-09 21:56:58 +02:00
David Brown
dfc276f1be doc: release notes: Update v2.2 for security
Add additional CVEs addressed in this release.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-03-09 21:37:25 +02:00
Francois Ramu
abd8ca94c2 soc: arm: stm32g474 config device
This patch aligns the Kconfig.defconfig.stm32g474re to the
Kconfig.defconfig.stm32g431rb

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-03-09 17:26:40 +02:00
Francois Ramu
cea65cb9cc board: arm: nucleo_g474re reflashing board
Reflash the nucleo_g474re successively

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-03-09 17:26:40 +02:00
Gerson Fernando Budke
2cfb11e050 drivers: ieee802154: rf2xx: Rem trx_state variable
The rx timeout timer callback need update trx_state variable and this
variable is protected by a mutex. Because of that, when compiling the
system with CONFIG_ASSERT=y the system reports 'ASSERTION FAIL
[!arch_is_in_isr()] @ ZEPHYR_BASE/kernel/include/ksched.h:262'.

This refactor the driver remove trx_state variable dependency and
consequently removes phy_mutex and rx timeout timer to be compliant
with kernel rules.

Fixes: #23198

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke
4c6ee8b3d9 boards: arm: atsamr21_xpro: Fix corrupted frames on rf2xx
When using internal IEEE 802.15.4 transceiver AT86RF233 at SPI speeds
above 6MHz was detected that frame buffer read returns corrupted data.
This set spi-max-frequency to 6MHz at atsamr21_xpro.dts to ensure best
relation of performance vs reliability.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke
be56e36fe4 drivers: ieee802154: rf2xx: Add RX improvements
The current version of at86rf2xx RX implementation don't uses advanced
capabilities offer by the transceiver. This access SRAM space to gatter
PHR information in parallel with transceiver frame reception. It allows
improve RX reception by handling properlly the frame protection feature
removing transceiver states changes.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke
287f654e68 drivers: ieee802154: rf2xx: Refactor rf2xx_thread_main
Current rf2xx_thread_main code have too many if/for/while imbrication.
Extract methods from rx2xx_thread_main for better readability.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke
d4f39742ea drivers: ieee802154: rf2xx: Add SRAM read method
Add SRAM read method to enable advanced uses on at86rf2xx driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Wayne Ren
5f0650b596 arch: arc: fix the bug of blt in syscall
blt is signed comparsion, if r6 is a negative number created by
malicious code, it will pass the check, bring a secure risk.

use blo (unsinged comparison) to do the check.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2020-03-09 10:08:18 +02:00
Johan Hedberg
bf8caf3956 doc: release notes: Remove TBD entry from Build and Infrastructure
There's presumably no more items coming to this section, so remove the
TBD bullet point.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-07 21:00:10 +02:00
Johan Hedberg
6ec317b2de doc: release notes: Add some information for ARC
ARC didn't have many changes, but there's a bunch of irq-related
fixes since the last release, so mention these.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-07 21:00:10 +02:00
Flavio Ceolin
4b2fc256cf sys: usermode: Document 0 size buffer memory check
Documenting that 0 size buffer has undefined behavior.
See: https://github.com/zephyrproject-rtos/zephyr/pull/23239

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-07 13:12:51 +02:00
Flavio Ceolin
8ed4b62dc0 syscalls: arm: Fix possible overflow in is_in_region function
This function is widely used by functions that validate memory
buffers. Macros used to check permissions, like Z_SYSCALL_MEMORY_READ
and Z_SYSCALL_MEMORY_WRITE, use these functions to check that a
pointers passed by user threads in a syscall.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-07 13:12:51 +02:00
Armand Ciejak
38a2e2cf89 drivers: eth: mcux: Write correct data into override register
Do not use the content of the status register to write into the
override register because it may have unpredictable effect,
instead to a read/modify/write on the override register.

Signed-off-by: Armand Ciejak <armandciejak@users.noreply.github.com>
2020-03-07 09:23:47 +02:00
Armand Ciejak
a3d413c51a drivers: eth: mcux: Fix PHY access in eth_mcux_phy_setup
It is necessary to poll the ENET_EIR_MII bit before reading
the data register as explained in the i.MX RT1060 reference
manual in chapter 41.7.17.4.
Use PHY_* functions from NXP HAL to correctly access the PHY
registers.

Signed-off-by: Armand Ciejak <armandciejak@users.noreply.github.com>
2020-03-07 09:23:47 +02:00
Andrew Boie
d6d42bef97 drivers: gpio: fix syscall handlers
No driver object checks were being performed for 3 APIs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-07 09:22:50 +02:00
Andrew Boie
f669b7cb9f drivers: kscan: fix syscall handlers
No check of the driver object was being performed for two
APIs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-07 09:22:50 +02:00
Ioannis Glaropoulos
61fc061fc4 tests: kernel: userspace: extend bad syscall-ID test-case
Extend the bad syscall-ID test case to cover
erroneously supplied larged unsiged syscall-ID
values.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-07 09:22:23 +02:00
Ioannis Glaropoulos
502b67ceba arch: arm: aarch32: userspace: fix syscall ID validation
We need an unsigned comparison when evaluating whether
the supplied syscall ID is lower than the syscall ID limit.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-07 09:22:23 +02:00
Martí Bolívar
fe6107f2b3 doc: finish reworking the board porting guide
Now that the west parts of this file are in better shape, it seems a
shame not to flesh out the rest a bit more.

It's been a while since we looked at this document, as it's still
referring to boards (like Arduino 101) that are no longer supported by
Zephyr, and is generally lacking in concrete, step-by-step advice
for going from zero to working board.

Let's fix that.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-06 19:31:06 +02:00
Daniel Leung
c3701f51d7 adc: mchp_xec: right justify ADC output data under 10-bit res
This enables the ADC output data to be shifted right when using
10-bit resolution. Or else, data would be left justified as if
it's doing 12-bit ADC with the right 2 bits filled with zeroes.

Fixes #23202

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-03-06 19:29:09 +02:00
Daniel Leung
7f2996b061 west: update Microchip HAL to latest version
This includes the following changes:
- modules: Fix bugs in ECIA and PECI headers
- modules: Fix bug in MEC1501 TACH header
- mec1501: fix bits for setting 10-bit ADC resolution

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-03-06 19:29:09 +02:00
Stephanos Ioannidis
9aed7fb040 drivers: serial: uart_sam0: Fix interrupt connection
This commit fixes the multiple SERCOM interrupt handling for the SAM
D5x and E5x devices by replacing the obsolete device tree symbol with
the new `DT_INST` symbol.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-06 18:34:12 +02:00
Johan Hedberg
80ea034f7d doc: release notes: Include LoRa in major features
Add LoRa to the major feature list of 2.2.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-06 18:26:05 +02:00
Joakim Andersson
bb42abdd7c Bluetooth: host: Fix LE SC OOB authentication and id for central role
If the application has used bt_le_oob_get_local to retrieve the OOB
RPA address and OOB authentication information the central role should
use this RPA address for the next RPA timeout period.

The central role always refreshes the RPA address for the initiator,
this will make the OOB information not usable as the peer cannot
recognize the central role since the RPA address is changed.
Check if the initiator can use the address for the duration of the of
remaining RPA period.

Fix central role using the advertiser identity when setting the private
address. The central role should only use the default identity.

Regressions from:
fbe3285bfa
and
4876a8f39a

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-06 18:25:48 +02:00
Alexey Eremin
6f3f3c230c Bluetooth: Make macro definition compatible with 7-2018-q2-update g++
In C++ designated initializers require that designators used in the
expression must appear in the same order as the data members.

In addition, 7-2018-q2-update version of g++ doesn't support
implicit member initialization, so all members must be
initialized.

Signed-off-by: Alexey Eremin <a.eremin.msu@gmail.com>
2020-03-06 11:27:46 +02:00
Flavio Ceolin
a2872c3a00 shell: utils: Fix buffer overrun in shell_spaces_trim
The third argument in memmove can possible be greater than remaining
buffer size. Just ensuring that memmove will changes bytes only inside
the string buffer and nothing else.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-06 10:08:46 +02:00
Joakim Andersson
c97e1aafb1 Bluetooth: Mesh: Fix possible NULL dereference in BT_DBG statement.
Fix possible NULL dereference in BT_DBG statement when
bt_mesh_friend_get is called before a successful cfg_srv init

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-06 10:04:46 +02:00
Trond Einar Snekvik
2835da8194 Bluetooth: Mesh: Fix cdb key update iteration
Fixes copy/paste error taking the size of the the wrong array.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-03-05 20:33:07 +02:00
Flavio Ceolin
46330f13ed doc: release notes: Add 2.2 update mbedTLS
Update libraries section with the mbedTLS version

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-05 12:39:30 +02:00
Flavio Ceolin
759c41ea3f doc: release notes: Add 2.2 release notes for security
Added notes about CVE's assigned in this release.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-05 12:39:30 +02:00
David Brown
4759da8819 doc: security: Create a vulnerabilities report
In addition to having security vulnerability fixes reported within each
release note page, consolidate all of them in a new vulnerabilities
document.

This gives us two advantages: 1. The vulnerabilities can easily be
referenced in a single place, which is useful for someone trying to
cross reference against CVE lists, and 2. It allows a release to be made
with just CVE numbers when issues are under embargo, and the details can
be added to this vulnerabilities page.  The release notes will be locked
to a tag, and updates will not be visible.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-03-05 12:39:13 +02:00
Andrew Boie
8d5bb88aa7 doc: add x86 and core kernel release notes
Add x86 and core kernel release notes for 2.2.0.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-05 10:28:22 +02:00
Carles Cufi
345d4f51c1 doc: gsg: macOS: Describe Gatekeeper workarounds
Describe how to work around the Gatekeeper enforcement of security
policies in apps launched from the Terminal.

Fixes #23168.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-05 09:43:27 +02:00
Gerson Fernando Budke
f7564323f5 drivers: eth: sam_gmac: Add priority queue checks
Improve priority queue conditional build. Now priority queue code is
enabled only if device have support to it. This enables GMAC driver
for devices with only one queue for RX/TX.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-04 23:11:42 +02:00
Gerson Fernando Budke
51f7fc8fba drivers: eth: eth_sam_gmac: Move queue init block
Move queue init block to avoid add many defines on code.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-04 23:11:42 +02:00
Gerson Fernando Budke
04e6045505 drivers: eth: eth_sam_gmac: Fix priority queues
The Atmel SAM SoC with ethernet port uses same GMAC driver. However,
there are differences between SoC GMAC implementation. Some SoCs have
priority queue and system can configure 0 up to 5, depending of SoC
version. This update current GMAC driver adding missing definitions.

Co-authored-by: Stephanos Ioannidis <root@stephanos.io>
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-04 23:11:42 +02:00
Gerson Fernando Budke
dc277a8733 drivers: eth: Kconfig.sam_gmac: Fix queue definitions
Add missing queue entries for sam gmac. This update the queue selection
to proper handle all supported SAM SoC that uses GMAC driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-04 23:11:42 +02:00
Daniel Glöckner
47ea3c4e2c drivers: eth: sam-e70: revision B has more queues
The first revision of the SAM E70 soc had three queues. The current
revision B has six queues. If we don't initialize all queues, the DMA
engine gets stuck when trying to read a descriptor from NULL. To enable
the initialization of the additional queues, the correct soc has to be
selected in the config options, f.ex. CONFIG_SOC_PART_NUMBER_SAME70Q21B
instead of CONFIG_SOC_PART_NUMBER_SAME70Q21.

Also rename GMAC_QUEUE_NO to GMAC_QUEUE_NUM as requested during review.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2020-03-04 23:11:42 +02:00
Jaron Kelleher
d63651dd01 riscv machine timer: Timer functions on long running platforms
When debugging on a long running platform, the MCU may get reset by
the debugger with an ndmreset toggle. Since there is no requirement
that this resets anything in particular on the platform, the CLINT
registers may not get reset. When this occurs with an mtime register
value that is larger than 32 bits the riscv machine timer will
continuously interrupt the system when the mtime register exceeds 32
bits in value. This is because the last_count value is used to update
the mtimecmp register, and its value is initialized to zero. Its
first update is with a 32-bit value, which loses information when the
mtime register exceeds 32 bits.

The proposed solution is to set the last_count value to the current
value in the mtime register when the timer is initialized. Since the
timer is fired at intervals that are less than 32 bits in value, the
next update of last_count will remain valid, and the system will
function as expected.

Signed-off-by: Jaron Kelleher <jkelleher@fb.com>
2020-03-04 23:08:49 +02:00
Martí Bolívar
180cbf1a00 doc: more board porting improvements
Incorporate more feedback suggested in #23080.

Suggested-by: Lucian Copeland <hierophect@gmail.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-04 22:37:52 +02:00
Martí Bolívar
748c7757ea samples: blinky: clean up error on unsupported board
This sample requires led0 in the board devicetree's /aliases.
Improve the error message when that is not available.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-04 21:50:43 +02:00
Carles Cufi
cf2d474adf doc: gsg: Add a note about blinky
Add a note that describes the fact that blinky does not run on all
boards supported by Zephyr, and propose an alternative (Hello World) for
those boards.

Fixes #23169.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-04 21:50:43 +02:00
Carles Cufi
f80164525f samples: blinky: Improve documentation
Improve the documentation of the blinky sample, fixing typos, adding
links to the relevant DT documentation and cleaning up a bit.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-04 21:50:43 +02:00
Martí Bolívar
67d8f755e2 runners: misc-flasher: hotfix
The 'command' command line argument for this flasher is now being
overridden by common code, which attaches the west subcommand name to
this.

Let's just hotfix this by renaming the argument in misc-flasher.
We can revisit the boundary between run_common.py arguments and
runners package arguments after the release.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-04 21:48:09 +02:00
Maureen Helm
d3957fb1f9 doc: release notes: Add 2.2 changes for all remaining drivers
Adds 2.2 release notes for all remaining driver classes. Moves RISC-V
driver changes from the architectures section to the drivers section.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-03-04 20:29:24 +02:00
Carles Cufi
6147bd3168 samples: sensor: bme680: Add an overlay
Add an overlay for the nRF52840 to be able to build the sample.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-04 20:29:00 +02:00
Carles Cufi
340ead4239 samples: sensor: bme280: Add overlay
And an overlay for the nRF52840 DK to be able to build the sample after
the transition to Device Tree.

Fixes #23148.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-04 20:29:00 +02:00
Piotr Mienkowski
18a744861f boards: set CONFIG_WDT_DISABLE_AT_BOOT=y for all Atmel SAM boards
On Atmel SAM family the watchdog peripheral is enabled by default. To
ease maintenance of tests and samples, which typically don't handle
watchdog, disable the watchdog during the boot.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-03-04 18:25:04 +02:00
Piotr Mienkowski
7e0f31e3e7 samples: tests: don't disable watchdog when it is used
To ease maintenance of samples and tests some SoCs define
CONFIG_WDT_DISABLE_AT_BOOT=y to disable the watchdog. Ensure the option
is set to n for samples and tests that require watchdog module not to be
disabled during boot.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-03-04 18:25:04 +02:00
Piotr Mienkowski
e609ad0c43 Revert "drivers: watchdog: Make WDT_DISABLE_AT_BOOT default to y"
This reverts commit 382e6fbccf.

Disabling watchdog at boot breaks watchdog API contract. Production
firmware should never ship with the option enabled. Unfortunately, this
is dangerosly easy to overlook. If left enabled, in the best case, it
will degrade functionality of the subsystem. In the worst case it
will leave watchdog permanently disbled.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-03-04 18:25:04 +02:00
Johann Fischer
23ace0e556 usb: mass_storage: check LBA range
Check if LBA is in range of the memory size.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-03-04 17:14:52 +02:00
Johann Fischer
c88155fd2d usb: mass_storage: fix possible page buffer overflow
The page buffer can overflow if dCBWDataTransferLength
is multiple of the BLOCK_SIZE but the host uses
OUT packets smaller than MPS durng transfer.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-03-04 17:14:52 +02:00
Anders Montonen
219d9fc082 kconfig: Fix typo in ARM_MPU help
The ARMv7-M MPU requires power-of-two alignment, not the ARMv8-M MPU, as
noted a few lines later.

Signed-off-by: Anders Montonen <Anders.Montonen@iki.fi>
2020-03-04 10:18:27 +02:00
Johann Fischer
e0318ff3ee doc: release notes: refine USB relese notes
Refine USB relese notes.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-03-04 09:36:46 +02:00
Johan Hedberg
de3c5ae9ff doc: release notes: Add information for Xtensa SoCs and boards
Mention the Intel Apollolake Audio DSP SoC and board that were added
for Zephyr 2.2.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-03 19:05:43 +02:00
Emil Obalski
a95298e54a doc: release notes: Add 2.2 release notes for USB subsystem
Added usb related notes for Zephyr 2.2

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-03-03 18:40:28 +02:00
Ravi kumar Veeramally
cfd0f3e18d tests: net: Enable NET_IPV4_HDR_OPTIONS in tests
Test case for IPv4 header options was added but
CONFIG_NET_IPV4_HDR_OPTIONS option was not enabled.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-03-03 16:50:32 +02:00
Ravi kumar Veeramally
491367115d net: ipv4: Fix compilation errors
opts_len renamed to total_opts_len in previous changes.
But it's not replaced at one place.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-03-03 16:50:32 +02:00
Krzysztof Chruscinski
0cc209d5b2 doc: release notes: Add 2.2 release notes for logging subsystem
Added entry regarding changes in the logger.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-03 14:01:56 +02:00
Krzysztof Chruscinski
ea331fd03f doc: release notes: Add 2.2 release notes for nrf_uarte serial driver
Added entry regarding UARTE driver implementation changes.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-03 14:01:56 +02:00
Krzysztof Chruscinski
e81a3ee8c2 doc: release notes: Add 2.2 release notes for clock control
Added entry regarding clock_control driver implementation changes.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-03 14:01:56 +02:00
Jan Van Winkel
e5ddc31f74 doc: release notes: Add display related release notes
Added display related release notes for Zephyr 2.2

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-03-03 09:31:14 +02:00
Martí Bolívar
f2469ce576 doc: board_porting: add link to west flash/debug info
Makes this page a little more visible to porters.

Suggested-by: Lucian Copeland <hierophect@gmail.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-03 09:30:32 +02:00
Martí Bolívar
24ce05c841 doc: improve west flash help for dfu-util
Try to make it clearer what's going on here.

Suggested-by: Lucian Copeland <hierophect@gmail.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-03 09:30:32 +02:00
Carles Cufi
8a5063924c doc: relnotes: Add Bluetooth Controller 2.2 release notes
Fill the Bluetooth Controller section in the 2.2 release notes.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-02 22:50:01 +02:00
Flavio Ceolin
fbeaa0a510 kernel: Stack pointer random depends on MULTITHREADING
Don't pretend with have stack randomization without multithreading.
When multithreading is disabled the "main" thread never starts. Zephyr
will run on the stack used for the z_cstart(), which on most
architectures is the interrupt stack.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-02 22:49:37 +02:00
Tomasz Bursztyka
18dee338d8 doc: release notes: Add 2.2 release notes for DMA
DW and STM32 changes added.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-02 21:27:46 +02:00
Carles Cufi
53431884c3 doc: toolchains: Remove warning about GNU Arm 8
Since the latest version available for download works well, there is no
reason anymore to warn the users about a particular, older toolchain
version not working correctly on Windows.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-02 21:27:30 +02:00
Johan Hedberg
50a396720d doc: release process: Update release creation instructions
Fix the GitHub web UI button name, and update the instructions to use
signed tags.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-02 19:36:51 +02:00
Johan Hedberg
8d645b4a8e doc: release notes: Add 2.2 changes for Bluetooth Mesh
Add release notes for Bluetooth Mesh.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-02 19:36:29 +02:00
Johan Hedberg
0280e0a471 doc: release notes: Add 2.2 changes for Bluetooth host
Add release notes for the Bluetooth host.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-02 19:36:29 +02:00
Johan Hedberg
ede8f165af doc: release notes: Add 2.2 changes for Bluetooth drivers
Add release notes for Bluetooth drivers.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-02 19:36:29 +02:00
Carles Cufi
b3bb324735 doc: gsg: Update SDK version
Several users have noticed that the SDK version in the GSG is outdated.
Update it to the latest, 0.11.2.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-02 18:52:10 +02:00
Andrzej Puzdrowski
177e075bb5 doc/releases/release-note-2.2: setting sample addition
Add info on introduction of the settings sample.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-03-02 17:41:21 +02:00
Andrzej Puzdrowski
f39f762054 doc/releases/release-note-2.2: flash driver part
Described changes in flash driver implementations.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-03-02 17:41:21 +02:00
Johann Fischer
105849cf38 usb: dfu: check requested length (wLength) during DFU_UPLOAD
During DFU_UPLOAD, the host could requests more data
as stated in wTransferSize. Limit upload length to the
size of the request buffer (USB_REQUEST_BUFFER_SIZE).

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-03-02 17:37:24 +02:00
Johan Hedberg
5372e78827 release: Zephyr 2.2.0-rc3
Bumped to v2.2.0-rc3

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-02-29 21:10:38 +02:00
Vinayak Kariappa Chettimada
4bacb0e098 Bluetooth: controller: legacy: Fix cond. compile error
Fix conditional compilation error when enabling
BT_CTLR_FAST_ENC for central only application builds.

Also added additional compilation to code exclusive to
central or peripheral role.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-29 19:39:41 +02:00
Martí Bolívar
dc0948424e scripts: run_common: fix command line --hex-file and friends
This is yet another bug introduced by the move to runners.yaml.
Sigh. I should have tested this better.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-29 19:38:49 +02:00
Martí Bolívar
f8cb3d4d53 scripts: run_common: rename 'args' to 'user_args'
This will also make the reason for a following bug fix easier to see.

Update a comment block to include all the work that needs doing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-29 19:38:49 +02:00
Martí Bolívar
97dbda2088 scripts: run_common: rename unknown_args to user_runner_args
This makes its true value clearer, and will make a later bug fix patch
easier to understand.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-29 19:38:49 +02:00
Vinayak Kariappa Chettimada
ca66f5b2e5 tests: Bluetooth: shell: Fix conditional compile error
When building the tests/bluetooth/shell application without
the BT_CENTRAL feature, compilation fails:

subsys/bluetooth/shell/bt.c:1642: undefined reference to
`bt_conn_create_auto_le'

Signed-off-by: Vinayak Kariappa Chettimada <vinayak.kariappa@gmail.com>
2020-02-29 10:47:18 +02:00
Ravi kumar Veeramally
2709b14bcb tests: net: Add wrong options length case
Wrong option length in IPv4 header options testcase
added. This should cover malformed packet case.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-02-28 22:34:11 +02:00
Ravi kumar Veeramally
22f93b35ab net: ipv4: Fix parsing of IPv4 header options
If IPv4 header options has wrong options length
(e.g. options length is more that actual data),
then parser decrements opts_len without checking
actual data length. Which crashes the network stack.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-02-28 22:34:11 +02:00
Tobias Svehagen
60563977df Bluetooth: Mesh: Fix handling of app index and local device key
Fix problem of not checking if the remote device key is actually our
own. This bug was intruduced in
46a95f12ad and causes failure of models
that use app_idx BT_MESH_KEY_DEV_REMOTE. Since this is used by cfg_cli,
it was not possible to do self-configuration.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-02-28 20:18:54 +02:00
Daniel Leung
2ac3a85273 soc: mec1501: wait for UART FIFO clear before deep sleep
It is observed that after each test, weird characters appear on
console. This problem goes away if deep sleep is disabled.
The theory is that the CPU runs to deep sleep (_sys_suspend())
faster than UART can shift all the bits out. If we spin wait
for UART FIFO to clear, this is no longer an issue. This is
circumstantial evidence to the theory. So for now, put in
a workaround to spin wait for UART FIFO to clear before
going into deep sleep.

Relates to #22885

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-02-28 20:18:13 +02:00
Jukka Rissanen
67e43a21c8 doc: release notes: Add information about GSM modem
The Modem chapter was missing mention about generic GSM modem
support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-02-28 16:37:41 +02:00
Martí Bolívar
647fe7a47a doc: dts/macros.rst: "clocks" macro fixes
The "fixed-clock" value referenced in the documentation is actually a
compatible value, not a property name. Fix that.

Harden the "expected to have a clock-frequency property" language to
use "must" instead of "expected". The scripts error out if a node with
fixed-clock compatible is missing a clock-frequency property; it's not
a soft expectation.

Be explicit about clock-frequency units.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-28 12:50:36 +02:00
Vinayak Kariappa Chettimada
f972fb057d Bluetooth: controller: Add Kconfig for Optimize for Speed
Add Kconfig option to support building the controller
optimized for speed.

Fixes #21601.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-28 10:55:33 +02:00
Vinayak Kariappa Chettimada
e1d9620187 Bluetooth: controller: legacy: Fix assert on DLE procedure stall
Fix local initiated Data Length Update procedure from being
stalled when a remote initiates a procedure with instant.

Fixes #23069.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-28 10:02:15 +02:00
Stephanos Ioannidis
fa19193898 boards: qemu_cortex_r5: Add board documentation
This commit adds the board documentation to the qemu_cortex_r5
platform.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-28 09:55:39 +02:00
Alexander Wachter
b96477dd69 SoC: SAM3x and SAM4: Add the Flash Controller to the DT
This commit adds Device-Tree instances of the Flash controller
to the SAM3X, SAM4E and SAM4S series. The Flash-Controller
is used to get the unique device identifier.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
a22f0ac1ab drivers: hwinfo: Don't disable CLOE on SAM3x seies
CLOE (Code Loop Optimization) does not exist on SAM3x.
Make the EEFC_FMR_CLOE disable depending on CONFIG_SOC_SERIES_SAM3X.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
4cfd4a707d SoC: stm32: Include LL utilities if HWINFO is selected
Include stm32XXxx_ll_utils.h in soc.h for every stm32 SoC,
if CONFIG_HWINFO_STM32 is selected.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
57bd09186b boards: Remove "supported: -hwinfo" from all boards
Remove all "supported: -hwinfo" definitions from the boards
yaml files and documentation. hwinfo can generally be tested
on every board because it returns -ENOTSUP if not supported.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
e49de0d866 drivers: hwinfo: Exclude NRF53 non-secure from hwinfo driver
Make the NRF hwinfo driver depending on !TRUSTED_EXECUTION_NONSECURE
because the FICR registers are not accessible from the non-secure
world.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
41b2f0a599 tests: hwinfo: Make the tests depending on HWINFO_HAS_DRIVER
The test checks for a correct implementation if HWINFO_HAS_DRIVER
is set, otherwise it checks for -ENOTSUP return value.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
39e4686d48 drivers: hwinfo: Introduce HWINFO_HAS_DRIVER Kconfig symbol
Introduce the HWINFO_HAS_DRIVER Kconfig symbol to get
the information if hwinfo is supported on the current platform.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Alexander Wachter
75724bf299 doc: hwinfo: Clarify return values.
Change the doxygen doc from "negative on error" to -ENOSUP and
negative value on driver specific errors.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Carles Cufi
02b630d494 Bluetooth: tester: Fix GATT service registration
The service registration logic was using the wrong variable to check for
a pending service to be registered, which led to the same service being
registered twice in some cases. Fix the logic so that a pending service
is only registered once.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-02-27 21:21:46 +02:00
Ioannis Glaropoulos
dca762f8ff tests: arch: arm_thread_swap: test FPSCR preservation in FP_SHARING
Under Sharing FP registers mode we would like to verify the
correct preservation of FPSCR during thread context switch.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-27 19:26:04 +02:00
Luuk Bosma
dfb80526b4 arch: arm: aarch32: clear CONTROL.FPCA for every CPU that has a FPU
Upon reset, the CONTROL.FPCA bit is, normally, cleared. However,
it might be left un-cleared by firmware running before Zephyr boot,
for example when Zephyr image is loaded by another image.
We must clear this bit to prevent errors in exception unstacking.
This caused stack offset when booting from a build-in EFM32GG bootloader

Fixes #22977

Signed-off-by: Luuk Bosma <l.bosma@interay.com>
2020-02-27 19:26:04 +02:00
Luuk Bosma
cc21aba55f arch: arm: aarch32: clear CPACR for every CPU that has a FPU
Upon reset, the Co-Processor Access Control Register is, normally,
0x00000000. However, it might be left un-cleared by firmware running
before Zephyr boot.
This restores the register back to reset value, even if CONFIG_FLOAT
is not set.
Clearing before setting supports switching between Full access
and Privileged access only.

Refactor enable_floating_point to support initialize
floating point registers for every CPU that has a FPU.

Signed-off-by: Luuk Bosma <l.bosma@interay.com>
2020-02-27 19:26:04 +02:00
Andries Kruithof
2c70df32b7 Bluetooth: controller: split: Fix regression errors
This commit fixes problems with LL tests CON/SLA/129, CON/SLA/130,
CON/SLA/132, CON/MAS/126, CON/MAS/127, CON/MAS/129, CON/MAS/55,
CON/SLA/57

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-02-27 19:14:32 +02:00
Joakim Andersson
5c1963b1c5 Bluetooth: tests: shell: Add missing dependency in mesh.conf
Add missing dependency in mesh.conf.
Handles this warning: Warning: BT_MESH_SHELL was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies:
BT_MESH_HEALTH_CLI (=n)

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-27 13:45:18 +02:00
Joakim Andersson
98827e9f6d Bluetooth: tests: shell: Remove config not supported on native_posix
Remove CONFIG_CONSOLE_HANDLER from project configuration. When building
for native_posix this produces the following warning:

warning: CONSOLE_HANDLER was assigned the value 'y' but gotthe value 'n'
Check these unsatisfied dependencies: SERIAL_SUPPORT_INTERRUPT (=n)

The shell works without this option since this is handled by the shell
itself instead.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-27 13:45:18 +02:00
Christian Taedcke
169f4865e4 editorconfig: Set max_line_length to 80
This way editors like emacs can highlight lines that are too long.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2020-02-27 12:57:23 +02:00
Erwan Gouriou
73f7028eb0 doc: Update shields section in V2.2 release note
Document noteworthy changes that will be released in V2.2.0

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-27 12:55:39 +02:00
Vinayak Kariappa Chettimada
7a3e29af06 Bluetooth: controller: legacy: Fix Tx pool corruption
Fix Tx pool from being corrupted when rough central device
uses invalid packet sequence numbers, causing NULL pointer
to be released into free data Tx pool.

Fixes #22968.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-27 12:54:35 +02:00
Daniel Leung
bf50aae693 xtensa: save/restore scompare1 during context switch
Xtensa uses two instructions to perform atomic compare-and-set
instruction: first the comparison register, then the actual
instruction to do compare-and-set. There is a potential that
context switching is performed before these two instructions.
A restored context may have the wrong value in the comparison
register. So we need to save and restore the comparison
register during context switching.

Fixes #21800

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-02-27 12:42:26 +02:00
Tobias Svehagen
7a737a0084 Bluetooth: Mesh: Fix bug with storing node in CDB
The free_slot->clear must be set to false since it could still be true
from previous use.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-02-27 12:40:19 +02:00
Alberto Escolar Piedras
2836513cd6 doc: release notes: Content for POSIX arch
Nothing significant has happened in the POSIX arch,
so just leave that section with an N/A

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2020-02-27 12:31:25 +02:00
Rubin Gerritsen
3a30eed083 bluetooth: Fix wrong warning text for unsupported Zephyr HCI commands
They were interchanged.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-02-27 12:31:01 +02:00
Dag Bjarvin
1a43a798e7 Bluetooth: controller: Merge 2 lines
Merge 2 lines that fit on one line

Signed-off-by: Dag Bjarvin <Dag.Bjarvin@nordicsemi.no>
2020-02-27 12:30:44 +02:00
Dominik Ermel
d09009d7c5 subsys/mgmt: Fix incorrect buffer space check
zephyr_smp_write_at is supposed to write len bytes of data at
the offset of a given net_buf, overwriting existing data and extending
beyond current buffer length, if needed. Unfortunately condition
checking if written data would fit within the buffer size has been
incorrectly implemented, making write impossible, when there has been
less bytes of space left within buffer tailroom than required to write
len bytes of data, even if len bytes written starting at given offset
would not cross the buffer boundary.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-02-27 12:28:22 +02:00
Jennifer Williams
d6373a38af samples: subsys: nvs: unchecked return values CID#203537
The sample contained calls that were not using the return
value, which was detected by Covery Scan as an issue. This
commit fixes it by changing to (void).

Fixes #18378
CID#203537

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2020-02-27 11:38:01 +02:00
Dominik Ermel
dd41b12250 tests/subsys/fs/fat: Incorrect mount path has been tested
While testing statvfs operation, same mount path has been tested twice,
instead of two different mount points as intended.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-02-27 11:37:25 +02:00
Gerard Marull-Paretas
6d003af827 lib/timeutil: add missing header required for s64_t
sys/timeutil.h could not be used without including first
<zephyr/types.h> because s64_t type definition was missing.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-02-27 11:35:43 +02:00
Andrzej Puzdrowski
208f15e521 doc/reference/runtime_conf/settings: reference missing API group
Added references to missing settings API groups so them
will be generated in documentation build.

Missing API are doxygen subgroup of already referenced doxygen group,
but subgroups aren't automatically extracted to the documentation
output.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-02-27 11:35:19 +02:00
Luiz Augusto von Dentz
9e8b78b8e1 Bluetooth: GATT: Fix not clearing CF_OUT_OF_SYNC
If the client is change-unware and disconnects the spec requires that
the stack still sends the error out of sync for the next request:

'The ATT_ERROR_RSP PDU is sent only once after the client becomes
change-unaware, unless the client _disconnects_ or the database changes
again before the client becomes change-aware in which case the
ATT_ERROR_RSP PDU shall be sent again'

Fixes #23110

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-02-27 11:26:30 +02:00
Trond Einar Snekvik
7b48611143 Bluetooth: Mesh: Group resends in proxy nodes
Resend transport segments for groups on the advertiser interface, even
if a connected proxy node holds the group.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-02-27 10:02:40 +02:00
Francois Ramu
ff072bc816 west.yml: update hal stm32g4xx and stm32l4R/stm32l4S modules
This updates the stm32cube drivers to fix the issue on sysclock

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-02-26 12:21:04 -06:00
Francois Ramu
f41ff24a3a driver: clock: stm32: boost voltage when clock exceeds 80MHz
This patch activates the boost mode for the main regulator
when the system frequency above 80MHz for stm32l4Rx/stm32l4Sx
soc series.
To save power, the boost mode should be disabled below 80MHz.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-02-26 12:21:04 -06:00
Francois Ramu
5c0687e58b driver: clock: stm32: boost voltage when clock exceeds 150MHz
This patch activates the boost mode for the main regulator
when the system frequency above 150MHz for stm32g4xx soc series.
To save power, the boost mode should be disabled below 150MHz.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-02-26 12:21:04 -06:00
Francois Ramu
0b4fbb916e driver: watchdog: stm32 install watchdog
This patches add a delay after setting the watchdog
to wait for the register (Prescaler and Counter registers)
to be updated before leaving (until LL_IWDG_IsReady is true)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-02-26 12:19:07 -06:00
Joakim Andersson
1ef16e6d96 Bluetooth: shell: Update help text of bt init command
Update help text of `bt init` command which says address could be
provided. This feature was removed by:
d22b7c9f2d

As a replacement the `bt id-create` command can be used instead.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-26 17:51:18 +02:00
Wolfgang Puffitsch
c3ee7d26d1 manifest: EDTT: update manifest to point to new revision in EDTT
Update EDTT so ATT reads filter on the CID.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-02-26 15:03:51 +01:00
Dariusz Lisik
d4d7c947b9 tracing: fixes C++ compilation issue
When tracing_cpu_stats.h is included by C++ file it will not compile
and link correctly due to missing #ifdef __cplusplus directives
in the header file.

Fixes #23072

Signed-off-by: Dariusz Lisik <dariusz.lisik@hidglobal.com>
2020-02-26 14:13:22 +02:00
Morten Priess
41481f92f7 Bluetooth: controller: Prevent LLCP handling of must-expire events
When a must-expire ticker callback is executed, it is important not to
call the LLCP state machine, as the lazy state is unavailable. The code
must rely on the next proper event to call ull_conn_llcp with an updated
non-zero lazy count.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-02-26 09:20:58 +01:00
Martí Bolívar
90edd01644 doc: west: 'west installation' is now 'west workspace'
This nomenclature change was done in west 0.7 because it seems to be a
lot easier for people to understand. Propagate it to all the west
documentation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-25 23:08:02 +02:00
Martí Bolívar
c3ddea01f2 doc: west: update structure page
The main change is that west 0.7 is not a namespace package anymore.
Make some other improvements while here.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-25 23:08:02 +02:00
Martí Bolívar
62c5b3d198 doc: west: add examples for each topology
Add example west.yml files showing how to build west workspaces of
each type. Split these into separate sections as a result since
they're longer.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-25 23:08:02 +02:00
180 changed files with 50719 additions and 43016 deletions

View File

@@ -9,6 +9,7 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80
# C
[*.{c,h}]

View File

@@ -30,8 +30,8 @@ jobs:
- name: install-pip
run: |
pip3 install setuptools
pip3 install 'breathe>=4.9.1' 'docutils>=0.14' \
'sphinx>=1.7.5' sphinx_rtd_theme sphinx-tabs \
pip3 install 'breathe>=4.9.1,<4.15.0' 'docutils>=0.14' \
'sphinx>=1.7.5,<3.0' sphinx_rtd_theme sphinx-tabs \
sphinxcontrib-svg2pdfconverter 'west>=0.6.2'
pip3 install pyelftools

View File

@@ -61,8 +61,8 @@ jobs:
- name: install-pip
run: |
pip3 install setuptools
pip3 install 'breathe>=4.9.1' 'docutils>=0.14' \
'sphinx>=1.7.5' sphinx_rtd_theme sphinx-tabs \
pip3 install 'breathe>=4.9.1,<4.15.0' 'docutils>=0.14' \
'sphinx>=1.7.5,<3.0' sphinx_rtd_theme sphinx-tabs \
sphinxcontrib-svg2pdfconverter 'west>=0.6.2'
pip3 install pyelftools

View File

@@ -347,7 +347,7 @@
/samples/ @nashif
/samples/basic/minimal/ @carlescufi
/samples/basic/servo_motor/*microbit* @jhe
/lib/updatehub/ @chtavares592 @otavio
/lib/updatehub/ @nandojve @otavio
/samples/bluetooth/ @jhedberg @Vudentz @joerchan
/samples/boards/intel_s1000_crb/ @sathishkuttan @dcpleung @nashif
/samples/display/ @vanwinkeljan
@@ -361,7 +361,7 @@
/samples/net/mqtt_publisher/ @jukkar @tbursztyka
/samples/net/sockets/coap_*/ @rveerama1
/samples/net/sockets/ @jukkar @tbursztyka @pfalcon
/samples/net/updatehub/ @chtavares592 @otavio
/samples/net/updatehub/ @nandojve @otavio
/samples/sensor/ @MaureenHelm
/samples/shields/ @avisconti
/samples/subsys/logging/ @nordic-krch @jakub-uC

View File

@@ -1,5 +1,5 @@
VERSION_MAJOR = 2
VERSION_MINOR = 2
PATCHLEVEL = 0
PATCHLEVEL = 1
VERSION_TWEAK = 0
EXTRAVERSION = rc2
EXTRAVERSION =

View File

@@ -206,7 +206,7 @@ SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_trap)
/* do sys_call */
mov_s ilink, K_SYSCALL_LIMIT
cmp r6, ilink
blt valid_syscall_id
blo valid_syscall_id
mov_s r0, r6
mov_s r6, K_SYSCALL_BAD

View File

@@ -16,7 +16,7 @@ config ARM_MPU
MCU implements Memory Protection Unit.
Notes:
The ARMv6-M and ARMv8-M MPU architecture requires a power-of-two
The ARMv6-M and ARMv7-M MPU architecture requires a power-of-two
alignment of MPU region base address and size.
The NXP MPU as well as the ARMv8-M MPU do not require MPU regions

View File

@@ -9,6 +9,8 @@
#define ZEPHYR_ARCH_ARM_CORE_AARCH32_CORTEX_M_MPU_ARM_MPU_V7_INTERNAL_H_
#include <sys/math_extras.h>
#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL
#include <logging/log.h>
@@ -200,6 +202,7 @@ static inline int is_in_region(u32_t r_index, u32_t start, u32_t size)
u32_t r_addr_start;
u32_t r_size_lshift;
u32_t r_addr_end;
u32_t end;
/* Lock IRQs to ensure RNR value is correct when reading RBAR, RASR. */
unsigned int key;
@@ -216,7 +219,12 @@ static inline int is_in_region(u32_t r_index, u32_t start, u32_t size)
MPU_RASR_SIZE_Pos) + 1;
r_addr_end = r_addr_start + (1UL << r_size_lshift) - 1;
if (start >= r_addr_start && (start + size - 1) <= r_addr_end) {
size = size == 0 ? 0 : size - 1;
if (u32_add_overflow(start, size, &end)) {
return 0;
}
if ((start >= r_addr_start) && (end <= r_addr_end)) {
return 1;
}

View File

@@ -10,6 +10,7 @@
#include <soc.h>
#include "arm_core_mpu_dev.h"
#include <sys/__assert.h>
#include <sys/math_extras.h>
#include <linker/linker-defs.h>
#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL
@@ -428,11 +429,17 @@ static inline int is_in_region(u32_t r_index, u32_t start, u32_t size)
{
u32_t r_addr_start;
u32_t r_addr_end;
u32_t end;
r_addr_start = SYSMPU->WORD[r_index][0];
r_addr_end = SYSMPU->WORD[r_index][1];
if (start >= r_addr_start && (start + size - 1) <= r_addr_end) {
size = size == 0 ? 0 : size - 1;
if (u32_add_overflow(start, size, &end)) {
return 0;
}
if ((start >= r_addr_start) && (end <= r_addr_end)) {
return 1;
}

View File

@@ -76,11 +76,18 @@ void __weak relocate_vector_table(void)
#endif /* CONFIG_CPU_CORTEX_M_HAS_VTOR */
#ifdef CONFIG_FLOAT
static inline void enable_floating_point(void)
#if defined(CONFIG_CPU_HAS_FPU)
static inline void z_arm_floating_point_init(void)
{
/*
* Upon reset, the Co-Processor Access Control Register is 0x00000000.
* Upon reset, the Co-Processor Access Control Register is, normally,
* 0x00000000. However, it might be left un-cleared by firmware running
* before Zephyr boot.
*/
SCB->CPACR &= (~(CPACR_CP10_Msk | CPACR_CP11_Msk));
#if defined(CONFIG_FLOAT)
/*
* Enable CP10 and CP11 Co-Processors to enable access to floating
* point registers.
*/
@@ -135,12 +142,23 @@ static inline void enable_floating_point(void)
* will be activated (FPCA bit on the CONTROL register) in the presence
* of floating point instructions.
*/
}
#else
static inline void enable_floating_point(void)
{
}
#endif /* CONFIG_FLOAT */
/*
* Upon reset, the CONTROL.FPCA bit is, normally, cleared. However,
* it might be left un-cleared by firmware running before Zephyr boot.
* We must clear this bit to prevent errors in exception unstacking.
*
* Note:
* In Sharing FP Registers mode CONTROL.FPCA is cleared before switching
* to main, so it may be skipped here (saving few boot cycles).
*/
#if !defined(CONFIG_FLOAT) || !defined(CONFIG_FP_SHARING)
__set_CONTROL(__get_CONTROL() & (~(CONTROL_FPCA_Msk)));
#endif
}
#endif /* CONFIG_CPU_HAS_FPU */
extern FUNC_NORETURN void z_cstart(void);
/**
@@ -154,7 +172,9 @@ extern FUNC_NORETURN void z_cstart(void);
void z_arm_prep_c(void)
{
relocate_vector_table();
enable_floating_point();
#if defined(CONFIG_CPU_HAS_FPU)
z_arm_floating_point_init();
#endif
z_bss_zero();
z_data_copy();
#if defined(CONFIG_ARMV7_R) && defined(CONFIG_INIT_STACKS)

View File

@@ -508,7 +508,10 @@ _do_syscall:
ldr ip, =K_SYSCALL_LIMIT
cmp r6, ip
#endif
blt valid_syscall_id
/* The supplied syscall_id must be lower than the limit
* (Requires unsigned integer comparison)
*/
blo valid_syscall_id
/* bad syscall id. Set arg1 to bad id and set call_id to SYSCALL_BAD */
str r6, [r0]

View File

@@ -163,6 +163,10 @@ _restore_context:
wsr.LEND a0
l32i a0, a1, BSA_LCOUNT_OFF
wsr.LCOUNT a0
#endif
#if XCHAL_HAVE_S32C1I
l32i a0, a1, BSA_SCOMPARE1_OFF
wsr.SCOMPARE1 a0
#endif
rsync

View File

@@ -34,6 +34,8 @@
* SP-52 Saved LEND special register (if loops enabled)
* SP-56 Saved LCOUNT special register (if loops enabled)
*
* SP-60 Saved SCOMPARE special register (if S32C1I enabled)
*
* (The above fixed-size region is known as the "base save area" in the
* code below)
*
@@ -62,12 +64,25 @@
* original/interrupted stack pointer.
*/
#define BASE_SAVE_AREA_SIZE_COMMON 44
#if XCHAL_HAVE_LOOPS
#define BASE_SAVE_AREA_SIZE 56
#define BASE_SAVE_AREA_SIZE_LOOPS 12
#else
#define BASE_SAVE_AREA_SIZE 44
#define BASE_SAVE_AREA_SIZE_LOOPS 0
#endif
#if XCHAL_HAVE_S32C1I
#define BASE_SAVE_AREA_SIZE_SCOMPARE 4
#else
#define BASE_SAVE_AREA_SIZE_SCOMPARE 0
#endif
#define BASE_SAVE_AREA_SIZE \
(BASE_SAVE_AREA_SIZE_COMMON + \
BASE_SAVE_AREA_SIZE_LOOPS + \
BASE_SAVE_AREA_SIZE_SCOMPARE)
#define BSA_A3_OFF (BASE_SAVE_AREA_SIZE - 20)
#define BSA_A2_OFF (BASE_SAVE_AREA_SIZE - 24)
#define BSA_SCRATCH_OFF (BASE_SAVE_AREA_SIZE - 28)
@@ -79,4 +94,9 @@
#define BSA_LEND_OFF (BASE_SAVE_AREA_SIZE - 52)
#define BSA_LCOUNT_OFF (BASE_SAVE_AREA_SIZE - 56)
#define BSA_SCOMPARE1_OFF \
(BASE_SAVE_AREA_SIZE - \
(BASE_SAVE_AREA_SIZE_COMMON + \
BASE_SAVE_AREA_SIZE_LOOPS + 4))
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_ASM2_CONTEXT_H_ */

View File

@@ -110,6 +110,10 @@
rsr.LCOUNT a0
s32i a0, a1, BSA_LCOUNT_OFF
#endif
#if XCHAL_HAVE_S32C1I
rsr.SCOMPARE1 a0
s32i a0, a1, BSA_SCOMPARE1_OFF
#endif
.endm
/*

View File

@@ -8,5 +8,3 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- hwinfo

View File

@@ -8,5 +8,3 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- hwinfo

View File

@@ -11,3 +11,4 @@ CONFIG_SERIAL=y
CONFIG_UART_SAM=y
CONFIG_UART_SAM_PORT_0=y
CONFIG_SOC_ATMEL_SAM3X_EXT_MAINCK=y
CONFIG_WDT_DISABLE_AT_BOOT=y

View File

@@ -8,5 +8,3 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- hwinfo

View File

@@ -8,5 +8,3 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- hwinfo

View File

@@ -81,7 +81,7 @@
compatible = "atmel,rf2xx";
reg = <0x0>;
label = "RF2XX_0";
spi-max-frequency = <8000000>;
spi-max-frequency = <6000000>;
irq-gpios = <&portb 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
reset-gpios = <&portb 15 GPIO_ACTIVE_LOW>;
slptr-gpios = <&porta 20 GPIO_ACTIVE_HIGH>;

View File

@@ -17,4 +17,3 @@ supported:
- i2c
- ieee802154
- usb_device
- hwinfo

View File

@@ -13,7 +13,6 @@ supported:
- can
- counter
- gpio
- hwinfo
- i2c
- netif:eth
- nvs

View File

@@ -11,7 +11,6 @@ flash: 256
supported:
- arduino_gpio
- gpio
- hwinfo
- i2c
- nvs
- pwm

View File

@@ -16,6 +16,5 @@ supported:
- adc
- arduino_gpio
- gpio
- hwinfo
- i2c
- usb_device

View File

@@ -11,7 +11,6 @@ supported:
- arduino_gpio
- counter
- gpio
- hwinfo
- i2c
- ieee802154
- spi

View File

@@ -10,7 +10,6 @@ supported:
- adc
- ble
- gpio
- hwinfo
- i2c
- pwm
- spi

View File

@@ -8,8 +8,6 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- hwinfo
testing:
ignore_tags:
- net

View File

@@ -16,6 +16,5 @@ ram: 32
flash: 16384
supported:
- i2c
- hwinfo
- counter
- usb_device

View File

@@ -18,6 +18,5 @@ supported:
- arduino_gpio
- counter
- gpio
- hwinfo
- i2c
- usb_device

View File

@@ -18,7 +18,6 @@ supported:
- arduino_gpio
- counter
- gpio
- hwinfo
- i2c
- netif:eth
- usb_device

View File

@@ -19,7 +19,6 @@ supported:
- counter
- display
- gpio
- hwinfo
- i2c
- netif:eth
- sdhc

View File

@@ -19,7 +19,6 @@ supported:
- counter
- display
- gpio
- hwinfo
- i2c
- netif:eth
- sdhc

View File

@@ -19,7 +19,6 @@ supported:
- counter
- display
- gpio
- hwinfo
- i2c
- netif:eth
- usb_device

View File

@@ -19,7 +19,6 @@ supported:
- counter
- display
- gpio
- hwinfo
- i2c
- netif:eth
- usb_device

View File

@@ -19,7 +19,6 @@ supported:
- counter
- display
- gpio
- hwinfo
- i2c
- netif:eth
- pwm

View File

@@ -15,5 +15,4 @@ toolchain:
ram: 32768
flash: 8192
supported:
- hwinfo
- counter

View File

@@ -1,4 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(pyocd "--target=stm32g474retx")
# use target=stm32g474rbtx instead of stm32g474retx
# to allow board re-flashing (see PR #23230)
board_runner_args(pyocd "--target=stm32g474rbtx")
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)

View File

@@ -6,8 +6,8 @@ toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 32
flash: 128
ram: 128
flash: 512
supported:
- arduino_gpio
- arduino_i2c

View File

@@ -0,0 +1,111 @@
.. _qemu_cortex_r5:
ARM Cortex-R5 Emulation (QEMU)
##############################
Overview
********
This board configuration will use QEMU to emulate the Xilinx Zynq UltraScale+
(ZynqMP) platform.
.. figure:: qemu_cortex_r5.png
:width: 600px
:align: center
:alt: Qemu
Qemu (Credit: qemu.org)
This configuration provides support for an ARM Cortex-R5 CPU and these devices:
* ARM PL-390 Generic Interrupt Controller
* Xilinx Zynq TTC (Cadence TTC)
* Xilinx Zynq UART
.. note::
This board configuration makes no claims about its suitability for use
with an actual ZCU102 hardware system, or any other hardware system.
Hardware
********
Supported Features
==================
The following hardware features are supported:
+--------------+------------+----------------------+
| Interface | Controller | Driver/Component |
+==============+============+======================+
| GIC | on-chip | generic interrupt |
| | | controller |
+--------------+------------+----------------------+
| TTC | on-chip | system timer |
+--------------+------------+----------------------+
| UART | on-chip | serial port |
+--------------+------------+----------------------+
The kernel currently does not support other hardware features on this platform.
Devices
========
System Timer
------------
This board configuration uses a system timer tick frequency of 1000 Hz.
Serial Port
-----------
This board configuration uses a single serial communication channel with the
on-chip UART0.
Known Problems or Limitations
==============================
The following platform features are unsupported:
* Dual-redundant Core Lock-step (DCLS) execution is not emulated.
* Xilinx Zynq TTC driver does not support tickless mode operation.
Programming and Debugging
*************************
Use this configuration to run basic Zephyr applications and kernel tests in the
QEMU emulated environment, for example, with the :ref:`synchronization_sample`:
.. zephyr-app-commands::
:zephyr-app: samples/synchronization
:host-os: unix
:board: qemu_cortex_r5
:goals: run
This will build an image with the synchronization sample app, boot it using
QEMU, and display the following console output:
.. code-block:: console
*** Booting Zephyr OS build v2.2.0 ***
threadA: Hello World from qemu_cortex_r5!
threadB: Hello World from qemu_cortex_r5!
threadA: Hello World from qemu_cortex_r5!
threadB: Hello World from qemu_cortex_r5!
threadA: Hello World from qemu_cortex_r5!
threadB: Hello World from qemu_cortex_r5!
threadA: Hello World from qemu_cortex_r5!
threadB: Hello World from qemu_cortex_r5!
threadA: Hello World from qemu_cortex_r5!
threadB: Hello World from qemu_cortex_r5!
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
Debugging
=========
Refer to the detailed overview about :ref:`application_debugging`.
References
**********
1. ARMv7-A and ARMv7-R Architecture Reference Manual (ARM DDI 0406C ID051414)
2. Cortex-R5 and Cortex-R5F Technical Reference Manual (ARM DDI 0460C ID021511)
3. Zynq UltraScale+ Device Technical Reference Manual (UG1085)

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -12,3 +12,4 @@ CONFIG_BOARD_SAM4E_XPRO=y
CONFIG_SOC_ATMEL_SAM4E_EXT_MAINCK=y
CONFIG_GPIO_SAM=y
CONFIG_GPIO=y
CONFIG_WDT_DISABLE_AT_BOOT=y

View File

@@ -11,3 +11,4 @@ CONFIG_UART_SAM_PORT_0=y
CONFIG_BOARD_SAM4S_XPLAINED=y
CONFIG_SOC_ATMEL_SAM4S_EXT_MAINCK=y
CONFIG_GPIO=y
CONFIG_WDT_DISABLE_AT_BOOT=y

View File

@@ -13,4 +13,5 @@ CONFIG_SERIAL=y
CONFIG_USART_SAM=y
CONFIG_USART_SAM_PORT_1=y
CONFIG_BOARD_SAM_E70_XPLAINED=y
CONFIG_WDT_DISABLE_AT_BOOT=y
CONFIG_BUILD_OUTPUT_HEX=y

View File

@@ -12,3 +12,4 @@ CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_USART_SAM=y
CONFIG_USART_SAM_PORT_1=y
CONFIG_WDT_DISABLE_AT_BOOT=y

View File

@@ -12,7 +12,6 @@ supported:
- adc
- can
- counter
- hwinfo
- i2c
- pwm
- spi

View File

@@ -9,5 +9,4 @@ toolchain:
ram: 256
flash: 1024
supported:
- hwinfo
- i2c

View File

@@ -9,7 +9,6 @@ toolchain:
- gnuarmemb
- xtools
supported:
- hwinfo
- ieee802154
- usb_device
- watchdog

View File

@@ -527,12 +527,10 @@ html_context = {
'theme_logo_only': False,
'current_version': version,
'versions': (("latest", "/"),
("2.2.0", "/2.2.0/"),
("2.1.0", "/2.1.0/"),
("2.0.0", "/2.0.0/"),
("1.14.1", "/1.14.1/"),
("1.13.0", "/1.13.0/"),
("1.12.0", "/1.12.0/"),
("1.11.0", "/1.11.0/"),
)
}

View File

@@ -239,7 +239,9 @@ steps:
Tagging needs to be done via explicit git commands and not via GitHub's release
interface. The GitHub release interface does not generate annotated tags (it
generates 'lightweight' tags regardless of release or pre-release).
generates 'lightweight' tags regardless of release or pre-release). You should
also upload your gpg public key to your GitHub account, since the instructions
below involve creating signed tags.
.. tabs::
@@ -263,8 +265,7 @@ steps:
#. Tag and push the version, using an annotated tag::
$ git pull
$ git tag -a v1.11.0-rc1
<Use "Zephyr 1.11.0-rc1" as the tag annotation>
$ git tag -m "Zephyr 1.11.0-rc1" -s v1.11.0-rc1
$ git push git@github.com:zephyrproject-rtos/zephyr.git v1.11.0-rc1
#. Create a shortlog of changes between the previous release (use
@@ -273,7 +274,7 @@ steps:
$ git shortlog v1.10.0..v1.11.0-rc1
#. Find the new tag at the top of the releases page and edit the release
with the ``Edit`` button with the following:
with the ``Draft a new release`` button with the following:
* Name it ``Zephyr 1.11.0-rc1``
* Copy the shortlog into the release notes textbox (*don't forget
@@ -306,16 +307,14 @@ steps:
#. Tag and push the version, using two annotated tags::
$ git pull
$ git tag -a v1.11.0
<Use "Zephyr 1.11.0" as the tag annotation>
$ git tag -m "Zephyr 1.11.0" -s v1.11.0
$ git push git@github.com:zephyrproject-rtos/zephyr.git v1.11.0
$ git tag -a zephyr-v1.11.0
<Use "Zephyr 1.11.0" as the tag annotation>
$ git tag -m "Zephyr 1.11.0" -s zephyr-v1.11.0
$ git push git@github.com:zephyrproject-rtos/zephyr.git zephyr-v1.11.0
#. Find the new tag at the top of the releases page and edit the release
with the ``Edit`` button with the following:
with the ``Draft a new release`` button with the following:
* Name it ``Zephyr 1.11.0``
* Copy the full content of ``docs/releases/release-notes-1.11.rst``

View File

@@ -42,7 +42,7 @@ tools. First, make sure your development system OS is updated:
.. group-tab:: macOS
On macOS Mojave, you can manually check for updates by choosing
On macOS Mojave or later, you can manually check for updates by choosing
System Preferences from the Apple menu, then clicking Software Update (and
click Update Now if there are). For other macOS versions, see the
`Update macOS topic in Apple support
@@ -306,15 +306,15 @@ including: compiler, assembler, linker, and their dependencies.
.. code-block:: bash
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.1/zephyr-sdk-0.11.1-setup.run
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.2/zephyr-sdk-0.11.2-setup.run
#. Run the installation binary, installing the SDK in your home
folder :file:`~/zephyr-sdk-0.11.1`:
folder :file:`~/zephyr-sdk-0.11.2`:
.. code-block:: bash
chmod +x zephyr-sdk-0.11.1-setup.run
./zephyr-sdk-0.11.1-setup.run -- -d ~/zephyr-sdk-0.11.1
chmod +x zephyr-sdk-0.11.2-setup.run
./zephyr-sdk-0.11.2-setup.run -- -d ~/zephyr-sdk-0.11.2
#. Set environment variables to let the build system know where to
find the toolchain programs:
@@ -322,7 +322,7 @@ including: compiler, assembler, linker, and their dependencies.
.. code-block:: bash
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-0.11.1
export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-0.11.2
The SDK contains a udev rules file that provides information
needed to identify boards and grant hardware access permission to flash
@@ -361,6 +361,12 @@ The sample :ref:`blinky-sample` blinks an LED on the target board. By
building and running it, we can verify that the environment and tools
are properly set up for Zephyr development.
.. note:: This sample is compatible with most boards supported by
Zephyr, but not all of them. See the :ref:`blinky sample requirements
<blinky-sample-requirements>` for more information. If this sample is not
compatible with your board, a good alternative to try is the
:ref:`Hello World sample <hello_world>`.
#. Set build environment variables:
.. tabs::

View File

@@ -237,19 +237,19 @@ Follow these steps to install the Zephyr SDK:
.. code-block:: console
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.1/zephyr-sdk-0.11.1-setup.run
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.2/zephyr-sdk-0.11.2-setup.run
(You can change *0.11.1* to another version if needed; the `Zephyr
(You can change *0.11.2* to another version if needed; the `Zephyr
Downloads`_ page contains all available SDK releases.)
#. Run the installation binary, installing the SDK at
:file:`~/zephyr-sdk-0.11.1`:
:file:`~/zephyr-sdk-0.11.2`:
.. code-block:: console
cd <sdk download directory>
chmod +x zephyr-sdk-0.11.1-setup.run
./zephyr-sdk-0.11.1-setup.run -- -d ~/zephyr-sdk-0.11.1
chmod +x zephyr-sdk-0.11.2-setup.run
./zephyr-sdk-0.11.2-setup.run -- -d ~/zephyr-sdk-0.11.2
You can pick another directory if you want. If this fails, make sure
Zephyr's dependencies were installed as described in `Install Requirements
@@ -258,7 +258,7 @@ Follow these steps to install the Zephyr SDK:
#. Set these :ref:`environment variables <env_vars>`:
- set :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` to ``zephyr``
- set :envvar:`ZEPHYR_SDK_INSTALL_DIR` to :file:`$HOME/zephyr-sdk-0.11.1`
- set :envvar:`ZEPHYR_SDK_INSTALL_DIR` to :file:`$HOME/zephyr-sdk-0.11.2`
(or wherever you chose to install the SDK)
If you ever want to uninstall the SDK, just remove the directory where you

View File

@@ -1,54 +1,40 @@
.. _installing_zephyr_mac:
.. _mac-setup-alts:
Install macOS Host Dependencies
###############################
macOS alternative setup instructions
####################################
This section describes how to set up a Zephyr development environment on macOS.
.. _mac-gatekeeper:
These instructions have been tested on the following macOS versions:
Important note about Gatekeeper
*******************************
* Mac OS X 10.11 (El Capitan)
* macOS Sierra 10.12
Starting with macOS 10.15 Catalina, applications launched from the macOS
Terminal application (or any other terminal emulator) are subject to the same
system security policies that are applied to applications launched from the
Dock. This means that if you download executable binaries using a web browser,
macOS will not let you execute those from the Terminal by default. In order to
get around this issue you can take two different approaches:
Update Your Operating System
****************************
* Run ``xattr -r -d com.apple.quarantine /path/to/folder`` where
``path/to/folder`` is the path to the enclosing folder where the executables
you want to run are located.
Before proceeding with the build, ensure your OS is up to date.
* Open "System Preferences" -> "Security and Privacy" -> "Privacy" and then
scroll down to "Developer Tools". Then unlock the lock to be able to make
changes and check the checkbox corresponding to your terminal emulator of
choice. This will apply to any executable being launched from such terminal
program.
.. _mac_requirements:
Note that this section does **not** apply to executables installed with
Homebrew, since those are automatically un-quarantined by ``brew`` itself. This
is however relevant for most :ref:`third_party_x_compilers`.
Install Requirements and Dependencies
*************************************
.. NOTE FOR DOCS AUTHORS: DO NOT PUT DOCUMENTATION BUILD DEPENDENCIES HERE.
This section is for dependencies to build Zephyr binaries, *NOT* this
documentation. If you need to add a dependency only required for building
the docs, add it to doc/README.rst. (This change was made following the
introduction of LaTeX->PDF support for the docs, as the texlive footprint is
massive and not needed by users not building PDF documentation.)
Zephyr requires Python 3, while macOS only provides a Python 2
installation. After following these instructions, the version of Python 2
provided by macOS in ``/usr/bin/`` will sit alongside the Python 3 installation
from Homebrew in ``/usr/local/bin``.
First, install :program:`Homebrew` by following instructions on the `Homebrew
site`_. Homebrew is a free and open-source package management system that
simplifies the installation of software on macOS. While installing Homebrew,
you may be prompted to install additional missing dependencies; please follow
any such instructions as well.
Now install these host dependencies with the ``brew`` command:
.. code-block:: console
brew install cmake ninja gperf ccache dfu-util qemu dtc python3
.. _Homebrew site: https://brew.sh/
.. _macOS Gatekeeper: https://en.wikipedia.org/wiki/Gatekeeper_(macOS)
Additional notes for MacPorts users
***********************************
While MacPorts is not officially supported in this guide, it is possible to use MacPorts instead of Homebrew to get all the required dependencies on macOS.
Note also that you may need to install ``rust`` and ``cargo`` for the Python dependencies to install correctly.
While MacPorts is not officially supported in this guide, it is possible to use
MacPorts instead of Homebrew to get all the required dependencies on macOS.
Note also that you may need to install ``rust`` and ``cargo`` for the Python
dependencies to install correctly.

View File

@@ -1,106 +1,12 @@
.. _installing_zephyr_win:
.. _win-setup-alts:
Install Windows Host Dependencies
#################################
Windows alternative setup instructions
######################################
This guide was tested on Windows versions 7, 8.1, and 10.
.. _win-wsl:
Update Your Operating System
****************************
Before proceeding with the build, ensure that you are running your
Windows system with the latest updates installed.
.. _windows_requirements:
Install Requirements and Dependencies
*************************************
.. NOTE FOR DOCS AUTHORS: DO NOT PUT DOCUMENTATION BUILD DEPENDENCIES HERE.
This section is for dependencies to build Zephyr binaries, *NOT* this
documentation. If you need to add a dependency only required for building
the docs, add it to doc/README.rst. (This change was made following the
introduction of LaTeX->PDF support for the docs, as the texlive footprint is
massive and not needed by users not building PDF documentation.)
There are 2 different ways of developing for Zephyr on Microsoft Windows:
#. :ref:`windows_install_native` (recommended)
#. :ref:`windows_install_wsl`
The first option is fully Windows native; the other requires emulation layers
that may result in slower build times.
.. _windows_install_native:
Option 1: Windows Command Prompt
================================
These instructions assume you are using the ``cmd.exe`` command prompt. Some of
the details, such as setting environment variables, may differ if you are using
PowerShell.
The easiest way to install the native Windows dependencies is to first install
`Chocolatey`_, a package manager for Windows. If you prefer to install
dependencies manually, you can also download the required programs from their
respective websites.
.. note::
Chocolatey will properly set up your environment so tools can be
found on your PATH. If you install programs manually, be sure to
verify the programs can also be found on your PATH. For example,
you may need to add ``C:\\Program Files\Git\bin`` after manually
installing Git for Windows.
.. note::
There are multiple ``set`` statements in this tutorial. You can avoid
typing them every time by placing them inside a ``.cmd`` file and
running that every time you open a command prompt.
#. If you're behind a corporate firewall, you'll likely need to specify a
proxy to get access to internet resources:
.. code-block:: console
set HTTP_PROXY=http://user:password@proxy.mycompany.com:1234
set HTTPS_PROXY=http://user:password@proxy.mycompany.com:1234
#. Install :program:`Chocolatey` by following the instructions on the
`Chocolatey install`_ page.
#. Open a command prompt (``cmd.exe``) as an **Administrator** (press the
Windows key, type "cmd.exe" in the prompt, then right-click the result and
choose "Run as Administrator").
#. Optionally disable global confirmation to avoid having to confirm
installation of individual programs:
.. code-block:: console
choco feature enable -n allowGlobalConfirmation
#. Install CMake:
.. code-block:: console
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
#. Install the rest of the tools:
.. code-block:: console
choco install git python ninja dtc-msys2 gperf
#. Close the Administrator command prompt window.
.. NOTE FOR DOCS AUTHORS: as a reminder, do *NOT* put dependencies for building
the documentation itself here.
.. _windows_install_wsl:
Option 2: Windows 10 WSL (Windows Subsystem for Linux)
======================================================
Windows 10 WSL (Windows Subsystem for Linux)
********************************************
If you are running a recent version of Windows 10 you can make use of the
built-in functionality to natively run Ubuntu binaries directly on a standard
@@ -126,7 +32,5 @@ command-prompt. This allows you to use software such as the :ref:`Zephyr SDK
.. NOTE FOR DOCS AUTHORS: as a reminder, do *NOT* put dependencies for building
the documentation itself here.
.. _Chocolatey: https://chocolatey.org/
.. _Chocolatey install: https://chocolatey.org/install
.. _Install the Windows Subsystem for Linux (WSL): https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
.. _Zephyr Issue 10420: https://github.com/zephyrproject-rtos/zephyr/issues/10420

View File

@@ -22,9 +22,9 @@ GNU ARM Embedded
.. warning::
The GNU ARM Embedded Toolchain for Windows, version **8-2018-q4-major**
has a `critical bug <https://github.com/zephyrproject-rtos/zephyr/issues/12257>`_
and should not be used. Toolchain version **7-2018-q2-update** is known to work.
On macOS Catalina or later you might need to :ref:`change a security
policy <mac-gatekeeper>` for the toolchain to be able to run from the
terminal.
#. :ref:`Set these environment variables <env_vars>`:

View File

@@ -65,14 +65,14 @@ Glossary of Terms
The set of Zephyr-supplied files that implement the Zephyr kernel,
including its core services, device drivers, network stack, and so on.
SoC
`System on a chip`_
west
A multi-repo meta-tool developed for the Zephyr project. See :ref:`west`.
west installation
A directory on your system with a :file:`.west` subdirectory and
a :term:`west manifest repository`. You clone the Zephyr source
code onto your system by creating a west installation using the
``west init`` command. See :ref:`west-multi-repo`.
A term for a :term:`west workspace` used prior to west 0.7.
west manifest
A YAML file named :file:`west.yml` which describes projects, or the Git
@@ -85,7 +85,15 @@ Glossary of Terms
:term:`west manifest`. Its location is given by the :ref:`manifest.path
configuration option <west-config-index>`. See :ref:`west-multi-repo`.
west workspace
A directory on your system with a :file:`.west` subdirectory and
a :term:`west manifest repository`. You clone the Zephyr source
code onto your system by creating a west workspace using the
``west init`` command. See :ref:`west-multi-repo`.
XIP
(eXecute In Place) a method of executing programs directly from long
term storage rather than copying it into RAM, saving writable memory for
dynamic data and not the static program code.
.. _System on a chip: https://en.wikipedia.org/wiki/System_on_a_chip

View File

@@ -271,6 +271,8 @@ reg
``reg = <0x40003000 0x1000>;`` means the register map occupies 0x1000 bytes
in the memory map.
.. _devicetree-in-out-files:
Input and output files
**********************

View File

@@ -587,9 +587,9 @@ example ``DT_<node>_CLOCK_CONTROLLER_0`` instead of
This inconsistency might be fixed in the future.
In addition, if the clock controller node has a ``fixed-clock`` property, it is
expected to also have a ``clock-frequency`` property giving the frequency, and
an additional macro is generated:
If a ``clocks`` controller node has a ``"fixed-clock"`` compatible, it
must also have a ``clock-frequency`` property giving its frequency in Hertz.
In this case, an additional macro is generated:
.. code-block:: none

View File

@@ -3,40 +3,26 @@
Board Porting Guide
###################
When building an application you must specify the target hardware and
the exact board or model. Specifying the board name results in a binary that
is suited for the target hardware by selecting the right Zephyr features and
components and setting the right Zephyr configuration for that specific target
hardware.
To add Zephyr support for a new :term:`board`, you at least need a *board
directory* with various files in it. Files in the board directory inherit
support for at least one SoC and all of its features. Therefore, Zephyr must
support your :term:`SoC` as well.
A board is defined as a special configuration of an SoC with possible additional
components.
For example, a board might have sensors and flash memory implemented as
additional features on top of what the SoC provides. Such additional hardware is
configured and referenced in the Zephyr board configuration.
Boards, SoCs, etc.
******************
The board implements at least one SoC and thus inherits all of the features
that are provided by the SoC. When porting a board to Zephyr, you should
first make sure the SoC is implemented in Zephyr.
Zephyr's hardware support hierarchy has these layers, from most to least
specific:
Hardware Configuration Hierarchy
********************************
- Board: a particular CPU instance and its peripherals in a concrete hardware
specification
- SoC: the exact system on a chip the board's CPU is part of
- SoC series: a smaller group of tightly related SoCs
- SoC family: a wider group of SoCs with similar characteristics
- CPU core: a particular CPU in an architecture
- Architecture: an instruction set architecture
Hardware definitions in Zephyr follow a well-defined hierarchy of configurations
and layers, below are the layers from top to bottom:
- Board
- SoC
- SoC Series
- SoC Family
- CPU Core
- Architecture
This design contributes to code reuse and implementation of device drivers and
features at the bottom of the hierarchy making a board configuration as simple
as a selection of features that are implemented by the underlying layers. The
figures below shows this hierarchy with a few example of boards currently
available in the source tree:
You can visualize the hierarchy like this:
.. figure:: board/hierarchy.png
:width: 500px
@@ -45,131 +31,429 @@ available in the source tree:
Configuration Hierarchy
Here are some examples. Notice how the SoC series and family levels are
not always used.
Hierarchy Example
.. list-table::
:header-rows: 1
+------------+-----------+--------------+------------+--------------+---------+
|Board |FRDM K64F |nRF52 NITROGEN|nRF51XX |Quark SE C1000|Arduino |
| | | | |Devboard |101 |
+============+===========+==============+============+==============+=========+
|SOC |MK64F12 |nRF52832 |nRF51XX |Quark SE C1000|Curie |
+------------+-----------+--------------+------------+--------------+---------+
|SOC Series |Kinetis K6x|Nordic NRF52 |Nordic NRF51|Quark SE |Quark SE |
| |Series | | | | |
+------------+-----------+--------------+------------+--------------+---------+
|SOC Family |NXP Kinetis|Nordic NRF5 |Nordic NRF5 |Quark |Quark |
+------------+-----------+--------------+------------+--------------+---------+
|CPU Core |Cortex-M4 |Cortex-M4 |Cortex-M0 |Lakemont |Lakemont |
+------------+-----------+--------------+------------+--------------+---------+
|Architecture|ARM |ARM |ARM |x86 |x86 |
+------------+-----------+--------------+------------+--------------+---------+
* - Board
- SoC
- SoC series
- SoC family
- CPU core
- Architecture
* - :ref:`nrf52_pca10040 <nrf52_pca10040>`
- nRF52832
- nRF52
- Nordic nRF5
- Arm Cortex-M4
- Arm
* - :ref:`frdm_k64f <frdm_k64f>`
- MK64F12
- Kinetis K6x
- NXP Kinetis
- Arm Cortex-M4
- Arm
* - :ref:`stm32h474i_disco <stm32h747i_disco_board>`
- STM32H747XI
- STM32H7
- STMicro STM32
- Arm Cortex-M7
- Arm
* - :ref:`rv32m1_vega_ri5cy <rv32m1_vega>`
- RV32M1
- (Not used)
- (Not used)
- RI5CY
- RISC-V
Make sure your SoC is supported
*******************************
Start by making sure your SoC is supported by Zephyr. If it is, it's time to
:ref:`create-your-board-directory`. If you don't know, try:
- checking :ref:`boards` for names that look relevant, and reading individual
board documentation to find out for sure.
- asking your SoC vendor
If you need to add SoC, CPU core, or even architecture support, this is the
wrong page, but here is some general advice.
Architecture
============
If your CPU architecture is already supported by Zephyr, there is no
architecture work involved in porting to your board. If your CPU architecture
is not supported by the Zephyr kernel, you can add support by following the
instructions available at :ref:`architecture_porting_guide`.
See :ref:`architecture_porting_guide`.
CPU Core
========
Some OS code depends on the CPU core that your board is using. For
example, a given CPU core has a specific assembly language instruction set, and
may require special cross compiler or compiler settings to use the appropriate
instruction set.
CPU core support files go in ``core`` subdirectories under :zephyr_file:`arch`,
e.g. :zephyr_file:`arch/x86/core`.
If your CPU architecture is already supported by Zephyr, there is no CPU core
work involved in porting to your platform or board. You need only to select the
appropriate CPU in your configuration and the rest will be taken care of by the
configuration system in Zephyr which will select the features implemented
by the corresponding CPU.
Platform
========
This layer implements most of the features that need porting and is split into
three layers to allow for code reuse when dealing with implementations with
slight differences.
SoC Family
----------
This layer is a container of all SoCs of the same class that, for example
implement one single type of CPU core but differ in peripherals and features.
The base hardware will in most cases be the same across all SoCs and MCUs of
this family.
SoC Series
----------
Moving closer to the SoC, the series is derived from an SoC family. A series is
defined by a feature set that serves the purpose of distinguishing different
SoCs belonging to the same family.
See :ref:`gs_toolchain` for information about toolchains (compiler, linker,
etc.) supported by Zephyr. If you need to support a new toolchain,
:ref:`build_overview` is a good place to start learning about the build system.
Please reach out to the community if you are looking for advice or want to
collaborate on toolchain support.
SoC
---
===
Finally, an SoC is actual hardware component that is physically available on a
board.
Zephyr SoC support files are in architecture-specific subdirectories of
:zephyr_file:`soc`. They are generally grouped by SoC family.
Board
=====
When adding a new SoC family or series for a vendor that already has SoC
support within Zephyr, please try to extract common functionality into shared
files to avoid duplication. If there is no support for your vendor yet, you can
add it in a new directory ``zephyr/soc/<YOUR-ARCH>/<YOUR-SOC>``; please use
self-explanatory directory names.
A board implements an SoC with all its features, together with peripherals
available on the board that differentiates the board with additional interfaces
and features not available in the SoC.
.. _create-your-board-directory:
A board port on Zephyr typically consists of two parts:
Create your board directory
***************************
- A hardware description (usually done by device tree), which specifies embedded
SoC reference, connectors and any other hardware components such as LEDs,
buttons, sensors or communication peripherals (USB, BLE controller, ...).
Once you've found an existing board that uses your SoC, you can usually start
by copy/pasting its board directory and changing its contents for your
hardware.
- A software configuration (done using Kconfig) of features and peripheral
drivers. This default board configuration is subordinated to features
activation which is application responsibility. Though, it should also enable
a minimal set of features common to many applications and to applicable
project-provided :ref:`samples-and-demos`.
You need to give your board a unique name. Run ``west boards`` for a list of
names that are already taken, and pick something new. Let's say your board is
called ``plank`` (please don't actually use that name).
Start by creating the board directory ``zephyr/boards/<ARCH>/plank``, where
``<ARCH>`` is your SoC's architecture subdirectory. (You don't have to put your
board directory in the zephyr repository, but it's the easiest way to get
started. See :ref:`custom_board_definition` for documentation on moving your
board directory to a separate repository once it's working.)
Your board directory should look like this:
.. code-block:: none
boards/<ARCH>/plank
├── board.cmake
├── CMakeLists.txt
├── doc
│   ├── plank.png
│   └── index.rst
├── Kconfig.board
├── Kconfig.defconfig
├── plank_defconfig
├── plank.dts
└── plank.yaml
Replace ``plank`` with your board's name, of course.
The mandatory files are:
#. :file:`plank.dts`: a hardware description in :ref:`devicetree` format. This
declares your SoC, connectors, and any other hardware components such as
LEDs, buttons, sensors, or communication peripherals (USB, BLE controller,
etc).
#. :file:`Kconfig.board`, :file:`Kconfig.defconfig`, :file:`plank_defconfig`:
software configuration in :ref:`kconfig` formats. This provides default
settings for software features and peripheral drivers.
The optional files are:
- :file:`board.cmake`: used for :ref:`flash-and-debug-support`
- :file:`CMakeLists.txt`: if you need to add additional source files to
your build.
One common use for this file is to add a :file:`pinmux.c` file in your board
directory to the build, which configures pin controllers at boot time. In
that case, :file:`CMakeLists.txt` usually looks like this:
.. code-block:: cmake
if(CONFIG_PINMUX)
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
endif()
- :file:`doc/index.rst`, :file:`doc/plank.png`: documentation for and a picture
of your board. You only need this if you're :ref:`contributing-your-board` to
Zephyr.
- :file:`plank.yaml`: a YAML file with miscellaneous metadata used by the
:ref:`sanitycheck_script`.
.. _default_board_configuration:
Default board configuration
***************************
Write your devicetree
*********************
When porting Zephyr to a board, you must provide the board's default
Kconfig configuration, which is used in application builds unless explicitly
overridden.
The devicetree file :file:`boards/<ARCH>/plank/plank.dts` describes your board
hardware in the Devicetree Source (DTS) format (as usual, change ``plank`` to
your board's name). If you're new to devicetree, see :ref:`devicetree-intro`.
In general, :file:`plank.dts` should look like this:
.. code-block:: none
/dts-v1/;
#include <your_soc_vendor/your_soc.dtsi>
/ {
model = "A human readable name";
compatible = "yourcompany,plank";
chosen {
zephyr,console = &your_uart_console;
zephyr,sram = &your_memory_node;
/* other chosen settings for your hardware */
};
/*
* Your board-specific hardware: buttons, LEDs, sensors, etc.
*/
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = < /* GPIO your LED is hooked up to */ >;
label = "LED 0";
};
/* ... other LEDs ... */
};
buttons {
compatible = "gpio-keys";
/* ... your button definitions ... */
};
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0; /* now you support the blinky sample! */
/* other aliases go here */
};
};
&some_peripheral_you_want_to_enable { /* like a GPIO or SPI controller */
status = "okay";
};
&another_peripheral_you_want {
status = "okay";
};
If you're in a hurry, simple hardware can usually be supported by copy/paste
followed by trial and error. If you want to understand details, you will need
to read the rest of the devicetree documentation and the devicetree
specification.
Write Kconfig files
*******************
Zephyr uses the Kconfig language to configure software features. Your board
needs to provide some Kconfig settings before you can compile a Zephyr
application for it.
Setting Kconfig configuration values is documented in detail in
:ref:`setting_configuration_values`, which you should go through. Note that the
default board configuration might involve both :file:`<BOARD>_defconfig` and
:file:`Kconfig.defconfig` files. The rest of this section contains some
board-specific guidelines.
:ref:`setting_configuration_values`.
In order to provide consistency across the various boards and ease the work of
users providing applications that are not board specific, the following
guidelines should be followed when porting a board. Unless explicitly stated,
peripherals should be disabled by default.
There are three mandatory Kconfig files in the board directory for a board
named ``plank``:
- Configure and enable a working clock configuration, along with a tick source.
.. code-block:: none
boards/<ARCH>/plank
├── Kconfig.board
├── Kconfig.defconfig
└── plank_defconfig
:file:`Kconfig.board`
Included by :zephyr_file:`boards/Kconfig` to include your board
in the list of options.
This should at least contain a definition for a ``BOARD_PLANK`` option,
which looks something like this:
.. code-block:: none
config BOARD_PLANK
bool "Plank board"
depends on SOC_SERIES_YOUR_SOC_SERIES_HERE
select SOC_PART_NUMBER_ABCDEFGH
:file:`Kconfig.defconfig`
Board-specific default values for Kconfig options.
The entire file should be inside an ``if BOARD_PLANK`` / ``endif`` pair of
lines, like this:
.. code-block:: none
if BOARD_PLANK
# Always set CONFIG_BOARD here. This isn't meant to be customized,
# but is set as a "default" due to Kconfig language restrictions.
config BOARD
default "plank"
# Other options you want enabled by default go next. Examples:
config FOO
default y
if NETWORKING
config SOC_ETHERNET_DRIVER
default y
endif # NETWORKING
endif # BOARD_PLANK
:file:`plank_defconfig`
A Kconfig fragment that is merged as-is into the final build directory
:file:`.config` whenever an application is compiled for your board.
You should at least select your board's SOC and do any mandatory settings for
your system clock, console, etc. The results are architecture-specific, but
typically look something like this:
.. code-block:: none
CONFIG_SOC_${VENDOR_XYZ3000}=y /* select your SoC */
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=120000000 /* set up your clock, etc */
CONFIG_SERIAL=y
Build, test, and fix
********************
Now it's time to build and test the application(s) you want to run on your
board until you're satisfied.
For example:
.. code-block:: console
west build -b plank samples/hello_world
west flash
For ``west flash`` to work, see :ref:`flash-and-debug-support` below. You can
also just flash :file:`build/zephyr/zephyr.elf`, :file:`zephyr.hex`, or
:file:`zephyr.bin` with any other tools you prefer.
.. _porting-general-recommendations:
General recommendations
***********************
For consistency and to make it easier for users to build generic applications
that are not board specific for your board, please follow these guidelines
while porting.
- Unless explicitly recommended otherwise by this section, leave peripherals
and their drivers disabled by default.
- Configure and enable a system clock, along with a tick source.
- Provide pin and driver configuration that matches the board's valuable
components such as sensors, buttons or LEDs, and communication interfaces
such as USB, Ethernet connector, or Bluetooth/Wi-Fi chip.
- When a well-known connector is present (such as used on an Arduino or
96board), configure pins to fit this connector.
- If your board uses a well-known connector standard (like Arduino, Mikrobus,
Grove, or 96Boards connectors), add connector nodes to your DTS and configure
pin muxes accordingly.
- Configure components that enable the use of these pins, such as
configuring an SPI instance for Arduino SPI.
configuring an SPI instance to use the usual Arduino SPI pins.
- If available, configure and enable a serial output for the console.
- If available, configure and enable a serial output for the console
using the ``zephyr,console`` chosen node in the devicetree.
- Propose and configure a default network interface.
- If your board supports networking, configure a default interface.
- Enable all GPIO ports.
- Enable all GPIO ports connected to peripherals or expansion connectors.
- If available, enable pinmux and interrupt controller drivers.
.. _flash-and-debug-support:
Flash and debug support
***********************
Zephyr supports :ref:`west-build-flash-debug` via west extension commands.
To add ``west flash`` and ``west debug`` support for your board, you need to
create a :file:`board.cmake` file in your board directory. This file's job is
to configure a "runner" for your board. (There's nothing special you need to
do to get ``west build`` support for your board.)
"Runners" are Zephyr-specific Python classes that wrap :ref:`flash and debug
host tools <debug-host-tools>` and integrate with west and the zephyr build
system to support ``west flash`` and related commands. Each runner supports
flashing, debugging, or both. You need to configure the arguments to these
Python scripts in your :file:`board.cmake` to support those commands like this
example :file:`board.cmake`:
.. code-block:: cmake
board_runner_args(nrfjprog "--nrf-family=NRF52")
board_runner_args(jlink "--device=nrf52" "--speed=4000")
board_runner_args(pyocd "--target=nrf52" "--frequency=4000000")
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
This example configures the ``nrfjprog``, ``jlink``, and ``pyocd`` runners.
.. warning::
Runners usually have names which match the tools they wrap, so the ``jlink``
runner wraps Segger's J-Link tools, and so on. But the runner command line
options like ``--speed`` etc. are specific to the Python scripts.
For more details:
- Run ``west flash --context`` to see a list of available runners which support
flashing, and ``west flash --context -r <RUNNER>`` to view the specific options
available for an individual runner.
- Run ``west debug --context`` and ``west debug --context <RUNNER>`` to get
the same output for runners which support debugging.
- Run ``west flash --help`` and ``west debug --help`` for top-level options
for flashing and debugging.
- See :ref:`west-runner` for Python APIs.
- Look for :file:`board.cmake` files for other boards similar to your own for
more examples.
To see what a ``west flash`` or ``west debug`` command is doing exactly, run it
in verbose mode:
.. code-block:: sh
west --verbose flash
west --verbose debug
Verbose mode prints any host tool commands the runner uses.
The order of the ``include()`` calls in your :file:`board.cmake` matters. The
first ``include`` sets the default runner if it's not already set. For example,
including ``nrfjprog.board.cmake`` first means that ``nrjfprog`` is the default
flash runner for this board. Since ``nrfjprog`` does not support debugging,
``jlink`` is the default debug runner.
.. _contributing-your-board:
Contributing your board
***********************
If you want to contribute your board to Zephyr, first -- thanks!
There are some extra things you'll need to do:
#. Make sure you've followed all the :ref:`porting-general-recommendations`.
They are requirements for boards included with Zephyr.
#. Add documentation for your board using the template file
:zephyr_file:`doc/templates/board.tmpl`. See :ref:`zephyr_doc` for
information on how to build your documentation before submitting
your pull request.
#. Prepare a pull request adding your board which follows the
:ref:`contribute_guidelines`.

View File

@@ -3,9 +3,7 @@
Porting
#######
This section contains details regarding porting the Zephyr kernel to new
architectures, SoCs and boards. This section also describes the standard
API interfaces supported by Zephyr.
These pages document how to port Zephyr to new hardware.
.. toctree::
:maxdepth: 1

View File

@@ -91,7 +91,6 @@ required for best test coverage for this specific board:
- gpio
- usb_device
- watchdog
- hwinfo
- can
- pwm
testing:

View File

@@ -532,8 +532,8 @@ For example, to print usage information about the ``jlink`` runner::
.. _west-runner:
Implementation Details
**********************
runners package API
*******************
The flash and debug commands are implemented as west *extension
commands*: that is, they are west commands whose source code lives

View File

@@ -45,12 +45,12 @@ There are three types of configuration file:
combination of :envvar:`%HOMEDRIVE%` and :envvar:`%HOMEPATH%`.
3. **Local**: Settings in this file affect west's behavior for the
current :term:`west installation`. The file is :file:`.west/config`, relative
to the installation's root directory.
current :term:`west workspace`. The file is :file:`.west/config`, relative
to the workspace's root directory.
A setting in a file which appears lower down on this list overrides an earlier
setting. For example, if ``color.ui`` is ``true`` in the system's configuration
file, but ``false`` in the installation's, then the final value is
file, but ``false`` in the workspace's, then the final value is
``false``. Similarly, settings in the user configuration file override system
settings, and so on.
@@ -76,11 +76,11 @@ To set ``manifest.path`` to :file:`some-other-manifest`:
Doing the above means that commands like ``west update`` will look for the
:term:`west manifest` inside the :file:`some-other-manifest` directory
(relative to the installation root directory) instead of the directory given to
(relative to the workspace root directory) instead of the directory given to
``west init``, so be careful!
To read ``zephyr.base``, the value which will be used as ``ZEPHYR_BASE`` if it
is unset in the calling environment (also relative to the installation root):
is unset in the calling environment (also relative to the workspace root):
.. code-block:: console
@@ -101,7 +101,7 @@ zephyr``.)
To set ``color.ui`` to ``false`` in the global (user-wide) configuration file,
so that west will no longer print colored output for that user when run in any
installation:
workspace:
.. code-block:: console
@@ -136,7 +136,7 @@ commands are documented in the pages for those commands.
* - ``commands.allow_extensions``
- Boolean, default ``true``, disables :ref:`west-extensions` if ``false``
* - ``manifest.path``
- String, relative path from the :term:`west installation` root directory
- String, relative path from the :term:`west workspace` root directory
to the manifest repository used by ``west update`` and other commands
which parse the manifest. Set locally by ``west init``.
* - ``update.fetch``

View File

@@ -41,7 +41,8 @@ globally for whenever you run west, use:
west config --global commands.allow_extensions false
If you want to, you can then re-enable them in a particular installation with:
If you want to, you can then re-enable them in a particular :term:`west
workspace` with:
.. code-block:: console

View File

@@ -18,7 +18,7 @@ introduction and command overview, see :ref:`west-multi-repo`.
Multiple Repository Model
*************************
West's view of the repositories in a :term:`west installation`, and their
West's view of the repositories in a :term:`west workspace`, and their
history, looks like the following figure (though some parts of this example are
specific to upstream Zephyr's use of west):
@@ -32,7 +32,7 @@ specific to upstream Zephyr's use of west):
The history of the manifest repository is the line of Git commits which is
"floating" on top of the gray plane. Parent commits point to child commits
using solid arrows. The plane below contains the Git commit history of the
repositories in the installation, with each project repository boxed in by a
repositories in the workspace, with each project repository boxed in by a
rectangle. Parent/child commit relationships in each repository are also shown
with solid arrows.
@@ -124,7 +124,7 @@ example, you might use ``git@example.com:base1`` if ``remote1`` supported Git
over SSH as well. Anything acceptable to Git will work.
The ``projects`` subsection contains a sequence describing the project
repositories in the west installation. Every project has a unique name. You can
repositories in the west workspace. Every project has a unique name. You can
specify what Git remote URLs to use when cloning and fetching the projects,
what revisions to track, and where the project should be stored on the local
file system.
@@ -157,7 +157,7 @@ In this manifest:
with a ``/`` and the project ``name`` to form the URL.
Locally, this project will be cloned at path ``extra/project-1`` relative to
the west installation's root directory, since it has an explicit ``path``
the west workspace's root directory, since it has an explicit ``path``
attribute with this value.
Since the project has no ``revision`` specified, ``master`` is used by
@@ -208,7 +208,7 @@ The list of project keys and their usage follows. Sometimes we'll refer to the
A project revision can be a branch, tag, or SHA. The default ``revision`` is
``master`` if not otherwise specified.
- ``path``: Optional. Relative path specifying where to clone the repository
locally, relative to the top directory in the west installation. If missing,
locally, relative to the top directory in the west workspace. If missing,
the project's ``name`` is used as a directory name.
- ``clone-depth``: Optional. If given, a positive integer which creates a
shallow history in the cloned repository limited to the given number of
@@ -254,7 +254,7 @@ The ``self`` subsection can be used to control the behavior of the
manifest repository itself. Its value is a map with the following keys:
- ``path``: Optional. The path to clone the manifest repository into, relative
to the west installation's root directory. If not given, the basename of the
to the west workspace's root directory. If not given, the basename of the
path component in the manifest repository URL will be used by default. For
example, if the URL is ``https://git.example.com/project-repo``, the manifest
repository would be cloned to the directory :file:`project-repo`.
@@ -411,7 +411,7 @@ You have a source code repository you want to use with Zephyr v1.14.1 LTS. You
want to maintain the whole thing using west. You don't want to modify any of
the mainline repositories.
In other words, the west installation you want looks like this:
In other words, the west workspace you want looks like this:
.. code-block:: none
@@ -441,7 +441,7 @@ You can do this with the following :file:`my-repo/west.yml`:
revision: v1.14.1
import: true
You can then create the installation on your computer like this, assuming
You can then create the workspace on your computer like this, assuming
``my-repo`` is hosted at ``https://git.example.com/my-repo``:
.. code-block:: console
@@ -480,7 +480,7 @@ master`` for the zephyr repository:
revision: master
import: true
You can create the installation in the same way:
You can create the workspace in the same way:
.. code-block:: console
@@ -711,7 +711,7 @@ Example 2.3: Continuous Integration overrides
---------------------------------------------
Your continuous integration system needs to fetch and test multiple
repositories in your west installation from a developer's forks instead of your
repositories in your west workspace from a developer's forks instead of your
mainline development trees, to see if the changes all work well together.
Starting with :ref:`west-manifest-ex2.2`, the CI scripts add a
@@ -890,7 +890,7 @@ Example 3.3: Downstream with path blacklist
-------------------------------------------
Here's an example showing how to blacklist all vendor HALs from mainline by
common path prefix in the installation, add your own version for the chip
common path prefix in the workspace, add your own version for the chip
you're targeting, and keep everything else.
.. code-block:: yaml

View File

@@ -37,13 +37,13 @@ instead. See :ref:`west-troubleshooting` for advice on common issues.
The name :file:`zephyrproject` is recommended, but you can choose any name
with no spaces anywhere in the path.
#. Create a :ref:`west installation <west-installation>` using the zephyr
#. Create a :ref:`west workspace <west-workspace>` using the zephyr
repository as a local manifest repository::
west init -l zephyr
This creates :file:`zephyrproject/.west`, marking the root of your
installation, and does some other setup. It will not change the contents of
workspace, and does some other setup. It will not change the contents of
the zephyr repository in any way.
#. Clone the rest of the repositories used by zephyr::

View File

@@ -14,19 +14,20 @@ rationale, and motivation.
multi-repo work, not to replace it. For tasks that only operate on one
repository, just use plain Git commands.
.. _west-installation:
.. _west-workspace:
Introduction
************
West's built-in commands allow you to work with projects composed of multiple
Git repositories installed under a common parent directory, which we call a
*west installation*. This works similarly to `Git Submodules
*west workspace* (before west 0.7, this was called a *west installation*). This
works similarly to `Git Submodules
<https://git-scm.com/book/en/v2/Git-Tools-Submodules>`_ and Google's `repo
<https://gerrit.googlesource.com/git-repo/>`_.
A west installation is the result of running the ``west init`` command, which
is described in more detail below. For upstream Zephyr, the installation looks
A west workspace is the result of running the ``west init`` command, which
is described in more detail below. For upstream Zephyr, the workspace looks
like this:
.. code-block:: none
@@ -43,34 +44,34 @@ like this:
├── net-tools
└── [ ... other projects ...]
Above, :file:`zephyrproject` is the name of the west installation's root
Above, :file:`zephyrproject` is the name of the west workspace's root
directory. This name is just an example -- it could be anything, like ``z``,
``my-zephyr-installation``, etc. The file :file:`.west/config` is the
installation's :ref:`local configuration file <west-config>`.
``my-zephyr-workspace``, etc. The file :file:`.west/config` is the
workspace's :ref:`local configuration file <west-config>`.
Every west installation contains exactly one *manifest repository*, which is a
Every west workspace contains exactly one *manifest repository*, which is a
Git repository containing a file named :file:`west.yml`, which is the *west
manifest*. The location of the manifest repository is given by the
:ref:`manifest.path configuration option <west-config-index>` in the local
configuration file. The manifest file, along with west's configuration files,
controls the installation's behavior. For upstream Zephyr, :file:`zephyr` is
controls the workspace's behavior. For upstream Zephyr, :file:`zephyr` is
the manifest repository, but you can configure west to use any Git repository
in the installation as the manifest repository. The only requirement is that it
in the workspace as the manifest repository. The only requirement is that it
contains a valid manifest file. See :ref:`west-manifests` for more details on
what this means.
Both of the :file:`tinycbor` and :file:`net-tools` directories are *projects*
managed by west, and configured in the manifest file. A west installation can
managed by west, and configured in the manifest file. A west workspace can
contain arbitrarily many projects. As shown above, projects can be located
anywhere in the installation. They don't have to be subdirectories of the
anywhere in the workspace. They don't have to be subdirectories of the
manifest directory, and they can be inside of arbitrary subdirectories inside
the installation's root directory. By default, the Zephyr build system uses
west to get the locations of all the projects in the installation, so any code
the workspace's root directory. By default, the Zephyr build system uses
west to get the locations of all the projects in the workspace, so any code
they contain can be used by applications. This behavior can be overridden using
the ``ZEPHYR_MODULES`` CMake variable; see
:zephyr_file:`cmake/zephyr_module.cmake` for details.
Finally, any repository managed by a west installation can contain
Finally, any repository managed by a west workspace can contain
:ref:`extension commands <west-extensions>`, which are extra west commands
provided by that project. This includes the manifest repository and any project
repository.
@@ -78,82 +79,180 @@ repository.
Topologies supported
********************
The following three source code topologies supported by west:
The following are example source code topologies supported by west.
* **T1**: Star topology with zephyr as the manifest repository:
- T1: star topology, zephyr is the manifest repository
- T2: star topology, a Zephyr application is the manifest repository
- T3: forest topology, freestanding manifest repository
- The zephyr repository acts as the central repository and includes a
complete list of projects used upstream
- Default (upstream) configuration
- Analogy with existing mechanisms: Git sub-modules with zephyr as the
super-project
- See :ref:`west-installation` for how mainline Zephyr is an example
of this topology
T1: Star topology, zephyr is the manifest repository
====================================================
* **T2**: Star topology with an application repository as the manifest
repository:
- The zephyr repository acts as the central repository and specifies
its :ref:`modules` in its :file:`west.yml`
- Analogy with existing mechanisms: Git submodules with zephyr as the
super-project
- A repository containing a Zephyr application acts as the central repository
and includes a complete list of other projects, including the zephyr
repository, required to build it
- Useful for those focused on a single application
- Analogy with existing mechanisms: Git sub-modules with the application as
the super-project, zephyr and other projects as sub-modules
- An installation using this topology could look like this:
This is the default. See :ref:`west-workspace` for how mainline Zephyr is an
example of this topology.
.. code-block:: none
.. _west-t2:
app-manifest-installation
├── application
│   ├── CMakeLists.txt
│   ├── prj.conf
│   ├── src
│   │   └── main.c
│   └── west.yml
├── modules
│   └── lib
│   └── tinycbor
└── zephyr
T2: Star topology, application is the manifest repository
=========================================================
* **T3**: Forest topology:
- Useful for those focused on a single application
- A repository containing a Zephyr application acts as the central repository
and names other projects required to build it in its :file:`west.yml`. This
includes the zephyr repository and any modules.
- Analogy with existing mechanisms: Git submodules with the application as
the super-project, zephyr and other projects as submodules
- A dedicated manifest repository which contains no Zephyr source code,
and specifies a list of projects all at the same "level"
- Useful for downstream distributions with no "central" repository
- Analogy with existing mechanisms: Google repo-based source distribution
- An installation using this topology could look like this:
A workspace using this topology looks like this:
.. code-block:: none
.. code-block:: none
forest
├── app1
│   ├── CMakeLists.txt
│   ├── prj.conf
│   ── src
│   └── main.c
├── app2
│   ├── CMakeLists.txt
│   ── prj.conf
│   └── src
│   └── main.c
├── manifest-repo
│   └── west.yml
├── modules
│   └── lib
│   └── tinycbor
└── zephyr
west-workspace
├── application
│   ├── CMakeLists.txt
│   ├── prj.conf
│   ── src
│   │   └── main.c
│   └── west.yml
├── modules
│   ── lib
│   └── tinycbor
└── zephyr
Here is an example :file:`application/west.yml` which uses
:ref:`west-manifest-import`, available since west 0.7, to import Zephyr v2.2.0
and its modules into the application manifest file:
.. code-block:: yaml
# Example T2 west.yml, using manifest imports.
manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v2.2.0
import: true
self:
path: application
You can still selectively "override" individual Zephyr modules if you use
``import:`` in this way; see :ref:`west-manifest-ex1.3` for an example.
Another way to do the same thing is to copy/paste :file:`zephyr/west.yml`
to :file:`application/west.yml`, adding an entry for the zephyr
project itself, like this:
.. code-block:: yaml
# Equivalent to the above, but with manually maintained Zephyr modules.
manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
defaults:
remote: zephyrproject-rtos
projects:
- name: zephyr
revision: v2.2.0
west-commands: scripts/west-commands.yml
- name: net-tools
revision: some-sha-goes-here
path: tools/net-tools
# ... other Zephyr modules go here ...
self:
path: application
(The ``west-commands`` is there for :ref:`west-build-flash-debug` and other
Zephyr-specific :ref:`west-extensions`. It's not necessary when using
``import``.)
The main advantage to using ``import`` is not having to track the revisions of
imported projects separately. In the above example, using ``import`` means
Zephyr's :ref:`module <modules>` versions are automatically determined from the
:file:`zephyr/west.yml` revision, instead of having to be copy/pasted (and
maintained) on their own.
T3: Forest topology
===================
- Useful for those supporting multiple independent applications or downstream
distributions with no "central" repository
- A dedicated manifest repository which contains no Zephyr source code,
and specifies a list of projects all at the same "level"
- Analogy with existing mechanisms: Google repo-based source distribution
A workspace using this topology looks like this:
.. code-block:: none
west-workspace
├── app1
│   ├── CMakeLists.txt
│   ├── prj.conf
│   └── src
│   └── main.c
├── app2
│   ├── CMakeLists.txt
│   ├── prj.conf
│   └── src
│   └── main.c
├── manifest-repo
│   └── west.yml
├── modules
│   └── lib
│   └── tinycbor
└── zephyr
Here is an example T3 :file:`manifest-repo/west.yml` which uses
:ref:`west-manifest-import`, available since west 0.7, to import Zephyr
v2.2.0 and its modules, then add the ``app1`` and ``app2`` projects:
.. code-block:: yaml
manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos
- name: your-git-server
url-base: https://git.example.com/your-company
defaults:
remote: your-git-server
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: v2.2.0
import: true
- name: app1
revision: SOME_SHA_OR_BRANCH_OR_TAG
- name: app2
revision: ANOTHER_SHA_OR_BRANCH_OR_TAG
self:
path: manifest-repo
You can also do this "by hand" by copy/pasting :file:`zephyr/west.yml`
as shown :ref:`above <west-t2>` for the T2 topology, with the same caveats.
.. _west-struct:
West Structure
**************
West's code is distributed via PyPI in a `namespace package`_ named ``west``.
See :ref:`west-apis` for API documentation.
West's code is distributed via PyPI in a Python package named ``west``. See
:ref:`west-apis` for API documentation.
This distribution also includes a launcher executable, also named ``west``. When
west is installed, the launcher is placed by :file:`pip3` somewhere in the
user's ``PATH``. This is the command-line entry point.
This distribution also includes a launcher executable, also named ``west``.
When west is installed, the launcher is placed by :file:`pip3` somewhere in the
user's filesystem (exactly where depends on the operating system, but should be
on the ``PATH`` :ref:`environment variable <env_vars>`). This launcher is the
command-line entry point.
.. _west-manifest-rev:
@@ -205,7 +304,7 @@ The ``west init`` and ``west update`` multi-repo commands are the most
important to understand.
- ``west init [-l] [-m URL] [--mr REVISION] [PATH]``: create a west
installation in directory :file:`PATH` (i.e. :file:`.west` etc. will be
workspace in directory :file:`PATH` (i.e. :file:`.west` etc. will be
created there). If the ``PATH`` argument is not given, the current working
directory is used. This command does not clone any of the projects in the
manifest; that is done the next time ``west update`` is run.
@@ -213,11 +312,11 @@ important to understand.
This command can be invoked in two ways:
1. If you already have a local clone of the zephyr repository and want to
create a west installation around it, you can use the ``-l`` switch to
create a west workspace around it, you can use the ``-l`` switch to
pass its path to west, as in: ``west init -l path/to/zephyr``. This is
the only reason to use ``-l``.
2. Otherwise, omit ``-l`` to create a new installation from a remote manifest
2. Otherwise, omit ``-l`` to create a new workspace from a remote manifest
repository. You can give the manifest URL using the ``-m`` switch, and its
revision using ``--mr``. For example, invoking west with: ``west init -m
https://github.com/zephyrproject-rtos/zephyr --mr v1.15.0`` would clone

View File

@@ -16,8 +16,8 @@ If you see this error when running ``west init``:
(choose from 'init', 'update', 'list', 'manifest', 'diff',
'status', 'forall', 'config', 'selfupdate', 'help')
Then you have an old version of west installed, and are trying to use it in an
installation that requires a more recent version.
Then you have an old version of west installed, and are trying to use it in a
workspace that requires a more recent version.
The easiest way to resolve this issue is to upgrade west and retry as follows:
@@ -29,23 +29,24 @@ The easiest way to resolve this issue is to upgrade west and retry as follows:
this step.)
#. Completely remove the :file:`zephyrproject/.west` directory (if you don't,
you will get the "already in an installation" error message discussed next).
you will get the "already in a workspace" error message discussed next).
#. Run ``west init`` again.
"already in an installation"
****************************
You may see this error when running ``west init``:
You may see this error when running ``west init`` with west 0.6:
.. code-block:: none
FATAL ERROR: already in an installation (<some directory>), aborting
If this is unexpected and you're really trying to create a new installation,
If this is unexpected and you're really trying to create a new west workspace,
then it's likely that west is using the :envvar:`ZEPHYR_BASE` :ref:`environment
variable <env_vars>` to locate a west installation elsewhere on your system.
This is intentional behavior; it allows you to put your Zephyr applications in
any directory and still use west.
variable <env_vars>` to locate a workspace elsewhere on your system.
This is intentional; it allows you to put your Zephyr applications in
any directory and still use west to build, flash, and debug them, for example.
To resolve this issue, unset :envvar:`ZEPHYR_BASE` and try again.

View File

@@ -71,7 +71,7 @@ west commands wrap).
If you want to use these build system targets but do not want to
install west on your system using ``pip``, it is possible to do so
by manually creating a :term:`west installation`:
by manually creating a :term:`west workspace`:
.. code-block:: console

View File

@@ -279,5 +279,22 @@ API Reference
The Settings subsystem APIs are provided by ``settings.h``:
API for general settings usage
==============================
.. doxygengroup:: settings
:project: Zephyr
API for key-name processing
===========================
.. doxygengroup:: settings_name_proc
:project: Zephyr
API for runtime settings manipulation
=====================================
.. doxygengroup:: settings_rt
:project: Zephyr
API of backend interface
========================
.. doxygengroup:: settings_backend
:project: Zephyr

File diff suppressed because it is too large Load Diff

View File

@@ -14,3 +14,4 @@ for ensuring security is addressed within the Zephyr project.
secure-coding.rst
sensor-threat.rst
hardening-tool.rst
vulnerabilities.rst

View File

@@ -0,0 +1,25 @@
.. _vulnerabilities:
Vulnerabilities
###############
This page collects all of the vulnerabilities that are discovered and
fixed in each release. It will also often have more details than is
available in the releases. Some vulnerabilities are deemed to be
sensitive, and will not be publically discussed until there is
sufficient time to fix them. Because the release notes are locked to
a version, the information here can be updated after the embargo is
lifted.
Release 1.14.0 and 2.0.0
------------------------
The following security vulnerability (CVE) was addressed in this
release:
* Fixes CVE-2019-9506: The Bluetooth BR/EDR specification up to and
including version 5.1 permits sufficiently low encryption key length
and does not prevent an attacker from influencing the key length
negotiation. This allows practical brute-force attacks (aka "KNOB")
that can decrypt traffic and inject arbitrary ciphertext without the
victim noticing.

View File

@@ -168,12 +168,14 @@ static int adc_xec_start_read(struct device *dev,
/* Setup ADC resolution */
reg = adc_regs->sar_control_reg;
reg &= ~MCHP_ADC_SAR_CTRL_RES_MASK;
reg &= ~(MCHP_ADC_SAR_CTRL_RES_MASK |
(1 << MCHP_ADC_SAR_CTRL_SHIFTD_POS));
if (sequence->resolution == 12) {
reg |= MCHP_ADC_SAR_CTRL_RES_12_BITS;
} else if (sequence->resolution == 10) {
reg |= MCHP_ADC_SAR_CTRL_RES_10_BITS;
reg |= MCHP_ADC_SAR_CTRL_SHIFTD_EN;
} else {
return -EINVAL;
}

View File

@@ -29,6 +29,11 @@ void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
pllinit->PLLM = pllm(CONFIG_CLOCK_STM32_PLL_M_DIVISOR);
pllinit->PLLN = CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER;
pllinit->PLLR = pllr(CONFIG_CLOCK_STM32_PLL_R_DIVISOR);
/* set power boost mode for sys clock greater than 150MHz */
if (sys_clock_hw_cycles_per_sec() >= MHZ(150)) {
LL_PWR_EnableRange1BoostMode();
}
}
#endif /* CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL */

View File

@@ -30,6 +30,12 @@ void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
pllinit->PLLM = pllm(CONFIG_CLOCK_STM32_PLL_M_DIVISOR);
pllinit->PLLN = CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER;
pllinit->PLLR = pllr(CONFIG_CLOCK_STM32_PLL_R_DIVISOR);
#ifdef PWR_CR5_R1MODE
/* set power boost mode for sys clock greater than 80MHz */
if (sys_clock_hw_cycles_per_sec() >= MHZ(80)) {
LL_PWR_EnableRange1BoostMode();
}
#endif /* PWR_CR5_R1MODE */
}
#endif /* CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL */

View File

@@ -20,9 +20,14 @@ config ETH_SAM_GMAC_NAME
required by all driver API functions. Device name has to be unique.
config ETH_SAM_GMAC_QUEUES
int "Number of hardware TX and RX queues"
int "Number of active hardware TX and RX queues"
default 1
range 1 3
range 1 1 if SOC_SERIES_SAM4E
range 1 3 if !SOC_SERIES_SAM4E && \
!SOC_ATMEL_SAME70_REVB && \
!SOC_ATMEL_SAMV71_REVB
range 1 6 if SOC_ATMEL_SAME70_REVB || \
SOC_ATMEL_SAMV71_REVB
help
Select the number of hardware queues used by the driver. Packets will be
routed to appropriate queues based on their priority.
@@ -44,6 +49,9 @@ config ETH_SAM_GMAC_FORCED_QUEUE
default 0
range 0 1 if ETH_SAM_GMAC_QUEUES = 2
range 0 2 if ETH_SAM_GMAC_QUEUES = 3
range 0 3 if ETH_SAM_GMAC_QUEUES = 4
range 0 4 if ETH_SAM_GMAC_QUEUES = 5
range 0 5 if ETH_SAM_GMAC_QUEUES = 6
help
Which queue to force the routing to. This affects both the TX and RX queues
setup.

View File

@@ -399,18 +399,29 @@ static void eth_mcux_phy_setup(void)
{
#ifdef CONFIG_SOC_SERIES_IMX_RT
const u32_t phy_addr = 0U;
u32_t status;
status_t res;
u32_t oms_override;
/* Prevent PHY entering NAND Tree mode override*/
ENET_StartSMIRead(ENET, phy_addr, PHY_OMS_STATUS_REG,
kENET_MiiReadValidFrame);
status = ENET_ReadSMIData(ENET);
/* Disable MII interrupts to prevent triggering PHY events. */
ENET_DisableInterrupts(ENET, ENET_EIR_MII_MASK);
if (status & PHY_OMS_NANDTREE_MASK) {
status &= ~PHY_OMS_NANDTREE_MASK;
ENET_StartSMIWrite(ENET, phy_addr, PHY_OMS_OVERRIDE_REG,
kENET_MiiWriteValidFrame, status);
/* Prevent PHY entering NAND Tree mode override. */
res = PHY_Read(ENET, phy_addr, PHY_OMS_OVERRIDE_REG, &oms_override);
if (res != kStatus_Success) {
LOG_WRN("Reading PHY reg failed (status 0x%x)", res);
} else {
if (oms_override & PHY_OMS_NANDTREE_MASK) {
oms_override &= ~PHY_OMS_NANDTREE_MASK;
res = PHY_Write(ENET, phy_addr, PHY_OMS_OVERRIDE_REG,
oms_override);
if (res != kStatus_Success) {
LOG_WRN("Writing PHY reg failed (status 0x%x)",
res);
}
}
}
ENET_EnableInterrupts(ENET, ENET_EIR_MII_MASK);
#endif
}

View File

@@ -66,7 +66,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
"due to the granularity of RX DMA"
#endif
#if (CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT + 1) * CONFIG_ETH_SAM_GMAC_QUEUES \
#if (CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT + 1) * GMAC_ACTIVE_QUEUE_NUM \
> CONFIG_NET_BUF_RX_COUNT
#error Not enough RX buffers to allocate descriptors for each HW queue
#endif
@@ -75,49 +75,269 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
/* RX descriptors list */
static struct gmac_desc rx_desc_que0[MAIN_QUEUE_RX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#if GMAC_PRIORITY_QUEUE_NUM >= 1
static struct gmac_desc rx_desc_que1[PRIORITY_QUEUE1_RX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 2
static struct gmac_desc rx_desc_que2[PRIORITY_QUEUE2_RX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 3
static struct gmac_desc rx_desc_que3[PRIORITY_QUEUE3_RX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 4
static struct gmac_desc rx_desc_que4[PRIORITY_QUEUE4_RX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 5
static struct gmac_desc rx_desc_que5[PRIORITY_QUEUE5_RX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
/* TX descriptors list */
static struct gmac_desc tx_desc_que0[MAIN_QUEUE_TX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#if GMAC_PRIORITY_QUEUE_NUM >= 1
static struct gmac_desc tx_desc_que1[PRIORITY_QUEUE1_TX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 2
static struct gmac_desc tx_desc_que2[PRIORITY_QUEUE2_TX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 3
static struct gmac_desc tx_desc_que3[PRIORITY_QUEUE3_TX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 4
static struct gmac_desc tx_desc_que4[PRIORITY_QUEUE4_TX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 5
static struct gmac_desc tx_desc_que5[PRIORITY_QUEUE5_TX_DESC_COUNT]
__nocache __aligned(GMAC_DESC_ALIGNMENT);
#endif
/* RX buffer accounting list */
static struct net_buf *rx_frag_list_que0[MAIN_QUEUE_RX_DESC_COUNT];
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static struct net_buf *rx_frag_list_que1[PRIORITY_QUEUE1_RX_DESC_COUNT];
#endif
#if GMAC_PRIORITY_QUEUE_NO == 2
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
static struct net_buf *rx_frag_list_que2[PRIORITY_QUEUE2_RX_DESC_COUNT];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
static struct net_buf *rx_frag_list_que3[PRIORITY_QUEUE3_RX_DESC_COUNT];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
static struct net_buf *rx_frag_list_que4[PRIORITY_QUEUE4_RX_DESC_COUNT];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
static struct net_buf *rx_frag_list_que5[PRIORITY_QUEUE5_RX_DESC_COUNT];
#endif
#if GMAC_MULTIPLE_TX_PACKETS == 1
/* TX buffer accounting list */
static struct net_buf *tx_frag_list_que0[MAIN_QUEUE_TX_DESC_COUNT];
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static struct net_buf *tx_frag_list_que1[PRIORITY_QUEUE1_TX_DESC_COUNT];
#endif
#if GMAC_PRIORITY_QUEUE_NO == 2
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
static struct net_buf *tx_frag_list_que2[PRIORITY_QUEUE2_TX_DESC_COUNT];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
static struct net_buf *tx_frag_list_que3[PRIORITY_QUEUE3_TX_DESC_COUNT];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
static struct net_buf *tx_frag_list_que4[PRIORITY_QUEUE4_TX_DESC_COUNT];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
static struct net_buf *tx_frag_list_que5[PRIORITY_QUEUE5_TX_DESC_COUNT];
#endif
#if defined(CONFIG_PTP_CLOCK_SAM_GMAC)
/* TX frames accounting list */
static struct net_pkt *tx_frame_list_que0[CONFIG_NET_PKT_TX_COUNT + 1];
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static struct net_pkt *tx_frame_list_que1[CONFIG_NET_PKT_TX_COUNT + 1];
#endif
#if GMAC_PRIORITY_QUEUE_NO == 2
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
static struct net_pkt *tx_frame_list_que2[CONFIG_NET_PKT_TX_COUNT + 1];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
static struct net_pkt *tx_frame_list_que3[CONFIG_NET_PKT_TX_COUNT + 1];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
static struct net_pkt *tx_frame_list_que4[CONFIG_NET_PKT_TX_COUNT + 1];
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
static struct net_pkt *tx_frame_list_que5[CONFIG_NET_PKT_TX_COUNT + 1];
#endif
#endif
#endif
#define MODULO_INC(val, max) {val = (++val < max) ? val : 0; }
static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue);
static void tx_descriptors_init(Gmac *gmac, struct gmac_queue *queue);
static int nonpriority_queue_init(Gmac *gmac, struct gmac_queue *queue);
#if GMAC_PRIORITY_QUEUE_NUM >= 1
static inline void set_receive_buf_queue_pointer(
Gmac *gmac,
struct gmac_queue *queue)
{
/* Set Receive Buffer Queue Pointer Register */
if (queue->que_idx == GMAC_QUE_0) {
gmac->GMAC_RBQB = (u32_t)queue->rx_desc_list.buf;
} else {
gmac->GMAC_RBQBAPQ[queue->que_idx - 1] =
(u32_t)queue->rx_desc_list.buf;
}
}
static inline void disable_all_priority_queue_interrupt(Gmac *gmac)
{
u32_t idx;
for (idx = 0; idx < GMAC_PRIORITY_QUEUE_NUM; idx++) {
gmac->GMAC_IDRPQ[idx] = UINT32_MAX;
(void)gmac->GMAC_ISRPQ[idx];
}
}
static int priority_queue_init(Gmac *gmac, struct gmac_queue *queue)
{
int result;
int queue_index;
__ASSERT_NO_MSG(queue->rx_desc_list.len > 0);
__ASSERT_NO_MSG(queue->tx_desc_list.len > 0);
__ASSERT(!((u32_t)queue->rx_desc_list.buf & ~GMAC_RBQB_ADDR_Msk),
"RX descriptors have to be word aligned");
__ASSERT(!((u32_t)queue->tx_desc_list.buf & ~GMAC_TBQB_ADDR_Msk),
"TX descriptors have to be word aligned");
/* Extract queue index for easier referencing */
queue_index = queue->que_idx - 1;
/* Setup descriptor lists */
result = rx_descriptors_init(gmac, queue);
if (result < 0) {
return result;
}
tx_descriptors_init(gmac, queue);
#if GMAC_MULTIPLE_TX_PACKETS == 0
k_sem_init(&queue->tx_sem, 0, 1);
#else
k_sem_init(&queue->tx_desc_sem, queue->tx_desc_list.len - 1,
queue->tx_desc_list.len - 1);
#endif
/* Setup RX buffer size for DMA */
gmac->GMAC_RBSRPQ[queue_index] =
GMAC_RBSRPQ_RBS(CONFIG_NET_BUF_DATA_SIZE >> 6);
/* Set Receive Buffer Queue Pointer Register */
gmac->GMAC_RBQBAPQ[queue_index] = (u32_t)queue->rx_desc_list.buf;
/* Set Transmit Buffer Queue Pointer Register */
gmac->GMAC_TBQBAPQ[queue_index] = (u32_t)queue->tx_desc_list.buf;
/* Enable RX/TX completion and error interrupts */
gmac->GMAC_IERPQ[queue_index] = GMAC_INTPQ_EN_FLAGS;
queue->err_rx_frames_dropped = 0U;
queue->err_rx_flushed_count = 0U;
queue->err_tx_flushed_count = 0U;
LOG_INF("Queue %d activated", queue->que_idx);
return 0;
}
static int priority_queue_init_as_idle(Gmac *gmac, struct gmac_queue *queue)
{
struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list;
struct gmac_desc_list *tx_desc_list = &queue->tx_desc_list;
__ASSERT(!((u32_t)rx_desc_list->buf & ~GMAC_RBQB_ADDR_Msk),
"RX descriptors have to be word aligned");
__ASSERT(!((u32_t)tx_desc_list->buf & ~GMAC_TBQB_ADDR_Msk),
"TX descriptors have to be word aligned");
__ASSERT((rx_desc_list->len == 1U) && (tx_desc_list->len == 1U),
"Priority queues are currently not supported, descriptor "
"list has to have a single entry");
/* Setup RX descriptor lists */
/* Take ownership from GMAC and set the wrap bit */
rx_desc_list->buf[0].w0 = GMAC_RXW0_WRAP;
rx_desc_list->buf[0].w1 = 0U;
/* Setup TX descriptor lists */
tx_desc_list->buf[0].w0 = 0U;
/* Take ownership from GMAC and set the wrap bit */
tx_desc_list->buf[0].w1 = GMAC_TXW1_USED | GMAC_TXW1_WRAP;
/* Set Receive Buffer Queue Pointer Register */
gmac->GMAC_RBQBAPQ[queue->que_idx - 1] = (u32_t)rx_desc_list->buf;
/* Set Transmit Buffer Queue Pointer Register */
gmac->GMAC_TBQBAPQ[queue->que_idx - 1] = (u32_t)tx_desc_list->buf;
LOG_INF("Queue %d set to idle", queue->que_idx);
return 0;
}
static int queue_init(Gmac *gmac, struct gmac_queue *queue)
{
if (queue->que_idx == GMAC_QUE_0) {
return nonpriority_queue_init(gmac, queue);
} else if (queue->que_idx <= GMAC_ACTIVE_PRIORITY_QUEUE_NUM) {
return priority_queue_init(gmac, queue);
} else {
return priority_queue_init_as_idle(gmac, queue);
}
}
#else
static inline void set_receive_buf_queue_pointer(
Gmac *gmac,
struct gmac_queue *queue)
{
gmac->GMAC_RBQB = (u32_t)queue->rx_desc_list.buf;
}
static int queue_init(Gmac *gmac, struct gmac_queue *queue)
{
return nonpriority_queue_init(gmac, queue);
}
#define disable_all_queue_interrupt(gmac)
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static int eth_sam_gmac_setup_qav(Gmac *gmac, int queue_id, bool enable);
static inline void eth_sam_gmac_init_qav(Gmac *gmac)
{
u32_t idx;
for (idx = GMAC_QUE_1; idx <= GMAC_ACTIVE_PRIORITY_QUEUE_NUM; idx++) {
eth_sam_gmac_setup_qav(gmac, idx, true);
}
}
#else
#define eth_sam_gmac_init_qav(gmac)
#endif
/*
* Cache helpers
*/
@@ -611,13 +831,7 @@ static void rx_error_handler(Gmac *gmac, struct gmac_queue *queue)
queue->rx_desc_list.buf[i].w0 &= ~GMAC_RXW0_OWNERSHIP;
}
/* Set Receive Buffer Queue Pointer Register */
if (queue->que_idx == 0) {
gmac->GMAC_RBQB = (u32_t)queue->rx_desc_list.buf;
} else {
gmac->GMAC_RBQBAPQ[queue->que_idx - 1] =
(u32_t)queue->rx_desc_list.buf;
}
set_receive_buf_queue_pointer(gmac, queue);
/* Restart reception */
gmac->GMAC_NCR |= GMAC_NCR_RXEN;
@@ -652,11 +866,11 @@ static int get_mck_clock_divisor(u32_t mck)
return mck_divisor;
}
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static int eth_sam_gmac_setup_qav(Gmac *gmac, int queue_id, bool enable)
{
/* Verify queue id */
if (queue_id < 1 || queue_id > GMAC_PRIORITY_QUEUE_NO) {
if (queue_id < GMAC_QUE_1 || queue_id > GMAC_ACTIVE_PRIORITY_QUEUE_NUM) {
return -EINVAL;
}
@@ -680,7 +894,7 @@ static int eth_sam_gmac_setup_qav(Gmac *gmac, int queue_id, bool enable)
static int eth_sam_gmac_get_qav_status(Gmac *gmac, int queue_id, bool *enabled)
{
/* Verify queue id */
if (queue_id < 1 || queue_id > GMAC_PRIORITY_QUEUE_NO) {
if (queue_id < GMAC_QUE_1 || queue_id > GMAC_ACTIVE_PRIORITY_QUEUE_NUM) {
return -EINVAL;
}
@@ -699,7 +913,7 @@ static int eth_sam_gmac_setup_qav_idle_slope(Gmac *gmac, int queue_id,
u32_t cbscr_val;
/* Verify queue id */
if (queue_id < 1 || queue_id > GMAC_PRIORITY_QUEUE_NO) {
if (queue_id < GMAC_QUE_1 || queue_id > GMAC_ACTIVE_PRIORITY_QUEUE_NUM) {
return -EINVAL;
}
@@ -742,7 +956,7 @@ static int eth_sam_gmac_get_qav_idle_slope(Gmac *gmac, int queue_id,
unsigned int *idle_slope)
{
/* Verify queue id */
if (queue_id < 1 || queue_id > GMAC_PRIORITY_QUEUE_NO) {
if (queue_id < GMAC_QUE_1 || queue_id > GMAC_ACTIVE_PRIORITY_QUEUE_NUM) {
return -EINVAL;
}
@@ -792,7 +1006,7 @@ static int eth_sam_gmac_setup_qav_delta_bandwidth(Gmac *gmac, int queue_id,
u32_t idle_slope;
/* Verify queue id */
if (queue_id < 1 || queue_id > GMAC_PRIORITY_QUEUE_NO) {
if (queue_id < GMAC_QUE_1 || queue_id > GMAC_ACTIVE_PRIORITY_QUEUE_NUM) {
return -EINVAL;
}
@@ -857,12 +1071,10 @@ static int gmac_init(Gmac *gmac, u32_t gmac_ncfgr_val)
/* Disable all interrupts */
gmac->GMAC_IDR = UINT32_MAX;
gmac->GMAC_IDRPQ[GMAC_QUE_1 - 1] = UINT32_MAX;
gmac->GMAC_IDRPQ[GMAC_QUE_2 - 1] = UINT32_MAX;
/* Clear all interrupts */
(void)gmac->GMAC_ISR;
(void)gmac->GMAC_ISRPQ[GMAC_QUE_1 - 1];
(void)gmac->GMAC_ISRPQ[GMAC_QUE_2 - 1];
disable_all_priority_queue_interrupt(gmac);
/* Setup Hash Registers - enable reception of all multicast frames when
* GMAC_NCFGR_MTIHEN is set.
*/
@@ -888,10 +1100,9 @@ static int gmac_init(Gmac *gmac, u32_t gmac_ncfgr_val)
/* Enable Qav if priority queues are used, and setup the default delta
* bandwidth according to IEEE802.1Qav (34.3.1)
*/
#if GMAC_PRIORITY_QUEUE_NO == 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM == 1
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 1, 75);
eth_sam_gmac_setup_qav(gmac, 1, true);
#elif GMAC_PRIORITY_QUEUE_NO == 2
#elif GMAC_ACTIVE_PRIORITY_QUEUE_NUM == 2
/* For multiple priority queues, 802.1Qav suggests using 75% for the
* highest priority queue, and 0% for the lower priority queues.
* This is because the lower priority queues are supposed to be using
@@ -904,10 +1115,25 @@ static int gmac_init(Gmac *gmac, u32_t gmac_ncfgr_val)
*/
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 1, 25);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 2, 50);
eth_sam_gmac_setup_qav(gmac, 1, true);
eth_sam_gmac_setup_qav(gmac, 2, true);
#elif GMAC_ACTIVE_PRIORITY_QUEUE_NUM == 3
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 1, 25);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 2, 25);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 3, 25);
#elif GMAC_ACTIVE_PRIORITY_QUEUE_NUM == 4
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 1, 21);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 2, 18);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 3, 18);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 4, 18);
#elif GMAC_ACTIVE_PRIORITY_QUEUE_NUM == 5
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 1, 15);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 2, 15);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 3, 15);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 4, 15);
eth_sam_gmac_setup_qav_delta_bandwidth(gmac, 5, 15);
#endif
eth_sam_gmac_init_qav(gmac);
return 0;
}
@@ -991,100 +1217,6 @@ static int nonpriority_queue_init(Gmac *gmac, struct gmac_queue *queue)
return 0;
}
static int priority_queue_init(Gmac *gmac, struct gmac_queue *queue)
{
int result;
int queue_index;
__ASSERT_NO_MSG(queue->rx_desc_list.len > 0);
__ASSERT_NO_MSG(queue->tx_desc_list.len > 0);
__ASSERT(!((u32_t)queue->rx_desc_list.buf & ~GMAC_RBQB_ADDR_Msk),
"RX descriptors have to be word aligned");
__ASSERT(!((u32_t)queue->tx_desc_list.buf & ~GMAC_TBQB_ADDR_Msk),
"TX descriptors have to be word aligned");
/* Extract queue index for easier referencing */
queue_index = queue->que_idx - 1;
/* Setup descriptor lists */
result = rx_descriptors_init(gmac, queue);
if (result < 0) {
return result;
}
tx_descriptors_init(gmac, queue);
#if GMAC_MULTIPLE_TX_PACKETS == 0
k_sem_init(&queue->tx_sem, 0, 1);
#else
k_sem_init(&queue->tx_desc_sem, queue->tx_desc_list.len - 1,
queue->tx_desc_list.len - 1);
#endif
/* Setup RX buffer size for DMA */
gmac->GMAC_RBSRPQ[queue_index] =
GMAC_RBSRPQ_RBS(CONFIG_NET_BUF_DATA_SIZE >> 6);
/* Set Receive Buffer Queue Pointer Register */
gmac->GMAC_RBQBAPQ[queue_index] = (u32_t)queue->rx_desc_list.buf;
/* Set Transmit Buffer Queue Pointer Register */
gmac->GMAC_TBQBAPQ[queue_index] = (u32_t)queue->tx_desc_list.buf;
/* Enable RX/TX completion and error interrupts */
gmac->GMAC_IERPQ[queue_index] = GMAC_INTPQ_EN_FLAGS;
queue->err_rx_frames_dropped = 0U;
queue->err_rx_flushed_count = 0U;
queue->err_tx_flushed_count = 0U;
LOG_INF("Queue %d activated", queue->que_idx);
return 0;
}
static int priority_queue_init_as_idle(Gmac *gmac, struct gmac_queue *queue)
{
struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list;
struct gmac_desc_list *tx_desc_list = &queue->tx_desc_list;
__ASSERT(!((u32_t)rx_desc_list->buf & ~GMAC_RBQB_ADDR_Msk),
"RX descriptors have to be word aligned");
__ASSERT(!((u32_t)tx_desc_list->buf & ~GMAC_TBQB_ADDR_Msk),
"TX descriptors have to be word aligned");
__ASSERT((rx_desc_list->len == 1U) && (tx_desc_list->len == 1U),
"Priority queues are currently not supported, descriptor "
"list has to have a single entry");
/* Setup RX descriptor lists */
/* Take ownership from GMAC and set the wrap bit */
rx_desc_list->buf[0].w0 = GMAC_RXW0_WRAP;
rx_desc_list->buf[0].w1 = 0U;
/* Setup TX descriptor lists */
tx_desc_list->buf[0].w0 = 0U;
/* Take ownership from GMAC and set the wrap bit */
tx_desc_list->buf[0].w1 = GMAC_TXW1_USED | GMAC_TXW1_WRAP;
/* Set Receive Buffer Queue Pointer Register */
gmac->GMAC_RBQBAPQ[queue->que_idx - 1] = (u32_t)rx_desc_list->buf;
/* Set Transmit Buffer Queue Pointer Register */
gmac->GMAC_TBQBAPQ[queue->que_idx - 1] = (u32_t)tx_desc_list->buf;
LOG_INF("Queue %d set to idle", queue->que_idx);
return 0;
}
static int queue_init(Gmac *gmac, struct gmac_queue *queue)
{
if (queue->que_idx == 0) {
return nonpriority_queue_init(gmac, queue);
} else if (queue->que_idx <= GMAC_PRIORITY_QUEUE_NO) {
return priority_queue_init(gmac, queue);
} else {
return priority_queue_init_as_idle(gmac, queue);
}
}
static struct net_pkt *frame_get(struct gmac_queue *queue)
{
struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list;
@@ -1270,19 +1402,28 @@ static void eth_rx(struct gmac_queue *queue)
}
#if !defined(CONFIG_ETH_SAM_GMAC_FORCE_QUEUE) && \
((CONFIG_ETH_SAM_GMAC_QUEUES != NET_TC_TX_COUNT) || \
((GMAC_ACTIVE_QUEUE_NUM != NET_TC_TX_COUNT) || \
((NET_TC_TX_COUNT != NET_TC_RX_COUNT) && defined(CONFIG_NET_VLAN)))
static int priority2queue(enum net_priority priority)
{
static const u8_t queue_priority_map[] = {
#if CONFIG_ETH_SAM_GMAC_QUEUES == 1
#if GMAC_ACTIVE_QUEUE_NUM == 1
0, 0, 0, 0, 0, 0, 0, 0
#endif
#if CONFIG_ETH_SAM_GMAC_QUEUES == 2
#if GMAC_ACTIVE_QUEUE_NUM == 2
0, 0, 0, 0, 1, 1, 1, 1
#endif
#if CONFIG_ETH_SAM_GMAC_QUEUES == 3
#if GMAC_ACTIVE_QUEUE_NUM == 3
0, 0, 0, 0, 1, 1, 2, 2
#endif
#if GMAC_ACTIVE_QUEUE_NUM == 4
0, 0, 0, 0, 1, 1, 2, 3
#endif
#if GMAC_ACTIVE_QUEUE_NUM == 5
0, 0, 0, 0, 1, 2, 3, 4
#endif
#if GMAC_ACTIVE_QUEUE_NUM == 6
0, 0, 0, 1, 2, 3, 4, 5
#endif
};
@@ -1328,7 +1469,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt)
#if defined(CONFIG_ETH_SAM_GMAC_FORCE_QUEUE)
/* Route eveything to the forced queue */
queue = &dev_data->queue_list[CONFIG_ETH_SAM_GMAC_FORCED_QUEUE];
#elif CONFIG_ETH_SAM_GMAC_QUEUES == CONFIG_NET_TC_TX_COUNT
#elif GMAC_ACTIVE_QUEUE_NUM == CONFIG_NET_TC_TX_COUNT
/* Prefer to chose queue based on its traffic class */
queue = &dev_data->queue_list[net_tx_priority2tc(pkt_prio)];
#else
@@ -1521,7 +1662,7 @@ static void queue0_isr(void *arg)
}
}
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static inline void priority_queue_isr(void *arg, unsigned int queue_idx)
{
struct device *const dev = (struct device *const)arg;
@@ -1572,20 +1713,41 @@ static inline void priority_queue_isr(void *arg, unsigned int queue_idx)
}
#endif
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static void queue1_isr(void *arg)
{
priority_queue_isr(arg, 1);
}
#endif
#if GMAC_PRIORITY_QUEUE_NO == 2
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
static void queue2_isr(void *arg)
{
priority_queue_isr(arg, 2);
}
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
static void queue3_isr(void *arg)
{
priority_queue_isr(arg, 3);
}
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
static void queue4_isr(void *arg)
{
priority_queue_isr(arg, 4);
}
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
static void queue5_isr(void *arg)
{
priority_queue_isr(arg, 5);
}
#endif
static int eth_initialize(struct device *dev)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
@@ -1702,7 +1864,7 @@ static void eth0_iface_init(struct net_if *iface)
NET_LINK_ETHERNET);
/* Initialize GMAC queues */
for (i = 0; i < GMAC_QUEUE_NO; i++) {
for (i = GMAC_QUE_0; i < GMAC_QUEUE_NUM; i++) {
result = queue_init(cfg->regs, &dev_data->queue_list[i]);
if (result < 0) {
LOG_ERR("Unable to initialize ETH queue%d", i);
@@ -1710,14 +1872,14 @@ static void eth0_iface_init(struct net_if *iface)
}
}
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
#if defined(CONFIG_ETH_SAM_GMAC_FORCE_QUEUE)
for (i = 0; i < CONFIG_NET_TC_RX_COUNT; ++i) {
cfg->regs->GMAC_ST1RPQ[i] =
GMAC_ST1RPQ_DSTCM(i) |
GMAC_ST1RPQ_QNB(CONFIG_ETH_SAM_GMAC_FORCED_QUEUE);
}
#elif CONFIG_ETH_SAM_GMAC_QUEUES == NET_TC_RX_COUNT
#elif GMAC_ACTIVE_QUEUE_NUM == NET_TC_RX_COUNT
/* If TC configuration is compatible with HW configuration, setup the
* screening registers based on the DS/TC values.
* Map them 1:1 - TC 0 -> Queue 0, TC 1 -> Queue 1 etc.
@@ -1779,13 +1941,13 @@ static enum ethernet_hw_caps eth_sam_gmac_get_capabilities(struct device *dev)
ETHERNET_PTP |
#endif
ETHERNET_PRIORITY_QUEUES |
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
ETHERNET_QAV |
#endif
ETHERNET_LINK_100BASE_T;
}
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static int eth_sam_gmac_set_qav_param(struct device *dev,
enum ethernet_config_type type,
const struct ethernet_config *config)
@@ -1833,7 +1995,7 @@ static int eth_sam_gmac_set_config(struct device *dev,
const struct ethernet_config *config)
{
switch (type) {
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
case ETHERNET_CONFIG_TYPE_QAV_PARAM:
return eth_sam_gmac_set_qav_param(dev, type, config);
#endif
@@ -1844,7 +2006,7 @@ static int eth_sam_gmac_set_config(struct device *dev,
return -ENOTSUP;
}
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
static int eth_sam_gmac_get_qav_param(struct device *dev,
enum ethernet_config_type type,
struct ethernet_config *config)
@@ -1879,7 +2041,7 @@ static int eth_sam_gmac_get_qav_param(struct device *dev,
return eth_sam_gmac_get_qav_delta_bandwidth(gmac, queue_id,
delta_bandwidth);
case ETHERNET_QAV_PARAM_TYPE_TRAFFIC_CLASS:
#if CONFIG_ETH_SAM_GMAC_QUEUES == NET_TC_TX_COUNT
#if GMAC_ACTIVE_QUEUE_NUM == NET_TC_TX_COUNT
config->qav_param.traffic_class = queue_id;
return 0;
#else
@@ -1900,9 +2062,9 @@ static int eth_sam_gmac_get_config(struct device *dev,
{
switch (type) {
case ETHERNET_CONFIG_TYPE_PRIORITY_QUEUES_NUM:
config->priority_queues_num = GMAC_PRIORITY_QUEUE_NO;
config->priority_queues_num = GMAC_ACTIVE_PRIORITY_QUEUE_NUM;
return 0;
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
case ETHERNET_CONFIG_TYPE_QAV_PARAM:
return eth_sam_gmac_get_qav_param(dev, type, config);
#endif
@@ -1943,17 +2105,35 @@ static void eth0_irq_config(void)
DEVICE_GET(eth0_sam_gmac), 0);
irq_enable(GMAC_IRQn);
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
IRQ_CONNECT(GMAC_Q1_IRQn, CONFIG_ETH_SAM_GMAC_IRQ_PRI, queue1_isr,
DEVICE_GET(eth0_sam_gmac), 0);
irq_enable(GMAC_Q1_IRQn);
#endif
#if GMAC_PRIORITY_QUEUE_NO == 2
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
IRQ_CONNECT(GMAC_Q2_IRQn, CONFIG_ETH_SAM_GMAC_IRQ_PRI, queue2_isr,
DEVICE_GET(eth0_sam_gmac), 0);
irq_enable(GMAC_Q2_IRQn);
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
IRQ_CONNECT(GMAC_Q3_IRQn, CONFIG_ETH_SAM_GMAC_IRQ_PRI, queue3_isr,
DEVICE_GET(eth0_sam_gmac), 0);
irq_enable(GMAC_Q3_IRQn);
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
IRQ_CONNECT(GMAC_Q4_IRQn, CONFIG_ETH_SAM_GMAC_IRQ_PRI, queue4_isr,
DEVICE_GET(eth0_sam_gmac), 0);
irq_enable(GMAC_Q4_IRQn);
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
IRQ_CONNECT(GMAC_Q5_IRQn, CONFIG_ETH_SAM_GMAC_IRQ_PRI, queue5_isr,
DEVICE_GET(eth0_sam_gmac), 0);
irq_enable(GMAC_Q5_IRQn);
#endif
}
static const struct soc_gpio_pin pins_eth0[] = PINS_GMAC0;
@@ -1978,7 +2158,8 @@ static struct eth_sam_dev_data eth0_data = {
CONFIG_ETH_SAM_GMAC_MAC5,
},
#endif
.queue_list = {{
.queue_list = {
{
.que_idx = GMAC_QUE_0,
.rx_desc_list = {
.buf = rx_desc_que0,
@@ -2001,6 +2182,7 @@ static struct eth_sam_dev_data eth0_data = {
},
#endif
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 1
}, {
.que_idx = GMAC_QUE_1,
.rx_desc_list = {
@@ -2011,7 +2193,7 @@ static struct eth_sam_dev_data eth0_data = {
.buf = tx_desc_que1,
.len = ARRAY_SIZE(tx_desc_que1),
},
#if GMAC_PRIORITY_QUEUE_NO >= 1
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
.rx_frag_list = rx_frag_list_que1,
#if GMAC_MULTIPLE_TX_PACKETS == 1
.tx_frag_list = {
@@ -2026,6 +2208,8 @@ static struct eth_sam_dev_data eth0_data = {
#endif
#endif
#endif
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 2
}, {
.que_idx = GMAC_QUE_2,
.rx_desc_list = {
@@ -2036,7 +2220,7 @@ static struct eth_sam_dev_data eth0_data = {
.buf = tx_desc_que2,
.len = ARRAY_SIZE(tx_desc_que2),
},
#if GMAC_PRIORITY_QUEUE_NO == 2
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
.rx_frag_list = rx_frag_list_que2,
#if GMAC_MULTIPLE_TX_PACKETS == 1
.tx_frag_list = {
@@ -2050,6 +2234,88 @@ static struct eth_sam_dev_data eth0_data = {
}
#endif
#endif
#endif
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 3
}, {
.que_idx = GMAC_QUE_3,
.rx_desc_list = {
.buf = rx_desc_que3,
.len = ARRAY_SIZE(rx_desc_que3),
},
.tx_desc_list = {
.buf = tx_desc_que3,
.len = ARRAY_SIZE(tx_desc_que3),
},
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
.rx_frag_list = rx_frag_list_que3,
#if GMAC_MULTIPLE_TX_PACKETS == 1
.tx_frag_list = {
.buf = (u32_t *)tx_frag_list_que3,
.len = ARRAY_SIZE(tx_frag_list_que3),
},
#if defined(CONFIG_PTP_CLOCK_SAM_GMAC)
.tx_frames = {
.buf = (u32_t *)tx_frame_list_que3,
.len = ARRAY_SIZE(tx_frame_list_que3),
}
#endif
#endif
#endif
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 4
}, {
.que_idx = GMAC_QUE_4,
.rx_desc_list = {
.buf = rx_desc_que4,
.len = ARRAY_SIZE(rx_desc_que4),
},
.tx_desc_list = {
.buf = tx_desc_que4,
.len = ARRAY_SIZE(tx_desc_que4),
},
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
.rx_frag_list = rx_frag_list_que4,
#if GMAC_MULTIPLE_TX_PACKETS == 1
.tx_frag_list = {
.buf = (u32_t *)tx_frag_list_que4,
.len = ARRAY_SIZE(tx_frag_list_que4),
},
#if defined(CONFIG_PTP_CLOCK_SAM_GMAC)
.tx_frames = {
.buf = (u32_t *)tx_frame_list_que4,
.len = ARRAY_SIZE(tx_frame_list_que4),
}
#endif
#endif
#endif
#endif
#if GMAC_PRIORITY_QUEUE_NUM >= 5
}, {
.que_idx = GMAC_QUE_5,
.rx_desc_list = {
.buf = rx_desc_que5,
.len = ARRAY_SIZE(rx_desc_que5),
},
.tx_desc_list = {
.buf = tx_desc_que5,
.len = ARRAY_SIZE(tx_desc_que5),
},
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
.rx_frag_list = rx_frag_list_que5,
#if GMAC_MULTIPLE_TX_PACKETS == 1
.tx_frag_list = {
.buf = (u32_t *)tx_frag_list_que5,
.len = ARRAY_SIZE(tx_frag_list_que5),
},
#if defined(CONFIG_PTP_CLOCK_SAM_GMAC)
.tx_frames = {
.buf = (u32_t *)tx_frame_list_que5,
.len = ARRAY_SIZE(tx_frame_list_que5),
}
#endif
#endif
#endif
#endif
}
},

View File

@@ -27,34 +27,71 @@
#define GMAC_FRAME_SIZE_MAX (GMAC_MTU + 18)
/** Cache alignment */
#define GMAC_DCACHE_ALIGNMENT 32
#define GMAC_DCACHE_ALIGNMENT 32
/** Memory alignment of the RX/TX Buffer Descriptor List */
#define GMAC_DESC_ALIGNMENT 4
#define GMAC_DESC_ALIGNMENT 4
/** Total number of queues supported by GMAC hardware module */
#define GMAC_QUEUE_NO 3
#if defined(CONFIG_SOC_ATMEL_SAME70_REVB) || \
defined(CONFIG_SOC_ATMEL_SAMV71_REVB)
#define GMAC_QUEUE_NUM 6
#elif !defined(CONFIG_SOC_SERIES_SAM4E)
#define GMAC_QUEUE_NUM 3
#else
#define GMAC_QUEUE_NUM 1
#endif
#define GMAC_PRIORITY_QUEUE_NUM (GMAC_QUEUE_NUM - 1)
#if (GMAC_PRIORITY_QUEUE_NUM >= 1)
BUILD_ASSERT_MSG(ARRAY_SIZE(GMAC->GMAC_TBQBAPQ) + 1 == GMAC_QUEUE_NUM,
"GMAC_QUEUE_NUM doesn't match soc header");
#endif
/** Number of priority queues used */
#define GMAC_PRIORITY_QUEUE_NO (CONFIG_ETH_SAM_GMAC_QUEUES - 1)
#define GMAC_ACTIVE_QUEUE_NUM (CONFIG_ETH_SAM_GMAC_QUEUES)
#define GMAC_ACTIVE_PRIORITY_QUEUE_NUM (GMAC_ACTIVE_QUEUE_NUM - 1)
/** RX descriptors count for main queue */
#define MAIN_QUEUE_RX_DESC_COUNT CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT
#define MAIN_QUEUE_RX_DESC_COUNT CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT
/** TX descriptors count for main queue */
#define MAIN_QUEUE_TX_DESC_COUNT (CONFIG_NET_BUF_TX_COUNT + 1)
#define MAIN_QUEUE_TX_DESC_COUNT (CONFIG_NET_BUF_TX_COUNT + 1)
/** RX/TX descriptors count for priority queues */
#if GMAC_PRIORITY_QUEUE_NO == 2
#define PRIORITY_QUEUE2_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE2_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
#define PRIORITY_QUEUE1_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE1_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#else
#define PRIORITY_QUEUE2_RX_DESC_COUNT 1
#define PRIORITY_QUEUE2_TX_DESC_COUNT 1
#define PRIORITY_QUEUE1_RX_DESC_COUNT 1
#define PRIORITY_QUEUE1_TX_DESC_COUNT 1
#endif
#if GMAC_PRIORITY_QUEUE_NO >= 1
#define PRIORITY_QUEUE1_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE1_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
#define PRIORITY_QUEUE2_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE2_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#else
#define PRIORITY_QUEUE1_RX_DESC_COUNT 1
#define PRIORITY_QUEUE1_TX_DESC_COUNT 1
#define PRIORITY_QUEUE2_RX_DESC_COUNT 1
#define PRIORITY_QUEUE2_TX_DESC_COUNT 1
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
#define PRIORITY_QUEUE3_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE3_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#else
#define PRIORITY_QUEUE3_RX_DESC_COUNT 1
#define PRIORITY_QUEUE3_TX_DESC_COUNT 1
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
#define PRIORITY_QUEUE4_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE4_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#else
#define PRIORITY_QUEUE4_RX_DESC_COUNT 1
#define PRIORITY_QUEUE4_TX_DESC_COUNT 1
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
#define PRIORITY_QUEUE5_RX_DESC_COUNT MAIN_QUEUE_RX_DESC_COUNT
#define PRIORITY_QUEUE5_TX_DESC_COUNT MAIN_QUEUE_TX_DESC_COUNT
#else
#define PRIORITY_QUEUE5_RX_DESC_COUNT 1
#define PRIORITY_QUEUE5_TX_DESC_COUNT 1
#endif
/*
@@ -147,6 +184,9 @@ enum queue_idx {
GMAC_QUE_0, /** Main queue */
GMAC_QUE_1, /** Priority queue 1 */
GMAC_QUE_2, /** Priority queue 2 */
GMAC_QUE_3, /** Priority queue 3 */
GMAC_QUE_4, /** Priority queue 4 */
GMAC_QUE_5, /** Priority queue 5 */
};
/** Minimal ring buffer implementation */
@@ -217,7 +257,7 @@ struct eth_sam_dev_data {
struct device *ptp_clock;
#endif
u8_t mac_addr[6];
struct gmac_queue queue_list[GMAC_QUEUE_NO];
struct gmac_queue queue_list[GMAC_QUEUE_NUM];
};
#define DEV_CFG(dev) \

View File

@@ -71,6 +71,8 @@ static inline int z_vrfy_gpio_pin_interrupt_configure(struct device *port,
static inline int z_vrfy_gpio_enable_callback(struct device *port,
gpio_pin_t pin)
{
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, enable_callback));
return z_impl_gpio_enable_callback((struct device *)port, pin);
}
#include <syscalls/gpio_enable_callback_mrsh.c>
@@ -78,12 +80,16 @@ static inline int z_vrfy_gpio_enable_callback(struct device *port,
static inline int z_vrfy_gpio_disable_callback(struct device *port,
gpio_pin_t pin)
{
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, disable_callback));
return z_impl_gpio_disable_callback((struct device *)port, pin);
}
#include <syscalls/gpio_disable_callback_mrsh.c>
static inline int z_vrfy_gpio_get_pending_int(struct device *dev)
{
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(dev, get_pending_int));
return z_impl_gpio_get_pending_int((struct device *)dev);
}
#include <syscalls/gpio_get_pending_int_mrsh.c>

View File

@@ -10,6 +10,9 @@ menuconfig HWINFO
if HWINFO
config HWINFO_HAS_DRIVER
bool
config HWINFO_SHELL
bool "Enable HWINFO Shell"
depends on SHELL
@@ -20,14 +23,15 @@ config HWINFO_STM32
bool "STM32 hwinfo"
default y
depends on SOC_FAMILY_STM32
select USE_STM32_LL_UTILS
select HWINFO_HAS_DRIVER
help
Enable STM32 hwinfo driver.
config HWINFO_NRF
bool "NRF device ID"
default y
depends on SOC_FAMILY_NRF
depends on SOC_FAMILY_NRF && !TRUSTED_EXECUTION_NONSECURE
select HWINFO_HAS_DRIVER
help
Enable Nordic NRF hwinfo driver.
@@ -35,6 +39,7 @@ config HWINFO_MCUX_SIM
bool "NXP kinetis device ID"
default y
depends on HAS_MCUX_SIM
select HWINFO_HAS_DRIVER
help
Enable NXP kinetis mcux hwinfo driver.
@@ -42,6 +47,7 @@ config HWINFO_IMXRT
bool "NXP i.mx RT device ID"
default y
depends on SOC_SERIES_IMX_RT
select HWINFO_HAS_DRIVER
help
Enable NXP i.mx RT hwinfo driver.
@@ -49,6 +55,7 @@ config HWINFO_SAM
bool "Atmel SAM device ID"
default y
depends on SOC_FAMILY_SAM
select HWINFO_HAS_DRIVER
help
Enable Atmel SAM hwinfo driver.
@@ -56,6 +63,7 @@ config HWINFO_SAM0
bool "Atmel SAM0 device ID"
default y
depends on SOC_FAMILY_SAM0
select HWINFO_HAS_DRIVER
help
Enable Atmel SAM0 hwinfo driver.
@@ -63,6 +71,7 @@ config HWINFO_ESP32
bool "ESP32 device ID"
default y
depends on SOC_ESP32
select HWINFO_HAS_DRIVER
help
Enable ESP32 hwinfo driver.
@@ -70,6 +79,7 @@ config HWINFO_LITEX
bool "LiteX device ID"
default y
depends on SOC_RISCV32_LITEX_VEXRISCV
select HWINFO_HAS_DRIVER
help
Enable LiteX hwinfo driver
endif

View File

@@ -73,7 +73,13 @@ static int hwinfo_sam_init(struct device *arg)
/* Disable code loop optimization and sequential code optimization. */
fmr = efc->EEFC_FMR;
#ifndef CONFIG_SOC_SERIES_SAM3X
efc->EEFC_FMR = (fmr & (~EEFC_FMR_CLOE)) | EEFC_FMR_SCOD;
#else
/* SAM3x does not have loop optimization (EEFC_FMR_CLOE) */
efc->EEFC_FMR |= EEFC_FMR_SCOD;
#endif
/* Read the device ID using code in RAM */
hwinfo_sam_read_device_id();

View File

@@ -1,7 +1,7 @@
/* ieee802154_rf2xx.c - ATMEL RF2XX IEEE 802.15.4 Driver */
/*
* Copyright (c) 2019 Gerson Fernando Budke
* Copyright (c) 2019-2020 Gerson Fernando Budke
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -77,16 +77,6 @@ static inline void trx_isr_handler(struct device *port,
k_sem_give(&ctx->trx_isr_lock);
}
static void trx_isr_timeout(struct k_timer *timer_id)
{
struct rf2xx_context *ctx = (struct rf2xx_context *)
k_timer_user_data_get(timer_id);
k_mutex_lock(&ctx->phy_mutex, K_FOREVER);
ctx->trx_state = RF2XX_TRX_PHY_STATE_IDLE;
k_mutex_unlock(&ctx->phy_mutex);
}
static void rf2xx_trx_set_state(struct device *dev,
enum rf2xx_trx_state_cmd_t state)
{
@@ -104,6 +94,30 @@ static void rf2xx_trx_set_state(struct device *dev,
RF2XX_TRX_PHY_STATUS_MASK));
}
static void rf2xx_trx_set_tx_state(struct device *dev)
{
u8_t status;
/**
* Ensures that RX automatically ACK will be sent when requested.
* Datasheet: Chapter 7.2.3 RX_AACK_ON Receive with Automatic ACK
* Datasheet: Figure 7-13. Timing Example of an RX_AACK Transaction
* for Slotted Operation.
*
* This will create a spin lock that wait transceiver be free from
* current receive frame process
*/
do {
status = (rf2xx_iface_reg_read(dev, RF2XX_TRX_STATUS_REG) &
RF2XX_TRX_PHY_STATUS_MASK);
} while (status == RF2XX_TRX_PHY_STATUS_BUSY_RX_AACK ||
status == RF2XX_TRX_PHY_STATUS_STATE_TRANSITION);
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TRX_OFF);
rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG);
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TX_ARET_ON);
}
static void rf2xx_trx_set_rx_state(struct device *dev)
{
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TRX_OFF);
@@ -131,8 +145,12 @@ static void rf2xx_trx_rx(struct device *dev)
* This obligate the driver to have rx_buf statically allocated with
* RX2XX_MAX_FRAME_SIZE.
*/
rf2xx_iface_frame_read(dev, rx_buf, RX2XX_FRAME_HEADER_SIZE);
pkt_len = rx_buf[RX2XX_FRAME_PHR_INDEX];
if (ctx->trx_model != RF2XX_TRX_MODEL_231) {
pkt_len = ctx->rx_phr;
} else {
rf2xx_iface_frame_read(dev, rx_buf, RX2XX_FRAME_HEADER_SIZE);
pkt_len = rx_buf[RX2XX_FRAME_PHR_INDEX];
}
if (pkt_len < RX2XX_FRAME_MIN_PHR_SIZE) {
LOG_ERR("invalid RX frame length");
@@ -190,6 +208,53 @@ static void rf2xx_trx_rx(struct device *dev)
K_THREAD_STACK_SIZEOF(ctx->trx_stack));
}
}
static void rf2xx_process_rx_frame(struct device *dev)
{
struct rf2xx_context *ctx = dev->driver_data;
if (ctx->trx_model != RF2XX_TRX_MODEL_231) {
rf2xx_trx_rx(dev);
} else {
/* Ensures that automatically ACK will be sent
* when requested
*/
while (rf2xx_iface_reg_read(dev, RF2XX_TRX_STATUS_REG) ==
RF2XX_TRX_PHY_STATUS_BUSY_RX_AACK) {
;
};
/* Set PLL_ON to avoid transceiver receive
* new data until finish reading process
*/
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_PLL_ON);
rf2xx_trx_rx(dev);
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_RX_AACK_ON);
}
}
static void rf2xx_process_tx_frame(struct device *dev)
{
struct rf2xx_context *ctx = dev->driver_data;
ctx->trx_trac = (rf2xx_iface_reg_read(dev, RF2XX_TRX_STATE_REG) >>
RF2XX_TRAC_STATUS) & 7;
k_sem_give(&ctx->trx_tx_sync);
rf2xx_trx_set_rx_state(dev);
}
static void rf2xx_process_trx_end(struct device *dev)
{
u8_t trx_status = (rf2xx_iface_reg_read(dev, RF2XX_TRX_STATUS_REG) &
RF2XX_TRX_PHY_STATUS_MASK);
if (trx_status == RF2XX_TRX_PHY_STATUS_TX_ARET_ON) {
rf2xx_process_tx_frame(dev);
} else {
rf2xx_process_rx_frame(dev);
}
}
static void rf2xx_thread_main(void *arg)
{
struct device *dev = INT_TO_POINTER(arg);
@@ -198,9 +263,9 @@ static void rf2xx_thread_main(void *arg)
while (true) {
k_sem_take(&ctx->trx_isr_lock, K_FOREVER);
k_mutex_lock(&ctx->phy_mutex, K_FOREVER);
isr_status = rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG);
/*
* IRQ_7 (BAT_LOW) Indicates a supply voltage below the
* programmed threshold. 9.5.4
@@ -228,39 +293,12 @@ static void rf2xx_thread_main(void *arg)
* IRQ_0 (PLL_LOCK) Indicates PLL lock.
*/
if (isr_status & (1 << RF2XX_RX_START)) {
ctx->trx_state = RF2XX_TRX_PHY_BUSY_RX;
k_timer_start(&ctx->trx_isr_timeout, K_MSEC(10), 0);
} else if (isr_status & (1 << RF2XX_TRX_END)) {
if (ctx->trx_state == RF2XX_TRX_PHY_BUSY_RX) {
/* Ensures that automatically ACK will be sent
* when requested
*/
while (rf2xx_iface_reg_read(dev,
RF2XX_TRX_STATUS_REG) ==
RF2XX_TRX_PHY_STATUS_BUSY_RX_AACK) {
};
/* Set PLL_ON to avoid transceiver receive
* new data until finish reading process
*/
rf2xx_trx_set_state(dev,
RF2XX_TRX_PHY_STATE_CMD_PLL_ON);
k_timer_stop(&ctx->trx_isr_timeout);
rf2xx_trx_rx(dev);
rf2xx_trx_set_state(dev,
RF2XX_TRX_PHY_STATE_CMD_RX_AACK_ON);
/*if (ctx->trx_state == RF2XX_TRX_PHY_BUSY_TX)*/
} else {
ctx->trx_trac =
(rf2xx_iface_reg_read(dev,
RF2XX_TRX_STATE_REG) >>
RF2XX_TRAC_STATUS) & 7;
k_sem_give(&ctx->trx_tx_sync);
rf2xx_trx_set_rx_state(dev);
if (ctx->trx_model != RF2XX_TRX_MODEL_231) {
rf2xx_iface_sram_read(dev, 0, &ctx->rx_phr, 1);
}
ctx->trx_state = RF2XX_TRX_PHY_STATE_IDLE;
} else if (isr_status & (1 << RF2XX_TRX_END)) {
rf2xx_process_trx_end(dev);
}
k_mutex_unlock(&ctx->phy_mutex);
}
}
@@ -434,37 +472,14 @@ static int rf2xx_tx(struct device *dev,
ARG_UNUSED(pkt);
struct rf2xx_context *ctx = dev->driver_data;
bool abort = true;
int response = 0;
k_mutex_lock(&ctx->phy_mutex, K_FOREVER);
/* Reset semaphore in case ACK was received after timeout */
rf2xx_trx_set_tx_state(dev);
rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG);
k_sem_reset(&ctx->trx_tx_sync);
if (ctx->trx_state == RF2XX_TRX_PHY_STATE_IDLE) {
ctx->trx_state = RF2XX_TRX_PHY_BUSY_TX;
abort = false;
/**
* Set extended TX mode
* Datasheet: chapter 7.2 Extended Operating Mode
*/
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TX_ARET_ON);
rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG);
rf2xx_iface_frame_write(dev, frag->data, frag->len);
rf2xx_iface_phy_tx_start(dev);
}
k_mutex_unlock(&ctx->phy_mutex);
if (abort) {
LOG_DBG("TX Abort, TRX isn't idle!");
return -EBUSY;
}
/**
* Wait transceiver...
*/
rf2xx_iface_frame_write(dev, frag->data, frag->len);
rf2xx_iface_phy_tx_start(dev);
k_sem_take(&ctx->trx_tx_sync, K_FOREVER);
switch (ctx->trx_trac) {
@@ -506,11 +521,11 @@ static int rf2xx_start(struct device *dev)
const struct rf2xx_config *conf = dev->config->config_info;
struct rf2xx_context *ctx = dev->driver_data;
k_mutex_lock(&ctx->phy_mutex, K_FOREVER);
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TRX_OFF);
rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG);
gpio_pin_interrupt_configure(ctx->irq_gpio, conf->irq.pin,
GPIO_INT_EDGE_TO_ACTIVE);
rf2xx_trx_set_rx_state(dev);
k_mutex_unlock(&ctx->phy_mutex);
return 0;
}
@@ -520,11 +535,10 @@ static int rf2xx_stop(struct device *dev)
const struct rf2xx_config *conf = dev->config->config_info;
struct rf2xx_context *ctx = dev->driver_data;
k_mutex_lock(&ctx->phy_mutex, K_FOREVER);
gpio_pin_interrupt_configure(ctx->irq_gpio, conf->irq.pin,
GPIO_INT_DISABLE);
rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TRX_OFF);
k_mutex_unlock(&ctx->phy_mutex);
rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG);
return 0;
}
@@ -545,8 +559,6 @@ static int power_on_and_setup(struct device *dev)
struct rf2xx_context *ctx = dev->driver_data;
u8_t config;
ctx->trx_state = RF2XX_TRX_PHY_STATE_IDLE;
rf2xx_iface_phy_rst(dev);
/* Sync transceiver state */
@@ -721,11 +733,8 @@ static int rf2xx_init(struct device *dev)
LOG_DBG("\nInitialize RF2XX Transceiver\n");
k_mutex_init(&ctx->phy_mutex);
k_sem_init(&ctx->trx_tx_sync, 0, 1);
k_sem_init(&ctx->trx_isr_lock, 0, 1);
k_timer_init(&ctx->trx_isr_timeout, trx_isr_timeout, NULL);
k_timer_user_data_set(&ctx->trx_isr_timeout, ctx);
if (configure_gpios(dev) != 0) {
LOG_ERR("Configuring GPIOS failed");
@@ -860,12 +869,10 @@ static struct ieee802154_radio_api rf2xx_radio_api = {
.spi.cs.devname = DT_INST_##n##_ATMEL_RF2XX_CS_GPIOS_CONTROLLER, \
.spi.cs.pin = DT_INST_##n##_ATMEL_RF2XX_CS_GPIOS_PIN, \
.spi.cs.flags = DT_INST_##n##_ATMEL_RF2XX_CS_GPIOS_FLAGS, \
}
};
#define IEEE802154_RF2XX_DEVICE_DATA(n) \
static struct rf2xx_context rf2xx_ctx_data_##n = { \
.trx_state = RF2XX_TRX_PHY_STATE_INITIAL, \
}
static struct rf2xx_context rf2xx_ctx_data_##n;
#define IEEE802154_RF2XX_RAW_DEVICE_INIT(n) \
DEVICE_AND_API_INIT( \

View File

@@ -1,7 +1,7 @@
/* ieee802154_rf2xx.h - IEEE 802.15.4 Driver definition for ATMEL RF2XX */
/*
* Copyright (c) 2019 Gerson Fernando Budke
* Copyright (c) 2019-2020 Gerson Fernando Budke
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -65,14 +65,6 @@ enum rf2xx_trx_state_trac_t {
RF2XX_TRX_PHY_STATE_TRAC_INVALID = 0x07,
};
enum rf2xx_trx_state_t {
RF2XX_TRX_PHY_STATE_INITIAL,
RF2XX_TRX_PHY_STATE_IDLE,
RF2XX_TRX_PHY_STATE_SLEEP,
RF2XX_TRX_PHY_BUSY_RX,
RF2XX_TRX_PHY_BUSY_TX,
};
enum rf2xx_trx_model_t {
RF2XX_TRX_MODEL_INV = 0x00,
RF2XX_TRX_MODEL_230 = 0x02,
@@ -127,11 +119,8 @@ struct rf2xx_context {
CONFIG_IEEE802154_RF2XX_RX_STACK_SIZE);
struct k_sem trx_isr_lock;
struct k_sem trx_tx_sync;
struct k_timer trx_isr_timeout;
struct k_mutex phy_mutex;
enum rf2xx_trx_model_t trx_model;
enum rf2xx_trx_state_t trx_state;
enum rf2xx_trx_state_trac_t trx_trac;
u8_t mac_addr[8];
@@ -139,6 +128,7 @@ struct rf2xx_context {
u8_t pkt_ed;
s8_t trx_rssi_base;
u8_t trx_version;
u8_t rx_phr;
};
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_RF2XX_H_ */

View File

@@ -1,7 +1,7 @@
/* ieee802154_rf2xx_iface.c - ATMEL RF2XX IEEE 802.15.4 Interface */
/*
* Copyright (c) 2019 Gerson Fernando Budke
* Copyright (c) 2019-2020 Gerson Fernando Budke
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -248,3 +248,49 @@ void rf2xx_iface_frame_write(struct device *dev,
LOG_DBG("Frame W: PhyStatus: %02X. length: %02X", status, length);
LOG_HEXDUMP_DBG(data, length, "payload");
}
void rf2xx_iface_sram_read(struct device *dev,
u8_t address,
u8_t *data,
u8_t length)
{
const struct rf2xx_context *ctx = dev->driver_data;
u8_t cmd = RF2XX_RF_CMD_SRAM_R;
u8_t status[2];
const struct spi_buf tx_buf[2] = {
{
.buf = &cmd,
.len = 1
},
{
.buf = &address,
.len = 1
},
};
const struct spi_buf_set tx = {
.buffers = tx_buf,
.count = 2
};
const struct spi_buf rx_buf[2] = {
{
.buf = status,
.len = 2
},
{
.buf = data,
.len = length
},
};
const struct spi_buf_set rx = {
.buffers = rx_buf,
.count = 2
};
if (spi_transceive(ctx->spi, &ctx->spi_cfg, &tx, &rx) != 0) {
LOG_ERR("Failed to exec rf2xx_sram_read");
}
LOG_DBG("SRAM R: length: %02X, status: %02X", length, status[0]);
LOG_HEXDUMP_DBG(data, length, "content");
}

View File

@@ -1,7 +1,7 @@
/* ieee802154_rf2xx_iface.h - ATMEL RF2XX transceiver interface */
/*
* Copyright (c) 2019 Gerson Fernando Budke
* Copyright (c) 2019-2020 Gerson Fernando Budke
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -107,4 +107,19 @@ void rf2xx_iface_frame_write(struct device *dev,
u8_t *data,
u8_t length);
/**
* @brief Reads sram data from the transceiver
*
* This function reads the sram data of the transceiver.
*
* @param[in] dev Transceiver device instance
* @param[in] address Start address to be read
* @param[out] data Pointer to the location to store data
* @param[in] length Number of bytes to be read from the sram space
*/
void rf2xx_iface_sram_read(struct device *dev,
u8_t address,
u8_t *data,
u8_t length);
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_RF2XX_IFACE_H_ */

View File

@@ -19,12 +19,16 @@ static inline int z_vrfy_kscan_config(struct device *dev,
static inline int z_vrfy_kscan_disable_callback(struct device *dev);
{
Z_OOPS(Z_SYSCALL_DRIVER_KSCAN(dev, disable_callback));
return z_impl_kscan_disable_callback((struct device *)dev);
}
#include <syscalls/kscan_disable_callback_mrsh.c>
static int z_vrfy_kscan_enable_callback(struct device *dev);
{
Z_OOPS(Z_SYSCALL_DRIVER_KSCAN(dev, enable_callback));
return z_impl_kscan_enable_callback((struct device *)dev);
}
#include <syscalls/kscan_enable_callback_mrsh.c>

View File

@@ -940,7 +940,7 @@ static const struct uart_driver_api uart_sam0_driver_api = {
#define UART_SAM0_IRQ_HANDLER_FUNC(n) \
.irq_config_func = uart_sam0_irq_config_##n,
#ifdef DT_ATMEL_SAM0_UART_0_IRQ_3
#ifdef DT_INST_0_ATMEL_SAM0_UART_IRQ_3
#define UART_SAM0_IRQ_HANDLER(n) \
static void uart_sam0_irq_config_##n(struct device *dev) \
{ \

View File

@@ -83,7 +83,8 @@ static void timer_isr(void *arg)
int z_clock_driver_init(struct device *device)
{
IRQ_CONNECT(RISCV_MACHINE_TIMER_IRQ, 0, timer_isr, NULL, 0);
set_mtimecmp(mtime() + CYC_PER_TICK);
last_count = mtime();
set_mtimecmp(last_count + CYC_PER_TICK);
irq_enable(RISCV_MACHINE_TIMER_IRQ);
return 0;
}

View File

@@ -14,13 +14,8 @@ if WATCHDOG
config WDT_DISABLE_AT_BOOT
bool "Disable at boot"
default y
help
Disable watchdog at Zephyr system startup for the SoCs that enable
the watchdog by default after reset.
Note that disabling this configuration option does not enable the
watchdog for the SoCs that boot with the watchdog disabled.
Disable watchdog at Zephyr system startup.
module = WDT
module-str = watchdog

View File

@@ -114,17 +114,20 @@ static int iwdg_stm32_install_timeout(struct device *dev,
tickstart = k_uptime_get_32();
while (LL_IWDG_IsReady(iwdg) == 0) {
/* Wait until WVU, RVU, PVU are reset before updating */
LL_IWDG_EnableWriteAccess(iwdg);
LL_IWDG_SetPrescaler(iwdg, prescaler);
LL_IWDG_SetReloadCounter(iwdg, reload);
/* Wait for the update operation completed */
while (LL_IWDG_IsReady(iwdg) != 0) {
if ((k_uptime_get_32() - tickstart) > IWDG_DEFAULT_TIMEOUT) {
return -ENODEV;
}
}
LL_IWDG_EnableWriteAccess(iwdg);
LL_IWDG_SetPrescaler(iwdg, prescaler);
LL_IWDG_SetReloadCounter(iwdg, reload);
/* Reload counter just before leaving */
LL_IWDG_ReloadCounter(iwdg);
return 0;
}

View File

@@ -35,6 +35,17 @@
};
soc {
/* Only used for HWINFO device ID */
flash-controller@400e0a00 {
compatible = "atmel,sam-flash-controller";
label = "FLASH_CTRL";
reg = <0x400e0a00 0x200>;
peripheral-id = <6>;
#address-cells = <1>;
#size-cells = <1>;
};
wdog: watchdog@400e1a50 {
compatible = "atmel,sam-watchdog";
reg = <0x400e1a50 0xc>;

View File

@@ -34,6 +34,17 @@
};
soc {
/* Only used for HWINFO device ID */
flash-controller@400e0a00 {
compatible = "atmel,sam-flash-controller";
label = "FLASH_CTRL";
reg = <0x400e0a00 0x200>;
peripheral-id = <6>;
#address-cells = <1>;
#size-cells = <1>;
};
wdog: watchdog@400e1850 {
compatible = "atmel,sam-watchdog";
reg = <0x400e1850 0x10>;

View File

@@ -35,6 +35,17 @@
};
soc {
/* Only used for HWINFO device ID */
flash-controller@400e0a00 {
compatible = "atmel,sam-flash-controller";
label = "FLASH_CTRL";
reg = <0x400e0a00 0x200>;
peripheral-id = <6>;
#address-cells = <1>;
#size-cells = <1>;
};
wdog: watchdog@400e1450 {
compatible = "atmel,sam-watchdog";
reg = <0x400e1450 0xc>;

View File

@@ -322,6 +322,7 @@ struct bt_le_adv_param {
*/
#define BT_LE_ADV_PARAM(_options, _int_min, _int_max) \
((struct bt_le_adv_param[]) { { \
.id = BT_ID_DEFAULT, \
.options = (_options), \
.interval_min = (_int_min), \
.interval_max = (_int_max), \

View File

@@ -817,10 +817,11 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
#define BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _value) \
{ \
.uuid = _uuid, \
.perm = _perm, \
.read = _read, \
.write = _write, \
.user_data = _value, \
.handle = 0, \
.perm = _perm, \
}
/** @brief Notification complete result callback.

View File

@@ -39,7 +39,9 @@ extern "C" {
* @param buffer Buffer to write the ID to.
* @param length Max length of the buffer.
*
* @retval size of the device ID copied or negative on error.
* @retval size of the device ID copied.
* @retval -ENOTSUP if there is no implementation for the particular device.
* @retval any negative value on driver specific errors.
*/
__syscall ssize_t hwinfo_get_device_id(u8_t *buffer, size_t length);

View File

@@ -578,6 +578,8 @@ void arch_mem_domain_destroy(struct k_mem_domain *domain);
* if the supplied memory buffer spans multiple enabled memory management
* regions (even if all such regions permit user access).
*
* @warning 0 size buffer has undefined behavior.
*
* @param addr start address of the buffer
* @param size the size of the buffer
* @param write If nonzero, additionally check if the area is writable.

View File

@@ -28,6 +28,7 @@
* true if the operation overflowed.
*/
/**@{*/
static bool u16_add_overflow(u16_t a, u16_t b, u16_t *result);
static bool u32_add_overflow(u32_t a, u32_t b, u32_t *result);
static bool u64_add_overflow(u64_t a, u64_t b, u64_t *result);
static bool size_add_overflow(size_t a, size_t b, size_t *result);
@@ -40,6 +41,7 @@ static bool size_add_overflow(size_t a, size_t b, size_t *result);
* true if the operation overflowed.
*/
/**@{*/
static bool u16_mul_overflow(u16_t a, u16_t b, u16_t *result);
static bool u32_mul_overflow(u32_t a, u32_t b, u32_t *result);
static bool u64_mul_overflow(u64_t a, u64_t b, u64_t *result);
static bool size_mul_overflow(size_t a, size_t b, size_t *result);

View File

@@ -29,6 +29,11 @@
#endif
#if use_builtin(__builtin_add_overflow)
static inline bool u16_add_overflow(u16_t a, u16_t b, u16_t *result)
{
return __builtin_add_overflow(a, b, result);
}
static inline bool u32_add_overflow(u32_t a, u32_t b, u32_t *result)
{
return __builtin_add_overflow(a, b, result);
@@ -44,6 +49,15 @@ static inline bool size_add_overflow(size_t a, size_t b, size_t *result)
return __builtin_add_overflow(a, b, result);
}
#else /* !use_builtin(__builtin_add_overflow) */
static inline bool u16_add_overflow(u16_t a, u16_t b, u16_t *result)
{
u16_t c = a + b;
*result = c;
return c < a;
}
static inline bool u32_add_overflow(u32_t a, u32_t b, u32_t *result)
{
u32_t c = a + b;
@@ -73,6 +87,11 @@ static inline bool size_add_overflow(size_t a, size_t b, size_t *result)
#endif /* use_builtin(__builtin_add_overflow) */
#if use_builtin(__builtin_mul_overflow)
static inline bool u16_mul_overflow(u16_t a, u16_t b, u16_t *result)
{
return __builtin_mul_overflow(a, b, result);
}
static inline bool u32_mul_overflow(u32_t a, u32_t b, u32_t *result)
{
return __builtin_mul_overflow(a, b, result);
@@ -88,6 +107,15 @@ static inline bool size_mul_overflow(size_t a, size_t b, size_t *result)
return __builtin_mul_overflow(a, b, result);
}
#else /* !use_builtin(__builtin_mul_overflow) */
static inline bool u16_mul_overflow(u16_t a, u16_t b, u16_t *result)
{
u16_t c = a * b;
*result = c;
return a != 0 && (c / a) != b;
}
static inline bool u32_mul_overflow(u32_t a, u32_t b, u32_t *result)
{
u32_t c = a * b;

Some files were not shown because too many files have changed in this diff Show More