How to set up assembly for several combined binaries

When working with embedded systems, it is sometimes necessary that the processor is loaded with several independent compiled and linked binaries; in my current project, it is assumed that the processor has both its own code and the code that it must transmit to the remote devices with which it exchanges data. If I programmed a chip with a hexadecimal or binary file, I could use a batch file to simply concatenate the contents of separately built and linked files (perhaps using "FIND / V" to delete things like writing to the end of a file in Intel format) . However, when using the Keil debugger to program the device, the chip is not loaded from such a file, but instead from the .AXF file.

If the image of the code to be sent to the remote devices changes many times while I test the code for the main device (to which the debugger is attached), what is probably the most useful way to configure the assembly? My tendency was to write a utility to convert the binary file of the remote processor code to a C file containing const unsigned char REMOTE_CPU_DATA[] = {...}'; , and configure the linker to find this section of the const file at the appropriate address, or the ASM file containing absolute data directives, and then use this utility as part of the build process for the main code, but converting binary data to text format for inclusion in the project seems unknowingly. In addition, would it be better to find a useful utility for such a conversion or write a special target code in something like C # or VB.NET (I could use any language, but first use the latter for PC development)? I would expect the ASM output to be Keil-specific, while the output of C would be aggregated for the development system, but using C, not ASM, would require adding a line to the linker specification to set the absolute address of the deleted CPU data [remote CPU address fixed to allow it to boot under software control, but the hardware channel through which it will be loaded does not yet exist].

+4
source share
1 answer

You can create an ELF file from a binary file with objcopy , for example,

 objcopy -I binary -B arm -O elf32-littlearm --rename-section \ .data=.remote.data remote.bin remote.elf 

You can then update your linker script as follows:

 .remote { REMOTE_CPU_DATA = . ; *(.remote.data); } 

Placement wherever you want. Data is accessed with 'C' using extern char REMOTE_CPU_DATA[]; or, nevertheless, you want to enter data. You can massage the endian binary using dd , etc.

Another way is to use the .incbin Gnu Assembler directive in accordance with the Linux firmware firmware file .

I don't know if Keil tools can handle ELF formats using objdump or gas . I think that similar ideas can be applied with Keil tools if they have similar semantics.

Edit: This can also be done from a shell script using some * nix tools,

 printf 'char REMOTE_CPU_DATA[] = {' && \ hexdump -v -e '16/1 "0x%x," "\n"' remote.bin && \ printf '};' > remote.c 
+2
source

Source: https://habr.com/ru/post/1484667/


All Articles