Practical 2 - Advanced Software

Practical 2 - Advanced Software

Important

You will need an Ethernet cable to connect the FPGA board to the network. There should be plenty around, find one and connect it to the on-desk Ethernet jack (numbered CSE/X/XXX-XX) that doesn’t have a green sticker on it. The green network is some crazy thing that Mike Freeman invented to confuse us.

The purpose of this practical is to develop a larger application using the ARM and the Ethernet. The application you will develop is an Ethernet-based text chat program. You should be able to use the UART/serial to send messages to other students and to read any messages sent to you.

You will need to refer to the Software API page for a description of how to access the Ethernet, and send and receive packets.

Create a new blank application project (use the Blank Project template), then follow the instructions in the Ethernet section on the Software API page for adding the lwIP library and code.

Everyone is assigned a unique MAC address and your solution should set its MAC address accordingly. Your assigned MAC address and other network information can be found on the EMBS Student Network page. Try not to accidentally MAC-spoof your fellow students or anything else on the network! Always double-check your source and destination MACs are in the right places, and don’t echo back packets without changing these, as the network switches will not like this.

Your application should use DHCP to get an IP address, at least at first. These will be in the range 192.168.10.1XX  where XX is the last two characters of your MAC (not the last numerical byte). For example, if your MAC is 00:11:22:33:00:42 your assigned IP will be 192.168.10.142(as shown in the address table ).

An interaction with your application will look like this:

  • The user enters the last octet of the target IP address and presses Enter.
  • The user types a message and presses Enter.
  • The application sends the message to the specified target using port 51000. The message appears on the UART output of the target board.
  • Your solution should queue up all received messages in some data structure while the user is typing, then once the user has finished and sent their message your system should display in order all the queued messages. Note that if you just “don’t call handle_ethernet()“ then some amount of internal buffering will happen in the lwIP library, but for the purpose of this exercise don’t rely on this.

You should be able to communicate with each other, but there is also a server on the network sending periodic broadcast messages (cat facts) from the IP address 192.168.10.1.

The server that you are talking to is 192.168.10.1 and is listening and sending on UDP port 51000

If you send a message to this server, it will respond to you with a copy of the message you sent (unless you send “STOP”). This is useful for testing.

Task

Complete this task and then show Ian so that we can review your work.

Info

You will notice that assigning an IP from DHCP can sometimes be a little slow. Once you have got everything working, you can turn off DHCP in the platform settings, but remember to set DEFAULT_IP_ADDRESS at the top of platform.c to your IP address so that you don’t collide with another student.