This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRFX migration legacy layer

I can get a clean build and working product with some workarounds, but a couple issues remain from migrating sdk 13.1 to sdk 15.0 (SES nrf52832 s132).

1) After nrf_drv to nrfx, and twi to twim conversions, the app_button.c had references to nrf_gpiote but the nrf_gpiote.c was removed and replaced with nrfx_gpiote.c in the project. Having to change the nrf references in app_button.c (an sdk file) seemed odd to get nrfx to work.

2) Also in sdk_config.h if I try to delete or set to zero GPIOTE_ENABLED I get errors:

error if set to zero: undefined reference to 'nrfx_gpiote_in_is_set'

error if deleted: builds and downloads but no advertising and scanner does not pick up the device.

but all ok when GPIOTE_ENABLED 1 when the file is not even in the project, (also NRFX_GPIOTE_ENABLED is set to one)

3) Not sure if related, but the same for UART_ENABLED. I can set UART_ENABLED to zero but not delete/remove from sdk_config.h,, even though nrf_uarte.c has been removed and not in the project.  If I try to delete the UART_ENABLED section, the error is, "compiling 'nrfx_uart.c', #error "No enabled UART instances , Check <nrfx_config.h>. I have NRFX_UARTE_ENABLED and NRFX_UART_ENABLED set to one.

With these three workarounds all is good, but I'm going for the sdk_config.h file to have no legacy layers.

-thank-you.

Parents
  • Hello,

    I think the problem is not that you are not using the legacy drivers, but that the NRFX defines are "overwritten" by the "legacy" defines. if you look at the file "apply_old_config.h", which I assume is included in your project, you will find this sort of thing for most of your NRFX defines:

     

    #if defined (LEGACY_DEFINE)

    #undef NRFX_DEFINE
    #define NRFX_DEFINE LEGACY_DEFINE

    #endif 

     

    So all your NRFX defines are redefined to the old defines if the old defines are defined. Not the smoothest approach when changing drivers, but it is what it is at this point in time.

     

    So either define all the "old" configs to the same as the new ones, or remove them completely (not enough to set them to 0, since this will still count as defined).

     

    Try this, and let me know if it still doesn't work.

     

    Best regards,

    Edvin

  • I just gave apply_old_config.h a look, and this file ( "apply_old_config.h")  had never been part of my project (didn't know about it). The UART_ENABLED was set to zero, but not able to delete.

  • Hello,

    Ok. I understand. I got your project from my colleague. I see what you mean with the app_button issue.

     

    If you remove the GPIPTE_ENABLED completely in sdk_config.h. It should be sufficient to comment out GPIOTE_ENABLED, but if you intend to remove it completely, and only use the nrfx drivers, I guess you can completely remove the GPIOTE_ENABLED section.

    // <e> GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer
    //==========================================================
    //#ifndef GPIOTE_ENABLED
    //#define GPIOTE_ENABLED 1
    //#endif
    // <o> GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins 
    #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4
    #endif

     

    The only error I get then is that app_button is missing nrf_drv_gpiote.h, which I assume that you have also removed. 

    All nrf_drv_gpiote.h does in SDK 15 is mapping the old nrf_drv_gpiote names to the new nrfx_gpiote names.

     

    Solutions:

    1. Either include this file, nrf_drv_gpiote.h which will map to the correct names.

    2. Alternatively, you can change the include in app_button.c from:

    #include "nrf_drv_gpiote.h"

    to

    #include "nrfx_gpiote.h"

    and then, change all the names and function calls that are used in app_button.c to the new ones in nrfx_gpiote.h. The correct names are listed in nrf_drv_gpiote.h.

     

    Best regards,

    Edvin

  • From before I had done your solution #2 and included the modified app_button.c_new file in the zip. I triple checked if I missed a rename but still getting the same error: undefined reference to 'nrfx_gpiote_in_is_set'.

    Then I tried solution #1 using the mapping file and standard app_button.c file, but exact same errors as solution #2 when GPIOTE_ENABLED = 0 or removed.

    -thank-you.

  • Hello,

    I didn't see the included app_button.c_new file before now. I tried solution #2, doing the following:

    1: Removed the three lines in sdk_config.h (commented them out, really)

    //#ifndef GPIOTE_ENABLED
    //#define GPIOTE_ENABLED 1
    //#endif

    2: Removed the file app_button.c from your project,

    3: changed the name of the file "app_button.c_new" to "app_button.c"

    4: included the (new file) app_button.c.

    5: Tried to compile. Got an error saying "#error "Board is not defined", so I added BOARD_PCA10040 to the preprocessor defines

    6: Compiled again, and this time without any issues.

     

    Can you please try to do the same, and let me know where in the process that your results differ from mine?

     

    Best regards,

    Edvin

  • In my previous reply I should have not included "or removed", that like noted in the very first post, the code compiles ok, but when flashed, the device does not advertise. I tested this in the DK and the same no advertise result as in the custom.

    -thank-you.

  • Hello,

    I can't run the example, because I don't have the ble280 twi device, so the bme280_init() doesn't return.

    If I commented out this, then I got an error 4 (NO_MEM) on bsp_init() in main.c This was because in sdk_config.h you had:

    #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1

    I changed it to

    #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4, and it ran ok.

     

    Try to change NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS to 4.

     

    If not, check the log output for reasons why the application may fail.

     

    Best regards,

    Edvin

Reply
  • Hello,

    I can't run the example, because I don't have the ble280 twi device, so the bme280_init() doesn't return.

    If I commented out this, then I got an error 4 (NO_MEM) on bsp_init() in main.c This was because in sdk_config.h you had:

    #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1

    I changed it to

    #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4, and it ran ok.

     

    Try to change NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS to 4.

     

    If not, check the log output for reasons why the application may fail.

     

    Best regards,

    Edvin

Children
  • i see that error NRF_ERROR_NO_MEM, but not sure how you linked it to LOW_POWER_EVENTS. i searched Infocenter but only get SoftDevice no memory for operation.

    I made the change and now good for s132 and no legacy layers remaining.

    I did the same for s112 but also had to remove nrfx_uart.c to get it working with no legacy layers.

    Much appreciated for this effort.

    -thank-you.

Related