From: lowcost on
Grant Edwards ha scritto:
> I give up. What about it?

ehm, ASCII text file don't contain any address, HEX file records needs
addresses; may be that the tool objcopy will make the good job starting
with default address 0x00 ; else you should
--set-start <addr> Set the start address to <addr>
to match eeprom starting address.

under windows i feed filein.cod to obsend.exe (st7 tools).
obsend filein.cod,f,fileout.hex,i

filein.cod = 4_byte_LH_address + 4byte_LH_lenght + ascii_file.txt

easy to make with any hex editor.

regards
From: Grant Edwards on
On 2008-05-04, lowcost <die.spam(a)invalid.com> wrote:
> Grant Edwards ha scritto:

>> I give up. What about it?
>
> ehm, ASCII text file don't contain any address, HEX file
> records needs addresses; may be that the tool objcopy will
> make the good job starting with default address 0x00 ; else
> you should --set-start <addr> Set the start address to <addr>
> to match eeprom starting address.

The --set-start option doesn't do what you think it does. It sets
the "entry point". It sets the address to which one is
supposed to jump in order to start execution of the resulting
image. The start address is sent using record type 0x03 and is
typically located at the end of the hex file:

$ objcopy -I binary -O ihex --set-start=0x5555 asdf.txt asdf.hex
$ head -n3 asdf.hex; tail -n3 asdf.hex
:100000000A546865207175657374696F6E206F6638
:1000100020656D756C6174696E672061207365720F
:1000200069616C20706F727420696E2075736572DF
:0A02C0002D200A4772616E740A0ACD
:04000003000055554F
:00000001FF

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
$ head -n3 asdf.hex
:105555000A546865207175657374696F6E206F668E
:1055650020656D756C6174696E6720612073657265
:1055750069616C20706F727420696E207573657235

note that --change-addresses also changes the start address in
addition to changing the load address:

:0A5815002D200A4772616E740A0A22
:04000003000055554F
:00000001FF

> under windows i feed filein.cod to obsend.exe (st7 tools).
> obsend filein.cod,f,fileout.hex,i
>
> filein.cod = 4_byte_LH_address + 4byte_LH_lenght + ascii_file.txt
>
> easy to make with any hex editor.

--
Grant Edwards grante Yow! My face is new, my
at license is expired, and I'm
visi.com under a doctor's care!!!!
From: Petter Gustad on
lowcost <die.spam(a)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?
From: lowcost on
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

regards
From: Grant Edwards on
On 2008-05-06, lowcost <die.spam(a)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!!