Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Cyclone V HPS UART, can't rx data

I can send RS232 data via HPS UART1 but unable to read data. The scope shows RS232 data on RX pin but test code can’t read any data from /dev/ttyS1 and nothing when I ‘cat /dev/ttyS1’

I can think of multiple reasons but right now I’m double checking the FPGA implementation. The RS232 pins that are used for UART1 are different then default. This has been implemented opening QSYS and select the HPS system, then select ‘peripheral pins'. Scroll down to the UART Controllers. Set the UART1 to use the FPGA fabric for it’s pinout. After generating the HDL the uart pins show up for connection, these are brought up to top.vhd and connected to the correct signals. The correct pins and voltages levels are called out in top.qsf. Please see attached photos

One question I regarding FPGA implementation: In QSYS should HPS pin mode be set to ‘FPGA’ or should be set to ‘HPS I/O set’ and then use LoanIO to map to different pins?

12 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    One more question.

    I build preloader (SPL) from u-boot sources (https://github.com/altera-opensource/u-boot-socfpga, socfpga_v2013.01.01) with handsoff defaults from repository:

    make mrproper

    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- socfpga_cyclone5_config

    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

    I get u-boot.img and u-boot-spl.bin. The last one I use to build preloader-mkpimage.bin:

    mkpimage --header-version 0 -o preloader-mkpimage.bin u-boot-spl.bin u-boot-spl.bin u-boot-spl.bin u-boot-s pl.bin

    But after updating SD card's partition 2 with this .bin (dd if=preloader-mkpimage.bin of=/dev/mmcblk0p3 bs=64k seek=0) - board doesn't boot at all.

    And now I am wondering if there is anything which I should modify (at prloader/u-boot sources) before building u-boot-spl.bin.

    u-boot build with the same way (u-boot.img) works fine.

    I've tried to build preloader-mkpimage.bin according to the https://rocketboards.org/foswiki/view/documentation/avgsrdpreloader as well but results are the same - board doesn't boot at all - no single character on serial console.

    Thanks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    I am trying to establish an UART communication between two cyclone V SoCs. I am using the FPGA option enabled in Qsys for UART in both SoCs. I have got the communication running between them, for eg. I can send a string using 'echo hello SoC > /dev/ttyS1' and my application running on other SoC receives the string. Now I am running an application at Tx side, where I want to send a string(for test purposes, later on will be a data of around 20 bytes) cyclically,(running Angstrom with a RT patch). However, at the Rx side, I receive the string only once, and then the 'read' function call blocks. At the Tx side, the further transmission fails with an error 'Invalid Argument', basically for the 'write' function. However, the first write succeeds.

    Here is a snippet :

    // Init code, common for both SoCs.

    if ((file_des_uart = open("/dev/ttyS1", O_RDWR | O_NOCTTY )) < 0) {
    		  perror("Failed to open the UART device file: ");
    		exit(1);
    	}
    	else {
    		puts ("uart ok");
    	}
            struct termios options;
    	tcgetattr(file_des_uart, &options);
    	options.c_cflag = B115200 | CS8 | CLOCAL | CREAD;		//<Set baud rate
    	options.c_iflag = IGNPAR;
    	options.c_oflag = 0;
    	options.c_lflag = 0;
    	tcflush(file_des_uart, TCIFLUSH);
    	tcsetattr(file_des_uart, TCSANOW, &options);

    //At Tx side

     char* tx_buf = "Hello SoC";
                   while(1 && cntr < 5) {
    		bytesSent = write(file_des_uart,(tx_buf),(strlen(tx_buf)+1));
    		if(bytesSent != strlen(tx_buf)+1) {
    			perror("Error: ");
    			break;
    		}
    		cntr++; //break after sending 5 times

    // At Rx side

      while(1)
    	{
    		if ((bytesSent = read(file_des_uart,(void*)rx_buf,50)) > 0) {
    			printf("uart : Received msg = %s\n",rx_buf);
    		}
    		if(bytesSent < 0) {
    			perror("uart : error in reading uart : ");
    			//break;
    		}
                   if(bytesSent == 0 {
                           printf("No data");
                   }                       
             }

    As far as I know, I am not using the DMA option, since I have not configured it anywhere, and I prefer not to use it. I would like to have a simple UART communication, between the two SoCs.

    Does anyone have a hand on this issue?