21#include <basictypes.h>
22#include <PlatformHeader.h>
29#define NBUP_ERR_NO_ERR 0
30#define NBUP_ERR_BAD_SOCK -1
31#define NBUP_ERR_TIMEOUT -2
32#define NBUP_ERR_TOO_LARGE -3
33#define NBUP_ERR_WRONG_PLAT -4
34#define NBUP_ERR_BAD_PROG -5
35#define NBUP_ERR_BAD_AUTH -6
50extern const char PlatformName[];
52const uint16_t FLAG_DOING_S0 = 1;
53const uint16_t FLAG_DOING_S3 = 2;
54const uint16_t FLAG_DOING_S7 = 4;
55const uint16_t FLAG_SUS_VALID = 8;
56const uint16_t FLAG_SAW_FINALS7 = 16;
57const uint16_t FLAG_SAW_BINARY = 32;
58const uint16_t FLAG_DOING_BINARY = 64;
59const uint16_t FLAG_NEED_AUTH_CHARS = 128;
60const uint16_t FLAG_DONE_S0 = 0x100;
64 bool m_bWrittenToFlash;
71 PlatformFlashHeaderStruct bsus;
72 PlatformFlashHeaderStruct sus;
75#ifdef APP_BUFFER_VERIFY
87 bool ParseChars(
char *chars,
int nChars);
88 void ParseOneChar(
char c);
89 void PutValue(uint8_t v);
106 int DoFlashProgram();
110 if ((m_Error) || (m_ErrorNum) || (!pRecord) || (DataRead < sus.CompleteRecordSize() - sus.SizeWithoutPad()) ||
111 ((m_flags & FLAG_SAW_FINALS7) == 0) || (m_flags & FLAG_NEED_AUTH_CHARS))
116 const char *GetError() {
return m_Error; };
118 int GetErrorNum() {
return m_ErrorNum; }
122 m_ErrorNum = ERR_BAD_AUTH;
123 m_Error =
"Bad Authentication";
126 bool bWaitingOnAuth() {
return (((m_flags & FLAG_NEED_AUTH_CHARS) != 0) || (m_ErrorNum == ERR_BAD_AUTH)); }
128 uint32_t GetbaseAddress() {
return BaseAddress; };
130 uint32_t GetLength() {
return sus.CompleteRecordSize() - sus.SizeWithoutPad(); };
132 uint32_t GetFullLength() {
return bsus.CompleteRecordSize(); };
134 const uint8_t *GetData() {
return pRecord; };
136 bool IsBinary() {
return ((m_flags & FLAG_DOING_BINARY) != 0); }
138 int32_t GetRemainingLen() {
return (int32_t)bsus.CompleteRecordSize() - DataRead; }
149typedef AppAuthResult (*AppAuthenticateFunc)(AppUpdateRecord *ar, uint8_t *chars,
int n);
150extern AppAuthenticateFunc pAppAuthFunc;
int ProgramApplication(uint32_t where, uint8_t *pAppImage)
Program an appliction image into Flash memory.
int UpdateFromStream(int fd, AppUpdateRecord *&pu, uint32_t timeout)
Program/update an appliction image from a data stream.
void RegisterAppSigningPublicKey(const char *pKey)
Enable APP Signing by registering a RSA PEM or DER format public key.