why does this printf fail in 8051?

I am new to 8051 and uVision.

I am able to get print to serial to work using register level code, but when I use printf the code goes into a hard run.

It is likely obvious to an experienced user so I am including a demo program below.

Note I am using a CAST 8051 core in an FPGA, and have 32K code and xdata rams.

Can anyone help?

#include <stdio.h>
#include <reg51t.h>


void init_serial0() {
  TH1 = (unsigned char) 250;
   PCON |= 0x80; // SMOD1=1 (double bit rate)
   TMOD = 0x20;  // Timer1 in auto-reload mode
  TCON = 0x40;  // Timer1 Run
  SCON = 0x50;  // 8-bit UART Mode, Timer1-driven, REN=1
}


void wait(void)  {    
    unsigned int i,j,x;
    for(i=0; i<10000; i++)
      for(j=0; j<50; j++) x++;
}


void main () {

    PMOD = 1; // set GPIO out as push-pull
    P0 = 0;

  init_serial0();
    
  printf("hello ..\n");

  while(1) {
        wait();
        P0 = 0x80;  // led on
        wait();
        P0 = 0;     // led off
    }
}