Electronics > Microcontrollers

ELF to binary for boot loader

(1/9) > >>

peter-h:
There is a lot of stuff online for ELF to BIN etc. For example arm-none-eabi-objcopy can generate the binary.

But not much on how this actually works.

Let's say you are programming a 32F4 within Cube IDE, using STLINK V2/V3. Does the IDE just feed a binary block to the debugger, to program the FLASH with? The debugger has very little storage it in. It must be just programming the stuff straight in, 0x08000000 onwards.

But there must be a way to specify gaps otherwise if you generated some text for bottom 100k and then top 40k, you would end up with a 1MB binary block, mostly empty. I don't think this is happening. So whatever is managing this process must be generating multiple binary blocks and programming these individually.

Also, AIUI, for single stepping, you need to have a symbol table "somewhere" and it can't be in the CPU FLASH because a 1MB binary could be several MB with symbols.

So the stuff loaded into the CPU must be just the binary block comprising of the sections 'text' and 'data'.

IOW, same as what you would need to generate for a boot loader which just takes a binary block and programs the CPU FLASH with it.

I am trying to work out how to generate a single binary block. The program will never have discontinuous text or data sections, and AFAIK data always follows text.

langwadt:

--- Quote from: peter-h on July 29, 2021, 08:46:00 pm ---There is a lot of stuff online for ELF to BIN etc. For example arm-none-eabi-objcopy can generate the binary.

But not much on how this actually works.

Let's say you are programming a 32F4 within Cube IDE, using STLINK V2/V3. Does the IDE just feed a binary block to the debugger, to program the FLASH with? The debugger has very little storage it in. It must be just programming the stuff straight in, 0x08000000 onwards.

But there must be a way to specify gaps otherwise if you generated some text for bottom 100k and then top 40k, you would end up with a 1MB binary block, mostly empty. I don't think this is happening. So whatever is managing this process must be generating multiple binary blocks and programming these individually.

Also, AIUI, for single stepping, you need to have a symbol table "somewhere" and it can't be in the CPU FLASH because a 1MB binary could be several MB with symbols.

So the stuff loaded into the CPU must be just the binary block comprising of the sections 'text' and 'data'.

IOW, same as what you would need to generate for a boot loader which just takes a binary block and programs the CPU FLASH with it.

I am trying to work out how to generate a single binary block. The program will never have discontinuous text or data sections, and AFAIK data always follows text.

--- End quote ---

a bin file doesn't have gaps and you need to specify where to put it in memory
an intelhex file can have gaps and specify the address for each line

SiliconWizard:
And... you can have a look here: https://stackoverflow.com/questions/19458031/how-to-create-a-executable-hex-from-elf-file-format

peter-h:
I saw that post and thought he was trying to generate a an .exe (a DOS, or windoze command line executable). These have a complicated format, with a load-time fixed-up table of jumps etc.

I am also very familiar with Intel hex. But I don't want to use that, due to the bulk. For a 1MB CPU you would need ~2MB intel hex.

So I guess the objective here is just a string of bytes representing the CPU FLASH, 0x08000000 onwards, as long as there is text+data. This must incidentally be what gets fed to the debugger too.

SiliconWizard:

--- Quote from: peter-h on July 29, 2021, 09:27:38 pm ---I saw that post and thought he was trying to generate a an .exe (a DOS, or windoze command line executable). These have a complicated format, with a load-time fixed-up table of jumps etc.

I am also very familiar with Intel hex. But I don't want to use that, due to the bulk. For a 1MB CPU you would need ~2MB intel hex.

So I guess the objective here is just a string of bytes representing the CPU FLASH, 0x08000000 onwards, as long as there is text+data. This must incidentally be what gets fed to the debugger too.

--- End quote ---

hex is a very simple format to deal with, much simpler than elf. So point is, you can use objcopy to generate a hex file from a elf file, and then do whatever you find convenient from the hex file. If a hex file is too big, you could either compress it, or convert it to some custom format.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version