blob: 6cd2e4e8678fce6dbd63e7460cc81e4c079e9736 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/***************************************************************************
***
*** Copyright 2005 Hon Hai Precision Ind. Co. Ltd.
*** All Rights Reserved.
*** No portions of this material shall be reproduced in any form without the
*** written permission of Hon Hai Precision Ind. Co. Ltd.
***
*** All information contained in this document is Hon Hai Precision Ind.
*** Co. Ltd. company private, proprietary, and trade secret property and
*** are protected by international intellectual property laws and treaties.
***
****************************************************************************/
#include "lib_types.h"
#include "lib_string.h"
#include "lib_queue.h"
#include "lib_malloc.h"
#include "lib_printf.h"
#include "cfe_iocb.h"
#include "cfe_devfuncs.h"
#include "cfe_ioctl.h"
#include "cfe_timer.h"
#include "cfe_error.h"
#include "ui_command.h"
#include "cfe.h"
#include "cfe_fileops.h"
#include "cfe_boot.h"
#include "bsp_config.h"
#include "cfe_loader.h"
#include "net_ebuf.h"
#include "net_ether.h"
#include "net_api.h"
#include "cfe_flashimage.h"
#include "addrspace.h"
#include "initdata.h"
#include "url.h"
#include "tftpd.h"
int ui_init_tftpdcmds(void);
static int tftpd_state = TFTPD_STATE_OFF;
extern int tftp_recv_timeout;
int get_tftpd_state(void)
{
return tftpd_state;
}
int set_tftpd_state(int state)
{
tftpd_state = state;
return 0;
}
static int ui_cmd_tftpd(ui_cmdline_t *cmd,int argc,char *argv[])
{
int ret;
xprintf("enter ui_cmd_tftpd \n");
if( (argc==1) && strcmp(argv[0], "nmrp") == 0 )
{
xprintf("Start TFTP server for nmrp \n");
ret = ui_docommand("flashimage nmrp");
if (ret == CFE_ERR_TIMEOUT || ret == CFE_ERR_BADIMAGE || ret == CFE_ERR_IOERR || (ret == -24))
{
//printf("Upgrade image failed!\n");
return -1;
}
else
{
//printf("Upgrade image success!\n");
return 0;
}
}
else
{
xprintf("Start TFTP server\n");
/* Extend the TFTP server timeout */
tftp_recv_timeout = 99999;
while (1)
{
/* Foxconn modified start pling 12/04/2008 */
//ret = ui_docommand("flash -writechksum : flash1.trx");
ret = ui_docommand("flashimage :");
/* Foxconn modified end pling 12/04/2008 */
if (ret == CFE_ERR_TIMEOUT || ret == CFE_ERR_BADIMAGE || ret == CFE_ERR_IOERR)
continue;
else
break;
}
ui_docommand("reset");
return 0;
}
}
int ui_init_tftpdcmds(void)
{
cmd_addcmd("tftpd",
ui_cmd_tftpd,
NULL,
"Start TFTP server",
"tftpd",
"");
return 0;
}
|