cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kef2189
Observer
Observer
1,316 Views
Registered: ‎02-18-2010

XMD and fork

Hello. 

 

I'm trying to fork a copy of XMD so that I can use the jtag_uart_server to connect my program to the a jtag line on my fpga.

 

I use the following code:

 

  pid_XMD = fork();
  if (pid_XMD == 0)
  {
        // child
        close(parent_to_XMD[1]);
        dup2(parent_to_XMD[0], fileno(stdin));
        dup2(fileno(xmdfd), fileno(stdout));  // dump output to log
        dup2(fileno(xmdfd), fileno(stderr));  // dump output to log

        // make incoming fd non-blocking

        fprintf(errfd, "Launching nios2-terminal\n");
        fprintf(errfd, "stdin is a tty %d\n", isatty(fileno(stdin)));
        fflush(errfd); 
        // Each jtag channel will need some special sauce from
        // a particular vendor...
        setsid();
        execlp("xmd", "xmd", NULL);
  }
  else
  {
        // parent
        close(parent_to_XMD[0]);

        // Now, write terminal command to XMD
 const char termCmd[] = "verbose 3\n\r\nterminal -jtag_uart_server 4444\n\r\n";      
 fprintf(errfd, "Try to write xmd cmd %d...\n", sizeof(termCmd));
      
        write(parent_to_XMD[1], termCmd, sizeof(termCmd));
  }

 

 

The problem is that, altough I get the following output in a file:

 

 

Xilinx Microprocessor Debugger (XMD) Engine
Xilinx EDK 11.4 Build EDK_LS4.68
Copyright (c) 1995-2009 Xilinx, Inc.  All rights reserved.

XMD%
XMD% Verbose Mode turned ON
XMD% XMD% Info:AutoDetecting cable. Please wait.
Info:Reusing A0060002 key.
Info:Reusing 24060002 key.
Info:Connecting to cable (Usb Port - USB21).
Info:Checking cable driver.
Info:Overriding Xilinx file <> with local file </proj/vssad/local/x86_64_linux26/pkgs/xilinx-ise-11.1i/EDK/bin/lin64/>
Info:File version of /etc/hotplug/usb/xusbdfwu.fw/xusbdfwu.hex = 1030.
Info: Using libusb.
Info: Kernel release = 2.6.5-7.276.PTF.196309.1-smp.
Info: Transfer delay fix = 150.
Info: Max current requested during enumeration is 74 mA.
Info:Type = 0x0004.
Info: Cable Type = 3, Revision = 0.
Info: Setting cable speed to 6 MHz.
Info:Cable connection established.
Info:Firmware version = 1303.
Info:File version of /proj/vssad/local/x86_64_linux26/pkgs/xilinx-ise-11.1i/ISE/data/xusb_xlp.hex = 1303.
Info:Firmware hex file version = 1303.
Info:PLD file version = 0012h.
Info: PLD version = 0012h.
Info:Type = 0x0004.
Info:ESN option: 00001178D06801.
XMD_DEBUG - Create new CableInterface for device # 2. Total 1 interfaces

JTAG chain configuration
--------------------------------------------------
Device   ID Code        IR Length    Part Name
 1       f5059093          16        XCF32P
 2       82ad6093          10        XC5VLX110T

Connected to MDM UART Target
JTAG-based Terminal Server.
(TCP Port no used is 4444)

XMD% XMD%

 

I am unable to connect to the server (notice that the 'connected client' prints are missing from this dump).  The socket will open, but I never receive data.  If I spawn xmd independently on a seperate terminal (without the fork), then my program successfully connects to that server and gets data.  This is extremely puzzling. 

 

Can anyone tell me the proper way to fork off xmd?

 

-Elliott

 

 

0 Kudos
0 Replies