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

getting mass storage example to work using J-link

HI

I am completely new to keil MCB 4300 !!

im trying to run the USB Host Mass Storage example using j link . but nothing is shown in my debug(printf) viewer !! i tried couple of solutions like this link :

www.keil.com/.../jlink_trace_itm_viewer.htm

but i get the error that says : stdin stdout multiply defined .........

can anyone help me please ?

Parents
  • You need a #pragma to stop in including library stuff in the linker,

    /**************************************************************************/
    
    /* Implementation of putchar (also used by printf function to output data)    */
    int SendChar(int ch)                    /* Write character to Serial Port     */
    {
            ITM_SendChar(ch); // From core_cm4.c
    
      return(ch);
    }
    
    /**************************************************************************/
    
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    
    int fputc (int ch, FILE *f) { return (SendChar(ch)); }
    
    int ferror (FILE *f) {
      /* Your implementation of ferror */
      return EOF;
    }
    
    void _ttywrch (int ch) { SendChar(ch); }
    
    void _sys_exit (int return_code) { for (;;); }
    
    /**************************************************************************/
    

    You'll need to #include <stdio.h> and make sure you have the trace clock matching the system clock. There are other retargeting examples, you might want to check those and the documentation.

Reply
  • You need a #pragma to stop in including library stuff in the linker,

    /**************************************************************************/
    
    /* Implementation of putchar (also used by printf function to output data)    */
    int SendChar(int ch)                    /* Write character to Serial Port     */
    {
            ITM_SendChar(ch); // From core_cm4.c
    
      return(ch);
    }
    
    /**************************************************************************/
    
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    
    int fputc (int ch, FILE *f) { return (SendChar(ch)); }
    
    int ferror (FILE *f) {
      /* Your implementation of ferror */
      return EOF;
    }
    
    void _ttywrch (int ch) { SendChar(ch); }
    
    void _sys_exit (int return_code) { for (;;); }
    
    /**************************************************************************/
    

    You'll need to #include <stdio.h> and make sure you have the trace clock matching the system clock. There are other retargeting examples, you might want to check those and the documentation.

Children