EmbeddedRelated.com
Forums

ASCII Text to I8HEX Format Converter

Started by dohzer May 1, 2008
On 2008-05-06, lowcost <die.spam@invalid.com> wrote:
> Grant Edwards ha scritto: >> If you want to relocate the output data to an address other >> than that of the input data [files of type "binary" have an >> implicit address of 0], you use the --change-addresses option: >> >> $ objcopy -I binary -O ihex --change-addresses=0x5555 asdf.txt asdf.hex > > thank you Grant , this seems to be a quite right answer to the > original question from Dohzer. please explain me how to obtain > these two .hex records ( "qwerty" at address 0x22 ) from ascii > .txt , under windows, avoiding record type 0x03 in I8HEX : it > will be useful for me too. > >:060022007177657274792C >:00000001FF
I don't see why you are about the start record, but it's trivial to delete it: $ echo -n qwerty >qwerty.txt $ objcopy --change-address=0x22 -I binary -O ihex qwerty.txt qwerty.hex $ sed -i '/^:04000003.*$/d' qwerty.hex $ cat qwerty.hex :060022007177657274792C :00000001FF You can put the objcopy and sed commands in a shell script so they can be used as a "single command" if you want. If you're crippled by Windows, you can install Cygwin to get a usable shell and set of command-line utilities. You can do the same thing with srecord, but since objcopy "comes with" the Gnu toolchain and can also manipulate ELF files, I tend to use it more often. -- Grant Edwards grante Yow! Sometime in 1993 at NANCY SINATRA will lead a visi.com BLOODLESS COUP on GUAM!!
lowcost <die.spam@invalid.com> writes:

> please explain me how to obtain these two .hex records ( "qwerty" at > address 0x22 ) from ascii .txt , under windows, avoiding record type > 0x03 in I8HEX : it will be useful for me too. > > :060022007177657274792C > :00000001FF
Stick in a assembly source file (qwerty.s): .section ".rodata" .ascii "qwerty" .end Run it through an assembler, presumably a cross assembler for your target architecture or the same byte ordering as your target (to create a .o file), a linker with a linker script to set the rodata section origin to 0x22 (to create an .elf file) and run objdump using the -Oihex option (to create the .hex file). Petter -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?