How to add Skyworks fem to nrf5340 audio

Hello,

I am using nrf5340 audio sample with the custom board. The nRF Connect SDK version I used is v2.7.0.

I referred to this post and tried to add skyworks fem to my nrf5340 audio application.

The following is the part I modified:

nrf5340_audio_dk_nrf5340_cpunet.overlay

/ {
    nrf_radio_fem: pa_lna {
        compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
        ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
        ctx-settle-time-us = < 23 >;
        crx-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
        crx-settle-time-us = < 5 >;
        cps-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
        tx-gain-db = < 13 >;
        rx-gain-db = < 14 >;
    };
};
&radio {
	fem = <&nrf_radio_fem>;
};

nrf5340_audio_dk_nrf5340_cpuapp.overlay

/ {
    nrf_radio_fem: pa_lna {
        compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
        ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
        ctx-settle-time-us = < 23 >;
        crx-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
        crx-settle-time-us = < 5 >;
        cps-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
        tx-gain-db = < 13 >;
        rx-gain-db = < 14 >;
    };
};

prj.conf

CONFIG_MPSL=y
CONFIG_MPSL_FEM_ONLY=y
CONFIG_MPSL_FEM_SIMPLE_GPIO=y

But it doesn't seem to work.

Is there any way to add skyworks fem to nrf5340 audio application?

Parents
  • Hello again, and once again sorry about the wait. Please contact your local RSM if the help you are getting here isn't prompt enough. And let me know if you need his contact info.

    LandyWang said:

    But I don’t quite understand with the step 4 of the document. Does it mean creating a child image/hci_ipc.overlay file to the nrf5340 audio application? But in NCS v2.7.0, the child image has been replaced by sys build. What should I do to apply the devicetree node to the network core?

    Hmm yeah that part is a bit confusing, though it is explaining how one would do it with the legacy/non-sysbuild way. In the old system you would just add a dts overlay file to a childimage folder, like you mentioned. You can build it without sysbuild if you prefer, using "--no-sysbuild" or the 'No sysbuild' checkbox when making a build configuration in VSC:

     

    In order to build it with sysbuild, you essentially do the same thing but call the folder sysbuild. 

    LandyWang said:

    I tried adding hci_ipc.overlay in sysbuild/ipc_radio, but it seems that fem has no effect.

    Could you make sure that the hci_ipc.overlay have any effect there, by for instance adding some jibberish to the overlay and check if it still builds.

    I think you should either place a file called nrf5340dk_nrf5340_cpunet.overlay in sysbuild/hci_ipc/, or in child_image/hci_ipc/, but there are different ways of doing this in sysbuild and it is a bit confusing to me too.

    Regards,

    Elfving

  • Thank you for your reply.

    I tried adding jibberish to the overlay and check if it still builds to ensure that the hci_ipc.overlay have effect.

    Whether hci_ipc.overlay is placed in sysbuild/hci_ipc/ or child_image/hci_ipc/, it seems to have no effect. The same goes for changing the file name to nrf5340dk_nrf5340_cpunet.overlay.

    Selecting the 'No sysbuild' checkbox when making a build configuration in VSC has the same result.

    It looks like I can't apply the devicetree node to the network core.

  • LandyWang said:

    Whether hci_ipc.overlay is placed in sysbuild/hci_ipc/ or child_image/hci_ipc/, it seems to have no effect. The same goes for changing the file name to nrf5340dk_nrf5340_cpunet.overlay.

    My mistake. Call it /sysbuild/ipc_radio.conf for additional configurations on the child image, and call it /sysbuild/nrf5340dk_nrf5340_cpunet.overlay for additional dts configurations.

    You might have to delete the current build and re-build it for it to locate the new configurations. I believe I tried this myself last time, but I've at least tried it now. It works on my side.

    Regards, and have a good week-end

  • Thank you for your reply.

    I tried adding FEM-related config to my sysbuild folder, but a compile error occurred.

    Here are my steps:

    1.Remove build configuration

    2. Add /sysbuild/ipc_radio.conf

    #
    # Copyright (c) 2023 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    #FEM
    CONFIG_MPSL=y
    CONFIG_MPSL_FEM_ONLY=y
    CONFIG_MPSL_FEM_SIMPLE_GPIO=y

    3. Add /sysbuild/nrf5340_audio_dk_nrf5340_cpunet.overlay

    / {
        nrf_radio_fem: pa_lna {
            compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
            ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
            ctx-settle-time-us = < 23 >;
            crx-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
            crx-settle-time-us = < 5 >;
            cps-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
            tx-gain-db = < 13 >;
            rx-gain-db = < 14 >;
        };
    };
    &radio {
    	fem = <&nrf_radio_fem>;
    };

    4. Add bild configuration(using sysbuild)

    My compile error is as follows:

    It seems that MPSL cannot be used. Is nrf5340 audio unable to configure MPSL? If so, how to configure skyworks fem on nrf5340 audio application?

  • Hello,

    Is anyone still following this issue?

  • Hi, and once again I am very sorry about the wait,

    LandyWang said:

    My compile error is as follows:

    So that is good that it atleast gives you an error, showing that the files are being taken into account. I think maybe the build system didn't register the conf files last time I tried to build this - I think I am now running into the same issue you are here if I am trying to enable MPSL explicitly. Or something along those lines. The error looks the same.

    [200/205] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/nordic/ownApplications/nrf5340_audio_sys27/build_2/ipc_radio/zephyr/zephyr_pre0.map
    cmd.exe /C "cd . && C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf && cmd.exe /C "cd /D C:\nordic\ownApplications\nrf5340_audio_sys27\build_2\ipc_radio\zephyr && C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.exe -E true""
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a(hci_driver.c.obj): in function `mpsl_work_submit':
    C:/nordic/ncs/v2.7.0/nrf/include/mpsl/mpsl_work.h:47: undefined reference to `mpsl_work_q'
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a(ecdh.c.obj): in function `hci_cmd_le_read_local_p256_public_key':
    C:/nordic/ncs/v2.7.0/nrf/subsys/bluetooth/controller/ecdh.c:316: undefined reference to `mpsl_work_q'
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a(ecdh.c.obj): in function `cmd_le_generate_dhkey':
    C:/nordic/ncs/v2.7.0/nrf/subsys/bluetooth/controller/ecdh.c:327: undefined reference to `mpsl_work_q'
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    [15/20] Generating ../merged.hex
    FAILED: modules/nrf/ipc_radio-prefix/src/ipc_radio-stamp/ipc_radio-build C:/nordic/ownApplications/nrf5340_audio_sys27/build_2/modules/nrf/ipc_radio-prefix/src/ipc_radio-stamp/ipc_radio-build
    cmd.exe /C "cd /D C:\nordic\ownApplications\nrf5340_audio_sys27\build_2\ipc_radio && C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.exe --build ."
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.EXE' --build C:/nordic/ownApplications/nrf5340_audio_sys27/build_2
    
    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

    However, this builds for me in the audio sample, and automatically adds MPSL as well.

    sysbuild/ipc_radio.overlay

    / {
        nrf_radio_fem: pa_lna {
            compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
            ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
            ctx-settle-time-us = < 23 >;
            crx-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
            crx-settle-time-us = < 5 >;
            cps-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
            tx-gain-db = < 13 >;
            rx-gain-db = < 14 >;
        };
    };
     
    &radio {
    	fem = <&nrf_radio_fem>;
    };

    boards/nrf5340_audio_dk_nrf5340_cpuapp.overlay

    &usbd {
    	hs_0: hs_0 {
    		compatible = "usb-audio-hs";
    		mic-feature-mute;
    		mic-channel-l;
    		mic-channel-r;
    
    		hp-feature-mute;
    		hp-channel-l;
    		hp-channel-r;
    	};
    };
    / {
        nrf_radio_fem: pa_lna {
            compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
            ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
            ctx-settle-time-us = < 23 >;
            crx-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
            crx-settle-time-us = < 5 >;
            cps-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
            tx-gain-db = < 13 >;
            rx-gain-db = < 14 >;
        };
    };
    

    Now sometimes when I build with a new build configuration, it's not automatically finding the appcore overlay for me. Either way, that can be circumvented by adding it manually in the build-config GUI. The reference to usbdd here is just from the audio sample, so I simply added the references to fem underneath this.

    Does that build for you?

    Regards

Reply
  • Hi, and once again I am very sorry about the wait,

    LandyWang said:

    My compile error is as follows:

    So that is good that it atleast gives you an error, showing that the files are being taken into account. I think maybe the build system didn't register the conf files last time I tried to build this - I think I am now running into the same issue you are here if I am trying to enable MPSL explicitly. Or something along those lines. The error looks the same.

    [200/205] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/nordic/ownApplications/nrf5340_audio_sys27/build_2/ipc_radio/zephyr/zephyr_pre0.map
    cmd.exe /C "cd . && C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf && cmd.exe /C "cd /D C:\nordic\ownApplications\nrf5340_audio_sys27\build_2\ipc_radio\zephyr && C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.exe -E true""
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a(hci_driver.c.obj): in function `mpsl_work_submit':
    C:/nordic/ncs/v2.7.0/nrf/include/mpsl/mpsl_work.h:47: undefined reference to `mpsl_work_q'
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a(ecdh.c.obj): in function `hci_cmd_le_read_local_p256_public_key':
    C:/nordic/ncs/v2.7.0/nrf/subsys/bluetooth/controller/ecdh.c:316: undefined reference to `mpsl_work_q'
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a(ecdh.c.obj): in function `cmd_le_generate_dhkey':
    C:/nordic/ncs/v2.7.0/nrf/subsys/bluetooth/controller/ecdh.c:327: undefined reference to `mpsl_work_q'
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    [15/20] Generating ../merged.hex
    FAILED: modules/nrf/ipc_radio-prefix/src/ipc_radio-stamp/ipc_radio-build C:/nordic/ownApplications/nrf5340_audio_sys27/build_2/modules/nrf/ipc_radio-prefix/src/ipc_radio-stamp/ipc_radio-build
    cmd.exe /C "cd /D C:\nordic\ownApplications\nrf5340_audio_sys27\build_2\ipc_radio && C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.exe --build ."
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.EXE' --build C:/nordic/ownApplications/nrf5340_audio_sys27/build_2
    
    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

    However, this builds for me in the audio sample, and automatically adds MPSL as well.

    sysbuild/ipc_radio.overlay

    / {
        nrf_radio_fem: pa_lna {
            compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
            ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
            ctx-settle-time-us = < 23 >;
            crx-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
            crx-settle-time-us = < 5 >;
            cps-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
            tx-gain-db = < 13 >;
            rx-gain-db = < 14 >;
        };
    };
     
    &radio {
    	fem = <&nrf_radio_fem>;
    };

    boards/nrf5340_audio_dk_nrf5340_cpuapp.overlay

    &usbd {
    	hs_0: hs_0 {
    		compatible = "usb-audio-hs";
    		mic-feature-mute;
    		mic-channel-l;
    		mic-channel-r;
    
    		hp-feature-mute;
    		hp-channel-l;
    		hp-channel-r;
    	};
    };
    / {
        nrf_radio_fem: pa_lna {
            compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
            ctx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
            ctx-settle-time-us = < 23 >;
            crx-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
            crx-settle-time-us = < 5 >;
            cps-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
            tx-gain-db = < 13 >;
            rx-gain-db = < 14 >;
        };
    };
    

    Now sometimes when I build with a new build configuration, it's not automatically finding the appcore overlay for me. Either way, that can be circumvented by adding it manually in the build-config GUI. The reference to usbdd here is just from the audio sample, so I simply added the references to fem underneath this.

    Does that build for you?

    Regards

Children
  • Thanks for your assistance.

    I used the new configuration you suggested and still encountered the same error.

    2. Add /sysbuild/ipc_radio.conf

    I had to remove sysbuild/ipc_radio.conf mentioned in here than it can compile successfully. I am confused whether the MPSL related config is really compiled?

    In addition, after using the new configuration and removing sysbuild/ipc_radio.conf, although the compilation was successful, the longest distance bis gateway and bis headset could maintain sync did not increase when measured.

  • LandyWang said:

    I had to remove sysbuild/ipc_radio.conf mentioned in here than it can compile successfully. I am confused whether the MPSL related config is really compiled?

    I believe MPSL wasn't required to be set explicitly. Did you have anything other than MPSL enabled there? If you check the buildfiles you can see that MPSL is still being enabled from just the right dts nodes being there.

    LandyWang said:
    the longest distance bis gateway and bis headset could maintain sync did not increase when measured.

    So the output power depends on what you've configured both the FEM and the nRF to transmit. You can configure how much you want it to output using  eg. CONFIG_BT_CTLR_TX_PWR_ANTENNA, and how much the FEM is configured to contribute with using tx-gain-db in the FEMs dts node. Then the SoC TXPOWER is changed to compensate for the remainder such that TXPOWER+FEM gain <= CONFIG_BT_CTRL_TX_PWR_ANTENNA. So for instance if you happened to be using the nRF52840, and have set a static 20dB gain in the FEM, and set CONFIG_BT_CTRL_TX_PWR_ANTENNA=15dBm, you'll only get 12dBm on the antenna, since -8dBm is the closest you can get on the '840.

    LandyWang said:
    the longest distance bis gateway and bis headset could maintain sync did not increase when measured.

    This is a difficult way to test it. Could you try instead doing it this way?

    Regards,

    Elfving

  • Did you have anything other than MPSL enabled there?

    In addition to MPSL, I also enable these in prj.conf.

    CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
    CONFIG_I2C=y
    CONFIG_I2C_NRFX=y

    If you check the buildfiles you can see that MPSL is still being enabled from just the right dts nodes being there.

    Which file should I check to confirm that MPSL is enabled?

    Then the SoC TXPOWER is changed to compensate for the remainder such that TXPOWER+FEM gain <= CONFIG_BT_CTRL_TX_PWR_ANTENNA. So for instance if you happened to be using the nRF52840, and have set a static 20dB gain in the FEM, and set CONFIG_BT_CTRL_TX_PWR_ANTENNA=15dBm, you'll only get 12dBm on the antenna, since -8dBm is the closest you can get on the '840.

    I understand, it means that I set tx-gain_db to 13 and rx_gain_db to 14 in the overlay, then if I set CONFIG_BT_CTLR_TX_PWR_ANTENNA to 0, then I will get -3dBm in tx and -2 dBm in rx, is that right?

    But when I tried to add CONFIG_BT_CTLR_TX_PWR_ANTENNA=0, the following warning appeared:

    CONFIG_BT_CTLR_TX_PWR_ANTENNA couldn't be set. Missing dependencies:
    BT_CTLR

    This is a difficult way to test it. Could you try instead doing it this way?

    I tried using this way but got the error.

    C:\WINDOWS\system32>nrfjprog --memrd 0x4000150C --log
    [error] [SeggerBackend] - JLinkARM.dll ReadMem returned error 1.
    [error] [SeggerBackend] - JLinkARM.dll ReadMem returned error 1.
    [error] [SeggerBackend] - JLinkARM.dll ReadMem returned error 1.
    [error] [SeggerBackend] - JLinkARM.dll ReadMem returned error 1.
    [error] [SeggerBackend] - JLinkARM.dll ReadMem returned error 1.
    [error] [  nRF53] - The read access failed due to memory protection.
    ERROR: Access to the selected address is blocked by the SPU.

  • Hi Landy, 
    Håkon is away this week. I will try to help in the mean time. 

    You can check the generated .config file in build\zephyr folder to see what configuration has been enabled. Please check if you have CONFIG_MPSL=y. There are some more CONFIG_MPSL_FEM_* configuration, maybe they are relevant to your project. 

    CONFIG_BT_CTLR_TX_PWR_ANTENNA should be set in the firmware for the network core (BT_CTRL = Bluetooth controller ) , in your case it can be the ipc_radio remote image.

    LandyWang said:
    I tried using this way but got the error.

    Seems like the chip  has readback protection. Please check if you have enabled APPROTECT. 

     

  • Hello,

    Thank you for your assistance.

    I checked the .config file in build\zephyr folder and determined that there is no MPSL related configuration in my nrf5340 audio application.

    That means I have to join MPSL myself, but this brings me back to the problem I encountered earlier:

    My compile error is as follows:

    Once added, it will cause a compile error.

    CONFIG_BT_CTLR_TX_PWR_ANTENNA should be set in the firmware for the network core (BT_CTRL = Bluetooth controller ) , in your case it can be the ipc_radio remote image.

    Thank you for your suggestion, I will try to add CONFIG_BT_CTLR_TX_PWR_ANTENNA in my ipc_radio remote image after solving the other problems.

    Seems like the chip  has readback protection. Please check if you have enabled APPROTECT. 

    I tried adding the following configuration to prj.conf to disable APPROTECT, but still encountered failed due to memory protection error.

    CONFIG_NRF_APPROTECT_USE_UICR=n
    CONFIG_NRF_APPROTECT_LOCK=n

Related