Draft for downloading the firmware image.
Also: Fixed permissions for chmod in the example README.mdpull/7/head
parent
bce859cbfd
commit
189be76165
|
@ -66,6 +66,7 @@ OBJS:= \
|
|||
freeRTOS/stream_buffer.o \
|
||||
freeRTOS/tasks.o \
|
||||
freeRTOS/timers.o \
|
||||
freeRTOS/printf-stdarg.o \
|
||||
$(FREERTOS_PORT)/port.o \
|
||||
freeRTOS/portable/MemMang/heap_5.o \
|
||||
src/startup_mk64f12.o \
|
||||
|
|
|
@ -53,7 +53,7 @@ The public key allowed by the board is the ECDSA key provided in the wolfSSH exa
|
|||
First of all, change the permission of this example private key distributed with wolfSSH. A SCP client may refuse to use SSH keys that are publicly readable. This can be done via:
|
||||
|
||||
```
|
||||
chmod 0700 wolfssh/keys/hansel-key-ecc.pem
|
||||
chmod 0600 wolfssh/keys/hansel-key-ecc.pem
|
||||
```
|
||||
|
||||
To initiate a firmware update, transfer the file using scp. Use the '-i' option to force public-key based authentication using hansel's private key as follows:
|
||||
|
|
|
@ -255,21 +255,47 @@ static uint8_t scratch[SCRATCH_BUFFER_SIZE];
|
|||
static uint8_t fileBuffer[SCP_BUFFER_SIZE];
|
||||
static uint32_t fileBuffer_off = 0;
|
||||
|
||||
/*
|
||||
typedef int (*WS_CallbackScpRecv)(WOLFSSH*, int, const char*, const char*,
|
||||
int, word64, word64, word32, byte*, word32,
|
||||
word32, void*);
|
||||
typedef int (*WS_CallbackScpSend)(WOLFSSH*, int, const char*, char*, word32,
|
||||
word64*, word64*, int*, word32, word32*,
|
||||
byte*, word32, void*);
|
||||
*/
|
||||
static int default_filemode = 0700;
|
||||
|
||||
static int update_send_data(WOLFSSH* ssh, int state, const char* basePath,
|
||||
const char* fileName, int fileMode, word64 mTime, word64 aTime,
|
||||
word32 fw_sz, byte* buf, word32 bufSz, word32 fileOffset,
|
||||
void* ctx)
|
||||
/* CallbackScpSend */
|
||||
int update_send_data(WOLFSSH* ssh, int state, const char* peerRequest,
|
||||
char* fileName, word32 fileNameSz, word64* mTime, word64* aTime,
|
||||
int* fileMode, word32 fileOffset, word32* totalFileSz, byte* buf,
|
||||
word32 bufSz, void* ctx)
|
||||
{
|
||||
return -1;
|
||||
uint32_t base = 0xFFFFFFFF;
|
||||
static int part = 0;
|
||||
if (state == 0) {
|
||||
part = 0;
|
||||
return WS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((state == 6) && (part == 0) && peerRequest) {
|
||||
if (strcmp(peerRequest,"/boot.bin") == 0)
|
||||
part = 1;
|
||||
else if (strcmp(peerRequest,"/update.bin") == 0)
|
||||
part = 2;
|
||||
else
|
||||
return WS_SCP_ABORT;
|
||||
*fileMode = default_filemode;
|
||||
*totalFileSz = WOLFBOOT_PARTITION_SIZE;
|
||||
}
|
||||
if (part && (state == 6)) {
|
||||
if (part == 1)
|
||||
base = WOLFBOOT_PARTITION_BOOT_ADDRESS;
|
||||
else
|
||||
base = WOLFBOOT_PARTITION_UPDATE_ADDRESS;
|
||||
|
||||
if (bufSz > 0) {
|
||||
XMEMCPY(buf, base + fileOffset, bufSz);
|
||||
} else {
|
||||
return WS_EOF;
|
||||
}
|
||||
if (bufSz + fileOffset >= WOLFBOOT_PARTITION_SIZE)
|
||||
return WS_EOF;
|
||||
return bufSz;
|
||||
}
|
||||
return WS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -420,13 +446,6 @@ int wolfssh_socket_recv(WOLFSSH *ssh, void *_data, word32 len, void *_ctx)
|
|||
return pico_socket_read(cli, data, len);
|
||||
}
|
||||
|
||||
/* Custom file header interface for SCP */
|
||||
static char file_header[] = "C0700 0 UPDATE.BIN";
|
||||
char *scp_get_file_hdr(WOLFSSH *ssh)
|
||||
{
|
||||
return file_header;
|
||||
}
|
||||
|
||||
void MainTask(void *pv)
|
||||
{
|
||||
int res;
|
||||
|
|
|
@ -54,14 +54,10 @@ static inline int pico_recv(void *ssl, char *buf, int len, void *ctx)
|
|||
#define XMALLOC(s, h, type) pvPortMalloc((s))
|
||||
#define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
|
||||
#define XFREE(p, h, type) vPortFree((p))
|
||||
#define NO_SCP_TIMESTAMP
|
||||
#define NO_SCP_ENTER_DIRECTORY
|
||||
#define NO_WOLFSSH_CLIENT
|
||||
#define WSCPFILEHDR scp_get_file_hdr
|
||||
|
||||
#define TIME_OVERRIDES
|
||||
static inline long XTIME(long *x) { return xTaskGetTickCount() / configTICK_RATE_HZ;}
|
||||
//#define WTIME XTIME
|
||||
#define WOLFSSH_NO_TIMESTAMP
|
||||
#define NO_ASN_TIME
|
||||
#define WOLFSSL_USER_CURRTIME
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 52a1e13470c7619fa3bc86af1f0b59836d609fc9
|
||||
Subproject commit fa0102eb894e02d6a2bccf49cf67092896c334a9
|
Loading…
Reference in New Issue