How to Render the sketch file/content running in arduino to a file in Linino?

Hi,

Is there a way I can render the content of the sketch running in Arduino to file in Linino using a sketch or though bridge.

I can get the name of the file using FILE but how to get the content of the sketch

Any pointers/advise is greatly appreciated

Regards,

BRE

I think you cannot. What’s your goal?

Hi Federico Fissore,

Thank you very much for the reply.

As asked,

My goal is follows:

I want to upload new sketch. Before I upload the new one. I want to save the old sketch and if in case if the new sketch is not good I would like to revert it back to the old one. Some kind of transaction model I want to put in place.

Any help/pointers is appreciated.

High Regards,

BREL

I don't think we can create an generic automatic solution, because many sketches do not have any way of telling whether they are good or bad. Only a user interacting with them can tell.

A history of the uploaded sketches may do. There is nothing of the sort ATM: both the IDE and yun's webpanel should be modified to make it work.

I have a similar problem and I solve it using version control system like git or mercurial or subversion. If the latest version of a sketch does not work, I get back to its previous version and upload again.

do you mean: saving the .hex in the git with the source code as well?

Hi Federico Fissore,

Thank you very much for the reply and I completely understand it is not easy.

Moving forward, I can build some loose transaction model around the same in customised way.

Once again, Thank you very much Sir.

Much appreciated.

High Regards,

BREL

[quote author=Federico Fissore link=topic=259568.msg1834551#msg1834551 date=1407447791] I have a similar problem and I solve it using version control system like git or mercurial or subversion. If the latest version of a sketch does not work, I get back to its previous version and upload again. [/quote]+1

Using a form of version control of the source code that generates the sketch(es) is question is the only sensible thing to do. It not only helps for fubars of not properly tested code into a production system, but also in case you are forced to replace the hardware altogether, in which case you would not be able to retrieve the existing running code.

Ralf

Backup Arduino Flash image:

cp /usr/bin/run-avrdude /usr/bin/backup-arduino
nano  /usr/bin/backup-arduino
#!/bin/sh

echo 1 > /sys/class/gpio/gpio21/value
avrdude  -q -q -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U efuse:r:/tmp/efuse:d; read efuse</tmp/efuse; rm /tmp/efuse
if [ $efuse -eq 203 ] # 203 = 0xCB
then
    avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xCB:m -Uflash:r:$1:r $2
else
    avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFB:m -Uflash:r:$1:r $2
fi
echo 0 > /sys/class/gpio/gpio21/value
root@Arduino:~#backup-arduino arduino.bin

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9587
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xCB"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xCB:
avrdude: load data efuse data from input file 0xCB:
avrdude: input file 0xCB contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading flash memory:

Reading | ################################################## | 100% 16.27s

avrdude: writing output file "arduino.bin"

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

A little challenge if Arduino fuse is set (above method will be failed):

sonnyyu:

bperrybap: For example, the employer may want to keep all the code in the final product/project private (closed).

Technically they will fail. The Atmel chipset use in Arduino is not secure based, to read firmware/code all is needed semi-invasive attacks. start with the removal of the chip package, put chip’s die under suitable microscope with a little time and skill, the firmware/code will be out.

This much like people put lock on door, It will stop owner if he forget carry key, but not do much if Pro want in

The Atmel chipset use in Arduino is not secure based.

Dear Sonnyyu,

Super

Thank you very much for the reply.

I was away, will try this out and let you know the outcome.

Sincere Regards

BRE