This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Build with optimization does not work with DFU

Hi, I'm using IAR ARM Embedded Workbench (v7.20) to build my Nordic applications. Recently I enabled optimizations (in Project Options: C/C++ Compiler:Optimizations: Level-High-Size). However, when I try to DFU this build it always fails. DFU-ing it works fine when I build my application with optimizations set to None. My guess is that there is a struct or some other data object that is getting optimized that needs to exist at a specific memory location for the DFU to work, but I'm not really sure. Any ideas on why DFU would fail with optimizations turned on? thanks! akbar

Parents
  • I think optimization cannot be applied to any code which relies on hardware performance.

    For example, in the API call of nrf_delay_ms, it runs multiple NOP instructions to achieve 1ms unit delay.

    In my opinion, if you optimize your code, the compiler may reduce this "redundant" function but totally mess up the timing of your program.

  • You can have high optimization on and nrf_delay_ms still works. It uses volatile to ensure that it doesn't get optimized away. It does not affect the timing.

    I have no idea why, but if you turn off static clustering in the IAR optimizations then the DFU works with high optimization. Not using the DFU static clustering can be enabled but OTA updates static clustering can't be enabled.

Reply
  • You can have high optimization on and nrf_delay_ms still works. It uses volatile to ensure that it doesn't get optimized away. It does not affect the timing.

    I have no idea why, but if you turn off static clustering in the IAR optimizations then the DFU works with high optimization. Not using the DFU static clustering can be enabled but OTA updates static clustering can't be enabled.

Children
No Data
Related