1:orphan: 2 3.. _migration_3.5: 4 5Migration guide to Zephyr v3.5.0 6################################ 7 8This document describes the changes required or recommended when migrating your 9application from Zephyr v3.4.0 to Zephyr v3.5.0. 10 11Any other changes (not directly related to migrating applications) can be found in 12the :ref:`release notes<zephyr_3.5>`. 13 14Required changes 15**************** 16 17Kernel 18====== 19 20* The kernel :c:func:`k_mem_slab_free` function has changed its signature, now 21 taking a ``void *mem`` pointer instead of a ``void **mem`` double-pointer. 22 The new signature will not immediately trigger a compiler error or warning, 23 instead likely causing a invalid memory access at runtime. A new ``_ASSERT`` 24 statement, that you can enable with :kconfig:option:`CONFIG_ASSERT`, will 25 detect if you pass the function memory not belonging to the memory blocks in 26 the slab. 27 28* :c:macro:`CONTAINER_OF` now performs type checking, this was very commonly 29 misused to obtain user structure from :c:struct:`k_work` pointers without 30 passing from :c:struct:`k_work_delayable`. This would now result in a build 31 error and have to be done correctly using 32 :c:func:`k_work_delayable_from_work`. 33 34C Library 35========= 36 37* The default C library used on most targets has changed from the built-in 38 minimal C library to Picolibc. While both provide standard C library 39 interfaces and shouldn't cause any behavioral regressions for applications, 40 there are a few side effects to be aware of when migrating to Picolibc. 41 42 * Picolibc enables thread local storage 43 (:kconfig:option:`CONFIG_THREAD_LOCAL_STORAGE`) where supported. This 44 changes some internal operations within the kernel that improve 45 performance using some TLS variables. Zephyr places TLS variables in the 46 memory reserved for the stack, so stack usage for every thread will 47 increase by 8-16 bytes. 48 49 * Picolibc uses the same malloc implementation as the minimal C library, but 50 the default heap size depends on which C library is in use. When using the 51 minimal C library, the default heap is zero bytes, which means that malloc 52 will always fail. When using Picolibc, the default is 16kB with 53 :kconfig:option:`CONFIG_MMU` or :kconfig:option:`ARCH_POSIX`, 2kB with 54 :kconfig:option:`CONFIG_USERSPACE` and 55 :kconfig:option:`CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT`. For all 56 other targets, the default heap uses all remaining memory on the system. 57 You can change this by adjusting 58 :kconfig:option:`CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE`. 59 60 * Picolibc can either be built as part of the OS build or pulled from the 61 toolchain. When building as part of the OS, the build will increase by 62 approximately 1000 files. 63 64 * When using the standard C++ library with Picolibc, both of those must come 65 from the toolchain as the standard C++ library depends upon the C library 66 ABI. 67 68 * Picolibc removes the ``-ffreestanding`` compiler option. This allows 69 significant compiler optimization improvements, but also means that the 70 compiler will now warn about declarations of `main` which don't conform to 71 the Zephyr required type -- ``int main(void)``. 72 73 * Picolibc has four different printf/scanf variants supported in Zephyr, 74 'double', 'long long', 'integer', and 'minimal. 'double' offers a 75 complete printf implementation with exact floating point in decimal and 76 hexadecimal formats, full integer support including long long, C99 77 integer size specifiers (j, z, t) and POSIX positional arguments. 'long 78 long' mode removes float support, 'integer' removes long long support 79 while 'minimal' mode also removes support for format modifiers and 80 positional arguments. Building the library as a module allows finer 81 control over the feature set provided at each level. 82 83 * Picolibc's default floating point input/output code is larger than the 84 minimal C library version (this is necessary to conform with the C 85 language "round trip" requirements for these operations). If you use 86 :kconfig:option:`CONFIG_CBPRINTF_FP_SUPPORT`, you will see increased 87 memory usage unless you also disable 88 :kconfig:option:`CONFIG_PICOLIBC_IO_FLOAT_EXACT`, which switches Picolibc 89 to a smaller, but inexact conversion algorithm. This requires building 90 Picolibc as a module. 91 92Optional Modules 93================ 94 95The following modules have been made optional and are not downloaded with `west update` by default anymore: 96 97* ``chre`` 98* ``lz4`` 99* ``nanopb`` 100* ``psa-arch-tests`` 101* ``sof`` 102* ``tf-m-tests`` 103* ``tflite-micro`` 104* ``thrift`` 105* ``zscilib`` 106 107To enable them again use the ``west config manifest.project-filter -- +<module 108name>`` command, or ``west config manifest.group-filter -- +optional`` to 109enable all optional modules, and then run ``west update`` again. 110 111Device Drivers and Device Tree 112============================== 113 114* ``zephyr,memory-region-mpu`` was renamed ``zephyr,memory-attr`` and its type 115 moved from 'enum' to 'int'. To have a seamless conversion this is the 116 required change in the DT: 117 118 .. code-block:: none 119 120 - "RAM" -> <( DT_MEM_ARM(ATTR_MPU_RAM) )> 121 - "RAM_NOCACHE" -> <( DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE) )> 122 - "FLASH" -> <( DT_MEM_ARM(ATTR_MPU_FLASH) )> 123 - "PPB" -> <( DT_MEM_ARM(ATTR_MPU_PPB) )> 124 - "IO" -> <( DT_MEM_ARM(ATTR_MPU_IO) )> 125 - "EXTMEM" -> <( DT_MEM_ARM(ATTR_MPU_EXTMEM) )> 126 127* Device dependencies (incorrectly referred as "device handles" in some areas) 128 are now an optional feature enabled by :kconfig:option:`CONFIG_DEVICE_DEPS`. 129 This means that an extra linker stage is no longer necessary if this option is 130 not enabled. 131 132* On all STM32 ADC, it is no longer possible to read sensor channels (Vref, 133 Vbat or temperature) using the ADC driver. The dedicated sensor driver should 134 be used instead. This change is due to a limitation on STM32F4 where the 135 channels for temperature and Vbat are identical, and the impossibility of 136 determining what we want to measure using solely the ADC API. 137 138* The RAM disk driver has been changed to support multiple instances and instantiation 139 using devicetree. As a result, Kconfig option :kconfig:option:`CONFIG_DISK_RAM_VOLUME_SIZE` 140 and Kconfig option :kconfig:option:`CONFIG_DISK_RAM_VOLUME_NAME` are removed, 141 and the application using the RAM disk must instantiate it using devicetree, 142 as in the following example: 143 144 .. code-block:: devicetree 145 146 / { 147 ramdisk0 { 148 compatible = "zephyr,ram-disk"; 149 disk-name = "RAM"; 150 sector-size = <512>; 151 sector-count = <192>; 152 }; 153 }; 154 155* The :dtcompatible:`goodix,gt911`, :dtcompatible:`xptek,xpt2046` and 156 :dtcompatible:`hynitron,cst816s` drivers have been converted from Kscan to 157 Input, they can still be used with Kscan applications by adding a 158 :dtcompatible:`zephyr,kscan-input` node. 159 160* The ``zephyr,gpio-keys`` binding has been merged into 161 :dtcompatible:`gpio-keys` and the callback definition has been renamed from 162 ``INPUT_LISTENER_CB_DEFINE`` to :c:macro:`INPUT_CALLBACK_DEFINE`. 163 164* The :dtcompatible:`ti,bq274xx` driver was using incorrect units for capacity 165 and power channels, these have been fixed and scaled by x1000 factor from the 166 previous implementation, any application using them has to be changed 167 accordingly. 168 169* The configuration options for the SSD1306 display driver can now be provided 170 via the Devicetree binding :dtcompatible:`solomon,ssd1306fb`. The following 171 Kconfig options: ``CONFIG_SSD1306_DEFAULT``, 172 ``CONFIG_SSD1306_SH1106_COMPATIBLE``, and ``CONFIG_SSD1306_REVERSE_MODE`` have 173 been removed. 174 175 * You can remove ``CONFIG_SSD1306_DEFAULT`` without any other modification. 176 177 * ``CONFIG_SSD1306_SH1106_COMPATIBLE`` was used to assert that the device is 178 (compatible with) SH1106. This has been replaced by a dedicated dts 179 compatible declaration. You may update an existing sh1106 node to change the 180 ``compatible`` designation from :dtcompatible:`solomon,ssd1306fb` to 181 :dtcompatible:`sinowealth,sh1106`. 182 183 * ``CONFIG_SSD1306_REVERSE_MODE`` is now set using the ``inversion-on`` 184 property of the devicetree node. 185 186* GPIO drivers not implementing IRQ related operations must now provide 187 ``NULL`` to the relevant operations: ``pin_interrupt_configure``, 188 ``manage_callback``, ``get_pending_int``. The public API will return 189 ``-ENOSYS`` when these are not available, instead of ``-ENOTSUP``. 190 191* STM32 Ethernet driver was misusing :c:func:`hwinfo_get_device_id` to generate 192 last 3 bytes of mac address, resulting in a high risk of collision when using 193 SoCs from the same lot. This is now fixed to use the whole range of entropy 194 available from the unique ID (96 bits). Devices using unique ID based mac address 195 will see last 3 bytes of their MAC address modified by this change. 196 197* On all STM32 (except F1x and F37x series), two new required properties have been 198 added to ADC to configure the source clock and the prescaler. 199 ``st,adc-clock-source`` allows choosing either synchronous or asynchronous clock source. 200 ``st,adc-prescaler`` allows setting the value of the prescaler for the chosen clock source. 201 Not all combinations are allowed. Refer to the appropriate RefMan for more information. 202 When choosing asynchronous clock, the choice of the kernel source clock is made in the 203 ``clocks`` node as it is done for other peripherals, for example, to select 204 HSI16 as clock source for STM32G0: 205 206 .. code-block:: devicetree 207 208 &adc { 209 clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00100000>, 210 <&rcc STM32_SRC_HSI ADC_SEL(2)>; 211 }; 212 213* On NXP boards with LPC DMA, the DMA controller node used to have its ``dma-channels`` property 214 set in the board DTS as a way to configure the amount of structures the driver will allocate. 215 This did not match the zephyr dma-controller binding, so this property is now fixed and set 216 in the SOC devicetree definition. Downstream boards should not override this property and 217 instead use the new driver Kconfig 218 :kconfig:option:`CONFIG_DMA_MCUX_LPC_NUMBER_OF_CHANNELS_ALLOCATED`. 219 220* The LPC55XXX series SOC (except LPC55S06) default main clock has been 221 updated to PLL1 source from XTAL32K running at 144MHZ. If the new 222 kconfig option :kconfig:option:`CONFIG_INIT_PLL1` 223 is disabled then the main clock is muxed to FRO_HR as before. 224 225* The Kconfig option ``CONFIG_GPIO_NCT38XX_INTERRUPT`` has been renamed to 226 :kconfig:option:`CONFIG_GPIO_NCT38XX_ALERT`. 227 228* The CAN controller timing API functions :c:func:`can_set_timing` and :c:func:`can_set_timing_data` 229 no longer fallback to the (Re-)Synchronization Jump Width (SJW) value set in the devicetree 230 properties for the given CAN controller upon encountering an SJW value corresponding to 231 ``CAN_SJW_NO_CHANGE`` (which is no longer available). The caller will therefore need to fill in 232 the ``sjw`` field in :c:struct:`can_timing`. To aid in this, the :c:func:`can_calc_timing` and 233 :c:func:`can_calc_timing_data` functions now automatically calculate a suitable SJW. The 234 calculated SJW can be overwritten by the caller if needed. The CAN controller API functions 235 :c:func:`can_set_bitrate` and :c:func:`can_set_bitrate_data` now also automatically calculate a 236 suitable SJW, but their SJW cannot be overwritten by the caller. 237 238* The CAN ISO-TP message configuration in :c:struct:`isotp_msg_id` is changed to use the following 239 flags instead of bit fields: 240 241 * :c:macro:`ISOTP_MSG_EXT_ADDR` to enable ISO-TP extended addressing 242 * :c:macro:`ISOTP_MSG_FIXED_ADDR` to enable ISO-TP fixed addressing 243 * :c:macro:`ISOTP_MSG_IDE` to use extended (29-bit) CAN IDs 244 245 The two new flags :c:macro:`ISOTP_MSG_FDF` and :c:macro:`ISOTP_MSG_BRS` were added for CAN FD 246 mode. 247 248* NXP i.MX RT based boards should now enable 249 :kconfig:option:`CONFIG_DEVICE_CONFIGURATION_DATA` at the board level when 250 using a DCD with the RT bootrom, and enable 251 :kconfig:option:`CONFIG_NXP_IMX_EXTERNAL_SDRAM` when using external SDRAM 252 via the SEMC 253 254* NXP i.MX RT11xx series SNVS pin control name identifiers have been updated to 255 match with the source data for these SOCs. The pin names have had the 256 suffix ``dig`` added. For example, ``iomuxc_snvs_wakeup_gpio13_io00`` has 257 been renamed to ``iomuxc_snvs_wakeup_dig_gpio13_io00`` 258 259Power Management 260================ 261 262* Platforms that implement power management hooks must explicitly select 263 :kconfig:option:`CONFIG_HAS_PM` in Kconfig. This is now a dependency of 264 :kconfig:option:`CONFIG_PM`. Before this change all platforms could enable 265 :kconfig:option:`CONFIG_PM` because empty weak stubs were provided, however, 266 this is no longer supported. As a result of this change, power management 267 hooks are no longer defined as weaks. 268 269* Multiple platforms no longer support powering the system off using 270 :c:func:`pm_state_force`. The new :c:func:`sys_poweroff` API must be used. 271 Migrated platforms include Nordic nRF, STM32, ESP32 and TI CC13XX/26XX. The 272 new API is independent from :kconfig:option:`CONFIG_PM`. It requires 273 :kconfig:option:`CONFIG_POWEROFF` to be enabled, which depends on 274 :kconfig:option:`CONFIG_HAS_POWEROFF`, an option selected by platforms 275 implementing the required new hooks. 276 277Bootloader 278========== 279 280* The :kconfig:option:`CONFIG_BOOTLOADER_SRAM_SIZE` default value is now ``0`` (was 281 ``16``). Bootloaders that use a part of the SRAM should set this value to an 282 appropriate size. :github:`60371` 283 284Bluetooth 285========= 286 287* The ``accept()`` callback's signature in :c:struct:`bt_l2cap_server` has 288 changed to ``int (*accept)(struct bt_conn *conn, struct bt_l2cap_server 289 *server, struct bt_l2cap_chan **chan)``, 290 adding a new ``server`` parameter pointing to the :c:struct:`bt_l2cap_server` 291 structure instance the callback relates to. :github:`60536` 292 293Networking 294========== 295 296* A new networking Kconfig option :kconfig:option:`CONFIG_NET_INTERFACE_NAME` 297 defaults to ``y``. The option allows user to set a name to a network interface. 298 During system startup a default name is assigned to the network interface like 299 ``eth0`` to the first Ethernet network interface. The option affects the behavior 300 of ``SO_BINDTODEVICE`` BSD socket option. If the Kconfig option is set to ``n``, 301 which is how the system worked earlier, then the name of the device assigned 302 to the network interface is used by the ``SO_BINDTODEVICE`` socket option. 303 If the Kconfig option is set to ``y`` (current default), then the network 304 interface name is used by the ``SO_BINDTODEVICE`` socket option. 305 306* Ethernet PHY devicetree bindings were updated to use the standard ``reg`` 307 property for the PHY address instead of a custom ``address`` property. As a 308 result, MDIO controller nodes now require ``#address-cells`` and 309 ``#size-cells`` properties. Similarly, Ethernet PHY devicetree nodes and 310 corresponding driver were updated to consistently use the node name 311 ``ethernet-phy`` instead of ``phy``. Devicetrees and overlays must be updated 312 accordingly: 313 314 .. code-block:: devicetree 315 316 mdio { 317 compatible = "mdio-controller"; 318 #address-cells = <1>; 319 #size-cells = <0>; 320 321 ethernet-phy@0 { 322 compatible = "ethernet-phy"; 323 reg = <0>; 324 }; 325 }; 326 327Other Subsystems 328================ 329 330* ZBus runtime observers implementation now relies on the HEAP memory instead of a memory slab. 331 Thus, zbus' configuration (kconfig) related to runtime observers has changed. To keep your runtime 332 observers code working correctly, you need to: 333 334 - Replace the integer ``CONFIG_ZBUS_RUNTIME_OBSERVERS_POOL_SIZE`` with the boolean 335 :kconfig:option:`CONFIG_ZBUS_RUNTIME_OBSERVERS`; 336 - Set the HEAP size with the :kconfig:option:`CONFIG_HEAP_MEM_POOL_SIZE`. 337 338* The zbus VDED delivery sequence has changed. Check the :ref:`documentation<zbus delivery 339 sequence>` to verify if it will affect your code. 340 341* MCUmgr SMP version 2 error codes entry has changed due to a collision with an 342 existing response in shell_mgmt. Previously, these errors had the entry ``ret`` 343 but now have the entry ``err``. ``smp_add_cmd_ret()`` is now deprecated and 344 :c:func:`smp_add_cmd_err` should be used instead, ``MGMT_CB_ERROR_RET`` is 345 now deprecated and :c:enumerator:`MGMT_CB_ERROR_ERR` should be used instead. 346 SMP version 2 error code defines for in-tree modules have been updated to 347 replace the ``*_RET_RC_*`` parts with ``*_ERR_*``. 348 349* MCUmgr SMP version 2 error translation (to legacy MCUmgr error code) is now 350 handled in function handlers by setting the ``mg_translate_error`` function 351 pointer of :c:struct:`mgmt_group` when registering a group. See 352 :c:type:`smp_translate_error_fn` for function details. Any SMP version 2 353 handlers made for Zephyr 3.4 need to be updated to include these translation 354 functions when the groups are registered. 355 356ARM 357=== 358 359* ARM SoC initialization routines no longer need to call `NMI_INIT()`. The 360 macro call has been removed as it was not doing anything useful. 361 362RISC V 363====== 364 365* The :kconfig:option:`CONFIG_RISCV_MTVEC_VECTORED_MODE` Kconfig option was renamed to 366 :kconfig:option:`CONFIG_RISCV_VECTORED_MODE`. 367 368Recommended Changes 369******************* 370 371* Setting the GIC architecture version by selecting 372 :kconfig:option:`CONFIG_GIC_V1`, :kconfig:option:`CONFIG_GIC_V2` and 373 :kconfig:option:`CONFIG_GIC_V3` directly in Kconfig has been deprecated. 374 The GIC version should now be specified by adding the appropriate compatible, for 375 example :dtcompatible:`arm,gic-v2`, to the GIC node in the device tree. 376 377* Nordic nRF based boards using :kconfig:option:`CONFIG_NFCT_PINS_AS_GPIOS` 378 to configure NFCT pins as GPIOs, should instead set the new UICR 379 ``nfct-pins-as-gpios`` property in devicetree. It can be set like this in the 380 board devicetree files: 381 382 .. code-block:: devicetree 383 384 &uicr { 385 nfct-pins-as-gpios; 386 }; 387 388* Nordic nRF based boards using :kconfig:option:`CONFIG_GPIO_AS_PINRESET` 389 to configure reset GPIO as nRESET, should instead set the new UICR 390 ``gpio-as-nreset`` property in devicetree. It can be set like this in the 391 board devicetree files: 392 393 .. code-block:: devicetree 394 395 &uicr { 396 gpio-as-nreset; 397 }; 398 399* The :kconfig:option:`CONFIG_MODEM_GSM_PPP` modem driver is obsolete. 400 Instead the new :kconfig:option:`CONFIG_MODEM_CELLULAR` driver should be used. 401 As part of this :kconfig:option:`CONFIG_GSM_MUX` and :kconfig:option:`CONFIG_UART_MUX` are being 402 marked as deprecated as well. The new modem subsystem :kconfig:option:`CONFIG_MODEM_CMUX` 403 and :kconfig:option:`CONFIG_MODEM_PPP` should be used instead. 404 405* Device drivers should now be restricted to ``PRE_KERNEL_1``, ``PRE_KERNEL_2`` 406 and ``POST_KERNEL`` initialization levels. Other device initialization levels, 407 including ``EARLY``, ``APPLICATION``, and ``SMP``, have been deprecated and 408 will be removed in future releases. Note that these changes do not apply to 409 initialization levels used in the context of the ``init.h`` API, 410 e.g. :c:macro:`SYS_INIT`. 411 412* The following CAN controller devicetree properties are now deprecated in favor specifying the 413 initial CAN bitrate using the ``bus-speed``, ``sample-point``, ``bus-speed-data``, and 414 ``sample-point-data`` properties: 415 416 * ``sjw`` 417 * ``prop-seg`` 418 * ``phase-seg1`` 419 * ``phase-seg1`` 420 * ``sjw-data`` 421 * ``prop-seg-data`` 422 * ``phase-seg1-data`` 423 * ``phase-seg1-data`` 424 425* ``<zephyr/arch/arm/aarch32/cortex_a_r/cmsis.h>`` and 426 ``<zephyr/arch/arm/aarch32/cortex_m/cmsis.h>`` are now deprecated in favor of 427 including ``<cmsis_core.h>`` instead. The new header is part of the CMSIS glue 428 code in the ``modules`` directory. 429 430* Random API header ``<zephyr/random/rand32.h>`` is deprecated in favor of 431 ``<zephyr/random/random.h>``. The old header will be removed in future releases 432 and its usage should be avoided. 433