Announcement

Collapse
No announcement yet.

Crash at startup

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • pauleilio
    replied
    Hi Sean,

    It would be a lot easier to troubleshoot if you could send me your code. You can send it to paul at 4dsystems dot com dot au

    Best regards

    Paul

    Leave a comment:


  • Sean Murphy
    replied
    I'm fairly certain that's not it. In the original version of the code, I had writeByte(port, LObyte(checksum));, sorry I just remembering that I had that in there now that you've made that comment. And with that LObyte() protection, the crash was still occurring

    Also, the crash issue only began happening once that code was being compiled in, but it in execution it occurs BEFORE that line of code ever has a chance at being executed. It's literally the presence of that call in the codebase causes a crash to happen right at boot time before any of my code really has a chance to get going - i.e. before that keypad lock() function is called, which all occurs in main() before I start my repeat...forever loop in main(). And the only way I'm able to successfully make that call now is because I cleaned up some global variables a little and reduced my footprint a little.

    At least that's what I think is happening.

    Is there any knowledge you can glean from any of the files in the .4DWork directory? I'd have to see what my boss would be willing for me to share, for intellectual property reasons, I probably wouldn't be able to post it here on the forums, but I could probably send it to you directly if that helps?

    Sean

    Leave a comment:


  • pauleilio
    replied
    Hello Sean,

    The only thing I can see is that the var checksum is being sent to serial port when the value can be greater than a byte. Not sure if that is the problem but I can't really see anything that might cause a crash. I will keep looking.

    Best regards

    Paul

    Leave a comment:


  • Sean Murphy
    started a topic Crash at startup

    Crash at startup

    I'm not even sure how to properly explain this one, but basically I'm having an issue where including code in my project to call a certain function causes the display to crash at startup even when I know that the function isn't even being called yet when the screen crashes. When I say "crash" I mean the LCD is all black pixels, only the backlight is on.

    Here's the setup: when the LCD boots up, after doing the file_LoadImageControl() stuff, I call a function lock(). lock() displays a numeric keypad requiring the user to enter a pin to unlock the screen. When I'm having the problem, I never even see the lock screen before the screen crashes.

    I had this basic setup (I have a lot more actual code naturally, just trying to simplify to ask the question):

    Code:
    func main()
       // load images from uSD card
       // *** when the crash happens, it occurs here, before lock() is called - numeric keypad never shows up ***
       lock(); // shows numeric keypad, never returns until user enters correct PIN
       repeat
          // lots of code here
          requestLightCmd(SERPORT, cmd); // <- adding this line was actually causing the crash
       forever
    endfunc
    
    func lock()
       // show numeric keyboard
       repeat
          // check for correct PIN, only return if correct otherwise
          // stay in this loop until user enters correct PIN
       forever
    endfunc
    
    func requestLightCmd(var port, var cmd)
        var checksum:= 0;
        checksum:= checksum + 0x4d; //sync 1
        checksum:= checksum + 0xd4; // sync 2
        checksum:= checksum + 0x02; // cmd id
        checksum:= checksum + 0x01; // size
        checksum:= checksum + cmd; // value
    
        writeByte(port, 0x4d); // sync 1
        writeByte(port, 0xd4); // sync 2
        writeByte(port, 0x02); // cmd id
        writeByte(port, 0x01); // size
        writeByte(port, cmd); // value
        writeByte(port, checksum); 
    endfunc
    
    func writeByte(var port, var data)
        if(port != COM0 && port != COM1)
            return;
        endif
        if(port == COM0)
            serout(data);
        else
            serout1(data);
        endif
    endfunc
    We'll call the code above my initial setup. The following changes were made with their noted results, all starting from that initial setup.

    Starting from initial setup, commented out new function call in main()
    // requestLightCmd(SERPORT, cmd);
    Result: LCD boots up to lock() screen

    Starting from initial setup, commented out body of requestLightCmd()
    In main():
    requestLightCmd(SERPORT, cmd);
    In requestLightCmd() function
    func requestLightCmd(var port, var cmd)
    /*
    var checksum:= 0;
    checksum:= checksum + 0x4d; //sync 1
    checksum:= checksum + 0xd4; // sync 2
    checksum:= checksum + 0x02; // cmd id
    checksum:= checksum + 0x01; // size
    checksum:= checksum + cmd; // value

    writeByte(port, 0x4d); // sync 1
    writeByte(port, 0xd4); // sync 2
    writeByte(port, 0x02); // cmd id
    writeByte(port, 0x01); // size
    writeByte(port, cmd); // value
    writeByte(port, checksum); // checksum // <- this line was originally causing problems
    */
    endfunc
    Result: LCD fails to boot properly, black screen before lock screen is ever shown

    I then removed some global variables I was no longer using, some functions that I no longer needed, redefined some variables as #constant and uncommented the body of requestLightCmd() and the LCD was able to boot up normally. So at this point the code is set up to actually call requestLightCmd() from main() and the LCD works, even though we haven't reached that point when the issue occurs.

    I'm not sure what the issue is. It seems like maybe it's a stack overflow or something like that? Because the presence of the crash is affected by the inclusion of code that doesn't even have a chance to execute when the issue shows up.

    When I compiled the code originally, where it was crashing the LCD, 4D Workshop reported:
    No Errors, code size = 11059 bytes out of 14400 total
    Initial RAM size = 390 bytes out of 14400 total
    Program will run from ram so total initial RAM size = 11449 bytes out of 14400 total
    Download to Flash successful.

    After rearranging code to get the LCD to work (even though what I rearranged occurs later) I got
    No Errors, code size = 11039 bytes out of 14400 total
    Initial RAM size = 390 bytes out of 14400 total
    Program will run from ram so total initial RAM size = 11429 bytes out of 14400 total
    Download to Flash successful.

    I'm kind of stumped as to what is going on...
    Sean
Working...
X