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

Discussion in 'B4R Questions' started by Alpandino, Aug 27, 2018.

  1. Alpandino

    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
    Code:
    #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
     

    Attached Files:

  2. tigrot

    tigrot Well-Known 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.
     
    Peter Simpson, Erel and BillMeyer like this.
  3. Alpandino

    Alpandino Member Licensed User

    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:
    Code:
    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: Aug 28, 2018
    Erel, inakigarm, tigrot and 1 other person like this.
  4. tigrot

    tigrot Well-Known Member Licensed User

    Bello, fortuna che non uso punti esclamativi!
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Amazing!!!
     
    BillMeyer likes this.
  6. Alpandino

    Alpandino Member Licensed User

    The system has crashed...
     
    Erel likes this.
  7. tigrot

    tigrot Well-Known Member Licensed User

    I remember something similar on old Telex. The end of text was given by sequence NNNN . This sequence dropped line.
    This makes me think that telex had a Mega onboard!:)
     
    Cableguy likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice