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

DFU on custom board, memory problem

Hello,

Currently, I'm trying to flash my custom board that has nRF52832 with an uart application that I integrated buttonless DFU. I'm running into a problem where when I try to flash my hex file that has the following combination :

  • Softdevice
  • Bootloader
  • Application
  • Bootloader setting

I got the following error :

"ERROR: The file specified is not a valid hex file, has data outside valid areas"

"ERROR: or does not have data in valid areas."

From what I understand, it is an error on the memory side where my program might have passed its limit. But I don't know how to fix it. I'm not sure the type of model of my nRF52832, but on nRF Connect, it says that it is NRF52832_xxAB_REV1, Core RAM: 32KiB and Core ROM: 256KiB in pages of 4KiB. I'm using SES with SDK 16.0.0

  • Hello,

    I see. You have the small version of the nRF52832, and I suspect that both the bootloader and the bootloader settings page hex files are configured for the 512 variant (not the 256 variant).

    If you try to flash only the bootloader or only the bootloader settings file without merging them, does it give the same message?

    Go to your project settings for the bootloader, and change all the start addresses according to your flash size. The range of the flash is:

    512kB variant: 0x0000 0000 -> 0x0008 0000

    256kB variant: 0x0000 0000 -> 0x0004 0000

    So what you need to do is to change the bootloader start address to move all the flash placement settings to match your flash size. 

    Most important are the settings in Section Placement Macros:

    And you can also change the settings in Memory Segments:

    Then you may need to edit your section placement macros in the flash_placement.xml file, mainly the "bootloader_settings_page" and "mbr_params_page". You find this file by right clicking your project from the project explorer in SES, and select "Edit Section Placement".

    Then you need to set the correct size for your bootloader settings file. This is done when you generate them:

    >nrfutil settings generate --help
    Usage: nrfutil settings generate [OPTIONS] HEX_FILE
    
    Options:
      --family [NRF51|NRF52|NRF52QFAB|NRF52810|NRF52840]
                                      nRF IC family: NRF51 or NRF52 or NRF52QFAB
                                      or NRF52810 or NRF52840  [required]
      --application TEXT              The application firmware file. This can be
                                      omitted ifthe target IC does not contain an
                                      application in flash.Requires --application-
                                      version or --application-version-string.
      --application-version INTEGER   The application version.
      --application-version-string TEXT
                                      The application version string, e.g.
                                      "2.7.31". Will be converted to an integer,
                                      e.g. 207031.
      --bootloader-version INTEGER    The bootloader version.  [required]
      --bl-settings-version INTEGER   The Bootloader settings version.Defined in
                                      nrf_dfu_types.h, the following apply to
                                      released SDKs:
                                      |SDK12.0.0 - SDK15.2.0|1|
                                      |SDK15.3.0 -          |2|  [required]
      --start-address INTEGER         Custom start address for the settings page.
                                      If not specified, then the last page of the
                                      flash is used.
      --no-backup                     Do not overwrite DFU settings backup page.
                                      If not specified, than the resulting .hex
                                      file will contain a copy of DFU settings,
                                      that will overwrite contents of DFU settings
                                      backup page.
      --backup-address INTEGER        Address of the DFU settings backup page
                                      inside flash. By default, the backup page
                                      address is placed one page below DFU
                                      settings. The value is precalculated based
                                      on configured settings address
                                      (<DFU_settings_address> - 0x1000).
      --app-boot-validation [NO_VALIDATION|VALIDATE_GENERATED_CRC|VALIDATE_GENERATED_SHA256|VALIDATE_ECDSA_P256_SHA256]
                                      The method of boot validation for
                                      application.
      --sd-boot-validation [NO_VALIDATION|VALIDATE_GENERATED_CRC|VALIDATE_GENERATED_SHA256|VALIDATE_ECDSA_P256_SHA256]
                                      The method of boot validation for
                                      SoftDevice.
      --softdevice FILE               The SoftDevice firmware file. Must be given
                                      if SD Boot Validation is used.
      --key-file FILE                 The private (signing) key in PEM format.
                                      Needed for ECDSA Boot Validation.
      --help                          Show this message and exit.

    Try to use the --family NRF52QDAB option, and it will put the start address for this file to 0x0003F000 instead of 0x0007F000.

    Best regards,

    Edvin

  • Hello,

    I did some changes to my bootloader's Section Placement Macros as following :

    I only changed the FLASH_PH_SIZE and FLASH_START. I did not make any changes to Memory Segments and flash_placement.xml file as I'm not sure what and how exactly to modify it into. So I would like your recommendation on what these modifications should be, please. Then I tried to reflash the program with the new setting for the bootloader and there was no more error but our custom board does not seem to be working. Nothing was advertising.

    A weird remark I notice was, I flashed my custom board with the bootloader with the default setting as shown in the following image :

    nRF Connect managed to see the custom board advertising DFUTarg and I was able to DFU the custom board with my uart application that was integrated with buttonless DFU.

  •  

    Fikri Saman said:
    A weird remark I notice was, I flashed my custom board with the bootloader with the default setting as shown in the following image :

     Can you please try to check what the memory looks like on nRF Connect for Desktop -> Programmer when you do this?

    I did some modifications, and I got this:

    (remember that my DK has 512kB flash, which is why it is gret on the upper half.)

    Check out the attached project. NB: I only changed the SES project, not the Keil, IAR or armgcc.

    pca10040_s132_ble_256k.zip

    There were some issues. I didn't manage to set the RAM size to 32kb, because the compiler complained about not enough space. I am not sure whether it will run properly on the 256k - 32k version. Perhaps the softdevice has grown too big to properly support this version in the later SDKs.

    Best regards,

    Edvin

  • Can you please try to check what the memory looks like on nRF Connect for Desktop -> Programmer when you do this?

    This is what the memory looks like when I flash only the bootloader with default memory settings on it :

    It would seem that there is only the softdevice but yet I can see DFUTarg on nRF Connect mobile.

    This is when I used your bootloader alongside with my application :

    But it still seems not to be working. I cannot see my device on nRF Connect mobile. This is only with the bootloader that you provided :

    I did see DFUTarg, and so I try to update it with my application but it failed to do so. This was the log file during the update :

    nRF Connect, 2020-06-25
    DfuTarg (CC:0F:60:FB:7D:AF)
    V	12:15:19.942	Connecting to CC:0F:60:FB:7D:AF...
    D	12:15:19.942	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	12:15:20.001	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	12:15:20.010	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	12:15:20.010	Connected to CC:0F:60:FB:7D:AF
    V	12:15:20.027	Discovering services...
    D	12:15:20.027	gatt.discoverServices()
    I	12:15:20.730	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)
    D	12:15:20.838	[Callback] Services discovered with status: 0
    I	12:15:20.838	Services discovered
    V	12:15:20.847	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    Secure DFU Service (0xFE59)
    - DFU Packet [WNR] (8ec90002-f315-4f60-9fb8-838830daea50)
    - DFU Control Point [N W] (8ec90001-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    I	12:15:20.873	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    I	12:15:20.927	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)
    V	12:15:25.256	[DFU] DFU service started
    V	12:15:25.257	[DFU] Opening file...
    I	12:15:25.266	[DFU] Firmware file opened successfully
    V	12:15:25.266	[DFU] Connecting to DFU target...
    D	12:15:25.267	[DFU] gatt = device.connectGatt(autoConnect = false)
    I	12:15:25.271	[DFU] Connected to CC:0F:60:FB:7D:AF
    V	12:15:25.271	[DFU] Discovering services...
    D	12:15:25.271	[DFU] gatt.discoverServices()
    I	12:15:25.274	[DFU] Services discovered
    D	12:15:25.291	[DFU] wait(1000)
    V	12:15:26.278	[DFU] Requesting new MTU...
    D	12:15:26.278	[DFU] gatt.requestMtu(517)
    I	12:15:26.310	[DFU] MTU changed to: 247
    V	12:15:26.312	[DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:26.312	[DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50, true)
    D	12:15:26.312	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I	12:15:26.340	[DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-00
    V	12:15:26.340	[DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
    A	12:15:26.340	[DFU] Notifications enabled
    D	12:15:26.340	[DFU] wait(1000)
    V	12:15:27.341	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.342	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    I	12:15:27.374	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-01
    I	12:15:27.375	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-02-00-00-00-00-00-00-00-00-00-00
    A	12:15:27.376	[DFU] Command object info received (Max size = 512, Offset = 0, CRC = 00000000)
    V	12:15:27.376	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.376	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    I	12:15:27.406	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 02-00-00
    I	12:15:27.406	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-02-01
    A	12:15:27.407	[DFU] Packet Receipt Notif disabled (Op Code = 2, Value = 0)
    V	12:15:27.407	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.407	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    I	12:15:27.435	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-01-8D-00-00-00
    I	12:15:27.435	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    A	12:15:27.435	[DFU] Command object created
    V	12:15:27.435	[DFU] Writing to characteristic 8ec90002-f315-4f60-9fb8-838830daea50
    D	12:15:27.435	[DFU] gatt.writeCharacteristic(8ec90002-f315-4f60-9fb8-838830daea50)
    I	12:15:27.438	[DFU] Data written to 8ec90002-f315-4f60-9fb8-838830daea50, value (0x): 12-8A-01-0A-44-08-01-12-40-08-00-10-34-1A-02-CB-01-20-00-28-00-30-00-38-E8-A4-02-42-24-08-03-12-20-A1-A0-1E-6C-6E-4B-18-64-19-B2-A3-53-3F-C0-4C-84-0F-04-F1-15-A0-DD-21-2B-15-92-BB-11-6B-AB-DF-DB-48-00-52-04-08-01-12-00-10-00-1A-40-9C-28-D5-11-9E-88-0B-93-4F-54-0E-89-93-CD-3F-4B-E4-80-90-F9-3C-CA-50-21-73-F8-06-69-18-74-37-40-13-3B-40-B8-9E-84-A4-C8-FA-A1-5B-0C-15-96-20-04-83-44-A1-0A-30-6D-4D-CD-FC-91-C3-33-F4-A7-D3-9D
    A	12:15:27.438	[DFU] Command object sent (CRC = C0964F9C)
    V	12:15:27.438	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.438	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    I	12:15:27.465	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    I	12:15:27.467	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-8D-00-00-00-9C-4F-96-C0
    A	12:15:27.468	[DFU] Checksum received (Offset = 141, CRC = C0964F9C)
    V	12:15:27.468	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.468	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    I	12:15:27.494	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    I	12:15:27.630	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    A	12:15:27.630	[DFU] Command object executed
    V	12:15:27.630	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.630	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    I	12:15:27.659	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-02
    I	12:15:27.660	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-10-00-00-00-00-00-00-00-00-00-00
    A	12:15:27.660	[DFU] Data object info received (Max size = 4096, Offset = 0, CRC = 00000000)
    V	12:15:27.695	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:15:27.695	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
    E	12:15:33.684	[DFU] Error (0x85): GATT ERROR
    V	12:15:33.684	[DFU] Disconnecting...
    D	12:15:33.685	[Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0)
    E	12:15:33.685	Error 8 (0x8): GATT CONN TIMEOUT
    I	12:15:33.685	Disconnected
    D	12:15:33.722	[DFU] gatt.disconnect()
    D	12:15:33.737	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    I	12:15:33.758	[DFU] Disconnected
    D	12:15:33.758	[DFU] gatt.refresh() (hidden)
    D	12:15:33.758	[DFU] gatt.close()
    D	12:15:33.758	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	12:15:33.758	[DFU] wait(600)
    D	12:15:34.345	gatt.close()
    D	12:15:34.350	wait(200)
    V	12:15:34.552	Connecting to CC:0F:60:FB:7D:AF...
    D	12:15:34.552	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	12:15:39.600	[Callback] Connection state changed with status: 133 and new state: DISCONNECTED (0)
    E	12:15:39.600	Error 133 (0x85): GATT ERROR
    I	12:15:39.600	Disconnected
    D	12:15:42.088	gatt.close()
    D	12:15:42.104	wait(200)
    

  • It looks like there is not enough RAM on the 256 version to run on the nRF52832 with 256KB flash and 32kB ram. Perhaps you should consider going for the nRF52832 with more flash and ram, or use an older SDK with a smaller space requirement.

    You will probably see that you run into some issue if you run a debug session with the bootloader that I attached earlier. Try "build and debug" and see what happens. Remember to hit F5 to run the bootloader. What does it say?

    BR,

    Edvin

Related