Skip to main content
Visitor II
December 20, 2024
Solved

Generating a HEX File with Custom Linker Modifications for STM32F407G-DISC

  • December 20, 2024
  • 3 replies
  • 957 views

I have a code that toggles only four LEDs on the STM32F407G-DISC. I want to generate a HEX file for this code and then make changes to the addresses using a linker file. After modifying the linker file, I want to see these changes reflected in the HEX file. Additionally, I plan to add three uint32_t variables with known addresses to my LED toggle code and locate their addresses in the HEX file. However, I have no knowledge about HEX and linker files. How can I achieve this?

    This topic has been closed for replies.
    Best answer by mƎALLEm

    As I said, do what to do with linker file and do the HEX file comparison. I suggested  Beyond Compare as it's an efficient tool in HEX compare: https://www.scootersoftware.com/v5help/viewhex.html

    SofLit_0-1734692498973.png

    See for studying HEX file format:

    https://developer.arm.com/documentation/ka003292/latest/

    https://en.wikipedia.org/wiki/Intel_HEX

     

    3 replies

    Technical Moderator
    December 20, 2024

    Hello @Meczup and welcome to the community,

    It's very vague question. Need to give more details: why you need to locate the addresses in HEX file? what Toolchain are you using?

     "After modifying the linker file, I want to see these changes reflected in the HEX file" do a diff between the HEX files using for example Beyond Compare tool. It can do HEX file comparison.

    MeczupAuthor
    Visitor II
    December 20, 2024

    I received an internship task where I need to compare two HEX files by modifying the address stored in the linker file. Therefore, I need to analyze the HEX files. I am currently using a text comparator to compare them, but I am not very proficient in changing the address. After observing these changes, I will try to analyze the variables with addresses I have defined myself on the HEX file.

    mƎALLEmAnswer
    Technical Moderator
    December 20, 2024

    As I said, do what to do with linker file and do the HEX file comparison. I suggested  Beyond Compare as it's an efficient tool in HEX compare: https://www.scootersoftware.com/v5help/viewhex.html

    SofLit_0-1734692498973.png

    See for studying HEX file format:

    https://developer.arm.com/documentation/ka003292/latest/

    https://en.wikipedia.org/wiki/Intel_HEX

     

    Graduate II
    December 20, 2024

    The .HEX file formats aren't overly complex, should be able to do with basic level file interaction and processing.

    From there loading as binary, patching, and rewriting.

    Probably rate that as High School level stuff. Basically shows an understanding of data representation, code/data in memory and files, code in micro-controllers, file manipulation. 

    Perhaps look also at tools like SRecords for inspiration.