Super lightweight, not at all robust, TFTP server for FRDM-K64F eval board.

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of FRDM_K64F-Ethernet by Rangel Alvarado

Super lightweight, not at all robust, TFTP server for FRDM-K64F eval board. This tool supports read-only access to two 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.

Committer:
audim
Date:
Thu Oct 11 20:45:38 2018 +0000
Revision:
2:28ddb9b073ec
Parent:
1:2944c0d494ff
clean up some comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
audim 1:2944c0d494ff 1 /* If you make any chnages to this file, then you must take the following steps.
audim 1:2944c0d494ff 2 ** 1) compile and upload this program to FRDM-K64F
audim 1:2944c0d494ff 3 ** 2) reset FRDM-K64F and wait for green light
audim 1:2944c0d494ff 4 ** 3) connect FRDM-K64F and IPCU 2 to the same Ethernet switch
audim 1:2944c0d494ff 5 ** 4) gain access to the IPCU 2 u-boot prompt
audim 1:2944c0d494ff 6 ** 5) type 'run upenv' and press Enter
audim 1:2944c0d494ff 7 ** 6) wait for green light
audim 1:2944c0d494ff 8 ** 7) type 'run chkenv' and press Enter
audim 1:2944c0d494ff 9 notice that there is an error, for example "byte at 0x0100033b (0x62) != byte at 0x0200033b (0x63)"
audim 1:2944c0d494ff 10 ** 8) type 'md.b 2000x00 100' and press Enter
audim 1:2944c0d494ff 11 replace the x with the base address in the error message
audim 1:2944c0d494ff 12 in the example above the error was at 33b, so enter 'md.b 2000300 100' and press Enter
audim 2:28ddb9b073ec 13 ** 9) find the 'filesize' entry in the memory dump, and edit the filesize value below to match (case sensitive)
audim 1:2944c0d494ff 14 ** 10) repeat steps 1 through 7 above, this time there should be no error message
audim 1:2944c0d494ff 15 */
audim 1:2944c0d494ff 16 char *env_string[] = {
audim 1:2944c0d494ff 17 "addargs=setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate sdhci-of.max_clock=$sdclk\n",
audim 1:2944c0d494ff 18 "baudrate=115200\n",
audim 2:28ddb9b073ec 19 "bootcmd=echo && echo This is a test environment. Must \"run upenv\" against && echo production server to restore production environment.\n",
audim 1:2944c0d494ff 20 "bootdelay=0\n",
audim 1:2944c0d494ff 21 "bootdrive=sda1\n",
audim 1:2944c0d494ff 22 "bootfile=uImage\n",
audim 1:2944c0d494ff 23 "chkenv=mw.b 1000000 0 1000 && tftpboot 1000000 $tftpdir/$ubootenv && mw.b 2000000 0 1000 && env export -t 2000000 && cmp.b 1000000 2000000 $filesize\n",
audim 1:2944c0d494ff 24 "consoledev=ttyS0\n",
audim 1:2944c0d494ff 25 "doboot=bootm $loadaddr - $fdtaddr;\n",
audim 1:2944c0d494ff 26 "dtboffset=180000\n",
audim 1:2944c0d494ff 27 "dtbsize=3500\n",
audim 1:2944c0d494ff 28 "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",
audim 1:2944c0d494ff 29 "ethact=eTSEC1\n",
audim 1:2944c0d494ff 30 "ethprime=eTSEC1\n",
audim 2:28ddb9b073ec 31 "ethtest=tftpboot 1000000 $tftpdir/ethtest_bin && sleep 3 && tftpboot 2000000 $tftpdir/ethtest_bin && cmp.b 1000000 2000000 $filesize\n",
audim 1:2944c0d494ff 32 "fdtaddr=ff0000\n",
audim 1:2944c0d494ff 33 "fdtfile=p1022ipcu_dtb\n",
audim 1:2944c0d494ff 34 "fileaddr=1000000\n",
audim 2:28ddb9b073ec 35 "filesize=ce1\n",
audim 1:2944c0d494ff 36 "flashfsfile=flashfs_jffs2\n",
audim 1:2944c0d494ff 37 "flashfsoffset=A00000\n",
audim 1:2944c0d494ff 38 "flashfssize=600000\n",
audim 1:2944c0d494ff 39 "flashhdboot=run sethdargs addargs;nand read $fdtaddr $dtboffset $dtbsize;nand read $loadaddr $kernoffset $kernsize; run doboot;\n",
audim 1:2944c0d494ff 40 "gatewayip=192.168.1.1\n",
audim 1:2944c0d494ff 41 "hostname=ipcu\n",
audim 1:2944c0d494ff 42 "hwconfig=esdhc;\n",
audim 1:2944c0d494ff 43 "ipaddr=192.168.1.100\n",
audim 1:2944c0d494ff 44 "kernoffset=200000\n",
audim 1:2944c0d494ff 45 "kernsize=800000\n",
audim 1:2944c0d494ff 46 "loadaddr=1000000\n",
audim 1:2944c0d494ff 47 "minimalboot=run setminimalargs addargs; nand read $fdtaddr $dtboffset $dtbsize; nand read $loadaddr $kernoffset $kernsize; run doboot;\n",
audim 1:2944c0d494ff 48 "minimalfsfile=rootfs_jffs2\n",
audim 1:2944c0d494ff 49 "minimalfsoffset=1000000\n",
audim 1:2944c0d494ff 50 "minimalfssize=F000000\n",
audim 1:2944c0d494ff 51 "monitor=1\n",
audim 1:2944c0d494ff 52 "netdev=eth0\n",
audim 1:2944c0d494ff 53 "netmask=255.255.255.0\n",
audim 1:2944c0d494ff 54 "nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath\n",
audim 1:2944c0d494ff 55 "nfsboot=run nfsargs addargs nfsget doboot;\n",
audim 1:2944c0d494ff 56 "nfsget=nfs $loadaddr $rootpath/boot/$bootfile; nfs $fdtaddr $rootpath/boot/$fdtfile;\n",
audim 1:2944c0d494ff 57 "ramboot=setenv bootargs root=/dev/ram rw console=$consoledev,$baudrate;tftp $ramdiskaddr $tftpdir/$ramdiskfile;tftp $loadaddr $tftpdir/$bootfile;tftp $fdtaddr $tftpdir/$fdtfile;bootm $loadaddr $tftpdir/$ramdiskaddr $fdtaddr\n",
audim 1:2944c0d494ff 58 "ramdiskaddr=2000000\n",
audim 1:2944c0d494ff 59 "ramdiskfile=uramdisk\n",
audim 1:2944c0d494ff 60 "rootpath=/opt/nfsroot\n",
audim 1:2944c0d494ff 61 "sdclk=22000000\n",
audim 1:2944c0d494ff 62 "serverip=192.168.1.10\n",
audim 1:2944c0d494ff 63 "sethdargs=setenv bootargs root=/dev/$bootdrive rw\n",
audim 1:2944c0d494ff 64 "setminimalargs=setenv bootargs tftpserver=$serverip tftpdir=$tftpdir root=/dev/mtdblock4 rw rootfstype=jffs2\n",
audim 1:2944c0d494ff 65 "tftpdir=/production\n",
audim 1:2944c0d494ff 66 "tftpkernel=setenv bootargs root=/dev/sda1 rw console=ttyS0,115200; tftpboot $loadaddr $tftpdir/$bootfile;tftpboot $fdtaddr $tftpdir/$fdtfile;run doboot\n",
audim 1:2944c0d494ff 67 "uboot=u-boot-nand_bin\n",
audim 1:2944c0d494ff 68 "ubootenv=u-boot-env_txt\n",
audim 1:2944c0d494ff 69 "updtb=tftpboot $loadaddr $tftpdir/$fdtfile; nand erase $dtboffset $filesize; nand write $loadaddr $dtboffset $filesize;\n",
audim 1:2944c0d494ff 70 "upenv=if tftpboot $loadaddr $tftpdir/$ubootenv; then env import -d $loadaddr $filesize && saveenv; else echo \"Missing file: $ubootenv\"; fi\n",
audim 1:2944c0d494ff 71 "upflashfs=tftpboot $loadaddr $tftpdir/$flashfsfile; nand erase $flashfsoffset $flashfssize; nand write $loadaddr $flashfsoffset $filesize;\n",
audim 1:2944c0d494ff 72 "upkernel=tftpboot $loadaddr $tftpdir/$bootfile; nand erase $kernoffset $filesize; nand write $loadaddr $kernoffset $filesize;\n",
audim 1:2944c0d494ff 73 "upminimal=tftpboot $loadaddr $tftpdir/$minimalfsfile; nand erase $minimalfsoffset $minimalfssize; nand write $loadaddr $minimalfsoffset $filesize;\n",
audim 1:2944c0d494ff 74 "upuboot=if tftpboot $loadaddr $tftpdir/$uboot; then nand erase 0 $filesize; nand write $loadaddr 0 $filesize; fi\n",
audim 1:2944c0d494ff 75 "usb_phy_type=ulpi\n",
audim 1:2944c0d494ff 76 "vtos=tftpboot 0x01000000 $tftpdir/vtos.ipcu.bin; go 0x01003000\n",
audim 1:2944c0d494ff 77 "\0" // end of table
audim 1:2944c0d494ff 78 };