nrf5340: Evaluating Power Consumption of XIP Functions

Hello,

I am looking into evaluating the nrf5340 with different functions running out of external flash, and how current draw is affected by these functions. We are looking at running some code out of qspi flash, and other code internally. We plan to measure the power consumption of different types of code running from the different resources, so we can decide what code is OK to run out of external flash. Is there a simple Zephyr sample project that I can start with where I can set some functions to run XIP out of the external QSPI flash, and others to run internally?

Walt

Parents
  • Recently we did some measurements to evaluate performance of the nRF5340 XIP. Execute in place (XIP) allows the CPU to execute program code directly from the external flash: https://infocenter.nordicsemi.com/topic/ps_nrf5340/qspi.html?cp=3_0_0_6_24_4#execute_in_place. Maybe this is something useful for you.

    For the experiment nRF Connect SDK Machine Learning application has been chosen: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/machine_learning/README.html#. Application design allows to separate Edge Impulse library to an external memory. There is only one call to this library from Edge Impulse wrapper module, and therefore this call is used to measure time of execution. Additional measurements of current allowed us to compare total energy used. Please note that given numbers include current consumed only by the nRF5340 alone. To have a complete number you should add an additional current used by an external Flash, which will vary between manufacturers.

    If you plan to run radio operations and use QSPI/XIP concurrently, you should only compare numbers for 1.8V. This is because of the following errata: https://infocenter.nordicsemi.com/topic/errata_nRF5340_Rev1/ERR/nRF5340/Rev1/latest/anomaly_340_133.html?cp=3_0_1_0_1_18

     

    The best results for execution from an external Flash were achieved for CPU freq == 128 MHz, with cache enabled and QSPI speed == 96 MHz. Execution time was 10% longer, and energy used was 27% higher comparing to the same setup while running from the internal Flash.

    Please note that execution time 10% longer, and energy used 27% higher does not apply to the entire solution, but only to a code parts running from an external Flash. If you split the code in a clever way so that rarely used functions are in the external Flash and often used functions are in the internal Flash, the results relating to the overall solution will be much better.

    Here are tips if you would like to repeat these measurements:

    • branch used for the experiment can be found at https://github.com/awojasinski-nordicsemi/sdk-nrf/tree/NRFX-1428-xip-performance-ncs

    • compilation: west build -b nrf5340dk_nrf5340_cpuapp
    • flashing firmware: nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --program build/zephyr/zephyr.hex

    • Compile to external memory:
      • in CMakeLists.txt change compile definition XIP_MEMORY=1
      • in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_HAVE_CUSTOM_LINKER_SCRIPT to y
    • Compile to internal memory
      • in CMakeLists.txt change compile definition XIP_MEMORY=0
      • in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_HAVE_CUSTOM_LINKER_SCRIPT to n
    • Change CPU clock to 128MHz
      • in CMakeLists.txt change compile definition CPU_128MHZ=1 (0 => 64MHz, 1=> 128MHz)
    • Change QSPI speed
      • in CMakeLists.txt change compile definition XIP_DIV
        • XIP_DIV=0 => 94MHz
        • XIP_DIV=1 => 48MHz
        • XIP_DIV=2 => 24MHz
    • Disable/Enable Cache
      • in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_NRF_ENABLE_CACHE to n/y
Reply
  • Recently we did some measurements to evaluate performance of the nRF5340 XIP. Execute in place (XIP) allows the CPU to execute program code directly from the external flash: https://infocenter.nordicsemi.com/topic/ps_nrf5340/qspi.html?cp=3_0_0_6_24_4#execute_in_place. Maybe this is something useful for you.

    For the experiment nRF Connect SDK Machine Learning application has been chosen: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/machine_learning/README.html#. Application design allows to separate Edge Impulse library to an external memory. There is only one call to this library from Edge Impulse wrapper module, and therefore this call is used to measure time of execution. Additional measurements of current allowed us to compare total energy used. Please note that given numbers include current consumed only by the nRF5340 alone. To have a complete number you should add an additional current used by an external Flash, which will vary between manufacturers.

    If you plan to run radio operations and use QSPI/XIP concurrently, you should only compare numbers for 1.8V. This is because of the following errata: https://infocenter.nordicsemi.com/topic/errata_nRF5340_Rev1/ERR/nRF5340/Rev1/latest/anomaly_340_133.html?cp=3_0_1_0_1_18

     

    The best results for execution from an external Flash were achieved for CPU freq == 128 MHz, with cache enabled and QSPI speed == 96 MHz. Execution time was 10% longer, and energy used was 27% higher comparing to the same setup while running from the internal Flash.

    Please note that execution time 10% longer, and energy used 27% higher does not apply to the entire solution, but only to a code parts running from an external Flash. If you split the code in a clever way so that rarely used functions are in the external Flash and often used functions are in the internal Flash, the results relating to the overall solution will be much better.

    Here are tips if you would like to repeat these measurements:

    • branch used for the experiment can be found at https://github.com/awojasinski-nordicsemi/sdk-nrf/tree/NRFX-1428-xip-performance-ncs

    • compilation: west build -b nrf5340dk_nrf5340_cpuapp
    • flashing firmware: nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --program build/zephyr/zephyr.hex

    • Compile to external memory:
      • in CMakeLists.txt change compile definition XIP_MEMORY=1
      • in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_HAVE_CUSTOM_LINKER_SCRIPT to y
    • Compile to internal memory
      • in CMakeLists.txt change compile definition XIP_MEMORY=0
      • in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_HAVE_CUSTOM_LINKER_SCRIPT to n
    • Change CPU clock to 128MHz
      • in CMakeLists.txt change compile definition CPU_128MHZ=1 (0 => 64MHz, 1=> 128MHz)
    • Change QSPI speed
      • in CMakeLists.txt change compile definition XIP_DIV
        • XIP_DIV=0 => 94MHz
        • XIP_DIV=1 => 48MHz
        • XIP_DIV=2 => 24MHz
    • Disable/Enable Cache
      • in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_NRF_ENABLE_CACHE to n/y
Children
No Data
Related