printf("%c".. not working on CW v7.1.2, CF V2 (52259evb)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

printf("%c".. not working on CW v7.1.2, CF V2 (52259evb)

2,346 Views
audiodane
Contributor I

Hello everyone..

 

Building with codewarrior v7.1.2 for the V2 family, specifically using the MCF52259 chip...

 

For simplicity, I am redirecting printf(...) to an AsynchroSerial module (AS1).  I am NOT using the internal console, but an external VT100 terminal interface for stdout.

 

The following code segment:

 

char UartChar = 'D';printf("%c", UartChar);

 

does nothing.  Following things through down through the debug process, I come across this snippet within printf_tiny_IO.c (line 460, file revision 1.5.2.2):

 

 

#if LIBDEF_PRINTF_CHAR        case 'c': /* char */          c1 = (char)va_arg(args, int);          str = (char *) &c1;          len = 1;          goto string; /*lint !e801 Use of goto is not deprecated */#endif

 

The line is not compiled into the project (no dots on the left hand side to place debug breakpoints).

 

I have tried adding the following to the project "C/C++ Preprocessor ---> Prefix Text" box:

 

 

#define LIBDEF_PRINTF_CHAR 1

 

But that does not seem to help the way I expect it should-- the code snippet above is STILL ignored, and I can find no higher-level #if condition that is missing..   Am I mis-understanding how to set this parameter in the v7.1.2 codewarrior tool?

 

 

 

thanks,

..dane

Labels (1)
0 Kudos
Reply
10 Replies

1,312 Views
CrasyCat
Specialist III

Hello

 

The point here is that the function printf is taken from the library, so building the project with #define LIBDEF_PRINTF_CHAR 1 will not help here.

 

You have 2 solutions here:

  1- Rebuild the library with #define LIBDEF_PRINTF_CHAR 1

  2- Add the file printf_tiny_IO.c to your project and rebuild the project. Make sure the file printf_tiny_IO.c  comes before the MSL library in the project link order tab.

 

I hope this helps

 

CrasyCat

0 Kudos
Reply

1,312 Views
audiodane
Contributor I

I have also tried your suggestion to rebuild the libraries, but don't know how.  I found an earlier post that seems to apply to an earlier version of the tools.  those paths don't exist with my CW v7.1.2 installation.

 

I would love to include the appropriate files locally so that it works without having to rebuild libraries on all my coworkers machines, though.  But at this point, I'm open to anything...

 

thanks,

..dane

0 Kudos
Reply

1,312 Views
CrasyCat
Specialist III

Hello

 

Can you check in your application .map file where the vprintf function is taken from?

 

CrasyCat

0 Kudos
Reply

1,312 Views
audiodane
Contributor I

Ahhh..    I found the .xMAP file (not .map) that shows the vprintf() routine coming from C_4i_CF_SZ_MSL.a.     I just don't know what project that build is located in ..

 

And now it turns out I need the %x supported also...   so %c and %x support are both needed.   Again, I'm open to rebuilding the libraries if I need to, but it would be much simpler if somehow I could do an "override" within my project that all other team members could more easily duplicate.

 

thanks!!!

..dane

0 Kudos
Reply

1,312 Views
CrasyCat
Specialist III

Hello

 

I have no clue why the override is not working for you.

If you want to get this one investigated, I would recommend you to submit a service request for that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

 

Attach the generated .zip file to the SR.

 

In order to rebuild the library:

  - In CodeWarrior open the file {Install}\ColdFire_Support\msl\MSL_C\MSL_ColdFire\Project\MSL_C.CF.SZ.mcp
  - Select build target 4i ColdFire SZ

  - Apply the changes in the Project settings

  - Build the project. This should generate a new .a file.

 

CrasyCat

0 Kudos
Reply

1,312 Views
audiodane
Contributor I

CrasyCat wrote:

Hello

 

I have no clue why the override is not working for you.

If you want to get this one investigated, I would recommend you to submit a service request for that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

 

Attach the generated .zip file to the SR.

 

In order to rebuild the library:

  - In CodeWarrior open the file {Install}\ColdFire_Support\msl\MSL_C\MSL_ColdFire\Project\MSL_C.CF.SZ.mcp
  - Select build target 4i ColdFire SZ

  - Apply the changes in the Project settings

  - Build the project. This should generate a new .a file.

 

CrasyCat


Working on the service request now.  Thank you.

 

Also, I was able to recompile the library just fine-- thank you!!   While this is a good interim fix, I do look forward to undersatnding the "better" fix soon from the SR..

0 Kudos
Reply

1,312 Views
audiodane
Contributor I

Service ticket told me how to utilize the full library support.  That increased code size by 300% (3x).  (yikes!)   But it still had problems compiling, telling me I needed to implement InitializeUART, ReadUART, and WriteUART functions, which I never had to do with the SZ library.

 

Given those two issues (3x code-size increase and additional function definition requirements), I decided to revert back to a custom-compiled library.  And to make it easier on other team players, I am going to copy the library files into a project subfolder ({Project}\Lib\Src).  That way we're using the same library across the board, and it's archived in case something changes down the road (compiler upgrade, etc).

 

Cheers,

..dane

0 Kudos
Reply

1,312 Views
CrasyCat
Specialist III

Hello

 

Just an additional side note here.

 

Can you try to add the module printf.c (instead of printf_tiny_IO.c) in your project.

Make sure this file is above the MSL library file in the link order tab and then rebuild the project.

 

This might fix the override problem you are seeing.

 

CrasyCat

0 Kudos
Reply

1,312 Views
audiodane
Contributor I

 


CrasyCat wrote:

Hello

 

Just an additional side note here.

 

Can you try to add the module printf.c (instead of printf_tiny_IO.c) in your project.

Make sure this file is above the MSL library file in the link order tab and then rebuild the project.

 

This might fix the override problem you are seeing.

 

CrasyCat


 

Tried that ...  gave me 47 new warnings and 6 new errors (errors at bottom):

 

 

Warning : implicit arithmetic conversion from 'int' to 'unsigned char'printf.c line 278     f.conversion_char = c;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned char'printf.c line 549    f.conversion_char = c;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned char' to 'char'printf.c line 1089     *--p = format.conversion_char;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'long' to 'unsigned long'printf.c line 1110    unsigned_num = num;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'long' to 'unsigned long'printf.c line 1130        unsigned_num = -num;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned char' to 'char'printf.c line 1141     base = set_base(format.conversion_char);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'int'printf.c line 1147     n = unsigned_num % base;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1163     *--p = n;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'long long' to 'unsigned long long'printf.c line 1181    unsigned_num = num;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'long long' to 'unsigned long long'printf.c line 1200        unsigned_num = -num;           /*- mm 050104 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned char' to 'char'printf.c line 1206     base = set_base(format.conversion_char);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long long' to 'int'printf.c line 1212     n = unsigned_num % base;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1228     *--p = n;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long long' to 'unsigned int'printf.c line 1234    return justify_conversion(base, digits, minus, p, buff, format);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned int'printf.c line 1382    snum = ((unsigned char *)&num)[0] << 25;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned int' to 'long'printf.c line 1395     exp  = snum - (TARGET_FLOAT_MAX_EXP-1);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned char'printf.c line 1423   orking_byte = (*(q + mantissa_byte)) >> (7 - (mantissa_bit & 7));  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1434        *--p = radix_marker;         Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned char' to 'char'printf.c line 1452     *--p = working_byte;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1459      *--p = radix_marker;       /*- mm 011130 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1501    c     = *--p - '0';  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1519     c = *--p - '0' + carry;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1525      *p = c + '0';  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned char'printf.c line 1540    dec->sig.length = new_length;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1688       *--p  = n % 10 + '0';  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1692      *--p = sign;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned char' to 'char'printf.c line 1693      *--p = format.conversion_char;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1706       *--p = radix_marker;       /*- mm 011130 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned char' to 'char'printf.c line 1708      *--p = *dec.sig.text;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 1754       *--p = radix_marker;          /*- mm 011130 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'int'printf.c line 1824      num_chars      = strlen(format_ptr);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned long'printf.c line 1827    (num_chars && !(*WriteProc)(WriteProcArg, format_ptr, num_chars)) /*- mm 990325 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned long'printf.c line 1836    (num_chars && !(*WriteProc)(WriteProcArg, format_ptr, num_chars))  /*- mm 990325 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'long'printf.c line 1897        long_num = va_arg(arg, size_t);        /*- mm 020529 -*/    Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'long'printf.c line 1963        long_num = va_arg(arg, unsigned long);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'long'printf.c line 1978        long_num = va_arg(arg, size_t);       /*- mm 020529 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned int' to 'long'printf.c line 1985        long_num = va_arg(arg, unsigned int);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'int'printf.c line 2090        if ((num_chars = wcstombs(buff, wcs_ptr, sizeof(buff))) < 0)  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned long'printf.c line 2115        if ((string_end = (char *) memchr(buff_ptr, 0, num_chars)) != 0)  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'int'printf.c line 2119        num_chars = strlen(buff_ptr);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'short'printf.c line 2142   ase short_argument:     * (short *)     buff_ptr = chars_written; break;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned long'printf.c line 2148   case size_t_argument:    * (size_t *)   buff_ptr = chars_written; break;  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 2193       *buff_ptr = va_arg(arg, int);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'unsigned long' to 'int'printf.c line 2248       num_chars      = strlen(curr_format);  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned long'printf.c line 2251   (num_chars && !(*WriteProc)(WriteProcArg, curr_format, num_chars)) /*- mm 990325 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'char'printf.c line 2262   l_char = (format.justification_options == zero_fill) ? '0' : ' ';  /*- mm 960722 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cWarning : implicit arithmetic conversion from 'int' to 'unsigned long'printf.c line 2291   if (num_chars && !(*WriteProc)(WriteProcArg, buff_ptr, num_chars))  /*- mm 990325 -*/  Project: TestMenu.mcp, Target: INTERNAL_RAM, Source File: printf.cError   : Undefined : "__fwrite"printf.c line 2335   Referenced from "__FileWrite" in Project: TestMenu.mcp, Target: INTERNAL_RAMError   : Undefined : "__num2dec"printf.c line 1299   Referenced from "double2hex" in Project: TestMenu.mcp, Target: INTERNAL_RAMError   : Undefined : "fabs"printf.c line 1462   Referenced from "double2hex" in Project: TestMenu.mcp, Target: INTERNAL_RAMError   : Undefined : "fwide"printf.c line 2363   Referenced from "printf" in Project: TestMenu.mcp, Target: INTERNAL_RAMError   : Undefined : "wcstombs"printf.c line 2092   Referenced from "__pformatter" in Project: TestMenu.mcp, Target: INTERNAL_RAMLink failed. 

 

 

:smileysad:

 

..dane

0 Kudos
Reply

1,312 Views
audiodane
Contributor I

 


CrasyCat wrote:

Hello

 

The point here is that the function printf is taken from the library, so building the project with #define LIBDEF_PRINTF_CHAR 1 will not help here.

 

You have 2 solutions here:

  1- Rebuild the library with #define LIBDEF_PRINTF_CHAR 1

  2- Add the file printf_tiny_IO.c to your project and rebuild the project. Make sure the file printf_tiny_IO.c  comes before the MSL library in the project link order tab.

 

I hope this helps

 

CrasyCat


 

I like the idea of having something locally handled (like option 2) so that others on the team have less manual library rebuilding to do...  However, it doesn't seem to be working.

 

I have attached my link order view.  You can see the printf_tiny_IO.c file is listed fourth from the top, before anything else.  I can Project -> Remove Object Code -> All Projects and a red checkmark shows to its left.  But when I invoke Make, the red check goes away but the Code and Data columns still show "0" for the pritnf_tiny_IO.c file, and when I go to debug, those lines are still left out.

 

I have also included the C/C++ preprocessor snapshot here as well.

 

Any pointers to what I'm doing wrong would be wonderful..

 

thanks,

..dane

 

 

0 Kudos
Reply