Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PA/LNA in bootloader

Hello.

I have pa/lna on my device. It works properly in application (rssi is about 30 dbm). But when application goes into bootloader (dfu over ble using nrfconnect on android) rssi is about 95-100 dbm. 

I tried to add pa/lna init to secure_bootloader code. And when i download this on erased chip, I see that rssi is about 20-30 in bootloader mode. But function sd_ble_opt_set() return 1. And when I download the application and start dfu, the application goes into bootloader mode and the signal level becomes 100 again.

Why it happens?

  • Hi,

    I assume the PA/LNA is controlled by GPIO pins using the PA/LNA support in the SoftDevice? Essentially this is just the SoftDevice asserting selected GPIO pins when there is radioactivity, so it is no different than controlling any other GPIO pins. It should be the same in the bootloader and application, but it has to be configured in both since the SoftDevice is initialized separately in the bootloader and application. Have you checked with a logic analyzer to see if the GPIO pins are controlled as expected? How do you configure the PA/LAN control in the SoftDevice and application?

  • Where could I add PA/LNA init in secure_bootloader code? Before nrf_bootloader_init()?

    My configuration for the PA/LNA. This code the same in the bootloader and application.

    static void pa_lna_start(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
    {
        uint8_t err_code;
    
        static const uint32_t gpio_toggle_ch = 0;
        static const uint32_t ppi_set_ch = 0;
        static const uint32_t ppi_clr_ch = 1;
        
        // Configure SoftDevice PA/LNA assist
        ble_opt_t opt;
        memset(&opt, 0, sizeof(ble_opt_t));
        // Common PA/LNA config
        opt.common_opt.pa_lna.gpiote_ch_id  = gpio_toggle_ch;        // GPIOTE channel
        opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_clr_ch;            // PPI channel for pin clearing
        opt.common_opt.pa_lna.ppi_ch_id_set = ppi_set_ch;            // PPI channel for pin setting
        // PA config
        opt.common_opt.pa_lna.pa_cfg.active_high = 1;                // Set the pin to be active high
        opt.common_opt.pa_lna.pa_cfg.enable      = 1;                // Enable toggling
        opt.common_opt.pa_lna.pa_cfg.gpio_pin    = gpio_pa_pin;      // The GPIO pin to toggle
      
        // LNA config
        opt.common_opt.pa_lna.lna_cfg.active_high  = 1;              // Set the pin to be active high
        opt.common_opt.pa_lna.lna_cfg.enable       = 1;              // Enable toggling
        opt.common_opt.pa_lna.lna_cfg.gpio_pin     = gpio_lna_pin;   // The GPIO pin to toggle
        
        err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
        NRF_LOG_INFO("pa_lna_assist end, result: %d, error: %s", err_code, nrf_strerror_get(err_code));
    //    APP_ERROR_CHECK(err_code);
    }

    I don’t understand why when downloading the bootloader to erased device everything works, but when I enter the bootloader mode from the application it doesn’t work.

  • I did some experiments:

    1. I use this script:

    nrfutil settings generate --family NRF52840 --application ../Output/Debug/Exe/app.hex --application-version 0 --bootloader-version 0 --bl-settings-version 1 bootloader_setting.hex
    mergehex --merge s140_nrf52_6.1.0_softdevice.hex secure_bootloader_ble_s140_pca10056_debug.hex bootloader_setting.hex --output bl_with_sd.hex
    mergehex --merge ../Output/Debug/Exe/app.hex bl_with_sd.hex --output my_app.hex
    nrfjprog --family NRF52 --reset --program my_app.hex --chiperase --verify

    And in my app I call function ble_dfu_buttonless_bootloader_start_prepare() after ble_dfu_support_service_init() and device enter bootloader mode. Result: rssi over 90-100.

    2. I use this script:

    mergehex --merge s140_nrf52_6.1.0_softdevice.hex secure_bootloader_ble_s140_pca10056_debug.hex bootloader_setting.hex --output bl_with_sd.hex
    nrfjprog --family NRF52 --reset --program bl_with_sd.hex --chiperase --verify

    Result: rssi over 20-30.

    My changes in secure_bootloader code are adding pa_lna_start() function and initialization pins before nrf_bootloader_init().

  • I fix this problem by adding pa/lna init at ble_dfu_transport_init() fucntion in nrf_dfu_ble.c after ble_stack_init(). 

    But I do not think this is a good solution. How to solve this?

  • Hi,

    I am sorry for the late reply.

    I am glad to hear you got it working. Why is it not a good idea to do the PA/LNA configuration in ble_dfu_transport_init()? I would say that is exactly where you should put it in the bootloader since that is where the SoftDevice (BLE stack) is initialized.

Related