Classes | Macros | Typedefs | Enumerations | Functions | Variables
yprog.c File Reference
#include "ydef.h"
#include "yproto.h"
#include <dirent.h>
#include <sys/stat.h>
#include "yhash.h"
#include "yjson.h"
#include "yprog.h"
#include <stdio.h>
Include dependency graph for yprog.c:

Go to the source code of this file.

Classes

struct  ckReqHeadCtx
 

Macros

#define __FILE_ID__   "yprog"
 
#define Flash_ready()   1
 
#define setOsGlobalProgress(prog, msg)   osProgLogProgressEx(__FILE_ID__,__LINE__, prog, msg)
 
#define uGetBootloader(serial, ifaceptr)   yUSBGetBooloader(serial, NULL, ifaceptr,NULL)
 
#define ulog(str)   dbglog("%s",str)
 
#define ulogChar(val)   dbglog("%c",val)
 
#define uLogProgress(msg)   yProgLogProgress(msg)
 
#define ulogU16(val)   dbglog("%x",val)
 
#define ytime()   ((u32) yapiGetTickCount())
 

Typedefs

typedef int(* yprogTcpReqCb) (void *ctx, const char *buffer, u32 len, char *errmsg)
 

Enumerations

enum  FLASH_HUB_CMD {
  FLASH_HUB_AVAIL = 0u, FLASH_HUB_STATE, FLASH_HUB_FLASH, FLASH_HUB_NOT_BUSY,
  FLASH_HUB_NONE
}
 
enum  FLASH_TYPE { FLASH_USB = 0u, FLASH_NET_SELF, FLASH_NET_SUBDEV }
 

Functions

int BlockingRead (BootloaderSt *dev, USB_Packet *pkt, int maxwait, char *errmsg)
 
static int checkFirmwareFromWeb (const char *serial, char *out_url, int url_max_len, int *fullsize, char *errmsg)
 
static int checkHardwareCompat (BootloaderSt *dev, const char *pictype)
 
static int checkHTTPHeader (void *ctx, const char *buffer, u32 len, char *errmsg)
 
static int checkRequestHeader (void *ctx_ptr, const char *buffer, u32 len, char *errmsg)
 
static int getBootloaderInfos (const char *devserial, char *out_hubserial, char *errmsg)
 
static int getTCPBootloaders (void *ctx, const char *buffer, u32 len, char *errmsg)
 
int IsValidBynFile (const byn_head_multi *head, u32 size, const char *serial, u16 flags, char *errmsg)
 
int IsValidBynHead (const byn_head_multi *head, u32 size, u16 flags, char *errmsg)
 
static int isWebPath (const char *path)
 
static void osProgLogProgressEx (const char *fileid, int line, int prog, const char *msg)
 
const char * prog_GetCPUName (BootloaderSt *dev)
 
int SendDataPacket (BootloaderSt *dev, int program, u32 address, u8 *data, int nbinstr, char *errmsg)
 
static int sendHubFlashCmd (const char *hubserial, const char *subpath, const char *devserial, FLASH_HUB_CMD cmd, const char *args, char *errmsg)
 
YPROG_RESULT uFlashDevice (void)
 
static int uFlashFlash ()
 
static int uFlashZone ()
 
static int uGetDeviceInfo (void)
 
static int upload (const char *hubserial, const char *subpath, const char *filename, u8 *data, u32 data_len, char *errmsg)
 
static int uSendCmd (u8 cmd, FLASH_DEVICE_STATE nextState)
 
static int uSendErase (u16 firstPage, u16 nPages, FLASH_DEVICE_STATE nextState)
 
static void uSendReboot (u16 signature, FLASH_DEVICE_STATE nextState)
 
int ValidateBynCompat (const byn_head_multi *head, u32 size, const char *serial, u16 flags, BootloaderSt *dev, char *errmsg)
 
YRETCODE yapiCheckFirmware_internal (const char *serial, const char *rev, u32 flags, const char *path, char *buffer, int buffersize, int *fullsize, char *errmsg)
 
static YRETCODE yapiCheckFirmware_r (const char *serial, int current_rev, u16 flags, const char *path, char *buffer, int buffersize, int *fullsize, char *errmsg)
 
static YRETCODE yapiCheckFirmwareFile (const char *serial, int current_rev, u16 flags, const char *path, char *buffer, int buffersize, int *fullsize, char *errmsg)
 
YRETCODE yapiUpdateFirmware_internal (const char *serial, const char *firmwarePath, const char *settings, int force, int startUpdate, char *msg)
 
static int yDownloadFirmware (const char *url, u8 **out_buffer, char *errmsg)
 
static void * yFirmwareUpdate_thread (void *ctx)
 
static void yGetFirmware (u32 ofs, u8 *dst, u16 size)
 
static int yLoadFirmwareFile (const char *filename, u8 **buffer, char *errmsg)
 
int yNetHubGetBootloaders (const char *hubserial, char *buffer, char *errmsg)
 
int ypGetBootloaderReply (BootloaderSt *dev, USB_Packet *pkt, char *errmsg)
 
int ypIsSendBootloaderBusy (BootloaderSt *dev)
 
void yProgFree (void)
 
void yProgInit (void)
 
static void yProgLogProgress (const char *msg)
 
int ypSendBootloaderCmd (BootloaderSt *dev, const USB_Packet *pkt, char *errmsg)
 
static int yStartFirmwareUpdate (const char *serial, const char *firmwarePath, const char *settings, u16 flags, char *msg)
 
int yUSBGetBooloader (const char *serial, const char *name, yInterfaceSt *iface, char *errmsg)
 

Variables

FIRMWARE_CONTEXT fctx
 
BootloaderSt firm_dev
 
USB_Packet firm_pkt
 

Macro Definition Documentation

#define __FILE_ID__   "yprog"

Definition at line 40 of file yprog.c.

#define Flash_ready ( )    1

Definition at line 565 of file yprog.c.

#define setOsGlobalProgress (   prog,
  msg 
)    osProgLogProgressEx(__FILE_ID__,__LINE__, prog, msg)

Definition at line 571 of file yprog.c.

#define uGetBootloader (   serial,
  ifaceptr 
)    yUSBGetBooloader(serial, NULL, ifaceptr,NULL)

Definition at line 606 of file yprog.c.

#define ulog (   str)    dbglog("%s",str)

Definition at line 566 of file yprog.c.

#define ulogChar (   val)    dbglog("%c",val)

Definition at line 568 of file yprog.c.

#define uLogProgress (   msg)    yProgLogProgress(msg)

Definition at line 572 of file yprog.c.

#define ulogU16 (   val)    dbglog("%x",val)

Definition at line 567 of file yprog.c.

#define ytime ( )    ((u32) yapiGetTickCount())

Definition at line 564 of file yprog.c.

Typedef Documentation

typedef int(* yprogTcpReqCb) (void *ctx, const char *buffer, u32 len, char *errmsg)

Definition at line 1373 of file yprog.c.

Enumeration Type Documentation

Enumerator
FLASH_HUB_AVAIL 
FLASH_HUB_STATE 
FLASH_HUB_FLASH 
FLASH_HUB_NOT_BUSY 
FLASH_HUB_NONE 

Definition at line 1489 of file yprog.c.

enum FLASH_TYPE
Enumerator
FLASH_USB 
FLASH_NET_SELF 
FLASH_NET_SUBDEV 

Definition at line 1680 of file yprog.c.

Function Documentation

int BlockingRead ( BootloaderSt dev,
USB_Packet pkt,
int  maxwait,
char *  errmsg 
)

Definition at line 423 of file yprog.c.

static int checkFirmwareFromWeb ( const char *  serial,
char *  out_url,
int  url_max_len,
int *  fullsize,
char *  errmsg 
)
static

Definition at line 2268 of file yprog.c.

static int checkHardwareCompat ( BootloaderSt dev,
const char *  pictype 
)
static

Definition at line 181 of file yprog.c.

static int checkHTTPHeader ( void *  ctx,
const char *  buffer,
u32  len,
char *  errmsg 
)
static

Definition at line 1613 of file yprog.c.

static int checkRequestHeader ( void *  ctx_ptr,
const char *  buffer,
u32  len,
char *  errmsg 
)
static

Definition at line 1504 of file yprog.c.

static int getBootloaderInfos ( const char *  devserial,
char *  out_hubserial,
char *  errmsg 
)
static

Definition at line 1444 of file yprog.c.

static int getTCPBootloaders ( void *  ctx,
const char *  buffer,
u32  len,
char *  errmsg 
)
static

Definition at line 1375 of file yprog.c.

int IsValidBynFile ( const byn_head_multi head,
u32  size,
const char *  serial,
u16  flags,
char *  errmsg 
)

Definition at line 328 of file yprog.c.

int IsValidBynHead ( const byn_head_multi head,
u32  size,
u16  flags,
char *  errmsg 
)

Definition at line 243 of file yprog.c.

static int isWebPath ( const char *  path)
static

Definition at line 1724 of file yprog.c.

static void osProgLogProgressEx ( const char *  fileid,
int  line,
int  prog,
const char *  msg 
)
static

Definition at line 584 of file yprog.c.

const char* prog_GetCPUName ( BootloaderSt dev)

Definition at line 120 of file yprog.c.

int SendDataPacket ( BootloaderSt dev,
int  program,
u32  address,
u8 *  data,
int  nbinstr,
char *  errmsg 
)

Definition at line 436 of file yprog.c.

static int sendHubFlashCmd ( const char *  hubserial,
const char *  subpath,
const char *  devserial,
FLASH_HUB_CMD  cmd,
const char *  args,
char *  errmsg 
)
static

Definition at line 1688 of file yprog.c.

YPROG_RESULT uFlashDevice ( void  )

Definition at line 1047 of file yprog.c.

static int uFlashFlash ( )
static

Definition at line 871 of file yprog.c.

static int uFlashZone ( )
static

Definition at line 730 of file yprog.c.

static int uGetDeviceInfo ( void  )
static

Definition at line 613 of file yprog.c.

static int upload ( const char *  hubserial,
const char *  subpath,
const char *  filename,
u8 *  data,
u32  data_len,
char *  errmsg 
)
static

Definition at line 1631 of file yprog.c.

static int uSendCmd ( u8  cmd,
FLASH_DEVICE_STATE  nextState 
)
static

Definition at line 716 of file yprog.c.

static int uSendErase ( u16  firstPage,
u16  nPages,
FLASH_DEVICE_STATE  nextState 
)
static

Definition at line 856 of file yprog.c.

static void uSendReboot ( u16  signature,
FLASH_DEVICE_STATE  nextState 
)
static

Definition at line 842 of file yprog.c.

int ValidateBynCompat ( const byn_head_multi head,
u32  size,
const char *  serial,
u16  flags,
BootloaderSt dev,
char *  errmsg 
)

Definition at line 314 of file yprog.c.

YRETCODE yapiCheckFirmware_internal ( const char *  serial,
const char *  rev,
u32  flags,
const char *  path,
char *  buffer,
int  buffersize,
int *  fullsize,
char *  errmsg 
)

Definition at line 2333 of file yprog.c.

static YRETCODE yapiCheckFirmware_r ( const char *  serial,
int  current_rev,
u16  flags,
const char *  path,
char *  buffer,
int  buffersize,
int *  fullsize,
char *  errmsg 
)
static

Definition at line 2181 of file yprog.c.

static YRETCODE yapiCheckFirmwareFile ( const char *  serial,
int  current_rev,
u16  flags,
const char *  path,
char *  buffer,
int  buffersize,
int *  fullsize,
char *  errmsg 
)
static

Definition at line 2143 of file yprog.c.

YRETCODE yapiUpdateFirmware_internal ( const char *  serial,
const char *  firmwarePath,
const char *  settings,
int  force,
int  startUpdate,
char *  msg 
)

Definition at line 2362 of file yprog.c.

static int yDownloadFirmware ( const char *  url,
u8 **  out_buffer,
char *  errmsg 
)
static

Definition at line 1734 of file yprog.c.

static void* yFirmwareUpdate_thread ( void *  ctx)
static

Definition at line 1777 of file yprog.c.

static void yGetFirmware ( u32  ofs,
u8 *  dst,
u16  size 
)
static

Definition at line 536 of file yprog.c.

static int yLoadFirmwareFile ( const char *  filename,
u8 **  buffer,
char *  errmsg 
)
static

Definition at line 502 of file yprog.c.

int yNetHubGetBootloaders ( const char *  hubserial,
char *  buffer,
char *  errmsg 
)

Definition at line 1420 of file yprog.c.

int ypGetBootloaderReply ( BootloaderSt dev,
USB_Packet pkt,
char *  errmsg 
)

Definition at line 403 of file yprog.c.

int ypIsSendBootloaderBusy ( BootloaderSt dev)

Definition at line 388 of file yprog.c.

void yProgFree ( void  )

Definition at line 88 of file yprog.c.

void yProgInit ( void  )

Definition at line 76 of file yprog.c.

static void yProgLogProgress ( const char *  msg)
static

Definition at line 576 of file yprog.c.

int ypSendBootloaderCmd ( BootloaderSt dev,
const USB_Packet pkt,
char *  errmsg 
)

Definition at line 396 of file yprog.c.

static int yStartFirmwareUpdate ( const char *  serial,
const char *  firmwarePath,
const char *  settings,
u16  flags,
char *  msg 
)
static

Definition at line 2110 of file yprog.c.

int yUSBGetBooloader ( const char *  serial,
const char *  name,
yInterfaceSt iface,
char *  errmsg 
)

Definition at line 463 of file yprog.c.

Variable Documentation

Definition at line 64 of file yprog.c.

BootloaderSt firm_dev

Definition at line 67 of file yprog.c.

USB_Packet firm_pkt

Definition at line 68 of file yprog.c.



yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13