• AVR Freaks

Hot!TCP/IP Lite & XC8 Compiler Bit Field Type Error

Author
dbissett
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2014/06/03 12:21:46
  • Location: 0
  • Status: offline
2019/09/19 08:20:10 (permalink)
0

TCP/IP Lite & XC8 Compiler Bit Field Type Error

A few days ago, I decided to try to get my 18f97j60 family devices to, under the TCP/IP Lite Stack, run Ethernet. . . .
 
XC8 2.10  MPLAB 5.25  TCP Lite Stack 2.2.8
 
I found that the stack itself will not compile.  There were three bit field type errors in file tcpip_types.h and one in file network.h.  After fumbling around the internet for a while I learned that I could change the XC8 library from C99 to C90.  The three errors in file tcpip_types.h went away but the one in nfile network.h did not.
In file included from mcc_generated_files/TCPIPLibrary/network.h:44:
mcc_generated_files/TCPIPLibrary/tcpip_types.h:58:22: error: bit-field 'vlanId' too large (12 bits)
        unsigned int vlanId:12; // not PIC compatible

 
Does anyone have a suggestion to get rid of this error?  If you have been there and done that, thanks for any help you can provide.
 
#1

10 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3076
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/19 09:37:18 (permalink)
    0
    Funny thing that MCC provides source code that's marked "not PIC compatible"  sad
    They should have done better...
     
    Anyway, as this union seems not to be referred to: comment the whole union and proceed.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    mbrowning
    USNA79
    • Total Posts : 1537
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/19 09:56:33 (permalink)
    5 (3)

    Go Navy! Beat Army!
    #3
    du00000001
    Just Some Member
    • Total Posts : 3076
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/19 10:19:47 (permalink)
    0
    Smile  

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/19 13:33:09 (permalink)
    0
    The final post in that topic says the faulty bitfield is only in an old version of the stack, and was fixed later.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    dbissett
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2014/06/03 12:21:46
    • Location: 0
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/21 13:22:29 (permalink)
    0
    OK, I got the compile working based on the suggestions in the thread.  Sadly, this turned into a miserable trip through the soft underbelly of Microchip code.  For the benefit of others, I'll document the steps and problems below.
     
    From the point of the beginning of this thread, the first step was to change the compiler library to C90. 
        Locate the project name in the Project pane or the Files pane and highlight the project name.
        From the Menu toolbar, File->Project Properties.  The Project Properties window will open.
        Select the "XC8 Linker" page.  Change C99 to C90 on the last option.
        Click the "Apply" button and watch for the progress bar on the lower right of the IDE main window.
        Close the Project Properties window.
     
    Run the compile again.  The first error will appear as follows:
    mcc_generated_files/TCPIPLibrary/tcpip_types.h:58:22: error: bit-field 'vlanId' too large (12 bits)
    Double click on this to edit and remove or comment out the whole union(lines 51 through 60).
     
    Run the compile again.  The first error will appear as follows:
    mcc_generated_files/TCPIPLibrary/ETHxxJ6x_driver.c:99:20: error: expected ';' after top level declarator
    The code will look like this: uint16_t errataTemp @ 0xE7E;  
    Change it to look like this:  uint16_t errataTemp __at(0xE7E);

     
    The next warning and errors listed are the result of the function definitions in the ethernet_driver.h file not matching the code in the .c files.  I chose to change the code to match the header.  Look for the warning that looks like this:
    mcc_generated_files/TCPIPLibrary/arpv4.c:93:16: warning: passing 'char *' to param of type 'uint8_t *'. . .

    Double click on this to edit.  On line 93 change "char" to "uint8_t".  Now look for an error that looks like this:
    mcc_generated_files/TCPIPLibrary/ETHxxJ6x_driver.c:759:6: error: conflicting types for 'ETH_Insert'
    Double click on this to edit.  On line 759 change the first instance of "uint8_t" to "char".
     
    Compile again.  The compile should complete successfully.
     
     
     


    post edited by dbissett - 2019/09/22 09:57:56
    #6
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11347
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/21 15:43:58 (permalink)
    4 (2)
    uint16_t errataTemp @ 0xE7E;
    Change the "@" to "=".

     
    I'm dubious that's the correct fix for that.  I haven't looked at the errata, but if something needs to be at that address, you should be using __at() to do that.
    #7
    dbissett
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2014/06/03 12:21:46
    • Location: 0
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/21 19:59:20 (permalink)
    0
    I did not write that code.  That is how it unpacks from the library download.  Whatever the authors intended, this code is not valid.  My repair is only an assumption about what was intended.  As I said, it does compile after my repair.  My next step in the process here is to get the chip to work.  My assumption about what is wrong here may not be correct.  We will see.
     
    I am disgusted with this code.  I have stumbled over at least three instances of invalid code that will not compile.  Doesn't anyone test this before it gets published?
     
    BTW,  Thanks to those who answered.   
    post edited by dbissett - 2019/09/21 20:02:57
    #8
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11347
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/21 22:04:46 (permalink)
    4 (2)
    Whatever the authors intended, this code is not valid.  My repair is only an assumption about what was intended.

     
    The code was valid when it was written, and your assumption is incorrect.  Previous compiler versions used "@" for absolute variable placement, but current compilers use "__at()" which is why it no longer compiles.  It appears there is, or was, an errata with this family (or the compiler)  that required moving Ethernet data through a particular memory address.
    #9
    dbissett
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2014/06/03 12:21:46
    • Location: 0
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/22 10:06:11 (permalink)
    5 (2)
    JT,
     
    Thanks for clarifying your suggestion.  I looked it up in the XC8 Users Guide and you are completely correct.  Your suggestion does appear to be in-line with the original intent of the code.  After changing the code it does compile correctly.  I have changed my repair narrative to reflect your suggestion.  Your help is appreciated.
    #10
    dbissett
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2014/06/03 12:21:46
    • Location: 0
    • Status: offline
    Re: TCP/IP Lite & XC8 Compiler Bit Field Type Error 2019/09/28 17:56:52 (permalink)
    0
    BTW,  Does anyone know where to locate the TCP Demo Application , with the Java client/server GUI program, that is mentioned in AN1921?
     
    Never mind, I found it.
    post edited by dbissett - 2019/09/29 10:02:49
    #11
    Jump to:
    © 2019 APG vNext Commercial Version 4.5