How to override printf's in PSoC4?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

How to override printf's in PSoC4?

   

Overriden the printf function in retarget.c, but still crashing in "__sinit" arm lib function call.

   

How can we skip (/ override) __sinit function call in PSoC4 compilation?

   

Aim is to go to fputc function defined in retarget.c from printf. 

   

Attaching project for reference.

0 Likes
7 Replies
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Not yet as a component, but this works for me. IO-pins are for CY8CKIT-044 PSoC4-M pioneer kit.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

1. Your project doesn't open in PSoC Creator 3.1 Service pack 3.

   

2. PFA better way to overide printf's, very crisp and small. In my opinion it is better than 100 projects in 100 Projects. - Test No. 23 tinyprintf Example.

   

3. If you would have answered to my problem of __sinit solution, I would have provided even crispier solution. I think, ARM GNU toolchain issue, ARM RVDS compiler have far better solution.

   

Thanks!

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Printf overriding project.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Latest Creator version is 3.3, so yours is more than a bit outdated. There is a new release announced for coming end of the year (usually a bit later).

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi, Bob. I'm running PSoC creator 3.3 on a Pioneer BLE kit with Cy8C-4248-LQI-583. I've set the pins in the cydwr to rx=p1[4] and tx=p1[5].

   

I can build and upload your file, and it prints "PuTTY Output" but then does not print the prompt or scanf for input. Looks like the PuTTY_UartPutString works, but that printf does not.

   

Is stdio functionality better in creator 4.0? I tend not to like .0 releases of toolchains, and am not enthused by the "BLE Code Examples Fail Digital Placement" erratum...

0 Likes

Best (and fastest, less resource consuming) way to print formatted:

   

Use
sprintf(Buffer,Format,Values);
UART_PutString(Buffer);

   

In Project -> Build Settings -> Linker Set Use newlib nano to true (default)
                                                             Set Use newlib nano float formatting to true
In Workspace -> System set the Heap size to 0x0200

   

Configure your UART Rx and Tx Buffer size to 80 .. 200 using the internal interrupt

   

The function family scanf() is not supported by newlib nano, you'll need to use atoi() macro

   

 

   

Bob
 

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Bob / Cypress team,

   

Here is the best solution for printf overriding. PFA attached project.

   

ARM GNU toolchain, I am not confident, as I have an option of ARM MDK compiler. Compiled image size with MDK compiler is far smaller than GNU tool chain. And MDK follows all standard definition and have documentation available.

   

Always prefer MDK over GNU toolchain.

   

File system simplest solution will also follow up on this post.

   

 

   

Thanks,

   

Rajender

0 Likes