This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Target not created

I keep getting a 'Target not created' error at the end of compile. When I comment out a printf, everything is fine. What is the problem?

Thank you.

  • Post the other error messages you see when you get "Target not created" as well as the shortest complete code that demonstrates the problem.

    Stefan

  • What other errors do you get before "Target not created?"

    ALWAYS start with the FIRST error!

  • There are no other error messages. Here is the dump:

    Build target 'Target 1'
    compiling can.c...
    CAN.C(258): warning C280: 'mask': unreferenced local variable
    CAN.C(280): warning C280: 'i': unreferenced local variable
    CAN.C(280): warning C280: 'mask': unreferenced local variable
    linking...
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?PCA_TEST?MAIN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?ADC_TEST?MAIN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?I2C_READ_TEST?MAIN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?I2C_WRITE_TEST?MAIN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?CAN_TRANSMIT?CAN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?CAN_RECEIVE?CAN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?_CAN_PRINT_MSG_BUF?CAN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?CAN_PRINT_STATUS?CAN
    *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
        SEGMENT: ?PR?CAN_PRINT_MSG?CAN
    *** WARNING L15: MULTIPLE CALL TO SEGMENT
        SEGMENT: ?PR?PRINTF?PRINTF
        CALLER1: ?PR?CAN_INT_HANDLER?CAN
        CALLER2: ?C_C51STARTUP
    *** ERROR L107: ADDRESS SPACE OVERFLOW
        SPACE:   DATA
        SEGMENT: ?DT?PCA_TEST?MAIN
        LENGTH:  0003H
    *** ERROR L107: ADDRESS SPACE OVERFLOW
        SPACE:   DATA
        SEGMENT: ?DT?CAN_PRINT_STATUS?CAN
        LENGTH:  0002H
    *** ERROR L107: ADDRESS SPACE OVERFLOW
        SPACE:   DATA
        SEGMENT: ?DT?CAN_RECEIVE?CAN
        LENGTH:  0001H
    *** ERROR L107: ADDRESS SPACE OVERFLOW
        SPACE:   DATA
        SEGMENT: ?DT?CAN_PRINT_MSG?CAN
        LENGTH:  0001H
    *** ERROR L107: ADDRESS SPACE OVERFLOW
        SPACE:   DATA
        SEGMENT: ?DT?GETCHAR
        LENGTH:  0001H
    *** ERROR L105: PUBLIC REFERS TO IGNORED SEGMENT
        SYMBOL:  ?_UNGETCHAR?BYTE
        SEGMENT: ?DT?GETCHAR
    Program Size: data=136.4 xdata=12 code=4173
    Target not created

  • Oh, sorry, there are other error messages. What does ADDRESS SPACE OVERFLOW mean?

  • "ALWAYS start with the FIRST error!"

    This isn't always as easy as it seems. If an uncalled function causes you to run out of, say, DATA space the linker will report "Address space overflow" first, then "Uncalled function ignored for overlay purposes". In this case you need to get rid of the uncalled function warning to fix the overflow error. In particular you can get a whole bunch of address space overflow errors which tend to hide the other warning.

    Stefan

  • Let me guess: you're calling printf() from an interrupt handler?

    Stefan

  • What does ADDRESS SPACE OVERFLOW mean?

    That your code tried to put more stuff into
    one of the 8051 address spaces (in the case at hand: into DATA) than fits into it. Pretty straightforward, I'd have thought, especially after you looking up the error message number
    in the docs.

    But in the case at hand, that's an indirect error. The real problem is that you have so much code compiled in your source files that isn't actually used for anything, as far as the compiler could tell. That wreaks havoc in the data overlay optimization step, and thus caused your data segment to overflow.

    Fix those "unused segment", and "multiply called segment" warnings before you go on---they're serious.

  • Let me guess: you're calling printf() from an interrupt handler?

    Yes. I tried replacing the printf with a function that uses puts(). The project compiles OK but the program hangs on this function call.

    So, you suggest I get rid of the uncalled functions first? I'll try that. But how can an uncalled function cause an overflow?

  • the linker will report "Address space overflow" first, then "Uncalled function ignored for overlay purposes"

    Hmm... the actual output posted quite clearly has those the other way round. The real catch, I think, is that the uncalled function message is classified as a warning, so the address space overflow is the first actual error message. So maybe the rule of thumb should be extended to:

    Always look at the first error message first, yet heed any warnings preceding it, too.

  • "the actual output posted quite clearly has those the other way round"

    I see that - however I get the opposite result. I posted that message before seeing the OP's error listing.

    Stefan

  • "Yes. I tried replacing the printf with a function that uses puts(). The project compiles OK but the program hangs on this function call."

    Calling the same function from an ISR and non-ISR code is a recipe for disaster. printf() may well call puts() internally hence the problem remains. I prefer not to call any functions from the ISR - I usually inline all code.

    "So, you suggest I get rid of the uncalled functions first?"

    Yes. A trick I sometimes use is to create a function containing dummy calls to all uncalled functions (if I plan to use these functions for real later in development). I then put a call to that function in some unreachable code in my main function:

    if(!SP)
    {
    MakeDummyCalls();
    }

    is my favourite.

    "But how can an uncalled function cause an overflow?"

    If the compiler can't see a call to a function it assumes the function must be called via a pointer and excludes it from the overlay map. Local variables in that function then have to be given their own unique storage locations - as though they had been declared static.

    Stefan

  • The problem disappears after you either remove all the uncalled functions, or make them callable. One thing I still don't understand is why a lot of uncalled functions in different modules cause an overflow while a lot of callable functions don't??

  • "One thing I still don't understand is why a lot of uncalled functions in different modules cause an overflow"

    You need to read-up on Data Overlaying in the manuals.

  • "One thing I still don't understand is why a lot of uncalled functions in different modules cause an overflow while a lot of callable functions don't??"

    For 'compiler' read 'compiler/linker':

    The compiler builds a call tree for your program. Based on this tree it can use the same physical memory locations to store local variables from different functions. This is called 'data overlaying'. If you don't call a function the compiler decides that it can't risk overlaying the local variables in case the function is called via a pointer, which it can't see. In this case unique memory locations are allocated for that function, meaning that uncalled functions use up more memory space.

    A feature that I'd like to see is some method of telling the compiler to completely ignore uncalled functions as this problem is a real nuisance during program development.

    Stefan