You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

/*
* vtftp.c
*
* Created on: 2019-6-10
* Author: Administrator
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ti/ndk/inc/netmain.h>
#include <ti/ndk/inc/tools/servers.h>
#include <ti/ndk/inc/nettools/nettools.h>
#include <ti/ndk/inc/tools/console.h>
#include "vcmd.h"
uint32_t vtftp_load_file(char *ip, char *file, uint32_t mem)
{
IPN ipInt;
uint32_t filesize = 0x2000000; // 32M;
printf("tftp download file %s from %s to mem: 0x%x \r\n", file, ip, mem);
ConStrToIPN(ip, &ipInt);
if (NtTftpRecv(ipInt, file, (char *)mem, &filesize, NULL) < 0) {
printf("tftp download fail \r\n");
return 0;
}
printf("tftp file download success and filesize: %d \r\n", filesize);
return filesize;
}
int do_tftp(cmd_tbl_t tbl, int argc, char *argv[])
{
char *ip;
char *filename;
uint32_t mem_bass;
//IPN ipInt;
//uint32_t filesize = 0x2000000; // 32M
if (argc != 4) {
printf("usage: %s [ip] [file] [mem_addr] \r\n", argv[0]);
return -1;
}
ip = argv[1];
filename = argv[2];
mem_bass = strtoul(argv[3], NULL, 0);
vtftp_load_file(ip, filename, mem_bass);
return 0;
}
CON_CMD(tftp, "tftp down", NULL, do_tftp)