• AVR Freaks

Hot!New Harmony framework crashing UDP

Author
ibbro
Starting Member
  • Total Posts : 87
  • Reward points : 0
  • Joined: 2015/10/22 07:34:56
  • Location: 0
  • Status: offline
2020/02/03 10:08:46 (permalink)
0

New Harmony framework crashing UDP

I let Harmony update the framework yesterday to the new versions including the .net. My project crashes hard under the new framework. I built a new project with the same components set the same, (as far as I can see) and put my code on top. Everything works as before except UDP which under the debugger never gets a connection and without the debugger causes a reset when the 1st packet is sent to it.
 
I know there are no actionable details included in this, just wondering if anyone using the TCPIP library has successfully moved to the new framework? I tried the tcpip_udp_server demo app under the new framework and it does work, so I'm thinking there is a harmony setting somewhere that needs changed.
 
#1

7 Replies Related Threads

    ibbro
    Starting Member
    • Total Posts : 87
    • Reward points : 0
    • Joined: 2015/10/22 07:34:56
    • Location: 0
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/03 12:27:10 (permalink)
    0
    Made the heap smaller and the new framework now works. Sheer luck, wasn't even a guess. But it works.
    #2
    nigelwright7557
    Super Member
    • Total Posts : 422
    • Reward points : 0
    • Joined: 2006/11/06 08:15:51
    • Location: 0
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/03 13:18:45 (permalink)
    0
    ibbrowning
    Made the heap smaller and the new framework now works. Sheer luck, wasn't even a guess. But it works.


    I can understand needing more stack but not less !
    I tend to stick with old versions of Harmony and let others find the bugs in newer versions before I later start to use it.
     
    #3
    rainad
    Moderator
    • Total Posts : 1329
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/03 14:10:37 (permalink)
    5 (1)
    Please give some details: which heap exactly have you made smaller: the project heap or the TCP/IP heap?
    Some numbers might help.
    Does your app uses dynamic allocation?
    If so, please make sure that you always check the returned value of malloc/calloc. Also, that you do not over step the allocated buffers boundaries. From what you describe, seems to be something along these lines.
     
    This kind of bug needs to be solved. The fact that it disappeared after changing some settings does not solve the issue. You'll add a new variable to a module or do some other change and the issue will resurface.
     
    ibbrowning
    Everything works as before except UDP which under the debugger never gets a connection and without the debugger causes a reset when the 1st packet is sent to it.

     
    So do you have a UDP socket in your application or not?
    And what's going on with the debugger, is the debugger affecting the behavior of the application?
     
    We've tested the H3 stack pretty thoroughly. IMO we'd have heard of such a major bug. But of course it's still possible, I'm not going to discard it upfront.
    Anyway, please give some details so we can get to the bottom of it.
     
    #4
    ibbro
    Starting Member
    • Total Posts : 87
    • Reward points : 0
    • Joined: 2015/10/22 07:34:56
    • Location: 0
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/04 12:29:34 (permalink)
    0
    I have set up a project starting with what I saw in the Harmony V3 tcpip_udp_server demo. I am using TCPIP_STACK_HEAP_TYPE_INTERNAL_HEAP which is the default when the TCPIP Library was added to Harmony
    TCPIP dynamic ram size is 39350 which was also the default.
     
    I had the project heap set to 102400 and everything worked until downloading the latest repository changes and generating from them. If the harmony tcpip stack does not subtract from that, then it is much larger than needed.
    Lowering project heap to 81920 is what made everything immediately work with the new repository. No other changes.
     
    I am certainly unclear on the various TCPIP heap options actually do. Where would I find documentation on this to make the best choice?
     
    The application only uses one UDP socket and is setup as server although the allowed sockets are still set to the Harmony defaults. The app is intended to be connected to a PC via ethernet on a private network with no gateway and no other devices. 
    I am not dynamically allocating any memory in my code.The only mallocs and callocs are in Harmony generated code.
     
    Harmony has TCPIP(UDP and DHCP server only), 1 USB CDC device, and SPI2. I have not found a way to get TCPIP working without CONSOLE, COMMAND, and DEBUG included but would like to run without them in the end.
     
    Before I got the app functioning again, when debugging I would just never get a connection. Stack initialized, got an IP, and opened the UDP server successfully. Then waited forever for a connection. It never jumped to an exception. Without the debugger the project would reset every time a packet was sent.
     
    Thanks
    post edited by ibbro - 2020/02/05 07:44:06
    #5
    BillP
    Super Member
    • Total Posts : 389
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/05 15:05:36 (permalink)
    0
    I have not found a way to get TCPIP working without CONSOLE, COMMAND, and DEBUG included but would like to run without them in the end.

    In the earlier (Hv2) versions of Harmony, I could just comment out the SYS_PRINT etc. lines.  As Harmony and the TCPIP library grew, more debug/log messages were added.  In Hv3 there are way too many debug messages to comment out, plus I really would like to see a message if an error occurred so I do not have to put the code on the debugger each time. 
    My solution is to add macros to my app.h file that removes any compiler errors.  In my implementation I have a LogMsg() routine that writes the printf line to a circular buffer which is then written to a CDC port.  The basics of this approach are in my MZ b**k.  Here are the macros you can use in your project:
    #undef SYS_DEBUG_PRINT
    #define SYS_DEBUG_PRINT(level, fmt, ...) do { if((level) <= SYS_ERROR_DEBUG) LogMsg(fmt, ##__VA_ARGS__); } while (0)

    #undef SYS_ERROR_PRINT
    #define SYS_ERROR_PRINT(level, fmt, ...) do { if((level) <= SYS_ERROR_DEBUG) LogMsg(fmt, ##__VA_ARGS__); } while (0)

    #undef SYS_ERROR
    #define SYS_ERROR(level,fmt, ...) do { if((level) <= SYS_ERROR_DEBUG) LogMsg(fmt, ##__VA_ARGS__); } while (0)

    #undef SYS_CONSOLE_PRINT
    #define SYS_CONSOLE_PRINT(fmt, ...) do { LogMsg(fmt, ##__VA_ARGS__); } while (0)

    #undef SYS_CONSOLE_MESSAGE
    #define SYS_CONSOLE_MESSAGE(fmt, ...) do { LogMsg(fmt, ##__VA_ARGS__); } while (0)

    typedef enum
    {
        /* Errors that have the potential to cause a system crash. */
        SYS_ERROR_FATAL = 0,
        /* Errors that have the potential to cause incorrect behavior. */
        SYS_ERROR_ERROR = 1,
        /* Warnings about potentially unexpected behavior or side effects. */
        SYS_ERROR_WARNING = 2,
        /* Information helpful to understanding potential errors and warnings. */
        SYS_ERROR_INFO = 3,
        /* Verbose information helpful during debugging and testing. */
        SYS_ERROR_DEBUG = 4
    } SYS_ERROR_LEVEL;

     
    If you write a dummy routine LogMsg() that just returns, I think your code will compile but you will not see any log messages.  Also note, however, that there will still be some TCPIP library routines that need to be changed because they reference CONSOLE, DEBUG, or COMMAND insert files.  These routines are:
     
    src-> config-> PIC32MZ-> driver-> ethmac-> src-> dynamic-> drv_ethmac_lib.h
    src-> config-> PIC32MZ-> library-> tcpip-> src-> tcpip_private.h
    src-> config-> PIC32MZ-> driver-> miim-> src-> dynamic-> drv_miim.c
    src-> config-> PIC32MZ-> driver-> ethphy-> src-> dynamic-> drv_ethphy.c


    After making all these changes, you should be able to compile and execute an Hv3 application that uses the TCPIP library.  Good luck.
     
    #6
    ibbro
    Starting Member
    • Total Posts : 87
    • Reward points : 0
    • Joined: 2015/10/22 07:34:56
    • Location: 0
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/05 17:49:43 (permalink)
    0
    That is very slick BillP. I will give it a try. Thank you.
    #7
    rainad
    Moderator
    • Total Posts : 1329
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: New Harmony framework crashing UDP 2020/02/07 08:07:35 (permalink)
    0
    ibbrowning
    I am certainly unclear on the various TCPIP heap options actually do. Where would I find documentation on this to make the best choice?

    The supported heap types are briefly described in the tcpip_heap.h header or the same info you can find in the Harmony documentation. Just standard stuff, nothing special, the heap name says it all about it.
     
    ibbrowning
    I had the project heap set to 102400 and everything worked until downloading the latest repository changes and generating from them. If the harmony tcpip stack does not subtract from that, then it is much larger than needed.

    Maybe that's the problem. You need to verify that what you have downloaded on your machine matches what the TCP/IP stack, i.e. net repo, requires. If you have other version of the core, csp, dev_packs, crypto, etc., etc., then things will definitely break. In these conditions, an out of the box demo works fine, until regeneration.
     
    ibbrowning
    Before I got the app functioning again, when debugging I would just never get a connection. Stack initialized, got an IP, and opened the UDP server successfully. Then waited forever for a connection. It never jumped to an exception. Without the debugger the project would reset every time a packet was sent.
     

    Not sure what the debugger is causing, it should not have any impact. Anyway, after solving the above issues (repo versions) if you still experience the project resetting, try to understand what's going on. Most likely an  exception occurs. Set a break point at the exception point or handler and try to see what was the line and module that were causing the fault. If you're running on PIC32MZ, then the exception is at EBASE and EBASE + 0x180 addresses, etc.
     
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5