2 Replies Latest reply on Jun 18, 2013 9:37 AM by randy.chapel

    FX3, CyU3PDebugPrint - coding for va_list, va_start, va_end

    randy.chapel

      Hi,

         

      Coding a CyU3PDebugPrint version for additional functionality, perhaps others have tried the same.  The purpose is to send back a buffer of formatted strings, in order to debug the MCU.  See below.  This compiles, but I have a problem with the link phase as noted lower in the message.  Not really sure what I am missing.

         

      Has anyone done something like this?

         

      Have an idea of what I am possibly missing?

         

      This only now happens due to the including of va_list, va_start, va_end due to stdarg.h

         

       

         

       

         

       

         

       

         

      #include <stdio.h>

         

      #include <stdarg.h>

         

      int CyU3PDebugPrintx(int a, char *format, ...) {

         

      uint8_t src[1024];

         

      va_list arg;

         

      int cnt;

         

       

         

      for (cnt = 0; cnt<LogBufferSizeLimit; cnt++) {

         

      src[cnt] = 0;

         

      }

         

       

         

      va_start(arg, format);

         

      vsprintf((char *)src, format, arg);

         

      perror((char*)src);

         

      va_end(arg);

         

       

         

      cnt = strlen((char*)src);

         

      DebugPipeLogging(src, cnt);

         

       

         

      return 0;

         

      } // CyU3PDebugPrintx

         

       

         

       

         

      **** Build of configuration Release for project USBVideoClass ****

         

       

         

      cs-make all 

         

      'Building file: ../uvc.c'

         

      'Invoking: ARM Sourcery Windows GCC C Compiler'

         

      arm-none-eabi-gcc -DTX_ENABLE_EVENT_TRACE -DDEBUG -DCYU3P_FX3=1 -D__CYU3P_TX__=1 -I"C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\inc" -I. -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"uvc.d" -MT"uvc.d" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"uvc.o" "../uvc.c"

         

      'Finished building: ../uvc.c'

         

      ' '

         

      'Building target: cyfxuvc.elf'

         

      'Invoking: ARM Sourcery Windows GCC C Linker'

         

      arm-none-eabi-gcc  ./cyfx_gcc_startup.o ./cyfxtx.o ./cyfxuvcdscr_BAE.o ./minicam_uart_BAE.o ./uvc.o    -T"C:\Cypress\EZ-USB FX3 SDK\1.2\/firmware/common/fx3.ld" -nostartfiles -Wl,-Map,cyfxuvc.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--gc-sections -Wl,--entry,CyU3PFirmwareEntry "C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\lib\fx3_release\cyfxapi.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\lib\fx3_release\cyu3threadx.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\lib\fx3_release\cyu3lpp.a"  "C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\lib\gcc\arm-none-eabi\4.5.2\libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"cyfxuvc.elf"

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':

         

      sbrkr.c:(.text+0x18): undefined reference to `_sbrk'

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-writer.o): In function `_write_r':

         

      writer.c:(.text+0x20): undefined reference to `_write'

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-closer.o): In function `_close_r':

         

      closer.c:(.text+0x18): undefined reference to `_close'

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-fstatr.o): In function `_fstat_r':

         

      fstatr.c:(.text+0x1c): undefined reference to `_fstat'

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-isattyr.o): In function `_isatty_r':

         

      isattyr.c:(.text+0x18): undefined reference to `_isatty'

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-lseekr.o): In function `_lseek_r':

         

      lseekr.c:(.text+0x20): undefined reference to `_lseek'

         

      C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a(lib_a-readr.o): In function `_read_r':

         

      readr.c:(.text+0x20): undefined reference to `_read'

         

      collect2: ld returned 1 exit status

         

      cs-make: *** [cyfxuvc.elf] Error 1