JAndrassy / ArduinoOTA

Arduino library to upload sketch over network to Arduino board with WiFi or Ethernet libraries
GNU Lesser General Public License v2.1
459 stars 92 forks source link

[SAMD21] undefined reference to `__text_start__' #19

Closed xseignard closed 4 years ago

xseignard commented 4 years ago

Hello, I'm trying to use your lib on a custom board, but for some reasons, it fails to compile due to the following error:

In function `OTAStorage::OTAStorage()':
OTAStorage.cpp:(.text._ZN10OTAStorageC2Ev+0x40): undefined reference to `__text_start__'

I tried various bootloader (microsoft uf2 and original arduino zero one). Can the variant.cpp I use can cause this problem ? (I use this one https://github.com/sparkfun/Arduino_Boards/blob/master/sparkfun/samd/variants/SparkFun_SAMD_Mini/variant.cpp)

Any idea ?

Best regards

JAndrassy commented 4 years ago

__text_start__ is defined in the linker script. the linker script is in the variant folder in the Arduino SAMD package. why do you use the Sparkfun SAMD package and to the Arduino one?

xseignard commented 4 years ago

Here is my dev env:

For some reasons, __text_start__ is missing in the linker script, see https://github.com/sparkfun/Arduino_Boards/blob/master/sparkfun/samd/variants/SparkFun_SAMD_Mini/linker_scripts/gcc/flash_with_bootloader.ld

Any idea how to overcome this ?

JAndrassy commented 4 years ago

__text_start__ is the flash location of the running sketch so it is the location where the new binary will be copied after receiving. add __text_start__ to the ld script. see https://github.com/arduino/ArduinoCore-samd/blob/703b87e02d1ce61cd3dddcaa7c4f9ff50c537f80/variants/mkrzero/linker_scripts/gcc/flash_with_bootloader.ld#L68

and recommended reading https://arduino.stackexchange.com/questions/54484/adding-a-custom-board-to-the-arduino-ide/60660#60660

xseignard commented 4 years ago

Hello Juraj, Thanks for your help. Since I don't use the arduino IDE, I created my own variant in platformio. I added the __text_start__ var in the linker script (see: https://github.com/xseignard/corpore-sano/blob/ota-ethernet/variants/Pioche/linker_scripts/gcc/flash_with_bootloader.ld#L68)

It compiles, but using ArduinoOTA makes my sketch not working anymore. It must be related to my limited understanding of your lib. I already use ethernet through UDP for other operations in my sketch (see: https://github.com/xseignard/corpore-sano/blob/ota-ethernet/src/main.ino#L69)

Is it possible that ArduinoOTA and my own code are conflicting ?

JAndrassy commented 4 years ago

I don't see any conflict. ArduinoOTA has a TCP server listening on port 65280 and UDP broadcast for MDNS

xseignard commented 4 years ago

Thanks for your answer. So what would be the problem then? Without ArduinoOTA my code works as expected, but when I add ArduinoOTA(here, here and here) it stops working, as in, no more UDP messages, and no debug on SerialUSB. Any idea ?

JAndrassy commented 4 years ago

after reset to apply the new binary, the COM port can change. first, to debug add while (!Serial); after Serial.begin. then add more Serial.prints.