Skip to content

Commit d1380d9

Browse files
authored
Added KERNEL_VERSION_MAJOR check in samples DTS overlay files to handle changes in Zephyr OS version 4. (#48)
2 parents b0fd16c + 343f342 commit d1380d9

File tree

6 files changed

+40
-23
lines changed

6 files changed

+40
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ The git repository is hosted at the following site:
3838
* Changed gitignore to ignore the build folder.
3939

4040
### Added
41+
* Added KERNEL_VERSION_MAJOR check in samples DTS overlay files to handle
42+
changes in Zephyr OS version 4
4143
* Added BACDL ZIGBEE and BSC datalink defines to Kconfig & CMakeLists.txt (#35)
4244
* Added baclog, you-are, who-am-i, create-object, delete-object, write-group,
4345
bramfs, bsramfs, and color-rgb modules to cmake. (#35)

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,36 @@ of the following ways:
5959

6060
`west init -m https://github.com/bacnet-stack/bacnet-stack-zephyr --mr default $my_workspace`
6161

62-
- Note that as Zephyr OS versions change, their API often changes.
63-
This library will use the following methods to accommodate the changes:
64-
1. Use defines from <zephyr/version.h> for API changes:
65-
```
66-
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4,2,0)
67-
typedef uint64_t mgmt_event_t;
68-
#else
69-
typedef uint32_t mgmt_event_t;
70-
#endif
71-
```
72-
2. In CMakeLists.txt via trying to load specific versions of the Zephyr
73-
package or checking using:
74-
```
75-
if ("${KERNEL_VERSION_STRING}" VERSION_GREATER_EQUAL "4.2.0")
76-
# Do stuff...
77-
endif()
78-
```
79-
3. In Kconfig by using 2 above and trying to load specific versions
80-
of the Zephyr plugin and updating CONF_FILE accordingly.
62+
# Backward Compatible Samples and Applications
63+
64+
Note that as Zephyr OS versions change, their API often changes.
65+
This library will use the following methods to accommodate the changes:
66+
67+
1. Use defines from <zephyr/version.h> for API changes:
68+
```
69+
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4,2,0)
70+
typedef uint64_t mgmt_event_t;
71+
#else
72+
typedef uint32_t mgmt_event_t;
73+
#endif
74+
```
75+
2. In CMakeLists.txt via trying to load specific versions of the Zephyr
76+
package or checking using:
77+
```
78+
if ("${KERNEL_VERSION_STRING}" VERSION_GREATER_EQUAL "4.2.0")
79+
# Do stuff...
80+
endif()
81+
```
82+
3. In Kconfig by using 2 above and trying to load specific versions
83+
of the Zephyr plugin and updating CONF_FILE accordingly.
84+
4. In .dts, .dtsi or .overlay files, use KERNEL_VERSION_NUMBER or
85+
KERNEL_VERSION_MAJOR defines. The C preprocessor is run on all
86+
devicetree files to expand macro references.
87+
```
88+
#if KERNEL_VERSION_MAJOR < 4
89+
/delete-node/ &storage_partition;
90+
#endif
91+
```
8192
8293
## Hello BACnet Stack
8394

zephyr/samples/profiles/b-ld/boards/nucleo_f429zi.overlay

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
6+
#if KERNEL_VERSION_MAJOR < 4
77
/delete-node/ &storage_partition;
8+
#endif
89

910
/ {
1011
leds {

zephyr/samples/profiles/b-ls/boards/nucleo_f429zi.overlay

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
6+
#if KERNEL_VERSION_MAJOR < 4
77
/delete-node/ &storage_partition;
8+
#endif
89

910
&flash0 {
1011
partitions {

zephyr/samples/profiles/b-sa/boards/nucleo_f429zi.overlay

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
6+
#if KERNEL_VERSION_MAJOR < 4
77
/delete-node/ &storage_partition;
8+
#endif
89

910
&flash0 {
1011
partitions {

zephyr/samples/profiles/b-ss/boards/nucleo_f429zi.overlay

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
6+
#if KERNEL_VERSION_MAJOR < 4
77
/delete-node/ &storage_partition;
8+
#endif
89

910
&flash0 {
1011
partitions {

0 commit comments

Comments
 (0)