-1

I am using stm32cubeIDE and trying to store crc at the end of binary for update purposes.I am using this method because otherwise the debug will not work and i have to mark the .crc region as NOLOAD to make debug works.

I have a CRC section at the end of the flash, that i have dedicated to store the CRC.

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 48K
  RAM2    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 16K
  BOOT     (rx)    : ORIGIN = 0x8000000,   LENGTH = 40K
  FLASH    (rx)    : ORIGIN = 0x800A000,   LENGTH = 221172
  CRC      (rx)    : ORIGIN = 0x803FFFC,   LENGTH = 4
}
    .crc :
  {
    . = ALIGN(4);
    KEEP (*(.crc))         /* .version sections (constants, strings, etc.) */
    KEEP (*(.crc*))        /* .version* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >CRC

I have a binary file crc.bin that contains the CRC the content of the binary file is simple: ABAB ABAB

I have defined a const value so that crc section gets included in elf file:

__attribute__((section(".crc"), used))
const uint32_t crc_placeholder = 0xFFFFFFFF;

i am using these post build commands:

arm-none-eabi-objdump -h DS_TEST_ST433CCU.elf&&arm-none-eabi-objdump -s -j .crc DS_TEST_ST433CCU.elf&&arm-none-eabi-objcopy --update-section .crc=crc.bin DS_TEST_ST433CCU.elf&&arm-none-eabi-objdump -s -j .crc DS_TEST_ST433CCU.elf&&arm-none-eabi-objcopy  -O binary DS_TEST_ST433CCU.elf  DS_TEST_ST433CCU1.bin

following is the output of these command:

arm-none-eabi-objdump -h DS_TEST_ST433CCU.elf

DS_TEST_ST433CCU.elf:     file format elf32-littlearm

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .isr_vector   0000018c  0800a000  0800a000  00001000  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .text         0000daac  0800a190  0800a190  00001190  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .rodata       00000628  08017c40  08017c40  0000ec40  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .ARM.extab    00000000  08018268  08018268  00011000  2**0
                  CONTENTS
  4 .ARM          00000008  08018268  08018268  0000f268  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .preinit_array 00000000  08018270  08018270  00011000  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  6 .init_array   00000004  08018270  08018270  0000f270  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .fini_array   00000004  08018274  08018274  0000f274  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .data         000001e0  20000000  08018278  00010000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  9 .bss          00002da8  200001e0  08018458  000101e0  2**2
                  ALLOC
 10 ._user_heap_stack 00000600  20002f88  08018458  00010f88  2**0
                  ALLOC
 11 .boot_app     00000000  08000000  08000000  00011000  2**0
                  CONTENTS
 12 .crc          00000004  0803fffc  0803fffc  00010ffc  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 13 .ARM.attributes 00000030  00000000  00000000  00011000  2**0
                  CONTENTS, READONLY
 14 .debug_info   0001fa45  00000000  00000000  00011030  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 15 .debug_abbrev 00005211  00000000  00000000  00030a75  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 16 .debug_aranges 00001d98  00000000  00000000  00035c88  2**3
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 17 .debug_rnglists 00001685  00000000  00000000  00037a20  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 18 .debug_macro  00029dc0  00000000  00000000  000390a5  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 19 .debug_line   00020976  00000000  00000000  00062e65  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 20 .debug_str    000efcb8  00000000  00000000  000837db  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 21 .comment      00000043  00000000  00000000  00173493  2**0
                  CONTENTS, READONLY
 22 .debug_frame  00008dc8  00000000  00000000  001734d8  2**2
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 23 .debug_line_str 0000005e  00000000  00000000  0017c2a0  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
arm-none-eabi-objdump -s -j .crc DS_TEST_ST433CCU.elf

DS_TEST_ST433CCU.elf:     file format elf32-littlearm

Contents of section .crc:
 803fffc ffffffff                             ....            
arm-none-eabi-objcopy --update-section .crc=crc.bin DS_TEST_ST433CCU.elf
arm-none-eabi-objdump -s -j .crc DS_TEST_ST433CCU.elf

DS_TEST_ST433CCU.elf:     file format elf32-littlearm

Contents of section .crc:
 803fffc 66666666 20666666 66                 abab abab       
arm-none-eabi-objcopy  -O binary DS_TEST_ST433CCU.elf  DS_TEST_ST433CCU1.bin

From where are these 66666666 20666666 66 getting in the elf file? and the final binary does not even contain abab abab.

1 Answer 1

2

66666666 20666666 66 is literally the string ffff ffff - not hex, but rather those literal nine bytes with a space in the middle. Your crc.bin file should be exactly four bytes long and contain binary data, not ASCII text.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.