Commit graph

99049 commits

Author SHA1 Message Date
Marti Bolivar
8c095285d1 scripts: west_commands: refactor run_common.py
Pull out some more common functionality we will need elsewhere into a
separate file.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-07 08:44:19 -05:00
Marti Bolivar
8c4479994c scripts: west_commands: refactor build.py
This is a prep work patch for adding another command.  Refactor
build.py to use a new Forceable superclass and find_build_dir() helper
routine. Fix a help string while we are here.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-07 08:44:19 -05:00
Carlos Stuart
0088175450 editorconfig: basic EditorConfig configuration
EditorConfig (https://editorconfig.org) is a widely supported
configuration tool that helps to ensure better consistency amongst
developers by auto-configuring an editor to match the original/intended
style i.e. tab-width etc.

This configuration covers many of the common file formats used in
zephyr.

The configuration was derived by looking at existing files and
ascertaining what configuration they currently use.

This is the top-most EditorConfig file meaning this is the root of all
other EditorConfigs, however sub-directories can set their own up if
they wish to override this.

This has proven especially useful when viewing uncrustified C source
code where the tab-width should be 8 to get proper alignment but many
editors use a tab-width of 4.

Lots of editors support this natively and those that do not probably
have a plugin or extension.

Tested by opening and saving various files to ensure no changes
occurred.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-07 08:15:23 -05:00
Andrew Boie
6ddd0d3f88 arc: uncrustify MPU sources
Using zephyr's .uncrustify.cfg

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-07 08:12:35 -05:00
Himanshu Jha
4c435625ab doc: coccinelle: Add documentation for SPFLAGS usage
Add documentation for -f=/--sp-flag= flag usage with an
example.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2019-02-07 08:12:20 -05:00
Himanshu Jha
b2fa9db074 scripts: coccicheck: Add support for SPFLAGS
SPFLAGS allows to pass additional flags supported by
spatch during transformation.

Both short notation `-f=` and `--sp-flag=` can be used
to pass the flag to the coccicheck.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2019-02-07 08:12:20 -05:00
Jakub Rzeszutko
870e5cb53e shell: fixed parameter type in exec_cmd function
Last parameter of exec_cmd function has been corrected from
structure type to pointer to structure type.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2019-02-07 13:58:43 +01:00
Ravi kumar Veeramally
7e8ded911d samples: sockets: Add packet socket sample application
Sample application which opens a packet socket and receives
every packet on the wire and send some dummy packet over
socket. Simple demo of how to use packet sockets.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Ravi kumar Veeramally
a9a2b3ea91 net: sockets: Add socket api to support AF_PACKET
This commit adds packet socket support to socket api.
This version supports basic packet socket features.
Protocol family is AF_PACKET, type of socket is
SOCK_RAW and proto type is ETH_P_ALL. The user will
receive every packet (with L2 header) on the wire.
For TX, the subsystem expects that the user has set
all the protocol headers (L2 and L3) properly.

Networking subsystem doesn't verify or alter the headers while
sending or receiving the packets. This version supports packet
socket over Etherent only. Also combination of other family
and protocols doesn't work (i.e. Application can not open
packet-socket and non packet-socket together).

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Ravi kumar Veeramally
5012223b31 net: l2: ethernet: Handover net packets to driver
If packet family is AF_PACKET and CONFIG_NET_SOCKETS_PACKET
is enabled, just handover the packet to driver for sending.
L2 layer will not touch AF_PACKETs at the moment.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Ravi kumar Veeramally
b458ebf755 net: core: Handle packets when packet sockets are enabled
If CONFIG_NET_SOCKETS_PACKET is enabled, then feed the packet
to net_packet_socket_input() for processing. It will search
for the net_contexts and if proper handler is found, pass
the packet to connection handler.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Ravi kumar Veeramally
337b6f9a73 net: context: Add packet socket support
This commit adds basic packet socket support to net_context and
allows application to receive or send network packets in raw
format.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Ravi kumar Veeramally
f0fb82dce9 net: ip: Add protocol family type to conn handler
As we are adding more protocol families and protocol types
to connection handlers, some values might be same across
different types. Current connection handler only stores
proto type to match the handler, which is not enough if
we add more types. Also combination of family and types
may vary too. So adding family to connection handler to
figure out best match.

Also changing proto variable in net_conn from u8_t to u16_t.
net_context has 16 bit proto.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Jukka Rissanen
49e6abab26 net: ip: Add helpers for packet socket support
Various defines and helpers for supporting packet sockets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Ravi kumar Veeramally
8de3a62444 net: pkt: Set default data_len to iface MTU
When creating net_pkt, the default value of net_pkt data_len was
set to zero. In case of RAW sockets, when family is AF_PACKET,
the data_len will be zero as there is no higher level protocol
information. So in this case, the default value of data_len
must be set to interface MTU

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Jukka Rissanen
ba99ef7c3e net: ethernet: Add more IEEE 802.3 protocol types
Add ETH_P_xxx protocol types if they are missing. After this
we can use the protocol types when working with BSD sockets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-07 14:43:30 +02:00
Daniel Glöckner
1e676d654f net: gptp: fix src MAC address
The return value of net_if_get_link_addr points to a struct net_linkaddr
instead of to the raw MAC address. Without this fix the source address
will always end in 06:03 and will most likely be the same for different
boards running the same software.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2019-02-07 12:58:57 +02:00
Filip Kubicz
1d199181ac Bluetooth: host: Meaningful error codes on advertising start
Translate HCI error codes to POSIX error codes in order to be able to
distinguish reason of connectable advertising start failure.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-02-07 12:56:26 +02:00
Filip Kubicz
5e4f6e9c73 Bluetooth: ctlr: Return different error codes on advertising start
Return meaninful HCI error when it's not possible to start advertising
because of maximum number of connections already in use.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-02-07 12:56:26 +02:00
Ulf Magnusson
7df60372c2 scripts/dts: Rename convert_string_to_label() to str_to_label()
Less spammy and as easy to understand ("label" seems a bit confusing
though, but it's consistent with other code).

Also simplify some surrounding code, and clean up the implementation of
str_to_label() a bit.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
9c1274b6e8 scripts/dts: Simplify code around insert_defs() calls
Pass the dictionary of definitions directly. Shorter and clearer.

Also get rid of some other temporary variables, a redundant str() call,
and some mysterious commented-out code in _extract_flash().

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
e8a077b6a3 scripts/dts: Remove redundant parentheses around 'if' conditions
Not needed in Python.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
b278500d94 scripts/dts: Remove dead and confusing pwm/gpio-related code
- Maybe the code is trying to turn integers into single-element list,
   but it won't work (needs to be [value] rather than list(value)).
   Don't think you could ever end up with an integer either.

 - extract_controller() assumes that prop_values is a list, so
   reduced[...].get(prop) should be reduced[...][prop]. get() means it's
   okay for the key to be missing, which makes the code confusing.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
d2985b31d8 scripts/dts: Remove dead and confusing code in get_phandles()
- The 'props' key is known to exist (and 'if enabled == ...:' would
    crash if it ever was missing)

  - 'd' is always a dictionary

  - There's no need to test if d['children'] is non-empty before looping
    through it

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
23afd94704 scripts/dts: Remove dead and confusing code in get_all_compatibles()
- The 'props' key is known to exist (and 'if enabled == ...:' would
   crash if it ever was missing)

 - 'd' is always a dictionary

 - There's no need to test if d['children'] is non-empty before looping
   through it

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
d26cb1fb55 scripts/dts: Remove redundant and confusing dict.get() calls
dict.get(key) signals to people reading the code that you're not sure
whether the key exists. It returns None if it doesn't.

When the key is known to exist, dict[key] should be used. This also
helps catch bugs by raising an exception if the key is missing.

Similarly, whether a key in a dict should be tested with

    if key in dict:

instead of with

    if dict.get(key):

The second version signals that you both want to make sure that the
exists and that it's truthy (e.g., non-empty). That's confusing if a
simple existence check was meant.

There seems to be a bug in output_keyvalue_lines() where

    fd.write("%s=%s\n" % (entry, defs[node].get(a)))

can end up writing '...=None'. Removing the .get() makes it throw an
exception instead. Keep the .get() for now and don't attempt to fix the
bug.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Ulf Magnusson
01db6469ca scripts/dts: Remove redundant dict.keys() calls
'x in dict' and 'for x in dict' in Python always uses the keys.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-07 10:39:37 +01:00
Tavish Naruka
0f3bd0f43b samples: subsys: Filesystem API sample with SDHC
Added sample to show disk access and FS api with
Fat filesystem and SDHC driver. Tested working with
nrf52840 (blip).

Signed-off-by: Tavish Naruka <docuser@docs.electronut.in>
2019-02-06 21:42:37 -05:00
Spoorthi K
8c1eecbada samples: cmsis_rtos_v2: Resolve control flow issue
Resolve control flow issue in cmsis_rtos_v2 sample.

Fixes: #12295

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2019-02-06 21:34:20 -05:00
Spoorthi K
cd1af7333e samples: cmsis_rtos_v1: Resolve control flow issue
Resolve control flow issue in cmsis_rtos_v1 sample.

Signed-off-by: Spoorthi K <spoorthi.k@intel.com>
2019-02-06 21:34:20 -05:00
Erwan Gouriou
3a447c8d8d driver/interrupt_controller: Clean up Kconfig symbol in stm32 driver
Cleanup unknown symbol in commentary.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-06 18:59:00 -06:00
Erwan Gouriou
a1750473b5 boards: nucleo_l4r5zi: Clean up Kconfig symbol.
Rename CONFIG_USB_DC_STM symbol.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-06 18:59:00 -06:00
Erwan Gouriou
b0245d4240 drivers: spi: Define SPI_6 symbol
Add SPI_6 Kconfig symbol as this is the higher supported instance on
STM32.
This makes symbol CONFIG_SPI_6, used in stm32 driver a valid symbol.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-06 18:59:00 -06:00
Johann Fischer
2d073e16d5 board: reel_board: remove board.h
Remove board.h, CONFIG_GPIO_NRF5_P1_DEV_NAME
was not used and is not defined anywhere.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-02-06 18:58:46 -06:00
Ioannis Glaropoulos
168de7ff33 arch: arm: enforce double-word stack alignment on exception entry
This commit enforces default double-word stack alignmnet
on exception entry for Cortex-M3 and Cortex-M4 MCUs. The
patch ensures that we have consistent behavior in all
Cortex-M MCUs (double-world stack alignment on exception
entry is enforced by default in ARMv6, ARMv8, and Cortex-M7
processors).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-06 18:54:58 -05:00
Ioannis Glaropoulos
bb56925b27 arch: arm: update doc for 8-byte stack alignment option for Cortex-M
This commit updates the documentation of Kconfig option:
STACK_ALIGN_DOUBLE_WORD for Cortex-M microprocessors, stating
that the option is used in ARMv7-M MCUs to enforce 8-byte
stack alignment upon exception entry.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-06 18:54:58 -05:00
Michael Scott
6cb768cb24 net: lwm2m: fix connection handling in RD client
A few cases were missed where we weren't cleaning up the existing
connection correctly.  This was easily missed because we try and
clean up the connection everywhere.

Instead, let's clean up any existing connection prior to starting
a new one in the do_bootstrap_reg() and do_registration()
functions.

Signed-off-by: Michael Scott <mike@foundries.io>
2019-02-06 18:52:31 -05:00
Michael Scott
6b990ba9bf net: lwm2m: boostrap support cleanup
- Fix enum naming throughout
- Correct next_instance logic
- Move to registration server if no bootstrap server is found
- Fixes to logging

Signed-off-by: Michael Scott <mike@foundries.io>
2019-02-06 18:52:31 -05:00
Vikas Manocha
bbe1a19786 arch: arm: replace main thread switching assembly to C using cmsis
use cmsis functions to avoid using direct assembly for main thread
switching.

This patch uses cmsis functions to:
	- set PSP(process stack pointer) to main stack
	- enable interrupts

Fixes #12878

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
2019-02-06 18:30:45 -05:00
Andrei Emeltchenko
5b3bd4e099 tests: usb: Include desc_sections test for native_posix
After including native_posix USB controller we can perform some simple
tests on native_posix.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-06 17:53:04 -05:00
Andrew Boie
f753ae92fb gen_mmu_x86: remove unused function
Fixes #13096

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-06 14:34:20 -08:00
Kumar Gala
4520237ef5 sensors: adxl372: Fixup SPI CS handling
Replace undefined Kconfig SPI CS defines with DTS based defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-06 14:01:51 -06:00
Ioannis Glaropoulos
a10f07305f arch: arm: fix macro name inside an inline comment
Fix the spelling of CONFIG_ARMV6_M_ARMV8_M_BASELINE inside
an #endif comment.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-02-06 11:44:35 -06:00
Alberto Escolar Piedras
da449468f8 arch: posix: posix_cheats: Add some comments
Add a few comments in posix_cheats.h explaining why the file
exists and how it is used.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-02-06 10:34:56 -05:00
Alberto Escolar Piedras
d798cbcbf5 arch: posix: posix_cheats: Do not rename types
There is no need to rename the POSIX types, so let's not do it to
simplify things
Also remove an unnecessary guard (POSIX_ARCH) to avoid mystifying
this any more than necessary

Related to #13054

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2019-02-06 10:34:56 -05:00
Carlos Stuart
655d3cc2b0 lib: cmsis_rtos_v2: Default thread prioity
If an unitialized/zeroed optional attribute was passed to osThreadNew
the priority would be osThreadNone i.e. uninitialized. This causes an
ASSERT to be hit as the priority isn't valid (it is not between
osPriorityIdle and osPriorityISR).

The fix checks the passed in priority is not osPriorityNone and assigns
osPriorityNormal. This is the correct CMSIS behaviour.

The ASSERT will still be hit if the priority is invalid (<0).

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-06 10:20:17 -05:00
Carlos Stuart
d47178bc95 lib: cmsis_rtos_v2: Default name if name is NULL
Fixed an issue whereby if an attribute structure was passed into a CMSIS
RTOS v2 'new' function with an invalid address i.e. NULL assigned to the
name (char*) member the memcpy at the end of each new function
would cause a segmentation fault i.e. read from an invalid
address.

This has been fixed by checking if the name is NULL and using the
default name from the init struct if it is. This is the same name
that would be used if not passing in the optional attr function
argument.

Changed the memcpy to strncpy to ensure that the copy does not read
beyond the end of the source string and changed the length from 16 to 15
(by means of a `sizeof(...)-1`) of the destination buffer to ensure that
it will always be nul-terminated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-06 10:20:17 -05:00
Carlos Stuart
c6375729ff tests: cmsis_rtos_v2: Dynamic thread stack tests
Added a set of tests that use the default thread stacks to ensure they
work the same as the passed in stacks. Abstracted the common
functionality into functions.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-06 10:20:17 -05:00
Carlos Stuart
d4eb2c9014 lib: cmsis_rtos_v2: Dynamic thread stacks
Implemented dynamic thread stacks for CMSIS threads by declaring an
array of default sized thread stacks. Allocation cannot be done on the
heap as some architectures require strict alignment for stacks so the
macro must be used to define the stack to ensure most compatibility.

Added a Kconfig variable to limit the number of dynamic threads on the
system (they also count towards total CMSIS thread count). This is so a
developer can have fine grained control over how many dynamic threads
can be allocated because all their stacks must be allocated up front so
could use a lot of memory needlessly if oversubscribed. The default
value is 0 which effectively disabled dynamic threads but also reduces
the memory impact to almost none.

Fixed an assert bug where thread_num was being tested against the
maximum allowed CMSIS threads - it previous checked for less than or
equal which actually (due to when the increment happens) allowed there
to be one more thread. The check now correctly uses less than and only
allowed up to the defined maximum.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-06 10:20:17 -05:00
Carlos Stuart
db24367652 tests: cmsis_rtos_v2: Dynamic memory pool tests
Implemented a second set of memory pool tests that function on a
dynamically allocated memory pool. Abstracted some of the common
functionality to a common function.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-06 10:20:17 -05:00