|
|
@ -5,6 +5,7 @@ |
|
|
|
#include <usrLib.h> |
|
|
|
#include <cacheLib.h> |
|
|
|
#include <sysSymTbl.h> |
|
|
|
#include <fcntl.h> |
|
|
|
#include "config.h" |
|
|
|
#if defined(INCLUDE_IPFTPS) |
|
|
|
#include <ipcom_sysvar.h> |
|
|
@ -19,6 +20,9 @@ int usr_ipftps_authenticate_nopasswd(Ipftps_session *session, char *password) |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#define VXWORKS_POS (0x400000) |
|
|
|
int lfsLowRawWrite(unsigned long offset, const char *buffer, int size); |
|
|
|
|
|
|
|
int loadUserApp() |
|
|
|
{ |
|
|
|
SEGMENT_ID seg; |
|
|
@ -43,7 +47,8 @@ int loadUserApp() |
|
|
|
if (symFind(sysSymTbl, &symDesc) == OK) { |
|
|
|
appEntry = (void (*)(void))(symDesc.value); |
|
|
|
printf("AppEntry: %p\r\n", appEntry); |
|
|
|
appEntry(); |
|
|
|
taskSpawn ("tUserApp", 100, 0, 0x10000, |
|
|
|
(FUNCPTR) appEntry,0,0,0,0,0,0,0,0,0,0); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
@ -64,3 +69,52 @@ int mw(unsigned long addr, unsigned int val) |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int updateVxWorks(const char *file, int pos) |
|
|
|
{ |
|
|
|
struct stat stbuf; |
|
|
|
size_t size; |
|
|
|
int fd, status; |
|
|
|
unsigned char *ptr; |
|
|
|
|
|
|
|
if (stat(file, &stbuf) != OK) { |
|
|
|
printf("Can't stat %s\r\n", file); |
|
|
|
return ERROR; |
|
|
|
} |
|
|
|
|
|
|
|
size = (stbuf.st_size + 0x10000 - 1) / 0x10000; |
|
|
|
size *= 0x10000; |
|
|
|
ptr = malloc(size); |
|
|
|
if (ptr == NULL) { |
|
|
|
printf("%s: out of memory\r\n", __FUNCTION__); |
|
|
|
return ERROR; |
|
|
|
} |
|
|
|
|
|
|
|
memset(ptr, 0xff, size); |
|
|
|
|
|
|
|
fd = open(file, O_RDONLY, 0); |
|
|
|
if (fd < 0) { |
|
|
|
printf("%s: can't open to read\r\n", __FUNCTION__); |
|
|
|
free(ptr); |
|
|
|
return ERROR; |
|
|
|
} |
|
|
|
printf("Reading: %d bytes\r\n", stbuf.st_size); |
|
|
|
size = read(fd, ptr, stbuf.st_size); |
|
|
|
close(fd); |
|
|
|
|
|
|
|
if (size != stbuf.st_size) { |
|
|
|
printf("%s: read size mismatch %d != filesize %d\r\n", __FUNCTION__, size, stbuf.st_size); |
|
|
|
free(ptr); |
|
|
|
return ERROR; |
|
|
|
} |
|
|
|
size = (stbuf.st_size + 0x100 - 1) / 0x100; |
|
|
|
size *= 0x100; |
|
|
|
printf("Write to flash\r\n"); |
|
|
|
if (pos <= 0) { |
|
|
|
pos = VXWORKS_POS; |
|
|
|
} |
|
|
|
status = lfsLowRawWrite(pos, ptr, size); |
|
|
|
free(ptr); |
|
|
|
printf("%s\r\n", status == OK ? "Success" : "Failed"); |
|
|
|
return status; |
|
|
|
} |
|
|
|