Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos mbed
Fork of FRDM_K64F-Ethernet by
Revision 2:28ddb9b073ec, committed 2018-10-11
- Comitter:
- audim
- Date:
- Thu Oct 11 20:45:38 2018 +0000
- Parent:
- 1:2944c0d494ff
- Commit message:
- clean up some comments
Changed in this revision
env.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/env.h Thu Oct 11 15:25:58 2018 +0000 +++ b/env.h Thu Oct 11 20:45:38 2018 +0000 @@ -10,13 +10,13 @@ ** 8) type 'md.b 2000x00 100' and press Enter replace the x with the base address in the error message in the example above the error was at 33b, so enter 'md.b 2000300 100' and press Enter -** 9) find the 'filesize' entry in the memory dump, and edit the filesize value below to match +** 9) find the 'filesize' entry in the memory dump, and edit the filesize value below to match (case sensitive) ** 10) repeat steps 1 through 7 above, this time there should be no error message */ char *env_string[] = { "addargs=setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate sdhci-of.max_clock=$sdclk\n", "baudrate=115200\n", -"bootcmd=echo && echo This is a test environment. Must 'run upenv' against && echo production server to restore production environment.\n", +"bootcmd=echo && echo This is a test environment. Must \"run upenv\" against && echo production server to restore production environment.\n", "bootdelay=0\n", "bootdrive=sda1\n", "bootfile=uImage\n", @@ -28,10 +28,11 @@ "envimport=if mmc part 0 && fatload mmc 0:1 $loadaddr $ubootenv; then env -d import $loadaddr $filesize && saveenv; else echo \"Missing file: $ubootenv\"; fi'\n", "ethact=eTSEC1\n", "ethprime=eTSEC1\n", +"ethtest=tftpboot 1000000 $tftpdir/ethtest_bin && sleep 3 && tftpboot 2000000 $tftpdir/ethtest_bin && cmp.b 1000000 2000000 $filesize\n", "fdtaddr=ff0000\n", "fdtfile=p1022ipcu_dtb\n", "fileaddr=1000000\n", -"filesize=c5c\n", +"filesize=ce1\n", "flashfsfile=flashfs_jffs2\n", "flashfsoffset=A00000\n", "flashfssize=600000\n",
--- a/main.cpp Thu Oct 11 15:25:58 2018 +0000 +++ b/main.cpp Thu Oct 11 20:45:38 2018 +0000 @@ -1,8 +1,8 @@ /* ** Super lightweight, not at all robust, TFTP server for FRDM-K64F eval board. -** This tool supports read-only access to one file. It does not support NACK responses -** or timeouts. The tool is intended for use by our test department to check out Ethernet -** functionality on our main processor board. +** This tool supports read-only access to a couple of files. It does not support +** NACK responses or timeouts. The tool is intended for use by our test department +** to check out Ethernet functionality on our main processor board. ** ** 11 October 2018 ** - am @@ -73,11 +73,12 @@ int main (void) { + // Ethernet infrastructure EthernetInterface eth; UDPSocket tftp_server; Endpoint client; - // create data packet storage + // data packet storage tftp_packet_t packet; char *packet_ptr = (char *)&packet; @@ -98,12 +99,12 @@ led_waiting = LED_ON; tftp_server.bind(TFTP_PORT); tftp_server.receiveFrom(client, packet_ptr, sizeof(packet)); + led_waiting = LED_OFF; // if it's a read request if (ntohs(packet.opcode) == RRQ) { // and it's for the environment file if (!strncmp(packet.request.filename_and_mode, "/production/u-boot-env_txt", 26)) { - led_waiting = LED_OFF; // send file int i_block = 1; int i_string = 0; @@ -129,11 +130,40 @@ led_error = LED_OFF; }; } - // error, we only support the u-boot-env.txt file - else tftp_send_error(tftp_server, client, 0, "this test board only supports reading the u-boot-env.txt file"); + // or the binary test file + else if (!strncmp(packet.request.filename_and_mode, "/production/ethtest_bin", 23)) { + // send a 4M byte file (8192 512-byte blocks) + for (int block = 1; block < 8194; block++) { // blocks 1-8192 are full, block 8193 is empty (end of file) + led_connected = LED_ON; + packet.opcode = htons(DATA); + packet.data.block_number = htons(block); + // fill packet with Gray code + for (uint16_t w=0; w<256; w++) { + packet.data.data[w] = (char)((w>>1)^w); + packet.data.data[256+w] = ~packet.data.data[w]; + } + tftp_server.sendTo(client, packet_ptr, (block<8193) ? 516 : 4); // 4 = sizeof(opcode + block_number) + led_connected = LED_OFF; + led_error = LED_ON; + tftp_server.receiveFrom(client, packet_ptr, sizeof(packet)); // wait for ACK + led_error = LED_OFF; + } + } + // error, we only support a couple of files + else { + led_error = LED_ON; + tftp_send_error(tftp_server, client, 0, "file not found, this board only has u-boot-env_txt and ethtest_bin"); + wait(3); // three seconds + led_error = LED_OFF; + } } // error, we only support read requests - else tftp_send_error(tftp_server, client, 0, "this test board only supports reading the u-boot-env.txt file"); + else { + led_error = LED_ON; + tftp_send_error(tftp_server, client, 0, "this test board only supports read requests"); + wait(3); // three seconds + led_error = LED_OFF; + } led_connected = LED_ON; led_waiting = LED_ON;