lknop/ControllinoMqtt

Invalid signature on Mega

Opened this issue · 6 comments

Hi!

I have a Controllino Mega, and im trying to enter configuration menu to set and store my own parameters after sucessfully sketch upload, but when I short RXD2 to ground, i receive "invalid signature". No errors during compilation or upload.

I've tried to modify settings to mine in configuration file (IP, broker, etc), but after compile and upload (no errors) i cant reach Controllino on Network (ping not responding). It seems like settings won't be stored by this way, maybe?

How can i fix it or skip signature device verification? Other sketches uploaded with ethernet integration works fine, Controllino works well for sure.

Thanks in advance!!

lknop commented

Hi,

RXD2 to ground puts controllino in a totally static mode without any network.

"Invalid signature" message is not an error, it just means that the configuration stored in EEPROM is either empty (like in your case) or incompatible (e.g. from a previous version). You can run controllino normally with this code, and once it is running go to configuration menu, set it all and reboot.

If possible please attach a log from the terminal, I will look into this.

[...] (cut the whole build log)
Linking everything together...
/home/r00t/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-gcc -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega2560 -o /tmp/arduino_build_406333/ControllinoMqtt.ino.elf /tmp/arduino_build_406333/sketch/Configuration.cpp.o /tmp/arduino_build_406333/sketch/ControllinoMqtt.ino.cpp.o /tmp/arduino_build_406333/sketch/ModbusRtu.cpp.o /tmp/arduino_build_406333/sketch/PLC.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/ArduinoSTL.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/algorithm.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/associative_base.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/bitset.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/char_traits.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/complex.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/del_op.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/del_opnt.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/del_ops.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/del_opv.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/del_opvnt.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/del_opvs.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/deque.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/eh_alloc.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/eh_globals.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/exception.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/func_exception.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/iomanip.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/ios.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/iostream.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/istream.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/iterator.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/limits.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/list.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/locale.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/map.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/new_handler.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/new_op.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/new_opnt.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/new_opv.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/new_opvnt.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/numeric.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/ostream.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/ostream_helpers.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/queue.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/set.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/sstream.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/stack.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/stdexcept.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/streambuf.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/string.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/support.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/typeinfo.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/utility.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/valarray.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/vector.cpp.o /tmp/arduino_build_406333/libraries/ArduinoSTL/abi/abi.cpp.o /tmp/arduino_build_406333/libraries/CONTROLLINO/Controllino.cpp.o /tmp/arduino_build_406333/libraries/SPI/SPI.cpp.o /tmp/arduino_build_406333/libraries/PubSubClient/PubSubClient.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/Dhcp.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/Dns.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/Ethernet.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/EthernetClient.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/EthernetServer.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/EthernetUdp.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/socket.cpp.o /tmp/arduino_build_406333/libraries/Ethernet/utility/w5100.cpp.o /tmp/arduino_build_406333/libraries/Queue/cppQueue.cpp.o /tmp/arduino_build_406333/libraries/SoftwareSerial/SoftwareSerial.cpp.o /tmp/arduino_build_406333/core/core.a -L/tmp/arduino_build_406333 -lm
/home/r00t/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_406333/ControllinoMqtt.ino.elf /tmp/arduino_build_406333/ControllinoMqtt.ino.eep
/home/r00t/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_406333/ControllinoMqtt.ino.elf /tmp/arduino_build_406333/ControllinoMqtt.ino.hex
Usando librería ArduinoSTL con versión 1.1.0 en la carpeta: /home/r00t/Arduino/libraries/ArduinoSTL
Usando librería EEPROM con versión 2.0 en la carpeta: /home/r00t/.arduino15/packages/arduino/hardware/avr/1.6.23/libraries/EEPROM
Usando librería CONTROLLINO con versión 3.0.5 en la carpeta: /home/r00t/Arduino/libraries/CONTROLLINO
Usando librería SPI con versión 1.0 en la carpeta: /home/r00t/.arduino15/packages/arduino/hardware/avr/1.6.23/libraries/SPI
Usando librería PubSubClient con versión 2.8 en la carpeta: /home/r00t/Arduino/libraries/PubSubClient
Usando librería Ethernet con versión 2.0.0 en la carpeta: /home/r00t/Descargas/arduino/arduino-1.8.13/libraries/Ethernet
Usando librería Queue con versión 1.9 en la carpeta: /home/r00t/Arduino/libraries/Queue
Usando librería SoftwareSerial con versión 1.0 en la carpeta: /home/r00t/.arduino15/packages/arduino/hardware/avr/1.6.23/libraries/SoftwareSerial
/home/r00t/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-size -A /tmp/arduino_build_406333/ControllinoMqtt.ino.elf
El Sketch usa 38924 bytes (15%) del espacio de almacenamiento de programa. El máximo es 253952 bytes.
Las variables Globales usan 2096 bytes (25%) de la memoria dinámica, dejando 6096 bytes para las variables locales. El máximo es 8192 bytes.
/home/r00t/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/bin/avrdude -C/home/r00t/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_406333/ControllinoMqtt.ino.hex:i

avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/home/r00t/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf"
     User configuration file is "/home/r00t/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/ttyACM0
     Using Programmer              : wiring
     Overriding Baud Rate          : 115200
     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : Wiring
     Description     : Wiring
     Programmer Model: AVRISP
     Hardware Version: 15
     Firmware Version Master : 2.10
     Vtarget         : 0.0 V
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "/tmp/arduino_build_406333/ControllinoMqtt.ino.hex"
avrdude: writing flash (38924 bytes):

Writing | ################################################## | 100% 6.26s

avrdude: 38924 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_406333/ControllinoMqtt.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_406333/ControllinoMqtt.ino.hex:
avrdude: input file /tmp/arduino_build_406333/ControllinoMqtt.ino.hex contains 38924 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.97s

avrdude: verifying ...
avrdude: 38924 bytes of flash verified

avrdude done. Thank you._

**I have been upload your sketch with no modifications.
And output for serial monitor:
23:25:35.984 -> Fallback logic
(when short RXD2 and ground):
23:25:41.349 -> Loading configuration...signature invalid!!!

Board information displayed on IDE:
BN: Arduino/Genuino Mega or Mega 2560
VID: 2341
PID: 0042
SN: 5563231373835161E002

Must be caused by wrong bootloader?

All libraries and boards of IDE are full updated. Running on Ubuntu 20.04, IDE 1.8.13.

Thanks in advance.**

lknop commented

@djmuerteitm Did you change the #define TRACE_LEVEL_DEBUG 1 ? Because you should be seeing the other debug messages such as the one from this code:
DEBUG_PRINT("Initializing PLC");

When the configuration is invalid, the controllino is in non-initialized state. Have you tried sending enter to the serial console? You should get the message To enter configuration mode press C

I will try to prepare better instructions in readme.md so that it's clearer how to get it started. I agree it is a bit confusing, I left the process from the old project I forked and it's not very obvious what should be done.

I will try send Enter and i tell you. Thanks :)

Hi again.

I sent enter using serial session, as you told me, throug Putty and i can reach config menu, but i cant set the parameters correctly. I try to set MAC using ( ), without it, on caps... but on reboot controllino and enter again on config menu, the params stored are like this...

1: Enter MAC => (0:0:2:a:0:3)
2: Enter IP => (192.000.008.001)
3: MQTT Server IP => (192.136.000.008)

Valid MAC is 90:a2:da:00:53:55
Ips are 192.168.1.70 for controllino and .50 for mqtt broker, but i cant set it right.

Trying set parameters on the sketch, but same results and no response to ping.

Any ideas? Thanks in advance :)

Update:
I tryed uploading another sketch, and upload yours again, with configured params on it, and it works.
But if I reboot controllino without RXD2 and GND shorted, it seems like settings are not loaded again (no ping). I need to short them to make it work again.

Reboot without short pins = not working and no ping
Reboot momentary shorted or still shorted = works.

Needs to still shorted?