Jump to content

Zybo webserver


Niels00126

Recommended Posts

Dear, 

At the moment me and and a few friends are testing different IOT's.

To upload data from a microcontroller or fpga to a webserver. Or upload to our website with $ comments. So our website will place the value's in the webserver.

Now our question is. 

How can we connect our zybo board to the internet. We know we need to use the ethernet port but its very hard to find any information about uploading data with the zybo board. 

We use the zybo board with the vivado 2016 version.

Greetings,

Niels

Link to comment
Share on other sites

Hi Niels00126,

Here is a link to a web server using freeRTOS with Zynq.  Here is a link using LightWeight IP Application Examples. You can also install Petalinux with a quick guide here. Here is a github repo about a web server for zynq. Here is a link that describes how to configure the BusyBox web server that comes with PetaLinux and create/install your own custom web content into the PetaLinux system image. Hope this helps!

cheers,

Jon

Link to comment
Share on other sites

Hello,

I have a similar issue. I want to use my ZYBO with some external sensors and send this data via ethernet. But the problem is that i dont know which configuration in Vivado I should do. I found a lot of examples of SDK, but i dont know which IP's I have to put in Vivado. Im just starting using Vivado, so Im a bit lost with this.

And is it possible to modify the echo server code, to make the ZYBO send data to the PC via ethernet, and get an answer, instead of being a simple echo.

Thank you very much for your time,

Best regards,

Kepler

Link to comment
Share on other sites

Hello Jon,

First of all thank you for your quick answer! 

Actually, I have already seen that tutorial before, but my board is ZYBO with Zynq-7000, so I tried to adapt this microblaze tutorial in vivado to zynq but it didn't work...

For example, in the point 3 it says adding clock and dd3. For ZYBO I don't have this DD3 option. And some different things in the next steps.

Could you please help me to know how to adapt that tutorial to ZYBO?

Thanks again, I really appreciate it.

Link to comment
Share on other sites

Okay, but I don't know how to connect the different "boxes" like they do with the microblaze example, because in that example they look in the list of the board which is allready configured, as you can see in the image.

So I don't know how to select that in the ZYBO, and for the next steps its a similar situation.

Hope you understand what I mean.

Thank you.

Best regards

Kepler

 

recorte.JPG

Link to comment
Share on other sites

The Zybo is ... unique.  It's a powerful enough computer to run Linux.  Indeed, it does run Linux.  I think what you want to start with is a working Linux distribution, with ethernet connected, and then to consider running a Linux-based webserver on the board.  Alternatively, I suppose you could run one without Linux ...

Have you looked at this example?

Dan

Link to comment
Share on other sites

  • 4 weeks later...

Hello again,

Im trying to put Linux in the ZYBO, following the steps in the link you send me. They suggest to follow the steps of the document "Getting Started with the Embedded Linux", I followed them all, but there is a step that I can't manage to do. Just before building the Linux Kernel. 

They say " Before building the kernel users must first download and install the ARM GNU tools from Xilinx. The installer and instructions for these Xilinx tools are available at: http://wiki.xilinx.com/zynq-tools."

When I go to that link I see many differents things as Vivado, SDK, Petalinux, and many more. I am not sure of which files I need to download exactly. Hope you understand my problem.

Thank you very much for your time.

Best regards.

Link to comment
Share on other sites

Hello Jon,

Thanks for the answer. But I have some serious doubts about what petalinux is about. I mean I have downloaded ubuntu, I ran it in Vmware. I downloaded Vivado and SDK. And now what I want is to have an ethernet communication between Zybo and my PC. I mean, in the tutorial that Dan told me, I didnt see anything about Petalinux. I think I missunderstood many things or concepts maybe. Hope you can help me to see everything with clearer view.

Thanks again,

Kepler Lima

Link to comment
Share on other sites

Hi Kepler,

Feel free to use either tutorial. Petalinux is a Xilinx development tool that contains everything necessary to build, develop, test and deploy Embedded Linux systems. Here is a link to its wiki. Here is another link to a xilinx page describing it.  I'm in the process of getting the software installed to go through the tutorial I linked above. If you search our forums you will see a lot of threads dealing with petalinux. Our main embedded linux engineer actively promotes petalinux in all of my discussion with him.

cheers,

Jon

Link to comment
Share on other sites

Hello,

So with Petalinux I can be able to create a ethernet communication between ZYBO and PC as well? Instead of using vivado and all those problematics programs :D, im sorry im exhausted of trying different methods.

I just want to send information of external sensors to my PC via ethernet.  I know that a serial communication would be much easier, but that is the task I was asked for...

I am bit desperate, after 1 month I still can´t manage to send data from the ZYBO to the PC via ethernet.

If you have any suggestion please let me know, and thank your for your time, I am learning a lot!

Kepler

Link to comment
Share on other sites

Hi Kepler,

I know that you can set up a server using petalinux. I have also attached a project with the lwip echo server done in vivado and sdk 2016.04. You can use the reference manual here for so assistance as well. Just use step 14 on this tutorial to connect the ethernet on the zybo to your pc. hope this helps!

cheers,

Jon

Zybo_echo.zip

Link to comment
Share on other sites

Hello Jon,

Thanks for the help, I downloaded thef Vivado and SDK 2016.4, and im trying to try your project. But when Im in SDK after programming the FPGA, I get the following message " Unable to lunch The selection cannot be lunched". I have done everything in vivado, synthetise, implementation, generated the bitstream, i also added zybo board file. Then I exported the hardware with the bitstream. Launch SDK. And I can´t run it after programming the FPGA. I tried creating an application project with Hello World, and try to launch it in this project, but I still can´t launch it. Do you have any idea about how to solve this issue?

Thank you.

Kepler

Link to comment
Share on other sites

Hi Kepler,

I'm not sure what is happening. If you could attach a screenshot of the error. Another solution is to start a new project and follow the new tutorial here that should walk you through setting up an echo server using the lwip.  Hope this helps!

cheers,

Jon

 

Link to comment
Share on other sites

Thanks Jon, EchoServer is finally working. Now I would like to modify the .c to receive something different. If the PC sends the string "Temperature" the board should answer "The temperature of the room is ...." instead of sending again "Temperature".

I manage to answer with a different string:

We just need to modify this line:

if (tcp_sndbuf(tpcb) > p->len) {
        err = tcp_write(tpcb, p->payload, p->len, 1);
    }

for this 

if (tcp_sndbuf(tpcb) > p->len) {
      err = tcp_write(tpcb, "The temperature is :\n\r", 22, 1);
    }

The problem is that I want to read what it is sent also. 

To do something like

if (tcp_read(tpcb,"Temperature\r",12,1))

err = tcp_write(tpcb, "The temperature is :\n\r", 22, 1);

The problem is that im not sure how to read, im not even sure if tcp_read exists.

 

Here is the main code :

--------------------------------------------------------------------------

err_t recv_callback(void *arg, struct tcp_pcb *tpcb,
                               struct pbuf *p, err_t err)
{
    /* do not read the packet if we are not in ESTABLISHED state */
    if (!p) {
        tcp_close(tpcb);
        tcp_recv(tpcb, NULL);
        return ERR_OK;
    }

    /* indicate that the packet has been received */
    tcp_recved(tpcb, p->len);

    /* echo back the payload */
    /* in this case, we assume that the payload is < TCP_SND_BUF */
    if (tcp_sndbuf(tpcb) > p->len) {
        err = tcp_write(tpcb, p->payload, p->len, 1);
    } else
        xil_printf("no space in tcp_sndbuf\n\r");

    /* free the received pbuf */
    pbuf_free(p);

    return ERR_OK;
}

err_t accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err)
{
    static int connection = 1;

    /* set the receive callback for this connection */
    tcp_recv(newpcb, recv_callback);

    /* just use an integer number indicating the connection id as the
       callback argument */
    tcp_arg(newpcb, (void*)(UINTPTR)connection);

    /* increment for subsequent accepted connections */
    connection++;

    return ERR_OK;
}


int start_application()
{
    struct tcp_pcb *pcb;
    err_t err;
    unsigned port = 7;

    /* create new TCP PCB structure */
    pcb = tcp_new();
    if (!pcb) {
        xil_printf("Error creating PCB. Out of Memory\n\r");
        return -1;
    }

    /* bind to specified @port */
    err = tcp_bind(pcb, IP_ADDR_ANY, port);
    if (err != ERR_OK) {
        xil_printf("Unable to bind to port %d: err = %d\n\r", port, err);
        return -2;
    }

    /* we do not need any arguments to callback functions */
    tcp_arg(pcb, NULL);

    /* listen for connections */
    pcb = tcp_listen(pcb);
    if (!pcb) {
        xil_printf("Out of memory while tcp_listen\n\r");
        return -3;
    }

    /* specify callback to use for incoming connections */
    tcp_accept(pcb, accept_callback);

    xil_printf("TCP echo server started @ port %d\n\r", port);

    return 0;
}

-------------------------------------------------------------------------------------------------

I am sure it shouldnt be a big deal right?

Hope you understand what I am asking.

Thanks!!

Kepler Lima Ferreira

 

 

Link to comment
Share on other sites

Okay I just need a method to read a String from the received packets. Because I made a GUI in LabView, by pressing a button the user sends the string "Temperature" or "Humidity", and i need the board to read these differents strings to know which value it has to send. Thank you Jon, without you I would still be blocked!

Kepler

Link to comment
Share on other sites

Hello Jon,

Thanks a lot, it is working !!! That is exactly what I needed, but don't worry about the button, I mean the button I already have it in LabView. I just press it in the application and I send the string "Temperature" or "Humidity". So this part I already have done it. Now I just need to work on my sensors, to get the values.

Thanks again!

Kepler

Link to comment
Share on other sites

  • 6 months later...
On 1/21/2017 at 2:11 PM, Kepler Lima said:

Hello Jon,

Thanks a lot, it is working !!! That is exactly what I needed, but don't worry about the button, I mean the button I already have it in LabView. I just press it in the application and I send the string "Temperature" or "Humidity". So this part I already have done it. Now I just need to work on my sensors, to get the values.

Thanks again!

Kepler

Hi ! @Kepler Lima

I read all the correspondence on the "Zybo webserver" forum page you wanted to use ZYBO with some external sensors and send this data via Ethernet.

In the end, I saw that you succeeded in getting the system to work.
The idea sounds very interesting and I would also like to try it but I am having some problems.
I would be happy if you could contact me for a few questions.
Thank you!

Link to comment
Share on other sites

  • 1 month later...
On ‎1‎/‎20‎/‎2017 at 7:41 PM, jpeyron said:

Hi Kepler,

I was able to edit echo.c to be able to do what you are asking. I am working on adding a button press that will get displayed as well. Here is what i have right now.

cheers,

Jon

echo.txt

Jon,

I think I have a good understanding of how you have modified the echo server program to respond to the temperature and humidity queries.  What I am stuck on is how to get the Zedboard, in my case, initiate communications with a PC.  This would be after the all of the communications has already been established in this current example.  I plan on keeping the "echo" portion of this example intact since I would like the PC to be able to query the Zedboard as to the current temperature.

Taking the basic premise of what is being talked about here, I would like to have an interrupt service routine, or a timer, or even some code inside the infinite loop in main(), be able to periodically check the current temperature.  If it exceeds a threshold, I would like the Zedboard to initiate communications with the PC to let it know an alarm situation is present.  I understand how the recv_callback() function is working to process the incoming "echo" commands, but am stuck in understanding how the main() function, or other routine, is able to access the tcp_pcb datastructure necessary to initiate communications to the PC.  I think I understand how recv_callback() has been modified so it will send back our custom text, but I don't see to create the datastructure to initiate communications.  The Zedboard would always be talking to the same PC at a known IP address and port.

Any help or direction in how to proceed will be greatly appreciated.

Thanks,

Stu

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...