B4R Question Sudden problem: avrdude: stk500v2_ReceiveMessage(): timeout

Alpandino

Member
Licensed User
Hi all.
I'm working on a project using an Arduino Mega. I wrote a library for Arduino, then I brought this library in B4R. After some troubles during the porting, now all is working fine. I started to write my code in B4R to expand the project and functionalities. I worked with this library and this code for a week.
From last Friday, suddenly, B4R is not able to upload the sketch to my Arduino.
In reality, I'm able to upload sketch really really small, as
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
End Sub

But if I try to upload sketchs sligthly more heavy, I receive the error attached. I tried to remove any reference to my library (without success), and above all I tried to upload the corresponding sketch written in C with classical Arduino IDE using my Arduino library: all is ok! So Arduino HW is not broken.

Finally, after several uninstall/install/update driver and so on, I opened the src.ino file generated from B4R using Arduino IDE (because B4R compiles without errors): at compile time all is ok, but in the upload phase I receive (again) the error attached.

A curious detail: after receiving the error, I must disconnect and connect the USB plug, otherwise I receive the other error message attached (Log Upload 2.txt)

I tried to upload my code with B4R using Arduino UNO, and all is fine (unfortunately I need Arduino Mega because my program use a lot of memory).

What can be the problem?
I'd like to use B4R, but now for me it's impossible.

Any suggestion will be appreciated!
Thanks
 

Attachments

  • Log Upload.txt
    15.6 KB · Views: 330
  • Log Upload 2.txt
    2.9 KB · Views: 357

Alpandino

Member
Licensed User
I think you are addressing Serial1 while using debug. You can use Serial2, 3 & 4 on mega. The stream on Serial1 disturbs comunications on debug device.

Thank you for the suggestion, but finally I found the root cause of the problem.
In my progam there was this line of code that crashes Arduino at the upload time:
B4X:
Log("***** Rastering finito!!!!! *****")

I did several tests and I found that if I print more than 2 exclamation marks in a Serial.print Arduino crashes, and it's impossible to upload any code.
Googling this problem, I came across this link:

https://forum.arduino.cc/index.php?topic=463814.0

This is an already know bug of Arduino Mega itself. I removed this line and all is working now.;):)
I've lost more than 3 days on it :confused:

Bye Bye
 
Last edited by a moderator:
Upvote 0
Top