Compilation Error when Configuring NRF21540 on NRF5340

I've been using ICMSG's IPC to exchange HCI messages between the netcore and appcore, and using SPI to exchange HCI information between the host and appcore. This setup enables HCI message transfer between the netcore and the host, and it works properly.

However, when I configure the NRF21540 FEM in the netcore, I get an error indicating that mpsl_work_q is undefined in hci_driver.c. I traced the code and found that mpsl_work_q is defined in mpsl_init.c, and it requires CONFIG_MPSL_FEM_ONLY=n. But when CONFIG_FEM=y is set, it automatically selects MPSL_FEM_ONLY.

So it seems like there's a conflict between my HCI and FEM configurations. How can I configure it to ensure both FEM and HCI are enabled at the same time?

Parents Reply Children
  • my sdk is ncs 2.6.1

    The netcore has a simple program whose function is to send messages from the BLE rx_queue to the appcore via ICMSG IPC, and forward the messages received through IPC to the Bluetooth module via bt_send. The program is based on the hci_spi implementation but replaces SPI with IPC.

    Below are the configuration items related to FEM and HCI in my prj.conf.

    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y
    CONFIG_BT_MAX_CONN=8
    CONFIG_BT_TINYCRYPT_ECC=n
    CONFIG_BT_HCI_RAW_RESERVE=1
    CONFIG_FEM=y
    CONFIG_FEM_AL_LIB=y
    CONFIG_MPSL_FEM=y

    CONFIG_SPI=y
    CONFIG_SPI_NRFX=y
    CONFIG_NRFX_SPIM0=y

    # CONFIG_MPSL_FEM_ONLY=y
    CONFIG_MPSL_FEM_NRF21540_GPIO=y
    # CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTA=7
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTB=7
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=7
    CONFIG_MPSL_FEM_NRF21540_RX_GAIN_DB=13
    The configuration related to FEM in the DTS overlay file of netcore.
    &spi0 {
        status = "okay";
        cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;

        pinctrl-0 = <&spi0_default>;
        pinctrl-1 = <&spi0_sleep>;
        pinctrl-names = "default", "sleep";

        nrf_radio_fem_spi: nrf21540_fem_spi@0 {
            compatible = "nordic,nrf21540-fem-spi";
            reg = <0>;
            spi-max-frequency = <8000000>;

            status = "okay";
        };
    };

    &radio{
        /delete-property/ ieee802154-supported;

        fem = <&nrf_radio_fem>;
    };
    / {
         nrf_radio_fem: nrf21540_fem {
            compatible = "nordic,nrf21540-fem";
            tx-en-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
            rx-en-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
            pdn-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
            ant-sel-gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
            mode-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
            spi-if = <&nrf_radio_fem_spi>;
            supply-voltage-mv = <3000>;

            status = "okay";
        };
    }
  • Are you basically creating your own netcore application based on an HCI sample then?

    You might need full fledge MPSL and not just the FEM part of MPSL. Try using:

    CONFIG_MPSL=y
    CONFIG_MPSL_FEM_ONLY=n
    

    Also, for further debugging, you will want to look at the compiled .config file as well, to check which Kconfig has taken effect.

  • Are you basically creating your own netcore application based on an HCI sample then?

    yes, base on the sample hci_spi 

    I tried adding CONFIG_MPSL_FEM_ONLY=n to my prj.conf file, but CONFIG_MPSL_FEM_ONLY=y still appears in the final .config file. It seems this is because in the fem_al Kconfig, CONFIG_MPSL_FEM_ONLY is automatically selected when CONFIG_FEM=y.

    So the error still persists.

  • OK, do you mean you are using CONFIG_FEM, which selects CONFIG_MPSL_FEM_ONLY?

    Do you need CONFIG_FEM for any particular reason?

    If not, please remove it. Use only CONFIG_MPSL and CONFIG_MPSL_FEM, and maybe explicitly disable CONFIG_MPSL_FEM_ONLY.

  • I don't necessarily need to configure CONFIG_FEM=y, it's just to get the nRF21540 working. Since this is our first time using the nRF5340 and NCS SDK, sometimes the configuration might not be appropriate. I followed your suggestion and removed CONFIG_FEM, but the same error still occurred. After removing CONFIG_FEM_AL_LIB, it compiled successfully.

    Now my configuration items in prj.conf are as follows:

    # CONFIG_FEM=y
    # CONFIG_FEM_AL_LIB=y
    CONFIG_MPSL_FEM=y

    CONFIG_SPI=y
    CONFIG_SPI_NRFX=y
    CONFIG_NRFX_SPIM0=y

    # CONFIG_MPSL_FEM_NRF21540_GPIO=y
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTA=13
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTB=7
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=13
    CONFIG_MPSL_FEM_NRF21540_RX_GAIN_DB=13
    The relevant configurations in the final generated .config file are as follows:
    #
    # Multiprotocol service layer (MPSL)
    #
    # CONFIG_MPSL_FEM_ONLY is not set
    CONFIG_MPSL_FEM_ANY_SUPPORT=y
    CONFIG_MPSL_FEM_NRF21540_GPIO_SUPPORT=y
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI_SUPPORT=y
    CONFIG_MPSL_FEM_NCS_SUPPORTED_FEM_USED=y
    CONFIG_MPSL_FEM_API_AVAILABLE=y
    CONFIG_MPSL_FEM=y
    # CONFIG_MPSL_FEM_NRF21540_GPIO is not set
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=13
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTA=13
    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTB=7
    CONFIG_MPSL_FEM_NRF21540_RX_GAIN_DB=13
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
    CONFIG_MPSL_FEM_POWER_MODEL=y
    CONFIG_MPSL_FEM_POWER_MODEL_NRF21540_USE_BUILTIN=y
    CONFIG_MPSL_FEM_BUILTIN_POWER_MODEL_UPDATE_PERIOD=2000
    CONFIG_MPSL_FEM_DEVICE_CONFIG_254=y
    The gain values obtained using the functions mpsl_fem_pa_is_configured and mpsl_fem_lna_is_configured are consistent with what I set in prj.conf, but when I scan the broadcast packets of the nRF5340, the RSSI does not seem to have any significant change. Is there any other way to determine if my FEM is working properly?
Related