Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlib defines POSIX primitives when -std=gnu #52739

Closed
stephanosio opened this issue Dec 2, 2022 · 0 comments · Fixed by #52740
Closed

Newlib defines POSIX primitives when -std=gnu #52739

stephanosio opened this issue Dec 2, 2022 · 0 comments · Fixed by #52740
Assignees
Labels
area: Networking area: newlib Newlib C Standard Library area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@stephanosio
Copy link
Member

Describe the bug

Newlib attempts to provide POSIX primitives in its headers when -std=gnu, which leads to various conflicts with the POSIX primitives provided by the Zephyr POSIX library and the networking subsystem (sockets).

To Reproduce

Build samples/net/sockets/echo for qemu_cortex_m3 with the following patch:

diff --git a/samples/net/sockets/echo/CMakeLists.txt b/samples/net/sockets/echo/CMakeLists.txt
index 1a1c3f4194..b77997ea65 100644
--- a/samples/net/sockets/echo/CMakeLists.txt
+++ b/samples/net/sockets/echo/CMakeLists.txt
@@ -2,6 +2,8 @@
 
 cmake_minimum_required(VERSION 3.20.0)
 
+set_property(GLOBAL PROPERTY CSTD gnu99)
+
 find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
 project(sockets_echo)

Expected behavior

Newlib should not define POSIX primitives unless the feature test macros such as _POSIX_SOURCE, _GNU_SOURCE and _DEFAULT_SOURCE, are explicitly defined by the user.

Note that -std=gnu should not imply _GNU_SOURCE or _DEFAULT_SOURCE because it merely specifies the language dialect (i.e. GNU C language extensions) to be used.

Impact

Unable to build applications that make use of Zephyr POSIX library and networking sockets with -std=gnu.

Logs and console output

[1/22] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/net/lib/utils/addr_utils.c.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/subsys/net/lib/utils/addr_utils.c.obj 
ccache /opt/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DMBEDTLS_CONFIG_FILE=\"config-tls-generic.h\" -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/stephanos/Dev/zephyrproject/zephyr/kernel/include -I/home/stephanos/Dev/zephyrproject/zephyr/arch/arm/include -I/home/stephanos/Dev/zephyrproject/zephyr/include -I/home/stephanos/Dev/zephyrproject/zephyr/samples/net/sockets/echo/build/zephyr/include/generated -I/home/stephanos/Dev/zephyrproject/zephyr/soc/arm/ti_lm3s6965 -I/home/stephanos/Dev/zephyrproject/zephyr/lib/libc/newlib/include -I/home/stephanos/Dev/zephyrproject/zephyr/subsys/net/l2 -I/home/stephanos/Dev/zephyrproject/zephyr/subsys/net/lib/sockets/. -I/home/stephanos/Dev/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/stephanos/Dev/zephyrproject/modules/crypto/mbedtls/include -I/home/stephanos/Dev/zephyrproject/modules/crypto/mbedtls/library -I/home/stephanos/Dev/zephyrproject/zephyr/modules/mbedtls/configs -I/home/stephanos/Dev/zephyrproject/zephyr/modules/mbedtls/include -fno-strict-aliasing -Os -imacros /home/stephanos/Dev/zephyrproject/zephyr/samples/net/sockets/echo/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m3 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/opt/zephyr-sdk-0.15.2/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/stephanos/Dev/zephyrproject/zephyr/samples/net/sockets/echo=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/stephanos/Dev/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/stephanos/Dev/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -std=gnu99 -MD -MT zephyr/CMakeFiles/zephyr.dir/subsys/net/lib/utils/addr_utils.c.obj -MF zephyr/CMakeFiles/zephyr.dir/subsys/net/lib/utils/addr_utils.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/subsys/net/lib/utils/addr_utils.c.obj -c /home/stephanos/Dev/zephyrproject/zephyr/subsys/net/lib/utils/addr_utils.c
In file included from /home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket.h:29,
                 from /home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socketutils.h:11,
                 from /home/stephanos/Dev/zephyrproject/zephyr/subsys/net/lib/utils/addr_utils.c:9:
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:111: warning: "fd_set" redefined
  111 | #define fd_set zsock_fd_set
      | 
In file included from /opt/zephyr-sdk-0.15.2/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:50,
                 from /home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket.h:25:
/opt/zephyr-sdk-0.15.2/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/select.h:46: note: this is the location of the previous definition
   46 | #define fd_set _types_fd_set
      | 
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:112: warning: "FD_SETSIZE" redefined
  112 | #define FD_SETSIZE ZSOCK_FD_SETSIZE
      | 
/opt/zephyr-sdk-0.15.2/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/select.h:31: note: this is the location of the previous definition
   31 | #       define  FD_SETSIZE      64
      | 
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:114:19: error: conflicting types for 'select'; have 'int(int,  zsock_fd_set *, zsock_fd_set *, zsock_fd_set *, struct timeval *)'
  114 | static inline int select(int nfds, zsock_fd_set *readfds,
      |                   ^~~~~~
/opt/zephyr-sdk-0.15.2/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/select.h:62:5: note: previous declaration of 'select' with type 'int(int,  _types_fd_set *, _types_fd_set *, _types_fd_set *, struct timeval *)'
   62 | int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
      |     ^~~~~~
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:121:20: error: expected identifier or '(' before '__extension__'
  121 | static inline void FD_ZERO(zsock_fd_set *set)
      |                    ^~~~~~~
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:126:49: error: expected ')' before '*' token
  126 | static inline int FD_ISSET(int fd, zsock_fd_set *set)
      |                                                 ^
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:126:19: error: expected ')' before '->' token
  126 | static inline int FD_ISSET(int fd, zsock_fd_set *set)
      |                   ^~~~~~~~
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:131:48: error: expected ')' before '*' token
  131 | static inline void FD_CLR(int fd, zsock_fd_set *set)
      |                                                ^
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:131:20: error: expected ')' before '->' token
  131 | static inline void FD_CLR(int fd, zsock_fd_set *set)
      |                    ^~~~~~
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:136:48: error: expected ')' before '*' token
  136 | static inline void FD_SET(int fd, zsock_fd_set *set)
      |                                                ^
/home/stephanos/Dev/zephyrproject/zephyr/include/zephyr/net/socket_select.h:136:20: error: expected ')' before '->' token
  136 | static inline void FD_SET(int fd, zsock_fd_set *set)
      |                    ^~~~~~
[...]

Environment (please complete the following information):

  • OS: Ubuntu 20.04
  • Toolchain: Zephyr SDK 0.15.2
  • Commit SHA: 4d906d9

Additional context

Note that:

  • Zephyr builds with -std=c99 by default and this results in GCC defining __STRICT_ANSI__.
  • When -std=gnu99, __STRICT_ANSI__ is not defined.

Newlib features.h, when neither __STRICT_ANSI__ nor any of the feature test macros is explicitly defined, assumes the "default source" feature set and defines _DEFAULT_SOURCE, which implies POSIX and BSD feature sets:

#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || \
   (!defined(__STRICT_ANSI__) && !defined(_ANSI_SOURCE) && \
   !defined(_ISOC99_SOURCE) && !defined(_POSIX_SOURCE) && \
   !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
#undef _DEFAULT_SOURCE
#define	_DEFAULT_SOURCE		1
#endif
#ifdef _DEFAULT_SOURCE
#define	__BSD_VISIBLE		1
#else
#define	__BSD_VISIBLE		0
#endif

Newlib sys/types.h defines various POSIX/BSD primitives and includes sys/select.h when __BSD_VISIBLE is true:

#if __BSD_VISIBLE
#include <machine/endian.h>
#include <sys/select.h>

Newlib sys/select.h, included by sys/types.h, defines the FD macros that are in conflict with the Zephyr-side FD macros:

#  define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
#  define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
#  define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
@stephanosio stephanosio added bug The issue is a bug, or the PR is fixing a bug area: Networking area: POSIX POSIX API Library area: newlib Newlib C Standard Library labels Dec 2, 2022
@stephanosio stephanosio self-assigned this Dec 2, 2022
@stephanosio stephanosio added the priority: medium Medium impact/importance bug label Dec 2, 2022
stephanosio added a commit to stephanosio/zephyr that referenced this issue Dec 2, 2022
This commit updates the Newlib integration to define `_ANSI_SOURCE`
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (`-std=gnu*`).

Newlib `features.h` defines `_DEFAULT_SOURCE` when `__STRICT_ANSI__`
is not defined by GCC (i.e. when `-std=gnu*`), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as `_POSIX_SOURCE`, `_GNU_SOURCE` and `_DEFAULT_SOURCE` are
explicitly defined.

Note that `-std=gnu` does not imply `_GNU_SOURCE` or `_DEFAULT_SOURCE`
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue zephyrproject-rtos#52739 for more details.

Signed-off-by: Stephanos Ioannidis <[email protected]>
stephanosio added a commit to stephanosio/nrfconnect-sdk-connectedhomeip that referenced this issue Dec 2, 2022
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
nordicjm pushed a commit to nrfconnect/sdk-connectedhomeip that referenced this issue Dec 2, 2022
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
jori-nordic pushed a commit to jori-nordic/zephyr that referenced this issue Dec 5, 2022
This commit updates the Newlib integration to define `_ANSI_SOURCE`
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (`-std=gnu*`).

Newlib `features.h` defines `_DEFAULT_SOURCE` when `__STRICT_ANSI__`
is not defined by GCC (i.e. when `-std=gnu*`), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as `_POSIX_SOURCE`, `_GNU_SOURCE` and `_DEFAULT_SOURCE` are
explicitly defined.

Note that `-std=gnu` does not imply `_GNU_SOURCE` or `_DEFAULT_SOURCE`
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue zephyrproject-rtos#52739 for more details.

Upstream PR: zephyrproject-rtos#52740

Signed-off-by: Stephanos Ioannidis <[email protected]>
carlescufi pushed a commit that referenced this issue Dec 5, 2022
This commit updates the Newlib integration to define `_ANSI_SOURCE`
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (`-std=gnu*`).

Newlib `features.h` defines `_DEFAULT_SOURCE` when `__STRICT_ANSI__`
is not defined by GCC (i.e. when `-std=gnu*`), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as `_POSIX_SOURCE`, `_GNU_SOURCE` and `_DEFAULT_SOURCE` are
explicitly defined.

Note that `-std=gnu` does not imply `_GNU_SOURCE` or `_DEFAULT_SOURCE`
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue #52739 for more details.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/connectedhomeip that referenced this issue Jan 5, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/connectedhomeip that referenced this issue Jan 6, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/connectedhomeip that referenced this issue Jan 6, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic added a commit to Damian-Nordic/connectedhomeip that referenced this issue Jan 9, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.
andy31415 added a commit to project-chip/connectedhomeip that referenced this issue Jan 9, 2023
* [nrfconnect] Bump nRF Connect SDK to 2.2.0

Change the recommended nRF Connect SDK version to v2.2.0.

* Start using Zephyr WiFi net_mgmt API and events

- replace wpa_supplicant API calls with generic Zephyr net_mgmt API
- use net events to manage WiFi connection
- refactoring of the whole platform/nrfconnect/wifi code

Signed-off-by: Marcin Kajor <[email protected]>

* Implemented proper handling of WiFi security modes.

With the current net_mgmt API it is necessary to scan networks to get
the security mode supported by an AP which we want to connect with.
Also fixed the invalid handling of net_mgmt event life time.

Signed-off-by: Marcin Kajor <[email protected]>

* Aligned Matter SDK to Zephyr 0.15.x revision.

These changes were implied the the recent Zephyr upmerge:
- updates of Zephyr include paths
- removal of disabling of gpio1 in board DTS overlays
- fix for the possible dangling pointer compilation error
  after gcc got more picky about that (v10.3 vs. v12.1)

Signed-off-by: Marcin Kajor <[email protected]>

* Increased the max number of BLE connections.

This is a workaround for the non-unreferenced BLE connection object
when restarting advertising in BLE disconnect callback.

Signed-off-by: Marcin Kajor <[email protected]>

* WiFi fail-safe related fixes

Make sure the fail-safe works as expected with WiFi networking:
- disconnect when reverting the configuration
- always cleanup the provisioning data structures before connecting
  to avoid dummy buffer overwriting and data length issues

Signed-off-by: Marcin Kajor <[email protected]>

* Introduced a workaround to send Router Solicitation after connect

Router Solicitation is not sent after connecting to the Wi-Fi
network by the Wi-Fi driver, so in result Thread Border Router
doesn't send Router Advertisement to the device. As a workaround
sending RS was added in the Matter platform code.

* Forward the channel number and RSSI from WIFiManager.

We can now use this feature in spite of stats still
not being implemented.

Signed-off-by: Marcin Kajor <[email protected]>

* Minor fixes for heap usage

Fix build with CHIP_MALLOC_SYS_HEAP Kconfig option that
replaces default malloc/free with alternatives based on
Zephyr's sys_heap.

Signed-off-by: Damian Krolik <[email protected]>

* Wi-Fi status handling fixes.

* Increase the SYSTEM_WORKQUEUE_STACK_SIZE to match supplicant needs
* Decrease the connection timeout to be lower than failsafe (35s)
* Adapt WiFiRequestStatus to follow supplicant implementation
* All of above makes the failsafe more robust

Signed-off-by: Marcin Kajor <[email protected]>

* wifi: RevertConfiguration optimization.

Do not disconnect/reconnect to the already attached network.

Signed-off-by: Marcin Kajor <[email protected]>

* Define _DEFAULT_SOURCE

This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

* Align examples with samples included in nRF Connect SDK 2.2.0

* Update remaining Docker images to 0.6.27

* Restyled by clang-format

* Restyled by shellharden

Signed-off-by: Marcin Kajor <[email protected]>
Signed-off-by: Damian Krolik <[email protected]>
Co-authored-by: Marcin Kajor <[email protected]>
Co-authored-by: Kamil Kasperczyk <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
cletnick pushed a commit to cletnick/connectedhomeip that referenced this issue Jan 10, 2023
* [nrfconnect] Bump nRF Connect SDK to 2.2.0

Change the recommended nRF Connect SDK version to v2.2.0.

* Start using Zephyr WiFi net_mgmt API and events

- replace wpa_supplicant API calls with generic Zephyr net_mgmt API
- use net events to manage WiFi connection
- refactoring of the whole platform/nrfconnect/wifi code

Signed-off-by: Marcin Kajor <[email protected]>

* Implemented proper handling of WiFi security modes.

With the current net_mgmt API it is necessary to scan networks to get
the security mode supported by an AP which we want to connect with.
Also fixed the invalid handling of net_mgmt event life time.

Signed-off-by: Marcin Kajor <[email protected]>

* Aligned Matter SDK to Zephyr 0.15.x revision.

These changes were implied the the recent Zephyr upmerge:
- updates of Zephyr include paths
- removal of disabling of gpio1 in board DTS overlays
- fix for the possible dangling pointer compilation error
  after gcc got more picky about that (v10.3 vs. v12.1)

Signed-off-by: Marcin Kajor <[email protected]>

* Increased the max number of BLE connections.

This is a workaround for the non-unreferenced BLE connection object
when restarting advertising in BLE disconnect callback.

Signed-off-by: Marcin Kajor <[email protected]>

* WiFi fail-safe related fixes

Make sure the fail-safe works as expected with WiFi networking:
- disconnect when reverting the configuration
- always cleanup the provisioning data structures before connecting
  to avoid dummy buffer overwriting and data length issues

Signed-off-by: Marcin Kajor <[email protected]>

* Introduced a workaround to send Router Solicitation after connect

Router Solicitation is not sent after connecting to the Wi-Fi
network by the Wi-Fi driver, so in result Thread Border Router
doesn't send Router Advertisement to the device. As a workaround
sending RS was added in the Matter platform code.

* Forward the channel number and RSSI from WIFiManager.

We can now use this feature in spite of stats still
not being implemented.

Signed-off-by: Marcin Kajor <[email protected]>

* Minor fixes for heap usage

Fix build with CHIP_MALLOC_SYS_HEAP Kconfig option that
replaces default malloc/free with alternatives based on
Zephyr's sys_heap.

Signed-off-by: Damian Krolik <[email protected]>

* Wi-Fi status handling fixes.

* Increase the SYSTEM_WORKQUEUE_STACK_SIZE to match supplicant needs
* Decrease the connection timeout to be lower than failsafe (35s)
* Adapt WiFiRequestStatus to follow supplicant implementation
* All of above makes the failsafe more robust

Signed-off-by: Marcin Kajor <[email protected]>

* wifi: RevertConfiguration optimization.

Do not disconnect/reconnect to the already attached network.

Signed-off-by: Marcin Kajor <[email protected]>

* Define _DEFAULT_SOURCE

This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

* Align examples with samples included in nRF Connect SDK 2.2.0

* Update remaining Docker images to 0.6.27

* Restyled by clang-format

* Restyled by shellharden

Signed-off-by: Marcin Kajor <[email protected]>
Signed-off-by: Damian Krolik <[email protected]>
Co-authored-by: Marcin Kajor <[email protected]>
Co-authored-by: Kamil Kasperczyk <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/sdk-connectedhomeip that referenced this issue Jan 16, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/sdk-connectedhomeip that referenced this issue Jan 17, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/sdk-connectedhomeip that referenced this issue Jan 17, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Damian-Nordic pushed a commit to Damian-Nordic/sdk-connectedhomeip that referenced this issue Feb 21, 2023
This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

Signed-off-by: Stephanos Ioannidis <[email protected]>
kkasperczyk-no added a commit to kkasperczyk-no/sdk-connectedhomeip that referenced this issue Mar 15, 2023
* [nrfconnect] Bump nRF Connect SDK to 2.2.0

Change the recommended nRF Connect SDK version to v2.2.0.

* Start using Zephyr WiFi net_mgmt API and events

- replace wpa_supplicant API calls with generic Zephyr net_mgmt API
- use net events to manage WiFi connection
- refactoring of the whole platform/nrfconnect/wifi code

Signed-off-by: Marcin Kajor <[email protected]>

* Implemented proper handling of WiFi security modes.

With the current net_mgmt API it is necessary to scan networks to get
the security mode supported by an AP which we want to connect with.
Also fixed the invalid handling of net_mgmt event life time.

Signed-off-by: Marcin Kajor <[email protected]>

* Aligned Matter SDK to Zephyr 0.15.x revision.

These changes were implied the the recent Zephyr upmerge:
- updates of Zephyr include paths
- removal of disabling of gpio1 in board DTS overlays
- fix for the possible dangling pointer compilation error
  after gcc got more picky about that (v10.3 vs. v12.1)

Signed-off-by: Marcin Kajor <[email protected]>

* Increased the max number of BLE connections.

This is a workaround for the non-unreferenced BLE connection object
when restarting advertising in BLE disconnect callback.

Signed-off-by: Marcin Kajor <[email protected]>

* WiFi fail-safe related fixes

Make sure the fail-safe works as expected with WiFi networking:
- disconnect when reverting the configuration
- always cleanup the provisioning data structures before connecting
  to avoid dummy buffer overwriting and data length issues

Signed-off-by: Marcin Kajor <[email protected]>

* Introduced a workaround to send Router Solicitation after connect

Router Solicitation is not sent after connecting to the Wi-Fi
network by the Wi-Fi driver, so in result Thread Border Router
doesn't send Router Advertisement to the device. As a workaround
sending RS was added in the Matter platform code.

* Forward the channel number and RSSI from WIFiManager.

We can now use this feature in spite of stats still
not being implemented.

Signed-off-by: Marcin Kajor <[email protected]>

* Minor fixes for heap usage

Fix build with CHIP_MALLOC_SYS_HEAP Kconfig option that
replaces default malloc/free with alternatives based on
Zephyr's sys_heap.

Signed-off-by: Damian Krolik <[email protected]>

* Wi-Fi status handling fixes.

* Increase the SYSTEM_WORKQUEUE_STACK_SIZE to match supplicant needs
* Decrease the connection timeout to be lower than failsafe (35s)
* Adapt WiFiRequestStatus to follow supplicant implementation
* All of above makes the failsafe more robust

Signed-off-by: Marcin Kajor <[email protected]>

* wifi: RevertConfiguration optimization.

Do not disconnect/reconnect to the already attached network.

Signed-off-by: Marcin Kajor <[email protected]>

* Define _DEFAULT_SOURCE

This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

* Align examples with samples included in nRF Connect SDK 2.2.0

* Update remaining Docker images to 0.6.27

* Restyled by clang-format

* Restyled by shellharden

Signed-off-by: Marcin Kajor <[email protected]>
Signed-off-by: Damian Krolik <[email protected]>
Co-authored-by: Marcin Kajor <[email protected]>
Co-authored-by: Kamil Kasperczyk <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
kkasperczyk-no added a commit to kkasperczyk-no/sdk-connectedhomeip that referenced this issue Mar 15, 2023
* [nrfconnect] Bump nRF Connect SDK to 2.2.0

Change the recommended nRF Connect SDK version to v2.2.0.

* Start using Zephyr WiFi net_mgmt API and events

- replace wpa_supplicant API calls with generic Zephyr net_mgmt API
- use net events to manage WiFi connection
- refactoring of the whole platform/nrfconnect/wifi code

Signed-off-by: Marcin Kajor <[email protected]>

* Implemented proper handling of WiFi security modes.

With the current net_mgmt API it is necessary to scan networks to get
the security mode supported by an AP which we want to connect with.
Also fixed the invalid handling of net_mgmt event life time.

Signed-off-by: Marcin Kajor <[email protected]>

* Aligned Matter SDK to Zephyr 0.15.x revision.

These changes were implied the the recent Zephyr upmerge:
- updates of Zephyr include paths
- removal of disabling of gpio1 in board DTS overlays
- fix for the possible dangling pointer compilation error
  after gcc got more picky about that (v10.3 vs. v12.1)

Signed-off-by: Marcin Kajor <[email protected]>

* Increased the max number of BLE connections.

This is a workaround for the non-unreferenced BLE connection object
when restarting advertising in BLE disconnect callback.

Signed-off-by: Marcin Kajor <[email protected]>

* WiFi fail-safe related fixes

Make sure the fail-safe works as expected with WiFi networking:
- disconnect when reverting the configuration
- always cleanup the provisioning data structures before connecting
  to avoid dummy buffer overwriting and data length issues

Signed-off-by: Marcin Kajor <[email protected]>

* Introduced a workaround to send Router Solicitation after connect

Router Solicitation is not sent after connecting to the Wi-Fi
network by the Wi-Fi driver, so in result Thread Border Router
doesn't send Router Advertisement to the device. As a workaround
sending RS was added in the Matter platform code.

* Forward the channel number and RSSI from WIFiManager.

We can now use this feature in spite of stats still
not being implemented.

Signed-off-by: Marcin Kajor <[email protected]>

* Minor fixes for heap usage

Fix build with CHIP_MALLOC_SYS_HEAP Kconfig option that
replaces default malloc/free with alternatives based on
Zephyr's sys_heap.

Signed-off-by: Damian Krolik <[email protected]>

* Wi-Fi status handling fixes.

* Increase the SYSTEM_WORKQUEUE_STACK_SIZE to match supplicant needs
* Decrease the connection timeout to be lower than failsafe (35s)
* Adapt WiFiRequestStatus to follow supplicant implementation
* All of above makes the failsafe more robust

Signed-off-by: Marcin Kajor <[email protected]>

* wifi: RevertConfiguration optimization.

Do not disconnect/reconnect to the already attached network.

Signed-off-by: Marcin Kajor <[email protected]>

* Define _DEFAULT_SOURCE

This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

* Align examples with samples included in nRF Connect SDK 2.2.0

* Update remaining Docker images to 0.6.27

* Restyled by clang-format

* Restyled by shellharden

Signed-off-by: Marcin Kajor <[email protected]>
Signed-off-by: Damian Krolik <[email protected]>
Co-authored-by: Marcin Kajor <[email protected]>
Co-authored-by: Kamil Kasperczyk <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
lecndav pushed a commit to lecndav/connectedhomeip that referenced this issue Mar 22, 2023
* [nrfconnect] Bump nRF Connect SDK to 2.2.0

Change the recommended nRF Connect SDK version to v2.2.0.

* Start using Zephyr WiFi net_mgmt API and events

- replace wpa_supplicant API calls with generic Zephyr net_mgmt API
- use net events to manage WiFi connection
- refactoring of the whole platform/nrfconnect/wifi code

Signed-off-by: Marcin Kajor <[email protected]>

* Implemented proper handling of WiFi security modes.

With the current net_mgmt API it is necessary to scan networks to get
the security mode supported by an AP which we want to connect with.
Also fixed the invalid handling of net_mgmt event life time.

Signed-off-by: Marcin Kajor <[email protected]>

* Aligned Matter SDK to Zephyr 0.15.x revision.

These changes were implied the the recent Zephyr upmerge:
- updates of Zephyr include paths
- removal of disabling of gpio1 in board DTS overlays
- fix for the possible dangling pointer compilation error
  after gcc got more picky about that (v10.3 vs. v12.1)

Signed-off-by: Marcin Kajor <[email protected]>

* Increased the max number of BLE connections.

This is a workaround for the non-unreferenced BLE connection object
when restarting advertising in BLE disconnect callback.

Signed-off-by: Marcin Kajor <[email protected]>

* WiFi fail-safe related fixes

Make sure the fail-safe works as expected with WiFi networking:
- disconnect when reverting the configuration
- always cleanup the provisioning data structures before connecting
  to avoid dummy buffer overwriting and data length issues

Signed-off-by: Marcin Kajor <[email protected]>

* Introduced a workaround to send Router Solicitation after connect

Router Solicitation is not sent after connecting to the Wi-Fi
network by the Wi-Fi driver, so in result Thread Border Router
doesn't send Router Advertisement to the device. As a workaround
sending RS was added in the Matter platform code.

* Forward the channel number and RSSI from WIFiManager.

We can now use this feature in spite of stats still
not being implemented.

Signed-off-by: Marcin Kajor <[email protected]>

* Minor fixes for heap usage

Fix build with CHIP_MALLOC_SYS_HEAP Kconfig option that
replaces default malloc/free with alternatives based on
Zephyr's sys_heap.

Signed-off-by: Damian Krolik <[email protected]>

* Wi-Fi status handling fixes.

* Increase the SYSTEM_WORKQUEUE_STACK_SIZE to match supplicant needs
* Decrease the connection timeout to be lower than failsafe (35s)
* Adapt WiFiRequestStatus to follow supplicant implementation
* All of above makes the failsafe more robust

Signed-off-by: Marcin Kajor <[email protected]>

* wifi: RevertConfiguration optimization.

Do not disconnect/reconnect to the already attached network.

Signed-off-by: Marcin Kajor <[email protected]>

* Define _DEFAULT_SOURCE

This commit updates the chip-module build configurations to define
`_DEFAULT_SOURCE` when compiling Matter because it uses non-standard
functions that are only available when `_DEFAULT_SOURCE` is defined.

Note that this used to be not necessary only because of a quirk in the
way Newlib handles the feature test macro, which resulted in Newlib
defining `_DEFAULT_SOURCE` when compiling with `-std=gnu`.

For more details, refer to the issue zephyrproject-rtos/zephyr#52739.

* Align examples with samples included in nRF Connect SDK 2.2.0

* Update remaining Docker images to 0.6.27

* Restyled by clang-format

* Restyled by shellharden

Signed-off-by: Marcin Kajor <[email protected]>
Signed-off-by: Damian Krolik <[email protected]>
Co-authored-by: Marcin Kajor <[email protected]>
Co-authored-by: Kamil Kasperczyk <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
krish2718 pushed a commit to krish2718/sdk-hostap that referenced this issue Mar 27, 2023
As per [1], newlibc now defines _ANSI_SOURCE to avoid POSIX conflicts,
but as hostapd needs POSIX stuff from libc, need to enable this
explicitly.

[1] - zephyrproject-rtos/zephyr#52739

Signed-off-by: Krishna T <[email protected]>
krish2718 pushed a commit to krish2718/sdk-hostap that referenced this issue Mar 27, 2023
As per [1], newlibc now defines _ANSI_SOURCE to avoid POSIX conflicts,
but as hostapd needs POSIX stuff from libc, need to enable this
explicitly.

[1] - zephyrproject-rtos/zephyr#52739

Signed-off-by: Krishna T <[email protected]>
coreboot-org-bot pushed a commit to coreboot/chrome-ec that referenced this issue Oct 25, 2023
Newlib's `string.h` declares `strnlen()` function only when _GNU_SOURCE,
_DEFAULT_SOURCE or _POSIX_C_SOURCE is defined. Zephyr intentionally
disables POSIX declarations by defining _ANSI_SOURCE to avoid conflicts
with Zephyr POSIX library and networking subsystem [1].

It's still possible to use `strnlen()` from Newlib, we just need to
define _POSIX_C_SOURCE to 200809.

[1] zephyrproject-rtos/zephyr#52739

BUG=b:299924239
TEST=zmake build bloonchipper

Change-Id: I8cd966cd0097dfc5bf72fb9db6db6e20d96f6dee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4973835
Commit-Queue: Patryk Duda <[email protected]>
Code-Coverage: Zoss <[email protected]>
Tested-by: Patryk Duda <[email protected]>
Reviewed-by: Sung-Chi Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking area: newlib Newlib C Standard Library area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant