error: pasting "_XXXX" and "(" does not give a valid preprocessing token

Im trying to enable rtc rv8263 support by copying changes made to support it from 

https://github.com/zephyrproject-rtos/zephyr/commit/37d6bc082782f0b66420c68f4ff57db5eb283d90

https://github.com/zephyrproject-rtos/zephyr/commit/db9b45a7b3f0d2a2b63a840d8d7d3abfcdb7709b

github.com/.../4c880f4b0a5fa6d55d731ddfec8b040361998427

to my nordic zephyr at /opt/nordic/ncs/v2.6.1/zephyr

I use the nrf52840dk board

Added this to prj.conf:

CONFIG_I2C=y
CONFIG_RTC=y
CONFIG_RTC_RV8263=y

This is what i added to app.overlay:

&i2c0 { /* SDA P0.26, SCL P0.27 */
	status = "okay";
	rv8263: rv8263@68 {
		compatible = "microcrystal,rv-8263-c8";
		reg = <0x68>;
		status = "okay";
        int-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
		clkout = <32768>;
	};
};

Currently i get the following compile error:

In file included from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/sys/util_macro.h:34,
from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/irq_multilevel.h:15,
from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/devicetree.h:20,
from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/device.h:12,
from /opt/nordic/ncs/v2.6.1/zephyr/drivers/rtc/rtc_rv8263.c:5:
/opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/sys/util_internal.h:59:21: error: pasting "_XXXX" and "(" does not give a valid preprocessing token
59 | __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
| ^~~~~
/opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/sys/util_macro.h:180:9: note: in expansion of macro 'Z_COND_CODE_1'
180 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
/opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/sys/util_macro.h:224:9: note: in expansion of macro 'COND_CODE_1'
224 | COND_CODE_1(_flag, _code, ())
| ^~~~~~~~~~~
/opt/nordic/ncs/v2.6.1/zephyr/drivers/rtc/rtc_rv8263.c:715:17: note: in expansion of macro 'IF_ENABLED'
715 | IF_ENABLED(DT_ANY_INST_HAS_PROP_STATUS_OKAY(int_gpios), \
| ^~~~~~~~~~
/Users/henrihallik/metercs/build_debug/zephyr/include/generated/devicetree_generated.h:15386:58: note: in expansion of macro 'RV8263_DEFINE'
15386 | #define DT_FOREACH_OKAY_INST_microcrystal_rv_8263_c8(fn) fn(0)
| ^~
/opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in expansion of macro 'DT_FOREACH_OKAY_INST_microcrystal_rv_8263_c8'
105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
| ^
/opt/nordic/ncs/v2.6.1/zephyr/drivers/rtc/rtc_rv8263.c:721:1: note: in expansion of macro 'DT_INST_FOREACH_STATUS_OKAY'
721 | DT_INST_FOREACH_STATUS_OKAY(RV8263_DEFINE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
[205/406] Building C object zephyr/drivers/spi/CMakeFiles/drivers__spi.dir/spi_nrfx_spim.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/580e4ef81c/bin/cmake --build /Users/henrihallik/metercs/build_debug

* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.

rv8263_support.patch

I have attached git patch that contains all the changes i have made to nrf sdk zephyr installation. This can be applied by:

cd /opt/nordic/ncs/v2.6.1/zephyr
git apply /path/to/rv8263_support.patch

to easily make the same changes i have made to reproduce the issue.

How to resolve this compile issue?

Parents
  • I think you should take this in Zephyr forum as the support seems to have been added to the later upstream zephyr and I have absolutely no idea on the compatibility of this patch on the earlier zephyr version which is used by nRF Connect SDKv2.6.1

    I would suggest to use nRF Connect SDKv2.7.0 as there seems to driver support for this RTC there and then build a patch on top of it.

Reply
  • I think you should take this in Zephyr forum as the support seems to have been added to the later upstream zephyr and I have absolutely no idea on the compatibility of this patch on the earlier zephyr version which is used by nRF Connect SDKv2.6.1

    I would suggest to use nRF Connect SDKv2.7.0 as there seems to driver support for this RTC there and then build a patch on top of it.

Children
  • Using nRFConnect SDKv2.7.0 fixed the issue. After switching sdk, copied the rv8263 support changes from https://github.com/zephyrproject-rtos/zephyr/commit/37d6bc082782f0b66420c68f4ff57db5eb283d90 into the v2.7.0/zephyr. Also added some things to devicetree:

    	i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 10)>,
    					<NRF_PSEL(TWIM_SCL, 0, 7)>;
    		};
    	};
    
    	i2c0_sleep: i2c0_sleep {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 10)>,
    					<NRF_PSEL(TWIM_SCL, 0, 7)>;
    			low-power-enable;
    		};
    	};
    
    &i2c0 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	clock-frequency = <400000>;
    	zephyr,concat-buf-size = <512>;
    
    	pinctrl-0 = <&i2c1_default>;
    	pinctrl-1 = <&i2c1_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	rv_8263_c8: rv-8263-c8@51 {
    		compatible = "microcrystal,rv-8263-c8";
    		reg = <0x51>;
    		status = "okay";
    		clkout = <1024>;
    		int-gpios = <&gpio1 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    	};
    };

Related