Skip to content

Commit

Permalink
Flash nano with new bootloader optiboot (#675)
Browse files Browse the repository at this point in the history
* Flash nano with new bootloader optiboot

Allows flash nano328 and nanoCC1101 with new bootloader optiboot by
changing the interface speed from 57600 to 115200

* 00_SIGNALduino.pm

Adapted code, to append second avrdude cmd to avrdude cmd.This supports nano with optiboot
Fixes #225

* 00_SIGNALduino.pm

Added logentry
  • Loading branch information
elektron-bbs authored Oct 29, 2019
1 parent dff524c commit df639e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGED
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
28.10.2019
00_SIGNALduino.pm: allows flash nano328 and nanoCC1101 with new bootloader optiboot
26.10.2019
00_SIGNALduino.pm: allows flash radino with DEF /dev/serial/by-id/
22.10.2019
Expand Down
12 changes: 10 additions & 2 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use lib::SD_Protocols;


use constant {
SDUINO_VERSION => "v3.4.1_dev_26.10",
SDUINO_VERSION => "v3.4.1_dev_28.10",
SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device
SDUINO_INIT_WAIT => 2,
SDUINO_INIT_MAXRETRY => 3,
Expand Down Expand Up @@ -450,6 +450,8 @@ SIGNALduino_flash($) {
delete($hash->{FLASH_RESULT}) if (exists($hash->{FLASH_RESULT}));

qx($hash->{helper}{avrdudecmd});


if ($? != 0 )
{
readingsSingleUpdate($hash,"state","FIRMWARE UPDATE with error",1); # processed in tests
Expand Down Expand Up @@ -654,8 +656,14 @@ SIGNALduino_Set($@)
}
$hash->{helper}{avrdudecmd} = $flashCommand;
$hash->{helper}{avrdudecmd}=~ s/\Q[PORT]\E/$port/g;
$hash->{helper}{avrdudecmd} =~ s/\Q[BAUDRATE]\E/$baudrate/g;
$hash->{helper}{avrdudecmd} =~ s/\Q[HEXFILE]\E/$hexFile/g;
if ($hardware =~ "^nano" && $^O eq 'linux') {
$hash->{logMethod}->($name ,5, "$name: try additional flash with baudrate 115200 for optiboot");
$hash->{helper}{avrdudecmd} = $hash->{helper}{avrdudecmd}." || ". $hash->{helper}{avrdudecmd};
$hash->{helper}{avrdudecmd} =~ s/\Q[BAUDRATE]\E/$baudrate/;
$baudrate=115200;
}
$hash->{helper}{avrdudecmd} =~ s/\Q[BAUDRATE]\E/$baudrate/;
$log .= "command: $hash->{helper}{avrdudecmd}\n\n";
InternalTimer(gettimeofday() + 1,"SIGNALduino_flash",$name);
$hash->{helper}{avrdudelogs} = $log;
Expand Down
4 changes: 2 additions & 2 deletions UnitTest/tests/test_firmware_flash_1-definition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmod test_firmware_flash_1 UnitTest dummyDuino
is($targetHash->{helper}{stty_pid}, undef, "check stty_pid value");

is(ReadingsVal($target,"state",""),"FIRMWARE UPDATE with error","check reading state");
is($targetHash->{helper}{avrdudecmd},'avrdude -c arduino -b 57600 -P none -p atmega328p -vv -U flash:w:./fhem/test.hex 2>./log/SIGNALduino-Flash.log',"check avrdude cmd");
is($targetHash->{helper}{avrdudecmd},'avrdude -c arduino -b 57600 -P none -p atmega328p -vv -U flash:w:./fhem/test.hex 2>./log/SIGNALduino-Flash.log || avrdude -c arduino -b 115200 -P none -p atmega328p -vv -U flash:w:./fhem/test.hex 2>./log/SIGNALduino-Flash.log',"check avrdude cmd");
is($OpenDev->called_count, 1, "check if DevIO_OpenDev is called once");

$targetHash->{helper}{avrdudecmd} = $preparedavrdudecmd;
Expand All @@ -83,7 +83,7 @@ defmod test_firmware_flash_1 UnitTest dummyDuino
is($targetHash->{helper}{stty_pid}, undef, "check stty_pid value");

is(ReadingsVal($target,"state",""),"FIRMWARE UPDATE with error","check reading state");
is($targetHash->{helper}{avrdudecmd},'avrdude -c arduino -b 57600 -P none -p atmega328p -vv -U flash:w:./fhem/test.hex 2>./jiddsidio/log/SIGNALduino-Flash.log',"check avrdude cmd");
is($targetHash->{helper}{avrdudecmd},'avrdude -c arduino -b 57600 -P none -p atmega328p -vv -U flash:w:./fhem/test.hex 2>./jiddsidio/log/SIGNALduino-Flash.log || avrdude -c arduino -b 115200 -P none -p atmega328p -vv -U flash:w:./fhem/test.hex 2>./jiddsidio/log/SIGNALduino-Flash.log',"check avrdude cmd");
is($OpenDev->called_count, 2, "check if DevIO_OpenDev is called once");
$OpenDev->unmock;
CommandAttr(undef,"global logdir $logdir");
Expand Down

0 comments on commit df639e4

Please sign in to comment.