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

Porting SDK14 project to SDK15.2 - IRQ handlers and other issues

I'm in the process of trying to port my SDK 14 project to SDK 15.2. I've made a pretty good amount of progress, but I have two issues that I can't seem to figure out.

The first is somewhat minor but very annoying. For some reason since I replaced the SDK 14 files with SDK 15.2 in my repo, the uint32_t type is no longer recognized by Eclipse even though other integers (uint16_t etc) are. APP_ERROR_CHECK is also marked as unrecognized. The compiler doesn't have issues with these though, so it seems to be something with Eclipse. If I go back to my SDK 14 branch (which just changes the code since my Eclipse settings are not tracked in my repo), uint32_t and APP_ERROR_CHECK are recognized by Eclipse without issue. This is annoying but not a blocker.

However, an issue I'm having with IRQ handlers is keeping me from progressing. Here's the output of my compiler (ARM GCC):

Compiling test_mode.c
In file included from /Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs.h:49:0,
                 from /Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/integration/nrfx/nrfx_glue.h:59,
                 from /Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/nrfx.h:46,
                 from /Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/components/libraries/delay/nrf_delay.h:44,
                 from /Users/user/Documents/source/firmware/system/app/inc/log_print.h:15,
                 from /Users/user/Documents/source/firmware/system/app/src/test_mode.c:9:
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:71:37: error: redundant redeclaration of 'SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler' [-Werror=redundant-decls]
 #define nrfx_twi_0_irq_handler      SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
                                     ^
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:71:37: note: in definition of macro 'nrfx_twi_0_irq_handler'
 #define nrfx_twi_0_irq_handler      SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:66:37: note: previous declaration of 'SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler' was here
 #define nrfx_spim_0_irq_handler     SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
                                     ^
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:66:37: note: in definition of macro 'nrfx_spim_0_irq_handler'
 #define nrfx_spim_0_irq_handler     SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:83:37: error: redundant redeclaration of 'SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler' [-Werror=redundant-decls]
 #define nrfx_twi_1_irq_handler      SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
                                     ^
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:83:37: note: in definition of macro 'nrfx_twi_1_irq_handler'
 #define nrfx_twi_1_irq_handler      SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:78:37: note: previous declaration of 'SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler' was here
 #define nrfx_spim_1_irq_handler     SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
                                     ^
/Users/user/Documents/source/firmware/nRF5_SDK_15.2.0_9412b96/modules/nrfx/soc/nrfx_irqs_nrf52832.h:78:37: note: in definition of macro 'nrfx_spim_1_irq_handler'
 #define nrfx_spim_1_irq_handler     SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [/Users/user/Documents/source/firmware/build/obj/test_mode.o] Error 1

I'm not completely sure what's going on, but it seems like the compiler thinks I'm trying to define the SPIM/TWI IRQ handler twice each for modules 0 and 1. But I'm not- at least not intentionally. My project intends to use TWI0, SPIM1, and SPIM2. My nrfx_config.h sets TWI/TWIS/TWIM/SPI/SPIS/SPIM enable flags as follows:

NRFX_TWI0_ENABLED 1
NRFX_TWI1_ENABLED 0
NRFX_SPIM0_ENABLED 0
NRFX_SPIM1_ENABLED 1
NRFX_SPIM2_ENABLED 1
All TWIM, TWIS, SPIS, and SPI are disabled.

If I search my entire working directory for NRFX_SPIM0_ENABLED, I find it defined in several places (excluding example directories).

  1. sdk/config/nrf52832/config/sdk_config.h
  2. sdk/integration/apply_old_config.h
  3. sdk/modules/nrfx/templates/nRF52832/nrfx_config.h
  4. <my application directory>/nrfx_config.h

So it was confusing to figure out which enable flag the compiler was actually using. But I added .orig extensions to numbers 1-3 so they won't be included and commented out the inclusion of apply_old_config.h in nrfx_glue.h. And I still get the same problem.

Other possible points of interest- I originally intended to use the legacy files provided to minimize the amount of changes I'd need to make to my application code up front. But I wondered if something in that legacy layer was causing issues, so I excluded it and made the necessary code changes (mostly nrf_drv_x to nrfx_x) and modified linker and sdk_config.h (and nrfx_config.h) files from the SDK instead of trying to modify the corresponding files I carried over from SDK 14. But none of those steps helped this SPI/TWI IRQ issue.

Any thoughts?

  • Hello,

    Regarding the Eclipse problem, that is something you will have to figure out, unfortunately. We don't support Eclipse officially. If you want to use a "free of charge"-IDE, you can look into Segger Embedded Studio, which is usually a "pay to use"-IDE, but Nordic has bought licences for users developing on Nordic Chips.

    Regarding the NRFX defines. Do you have any non-NRFX defines as well? e.g: TWI0_ENABLED, TWI1_ENABLED SPIM0_ENABLED, SPIM1_ENABLED, SPIM2_ENABLED? If you look in the apply_old_config.h file, you can see that if you do, the NRFX defines will be undefined and redefined.

    Also, I recommend that you don't have two files called nrfx_config.h, as the compiler will not understand which one to use. 

    I see that you renamed the first 3 files. what is the output from the compiler after you did this?

    Best regards,

    Edvin

  • Understood about Eclipse not being officially supported. I wouldn't have posted about it except that I was going to be posting about this IRQ issue anyway, so I was just hoping someone in the community had come across this issue before and knew how to sort it out.

    The only places TWI0/TWI1/SPIM0/SPIM1/SPIM2_ENABLED are defined are in my working copy of sdk_config.h in my application directory in the "legacy layer" sections. But they're all set to 0. I noticed SPI_0_USE_EASY_DMA was set to 1, so I tried setting it to 0 just in case, but I still get the same issue. Also, as mentioned previously, apply_old_config.h has been renamed to apply_old_config.h.orig to prevent inclusion.

    I don't have two files called nrfx_config.h. I copied the one from inside the SDK into my application directory and renamed the original file nrfx_config.h.orig to avoid the issue you described.

    The compiler output in my original post is from after renaming those three files. I have since gone back and renamed all sdk_config.h and nrfx_config.h files in the SDK (not including examples), even in directories for nRF52840 and nRF52810 just to be sure that my compiler isn't looking to those, and it didn't help.

    In trying things out, I've found that in nrfx_irqs_nrf52832.h, if I comment out line 66 (#define nrfx_spim_0_irq_handler     SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler) since I'm not trying to use SPIM0 and line 83 (#define nrfx_twi_1_irq_handler      SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler) since I'm not trying to use TWI1, my code compiles and things seem to work. But this doesn't seem like the correct solution and leaves me wondering what other problems might be caused by the underlying issue. (If I comment out these lines, the next thing I notice is issues with SAADC events, but I'll worry about that later in case I still have bigger issues with interrupts in general than I realize.)

  • Hello,

    Is it possible to reproduce the issue with the armgcc folder, so that I can try to replicate it just using the makefile from the armgcc folder? 

    If so, could you send the project?

    Best regards,

    Edvin

  • Sorry about the delayed response. I'm not sure I understand exactly what you mean. Do you mean to try to reproduce it with the armgcc makefile in one of the examples? Unfortunately the structure of my project's makefiles are pretty different from the example makefiles so I think there would be a non-trivial amount of work involved. Would it be sufficient to attach my config files? I have attached them just in case.

    In looking into this with fresh eyes just now, it seems odd to me that nrfx_spim.h includes prototypes for SPIM0, SPIM1, SPIM2, and SPIM3 regardless of which SPIM modules are enabled. And nrfx_twi.h includes prototypes for TWI0 and TWI1, regardless of which TWI modules are enabled. If I undo my previous comments/edits to nrfx_irqs_nrf52832.h as previously mentioned and instead gate all the nrfx_spim_x_irq_handler(void) and nrfx_twi_x_irq_handler(void) IRQ handler prototypes behind corresponding #if NRFX_CHECK(NRFX_XXXX_ENABLED) (like the corresponding IRQ handler definitions are gated), my project compiles. Shouldn't the IRQ handler prototypes be gated behind NRFX_CHECKS so that they're not duplicated when nrfx_irqs_nrf52832.h is included?

    2664.sdk_config.hnrfx_config.h

  • What do you mean by prototypes for SPIM0, SPIM1, SPIM2 and SPIM3? It doesn't look like to me that it gates all the nrfx_spim_x_irq_handler(void) when you enable one of them. They are all behind an

    #if NRFX_CHECK(NRFX_SPIX_ENABLED)
    nrfx_spim_x_irq_handler,
    #endif 

    Can you see if you get the same issue if you try the segger embedded studio (ses) project from SDK15.2.0? 

    Best regards,

    Edvin

Related