Trying to build nrf52-ble-image-transfer-demo project in Keil but getting build errors

Hello,

I am trying to the build the following demo from github on Keil:

https://github.com/NordicPlayground/nrf52-ble-image-transfer-demo

I am using Keil uVision V5 MDK-Lite with default compiler V6 along with nRF5SDK160098a08e2 and s132nrf52701 softdevice

I managed to get the softdevice, Nordic Packages, etc. setup properly (I think!)

I flashed (loaded) the s132_nrf52_7.0.1_softdevice.hex to the nRF52 DK nRF52832 eval boards

I get the following build errors:

Build started: Project: image_transfer_demo_pca10040_s132
*** Using Compiler 'V6.19', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin'
*** Warning: You are compiling one or more files of source type C++ and have selected 'use MicroLIB'. MicroLIB does not support C++!

Build target 'nrf52832_xxaa'
ArmClang: error: no such file or directory: '../../../../../../components/libraries/bsp/bsp.c'
ArmClang: error: no input files
compiling bsp.c...
ArmClang: error: no such file or directory: '../../../../../../components/libraries/bsp/bsp_btn_ble.c'
ArmClang: error: no input files
compiling bsp_btn_ble.c...
RTE/Device/nRF52832_xxAA/system_nrf52.c(30): error: 'nrf52_erratas.h' file not found
#include "nrf52_erratas.h"
^~~~~~~~~~~~~~~~~
1 error generated.
compiling system_nrf52.c...
C:/Nordic/sdk/nRF5SDK160098a08e2/components/libraries/util/app_error_handler_keil.c(45): error: expected '(' after 'asm'
__ASM void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
^
C:/Nordic/sdk/nRF5SDK160098a08e2/components/libraries/util/app_error_handler_keil.c(45): error: expected ';' after top-level asm block
__ASM void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
^
;
C:/Nordic/sdk/nRF5SDK160098a08e2/components/libraries/util/app_error_handler_keil.c(47): error: use of undeclared identifier 'PRESERVE8'
PRESERVE8 {TRUE}
^
3 errors generated.
compiling app_error_handler_keil.c...
".\_build\nrf52832_xxaa.axf" - 8 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01

For the 

ArmClang: error: no such file or directory: '../../../../../../components/libraries/bsp/bsp.c'
ArmClang: error: no input files
compiling bsp.c...
ArmClang: error: no such file or directory: '../../../../../../components/libraries/bsp/bsp_btn_ble.c'
ArmClang: error: no input files

errors: I did make sure the both C/C++ and ASM Include Paths point to the SDK I downloaded but I still get these errors.

Please advise. 

Thanks,

Adnan

Parents
  • Hi Adnan

    I would recommend using Segger Embedded Studio if you can. This has been the main development platform for Nordic products for a while, and is the one I used when writing the image transfer demo example. 

    That being said I think your issue is caused by using the wrong compiler. 

    If you open Options for Target nrf52832_xxaa in Keil uVision and go to the Target tab you can select which compiler to use. In my case I can get it to build if I select "Use default compiler version 5" or "V5.06 update 6 (build 750)":

    Please note that your list might look different, depending on which compilers you have installed. 

    After selecting the right compiler I get a different issue related to the nrf_erratas.h file, but this apparently is a known issue. The issue is described in more detail in the below case:
    https://devzone.nordicsemi.com/f/nordic-q-a/53946/rte-device-nrf52832_xxaa-system_nrf52-c-29-error-5-cannot-open-source-input-file-nrf_erratas-h-no-such-file-or-directory

    Best regards
    Torbjørn

  • Hello Torbjorn,

    Thank you for the quick response. I was wondering if also the nRF5 SDK + Softdevice versions maybe causing an issue? I can change it to the older nRF5SDK153059ac345 and s132nrf52611 Softdevice.

    Please advise. 

    Thanks,

    Adnan

  • Hello Torbjorn,

    Hope all is well. I was wondering if you knew what nRF_DeviceFamilyPack version is required of the build? I am suing the latest one 8.44.1 but that is giving me odd:

    ".\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrf_drv_ppi_init (referred from main.o)." type errors. 

    There are a lot of versions to pick from so wanted to know if you knew the correct one.

    Please advise.

    Thanks,

    Adnan

  • Hi Adnan

    You should be able to use the latest device family pack, which is v8.52.0. 

    That said, there seems to be an issue when using later versions of Keil with the older SDK's. I couldn't get the sample to build until I followed the instructions shared in this case.

    Please give that a go and see if it fixes your issue. 

    If you still get the undefined symbol error, double check if the nrf_drv_ppi.c file is included in your project. 

    Best regards
    Torbjørn 

  • Hello Torbjorn,

    Thank you for the info. So the latest Device Family Pack I have access to via the Package manager is 8.44.1 (maybe because I an using MDK Lite?).

    I did actually follow the instructions given in case https://devzone.nordicsemi.com/f/nordic-q-a/55378/mdk-uvision-sdk-16-0-keil-family-pack-installation/224413#224413 but no luck.

    I still have the same errors as I gave yesterday. I can also confirm that file nrf_drv_ppi.c is included in my project. Can there an issue with the apply_old_config.h file?

    Please advise.

    Thanks,

    Adnan

  • Hi Adnan

    You can download all the device family packs from here:
    https://developer.nordicsemi.com/nRF5_SDK/pieces/nRF_DeviceFamilyPack/

    Could you try to install v8.52.0 and see if it works better?

    You need to double click the file after downloading it, and it will launch the installer. 

    Best regards
    Torbjørn

  • Hello Torbjorn,

    Thank you for the follow up. I took your advise and switched to Segger Embedded Studio over the weekend. I managed to get the project setup and had to modify the common include paths and paths in the .emProject file but now the project compiles and am able to download it onto the nRF52 DK eval board. So thank you for your guidance on this issue.

    The issue I am now having is that I get the following error on the J-Link RTT Viewer:

    00> <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at C:\Nordic\sdk\nRF5SDK160098a08e2\examples\nrf52-ble-image-transfer-demo-master_segger\main.c:463
    00> PC at: 0x0002786D
    00> <error> app: End of error report

    The line number points to the following function:

    /**@brief Function for the SoftDevice initialization.
    *
    * @details This function initializes the SoftDevice and the BLE event interrupt.
    */
    static void ble_stack_init(void)
    {
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    }

    I am wondering if the SoftDevice needs to be configured as I have not done anything with respect to that? Or maybe I need to configure anything else?

    Please advise and thanks!

    Adnan

Reply
  • Hello Torbjorn,

    Thank you for the follow up. I took your advise and switched to Segger Embedded Studio over the weekend. I managed to get the project setup and had to modify the common include paths and paths in the .emProject file but now the project compiles and am able to download it onto the nRF52 DK eval board. So thank you for your guidance on this issue.

    The issue I am now having is that I get the following error on the J-Link RTT Viewer:

    00> <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at C:\Nordic\sdk\nRF5SDK160098a08e2\examples\nrf52-ble-image-transfer-demo-master_segger\main.c:463
    00> PC at: 0x0002786D
    00> <error> app: End of error report

    The line number points to the following function:

    /**@brief Function for the SoftDevice initialization.
    *
    * @details This function initializes the SoftDevice and the BLE event interrupt.
    */
    static void ble_stack_init(void)
    {
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    }

    I am wondering if the SoftDevice needs to be configured as I have not done anything with respect to that? Or maybe I need to configure anything else?

    Please advise and thanks!

    Adnan

Children
  • Hi Adnan

    Do you get the same error if you press the reset button on the DK?

    What if you start a debug session in Segger Embedded Studio (SES), does this work?

    If either of those fix the issue then this is a known inconsistency in SES. When you flash the application to the board the debugger will not perform a full reset, instead it will simply start program execution at the application start address. The problem with this is that it bypasses the reset handler of the SoftDevice, which means the SoftDevice will not be reset but will remain running in the background. When the application then runs it will try to enable the SoftDevice for the second time, which causes it to return the invalid state error. 

    There is no good workaround to this other than to press the reset button on the DK after programming the board. 

    Best regards
    Torbjørn

  • Hello Torbjorn,

    Please note that I am able to compile and download to the board. Also it does enter into the Main loop function.

    Pressing the RESET button on the DK board does not solve the issue. I have verified all the SoftDevice settings and configurations and look up to spec.

    I was wondering if the following can be an issue:

    I have used VS Code to compile and flash this same board. Is it possible that that is the issue?

    Is there a way to clean out the Zephyr stuff and load the older Segger code + firmware? Also vice-versa, remove Segger code base and install Zephyr code base?

    Please advise.

    Thanks,

    Adnan

  • Hello Torbjorn,

    Just an update: When I am in debug mode, the issue of nrf_sdh_enable_request failing seems to go away and the RESET button still doesn't help in normal run mode.

    Also now the ArduCAM SPI bus check keeps failing:

    while(1){
    //Check if the ArduCAM SPI bus is OK
    arducam_write_reg(ARDUCHIP_TEST1, 0x55);
    temp = arducam_read_reg(ARDUCHIP_TEST1);
    if (temp != 0x55){
    //Serial.println(F("ACK CMD SPI interface Error! END"));
    nrf_delay_ms(1000);
    continue;
    }else{
    //Serial.println(F("ACK CMD SPI interface OK. END"));break;
    }
    }

    It never returns 0x55. Can it be that both these issues are linked? Maybe something is going on with the SoftDevice. I am using S132 V7.0.1 as recommended by you.

    Please advise.

    Thanks,

    Adnan

  • Hi Adnan

    What does the read_reg function return then? 
    Could you check the value of the temp variable in the debugger?

    Are you sure that the Arducam is properly connected to the DK?
    Maybe you could share a picture of your setup?

    Best regards
    Torbjørn

  • Hello Torbjorn,

    The read_reg returns random values (between 0x00 - 0x67) and sometimes 0x55 and if it does, the software hangs on twim_busy in the function:

    //I2C Write 16bit address, 8bit data
    uint8_t arducam_wrSensorReg16_8(int regID, int regDat)
    {
    uint8_t txBuf[3] = {regID >> 8, regID & 0x00FF, regDat & 0x00FF};
    arducam_twi_tx_rx(txBuf, 3, 0, 0);
    while(twim_busy);
    nrf_delay_ms(1);
    return (1);
    }

    The Arducam is connected properly to the DK, I have checked it multiple times. I have connected it as follows:

    pinScl = 27;
    pinSda = 26;
    pinSck = 25;
    pinMiso = 24;
    pinMosi = 23;
    pinCsn = 22;

    pinVCC = 5V

    pinGND = GND

    Please advise.

    Thanks,

    Adnan

Related