NetBurner 3.5.0
PDF Version
 
StreamUpdate.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
15/*
16 * The code module also contains functions to read and write the User Parameter
17 * section of onboard flash memory as a stream. They are here for compatibility
18 * with proir tools releases, but the recommended 3.x tools method is to use
19 * the application storage of the Configuration System, since it can be accessed
20 * through the Configuration Server and JSON objects.
21 */
22
34#ifndef _NB_STREAM_UP_H
35#define _NB_STREAM_UP_H
36
37#include <basictypes.h>
38
43#define STREAM_UP_FAIL (0)
44#define STREAM_UP_OK (1)
66
87
88// Send an application image as to an output stream in s-record S19 format
89int SendApplicationCodeAsS19(int fd);
90
91// Exposed to allow custom updates to be used
92int ProcessS3(const char *cp, uint32_t base_Addr, puint8_t CopyTo, uint32_t &cur_pos, uint32_t maxlen);
93
94//=================================== USER FLASH FUNCTIONS =========================================
95
96/*
97 * Send User Parameter Flash data as a binary output stream to the specified file
98 * descriptor.
99 *
100 * Parameters:
101 * int fd The socket file descriptor to send the data to
102 *
103 * Returns:
104 * STREAM_UP_OK The system was able to send the data
105 * STREAM_UP_FAIL The system failed to send the data
106 *
107 * See Also:
108 * int SendUserFlashToStreamAsS19(int fd);
109 * int ReadBinaryUserFlashFromStream(int fd);
110 * int ReadS19UserFlashFromStream(int fd);
111 */
112int SendUserFlashToStreamAsBinary(int fd);
113
114/*
115 * Send User Parameter Flash data as an ASCII s-record S19 output stream to the
116 * specified file descriptor.
117 *
118 * Parameters:
119 * int fd The socket file descriptor to send the data to
120 *
121 * Returns:
122 * STREAM_UP_OK The system was able to send the data
123 * STREAM_UP_FAIL The system failed to send the data
124 *
125 * See Also:
126 * int SendUserFlashToStreamAsBinary(int fd);
127 * int ReadBinaryUserFlashFromStream(int fd);
128 * int ReadS19UserFlashFromStream(int fd);
129 */
130int SendUserFlashToStreamAsS19(int fd);
131
132/*
133 * Read data from an ASCII s-record S19 input stream and store it in
134 * User Parameter Flash.
135 *
136 * Parameters:
137 * int fd The socket file descriptor to read data from
138 *
139 * Returns:
140 * STREAM_UP_OK The system was able to read the data and update flash
141 * STREAM_UP_FAIL The system failed to read or update
142 *
143 * See Also:
144 * int SendUserFlashToStreamAsS19(int fd);
145 * int SendUserFlashToStreamAsBinary(int fd);
146 * int ReadBinaryUserFlashFromStream(int fd);
147 */
148int ReadS19UserFlashFromStream(int fd);
149
150/*
151 * Read data from an binary input stream and store it in User Parameter Flash.
152 *
153 * Parameters:
154 * int fd The socket file descriptor to read data from
155 *
156 * Returns:
157 * STREAM_UP_OK The system was able to read the data and update flash
158 * STREAM_UP_FAIL The system failed to read or update
159 *
160 * See Also:
161 * int SendUserFlashToStreamAsS19(int fd);
162 * int SendUserFlashToStreamAsBinary(int fd);
163 * int ReadS19UserFlashFromStream(int fd);
164 */
165int ReadBinaryUserFlashFromStream(int fd);
166
167//=================================== UTILITY STRUCURES AND FUNCTIONS =========================================
168
169// Structure to hold the data from a update before actually programming it in flash
170struct TwoPartUpdateStruct
171{
172 uint8_t S0Record[24];
173 puint8_t pBlob;
174 uint32_t address;
175 uint32_t pgm_size;
176 int Result;
177
178 TwoPartUpdateStruct()
179 {
180 pBlob = 0;
181 Result = STREAM_UP_FAIL;
182 };
183};
184
185/*
186 * Populates the structure with an allocated binary buffer to program into flash.
187 * Returns STREAM_UP_OK, and sets structure result to STREAM_UP_OK if successful.
188 */
189int ReadTwoPartAppUdate(int fd, TwoPartUpdateStruct &us);
190
191/*
192 * Take a successfully read stream update and programs the flash memory.
193 * Returns STREAM_UP_FAIL if update fails.
194 * Forces a device reboot on success.
195 * Frees any dynamically allocated memory.
196 */
197int DoTwoPartAppUpdate(TwoPartUpdateStruct &us);
198
199/*
200 * Called to abort an update and free any dynamically allocated memory
201 */
202void AbortTwoPartAppUpdate(TwoPartUpdateStruct &us);
203
204#endif
205
int ReadBinaryApplicationCodeFromStream(int fd)
Read a binary application image from an input stream and program flash memory.
int ReadS19ApplicationCodeFromStream(int fd)
Read an ASCII application image in s-record .s19 format from an input stream and program flash memory...
#define STREAM_UP_FAIL
Action failed.
Definition StreamUpdate.h:43