Commit graph

41120 commits

Author SHA1 Message Date
Jakub Rzeszutko
b928b71756 shell: rename shell_help_print function
Function printing help has been renamed to shell_help.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko
9e958b405c doc: shell: update according to new help usage
Updated documentation according to recent changes:
1. Removed options from the shell.
2. Simplified help usage.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko
3064ca4f2f shell: creating new module for help functionality
1. Created new shell module: shell_help.
2. Simplified command handlers with new shell print macros.
3. Removed help functions from command handlers.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko
e0be6a10b3 shell: printing command's help by shell engine
Removed printing command help from help handler. It is now
realized by the shell engine. This change saves a lot of flash
but still allows to print help in command handler with function
shell_help_print.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko
5451ff2848 shell: remove "options" concept
Removing help "options" from shell API.

Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.

Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.

And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Loic Poulain
c67bb6d440 wifi: eswifi: Fix/clean TCP receive
This patch adds support for blocking tcp receive (with timeout).
This patch removes dedicated socket polling thread to use common
eswifi workqueue instead.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-12-05 08:56:24 -05:00
Loic Poulain
791343bb18 wifi: eswifi: Add support for non-blocking TCP connect/send
Current implementation unconditionnaly performs blocking connect
and send. Add support for non-blocking version using eswifi workqueue.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-12-05 08:56:24 -05:00
Paul Sokolovsky
1ef52f5c30 samples: console: echo: Be sure to print (both) CR LF in messages
As it stands now, the console effectively works in raw mode, so all
messages should end with "\r\n". This was missed previously, because
the sample was run in QEMU, on top of POSIX cooked console. Running
on real hardware showed this issue.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-12-05 08:54:20 -05:00
Aurelien Jarno
0ac7338258 drivers: console: fix USB_UART_CONSOLE
The USB_UART_CONSOLE option itself is not enough to enable console on
the USB UART port. Most of the code is actually shared with
UART_CONSOLE, so this symbol has to be selected.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Aurelien Jarno
46a1bb7cdd usb: cdc_acm: select SERIAL_HAS_DRIVER and SERIAL_SUPPORT_INTERRUPT
USB CDC ACM is a serial driver like another. Therefore select both
SERIAL_HAS_DRIVER and SERIAL_SUPPORT_INTERRUPT. This allows one to
enable the console driver without having to enable another serial
driver.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Aurelien Jarno
3eda3b61f8 usb: cdc_acm: fix interrupt mode
The CDC ACM driver has to emulate the TX and RX interrupts from the USB
ones. However it does not correctly emulate them as "TX buffer empty"
and "RX buffer not empty" interrupts.

For "TX buffer empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the TX buffer is
  empty
- An interrupt should be triggered when the USB device get configured

For "RX buffer not empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the RX buffer is
  not empty

This make the a console on the USB CDC ACM port usable for the shell
and the logs.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Pawel Dunaj
e344e5752c ext: debug: segger: Fix SEGGER header inclusion
Fix issue caused by 3fc497ac9a

This change removes `rtt` and `systemview` from header includes
as these are already placed in the path.

Also `SEGGER_SYSVIEW_ConfDefaults.h` header included from
`SEGGER_SYSVIEW_Int.h` is placed higher to make sure `INLINE`
definition is properly visible.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2018-12-05 14:35:42 +01:00
Krzysztof Chruscinski
7c68befb15 logging: Fix initial log level in shell
Shell log backends were initialized from shell context. After
lowering logger thread priority order has been flipped. That
revealed a bug where shell logger backend was enabled before
backend ID's has been assigned during logger initialization.

ID assignment is moved to log backend enabling function making
it independent of order of initialization.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-12-05 14:35:33 +01:00
Håkon Øye Amundsen
2a5a02e114 cmake: fix incorrect lower case variable
This patch fixes a bug where a incorrect lower case
variable 'MERGED_HEX_NAME' resulted in the 'flash'
target not getting the correct path to the hex file to flash.
This since cmake/flash/CMakeLists.txt uses the variable
${MERGED_HEX_NAME}.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2018-12-05 14:33:24 +01:00
Tomasz Bursztyka
1a59e0abf1 drivers/ethernet: Adapt stellaris driver to new L2 behaviour
L2 is the one who requests the packet to be sent, and not via net_if API
anymore. Stellaris driver was merged right after this behaviour change
and was thus lacking the proper modification.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 15:04:56 +02:00
Peter A. Bigot
3134468801 drivers: gpio: nrfx: fix lost level interrupts
Nordic devices detect edge interrupts through the PORT event which is
generated on a rising edge of DETECT, which itself is asserted when any
GPIO is configured for sense level detection and the GPIO's input signal
matches the configuration.

The previous code in Zephyr attempts to detect when at least one GPIO
SENSE signal is still asserted, and intentionally leaves the PORT event
uncleared to ensure the interrupt is re-entered.

This approach fails when no pin satisfies its SENSE condition during the
check but at least one input changes level between the completion of the
check and the clear of the PORT event.  Such a failure can be observed
on the pca20020 hardware when multiple sensors configured for level
triggers are active.  In this situation the corresponding sensor trigger
signals remain asserted but the PORT event required to drive their
processing has already been cleared.

The fix is to ensure that the SENSE configuration for all GPIOs across
all port instances is disabled prior to unconditionally clearing the
PORT event, then re-enabling the SENSE configuration for all GPIOs once
callbacks associated with detected SENSE triggers have been performed.
The act of re-enabling will ensure any relevant SENSE condition causes a
new rising edge on DETECT and so a new PORT event.

Closes issue #11806

See: https://devzone.nordicsemi.com/f/nordic-q-a/7246/missing-interrupts-on-gpioe-port-events

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2018-12-05 12:15:11 +01:00
Paul Sokolovsky
6825d91a1b include: __assert: Fix output formatting of __ASSERT_NO_MSG()
Previously, this macro after the main line would print a tab without
newline, leading to messy output. Also, as printk() was made to
return void, remove explicit casts to (void) in its calls.

Before:

tx_fifo: 0x20007298 42
ASSERTION FAIL [(len & 3) == 0 && len >= 4] @ eth_smsc911x.c:83:
	eth_smsc9220_isr: 8 8
in RX FIFO: pkts: 1, bytes: 48

After:

tx_fifo: 0x20007298 42
ASSERTION FAIL [(len & 3) == 0 && len >= 4] @ eth_smsc911x.c:83
eth_smsc9220_isr: 8 8
in RX FIFO: pkts: 1, bytes: 48

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-12-05 11:21:51 +01:00
Nicolás Bértolo
258fd2dbeb kernel: mutex: delay setting lock_count = 0.
It is necessary to delay setting lock_count = 0 because an unlocking thread
maybe swapped out when it calls adjust_owner_prio(). If the thread that starts
running sees lock_count = 0 it will successfully acquire the mutex even though
it is not fully unlocked yet.

Fixes #11798.

Signed-off-by: Nicolás Bértolo <nicolasbertolo@gmail.com>
2018-12-05 11:00:10 +01:00
Tomasz Bursztyka
93fc23bc7e net/icmpv6: Verify header's checksum relevantly
Missing verification.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Tomasz Bursztyka
6c291524bc net/icmpv4: Verify header's checksum relevantly
Missing verification.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Tomasz Bursztyka
3db4378d9e net/ipv4: Verify header's checksum relevantly
Missing verification.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Tomasz Bursztyka
0dd5113ca4 net/connection: Verify UDP and TCP checksum the easy way
No need to store/reset/recompute the chksums, only compute it again and
if it's not 0: drop the packet.

RFC 1071:

"To check a checksum, the 1's complement sum is computed over the
 same set of octets, including the checksum field.  If the result
 is all 1 bits (-0 in 1's complement arithmetic), the check succeeds."

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Tomasz Bursztyka
b4f79ae418 net: Return fully calculated chksum
IPv4, ICMPv4/6, UDP, TCP: all checksums are meant to be one's complement
on a calculated sum. Thus return one's complement already from the right
place instead of applying it in each and every place where
net_calc_chksum is called.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Krzysztof Chruscinski
07e01cbb70 shell: Fix thread priority
Removed kconfig option for setting shell thread priority and fix
it to K_LOWEST_APPLICATION_THREAD_PRIO.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-12-05 10:37:45 +01:00
Kumar Gala
459ad673ba scripts: extract_dts_includes: Fix DeprecationWarning
With python3.7 we get the following warning:

	extract_dts_includes.py:496: DeprecationWarning: Using or
	importing the ABCs from 'collections' instead of from
	'collections.abc' is deprecated, and in 3.8 it will stop
	working.

Fix this by using 'from collections.abc import Mapping' instead of
'import collections'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-04 22:54:46 -05:00
Marti Bolivar
f4c3163d3b arch: riscv32: provide a general mechanism for saving SoC context
RISC-V permits myriad extensions to the ISA, any of which may imply
additional context that must be saved and restored on ISR entry and
exit. The current in-tree example is the Pulpino core, which has extra
registers used by ISA extensions for running loops that shouldn't get
clobbered by an ISR.

This is currently supported by including pulpino-specific definitions
in the generic architecture code. This works, but it's a bit inelegant
and is something of a layering violation. A more generic mechanism is
required to support other RISC-V SoCs with similar requirements
without cluttering the arch code too much.

Provide that by extending the semantics of the existing
CONFIG_RISCV_SOC_CONTEXT_SAVE option to allow other SoCs to allocate
space for saving and restoring their own state, promoting the
currently pulpino-specific __soc_save_context / __soc_restore_context
routines to a RISC-V arch API.

The cost of making this generic is two more instructions in each ISR
to pass the SoC specific context to these routines in a0 rather than
just assuming the stack points to the right place. This is minimal,
and should have been done anyway to keep with the ABI.

As a first (and currently only in-tree) customer, convert the Pulpino
SoC code to this new mechanism.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-04 22:54:23 -05:00
Marti Bolivar
b85d893d60 arch: riscv32: fix IRQ handling bugs when benchmarking
The way that CONFIG_EXECUTION_BENCHMARKING=y is handled on this
architecture is incorrect. The goals are:

- call read_timer_start_of_isr() as close as possible to the
  beginning of the ISR
- call read_timer_end_of_isr() after all preparations have
  been made to call the driver-level IRQ handler, but it hasn't
  been called yet

The current implementation could cause kernel crashes, though.

The read_timer_start_of_isr() call is made before saving MEPC or any
SoC-specific context. The MEPC issue is not that big of a deal, but
doing it before saving SoC context could clobber state that hasn't
been saved yet and corrupt the kernel.

One example is a pulpino style RISC-V SoC. Some Pulpino cores have
extra registers that are used for ISA extensions used to generate code
for C loops. There's no guarantee read_timer_start_of_isr() will never
have a loop inside: in fact, the RISC-V User-Level ISA v2.2 explicitly
recommends using a loop to get the 64-bit value of the "cycle" CSR. A
Pulpino-like SoC with a cycle CSR could thus naturally have a
read_timer_start_of_isr() implementation that involves loops. Saving
the loop state before reading the timer would then be needed.

Fix this issue by moving the call to read_timer_start_of_isr to after
all context saving is done. (This is a fairer comparison to Arm
Cortex-M SoCs anyway, since register stacking is performed in hardware
on Cortex M and is done before the first ISR instruction executes.)

The call to read_timer_end_of_isr() has an issue as well: it's called
after the ISR's argument has been stored in a0 and the ISR address is
in t1, but before actually calling the ISR itself.

In the standard RV32I calling convention, both t1 and a0 are caller
saved, so read_timer_end_of_isr() is within its rights to set them to
any garbage, which we'll happily treat as a function and its argument
and execute.

Avoid that possibility by saving the register values to the stack in
this configuration.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-04 22:54:23 -05:00
Marti Bolivar
eef071ebc3 arch: riscv32: fix comment in offsets.c
The structure names appear to have changed.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-04 22:54:23 -05:00
Marti Bolivar
7425195a25 arch: riscv32: fix INCLUDE_RESET_VECTOR Kconfig help
The generated stub doesn't actually initialize the CPU or jump to
__start. All it does is set up the interrupt stack and jump to
_PrepC. Fix the help.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-04 22:54:23 -05:00
Marti Bolivar
0b234f2518 arch: riscv32: fix fatal.c build without printk
If CONFIG_PRINTK=n, cause_str will not be defined, and _Fault() will
fail to build. Fix that by ifdeffing out the printk call in that case.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-12-04 22:54:23 -05:00
Patrik Flykt
b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
079f55d519 samples: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
8325a395ea soc: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
a76e37a707 misc: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
186fb94bcb lib: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
d0d9eb0e38 kernel: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
25e8e4d4e7 boards: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
494ef1cfe2 arch: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Patrik Flykt
1b48cb6dc1 scripts/coccinelle: Add Coccinelle script for unsigned values
Add a Coccinelle script that adds an 'U' to values assigned to
unsigned variables, according ot MISRA-C rule 7.2.

Add a 'report' mode to the script that can be used by developer/CI
and a 'patch' mode that should do the heavy lifting.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Aurelien Jarno
c6727d49b7 arch: ARM: set -mthumb, -mcpu, -mfpu and -mfloat-abi in linker flags
Some toolchains are built with multilib enabled in order to provide
multiple versions of the same library, optimized for different ABI
or architecture. They require the the ABI/architecture/CPU selection
options to be passed at linked time. This is important for example
when linking with newlib.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-04 19:40:39 -05:00
Aurelien Jarno
d941df7ea7 arch: ARM: set -mabi and -march in linker flags
Some toolchains are built with multilib enabled in order to provide
multiple versions of the same library, optimized for different ABI
or architecture. They require the -march= and -mabi= options to be
passed at link time. This is important for example when linking with
newlib.

We do that by passing zephyr_ld_options the same arguments than
zephyr_compile_options. The -mabi option is passed directly while the
-march option, if defined, is passed through ${ARCH_FLAG}.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-04 19:40:39 -05:00
Krzysztof Chruscinski
f78067e1f9 shell: Refactor RTT backend
Improved reception in the backend and replaced thread
with periodic timer as thread was used only to
periodically poll RTT data availability and using timer
is more RAM-wise efficient.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-12-04 16:24:44 -05:00
Rajavardhan Gundi
2ed29b5545 tests: intel_s1000: i2c: Support green and white LED blinking
S1000 i2c test was blinking only blue and red lights. However, if
we have to distinguish between 2 test images for whatever reasons,
it is handy to have one test image blinking blue-red while the
other blinks green-white.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-04 16:08:34 -05:00
Marcin Szymczyk
d5b79ff42c usb: hid: implement idle rate
Idle rate functionality has been implemented for HID USB class.
Bassed on Device Class Definition for Human Interface Devices 1.11.
Tested with USB3CV and host with idle rate.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Marcin Szymczyk
6a4ddffaf9 usb: hid: default request handlers
HID class now defaults to universal request callbacks in case they
are not provided by the application. This applies to following,
class-specific requests: Get_Report, Set_Report, Get_Idle, Set_Idle,
Get_Protocol and Set_Protocol.
Tested with USB3CV.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Jukka Rissanen
4565ca86da samples: net: syslog: Remote syslog service example
The sample application will send syslog messages to remote
syslog server.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-04 15:55:53 -05:00
Jukka Rissanen
88d3a0a88f net: config: Enable syslog to network in init
Start to send syslog messages to net after we have a proper
IP address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-04 15:55:53 -05:00
Jukka Rissanen
44a9bb6abe logging: Add network backend
Allow logging subsystem to send the logging messages to outside
system. This backend implements RFC 5424 (syslog protocol) and
RFC 5426 (syslog over UDP).

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-04 15:55:53 -05:00