avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] AVR recording AVR...


From: Theodore A. Roth
Subject: Re: [avr-gcc-list] AVR recording AVR...
Date: Fri, 12 Apr 2002 09:52:47 -0600 (MDT)

I think might be able to compile the first program with the 2nd program 
contained in an array of uint8_t's stored in progmem. You'll have to 
convert the 2nd .bin in a string of ascii chars (with lots of backslash 
escapes for the nonprintable values). Python or perl might help there, 
maybe like this:

cat > dlprog.py <<EOF
#! /usr/bin/env python

import sys

try:
        dlprog = open(sys.argv[1]).read()
except IndexError:
        print 'Usage: %s <file>' %(sys.argv[0])

print '#ifndef DLPROG_H'
print '#define DLPROG_H'

print 'uint32_t dlprog_size = 0x%x;' % (len(dlprog))
print 'uint8_t __ATTR_PROGMEM__ dlprog[] = {'

for i in range(0,len(dlprog),8):
        print '\t',
        for c in dlprog[i:i+8]:
                print '0x%02x, ' % (ord(c)),
        print
        
print '};'

print '#endif /* DLPROG_H */'
EOF

Then do this:

  $ python dlprog.py prog2.bin > dlprog.h

and just #include "dlprog.h" in prog1.c. Now, you can just use memcpy_P() 
to copy from the dlprog array defined in the generated header file (you 
need to #include <progmem.h> to get memcpy_P).

The above python script will automate the convertion of the 2nd program to 
an includable header, thus you don't have to rewrite the programmer 
program every time you change the 2nd program. You could even automate all 
of this in a Makefile too.

Ugly, but it might work.


Hope that helps,

Ted Roth


On Fri, 12 Apr 2002, Andre Mastella wrote:

>Hi,
>       do somebody know how can I join 2 .bin files in one file?
>
>       The problem is this:
>
>       I have a little program made for AVR to program another AVR via ISP.
>It's the first .c file compiled to .bin.
>
>       I have another program that's the one I want to really have
>programmed to a 3rd AVR. It's the 2nd .bin file
>
>       Using GCC (or not) I want to put them together in order that I can
>make an AVR programmer...
>
>       Any help is wellcome.
>
>       Thanks.
>
>       Andre
>avr-gcc-list at http://avr1.org
>

avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]