File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 2828 */
2929typedef struct _pbsys_program_load_data_header_t {
3030 /**
31- * How much to write on shutdown. This is reset to 0 on load, and should be
32- * set whenever any data is updated. This must always remain the first
33- * element of this structure.
31+ * How much to write on shutdown (and how much to load on boot). This is
32+ * reset to 0 in RAM on load, and should be set whenever any data is
33+ * updated. This must always remain the first element of this structure.
3434 */
3535 uint32_t write_size ;
3636 #if PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM
Original file line number Diff line number Diff line change @@ -38,6 +38,14 @@ typedef struct {
3838data_map_t pbsys_user_ram_data_map __attribute__((section (".noinit" ), used ));
3939static data_map_t * map = & pbsys_user_ram_data_map ;
4040
41+ /**
42+ * Sets write size to how much data must be written on shutdown. This is not
43+ * simply a boolean flag because it is also used as the load size on boot.
44+ */
45+ static void update_write_size (void ) {
46+ map -> header .write_size = sizeof (pbsys_program_load_data_header_t ) + map -> header .program_size ;
47+ }
48+
4149static bool pbsys_program_load_start_user_program_requested ;
4250static bool pbsys_program_load_start_repl_requested ;
4351
@@ -87,9 +95,11 @@ pbio_error_t pbsys_program_load_set_program_size(uint32_t size) {
8795 return PBIO_ERROR_BUSY ;
8896 }
8997
98+ // Update program size.
9099 map -> header .program_size = size ;
91- // Data was updated, so set the write size.
92- map -> header .write_size = size + sizeof (pbsys_program_load_data_header_t );
100+
101+ // Program size was updated, so set the write size.
102+ update_write_size ();
93103
94104 return PBIO_SUCCESS ;
95105}
You can’t perform that action at this time.
0 commit comments