[C.CC USERS] Plumbing Firmware upload

Matt Jadud matt at jadud.com
Fri Jan 7 19:54:07 GMT 2011


On Fri, Jan 7, 2011 at 14:11, Steve Pretty
<steve.g.pretty at btinternet.com> wrote:
> OK - if it is difficult to check that the firmware is loaded onto Arduino
> using avrdude, an alternative approach might be to always load the firmware
> followed by the occam code "blob" when the user presses the run button.

That is a thought; the first time in a session that you try and upload
bytecode, a firmware upload takes place first. This way, it isn't
*every* time, but it would happen the *first* time you upload code in
a given session.

Thoughts?

Cheers,
Matt

AND, RELATED BUT MOSTLY JUST FOR MY OWN EDIFICATION...

I did a bit of poking around.

avrdude -D -c arduino -y -p m1280 -b 57600 -P /dev/ttyUSB0 -U
flash:r:testing.hex:i

This reads the entirety of the flash from the Seeed Mega, and writes
it to a file called "testing.hex". Then, I was able to 'grep' for
"tvm":

reynoldsm at ubuntu:~/git/paper-es-sensor$ cat testing.hex | grep '74766D'
:20012000000A46696E616C206D616368696E652073746174653A000A0025630074766D2D45
:206380002055000073796D4C002E6F66665507E873796D530022432E74766D73706563698C

This looks like we see "tvm" somewhere in the VM (which we should),
and we see it later in the flash where the bytecode has been uploaded.
Now, I uploaded an Arduino sketch, and did the same thing:

reynoldsm at ubuntu:~/git/paper-es-sensor$ cat testing-sketch.hex | grep '74766D'
:206380002055000073796D4C002E6F66665507E873796D530022432E74766D73706563698C

The only place we see this is in the bytecode stream.

Of course, if you ever write a C program that contains the string
"tvm," we would detect it using something like this. We could, though,
look for a tag in the firmware around a particular memory address,
which would improve things...

So, yes, in theory, we can do this. AVRDUDE will let us dump the flash
of the device as Intel hex, and we can search it for a tag that we
embed. If we did it the first time you connect to a device in a given
session, it would add a "woopsie" check that would help... well, it
would probably help me from time to time, too.



More information about the users mailing list