22
22
#include <mmc.h>
23
23
#include <kubos.h>
24
24
#include <dfu.h>
25
+ DECLARE_GLOBAL_DATA_PTR ;
25
26
26
27
#define UPDATE_COUNT_ENVAR "kubos_updatecount"
27
28
#define DEV_ENVAR "kubos_updatedev"
@@ -86,8 +87,12 @@ int update_mmc(char * file, void * load_addr, char * dev_num)
86
87
int data_offset = (fit_size + 3 ) & ~3 ;
87
88
void * data_addr = load_addr + data_offset ;
88
89
89
- int max_size = gd -> start_addr_sp - data_addr - CONFIG_SYS_DFU_DATA_BUF_SIZE ;
90
- printf ("Max file size: %d\n" , max_size );
90
+ // U-Boot reserves memory for itself at the end of RAM, while we're loading
91
+ // the update file at the beginning.
92
+ // So the largest update entity we could possibly allow is the amount of
93
+ // space between the two, minus the room needed for the DFU chunk buffer,
94
+ // minus a little bit of wiggle room (1K)
95
+ int max_size = gd -> start_addr_sp - (unsigned long ) data_addr - CONFIG_SYS_DFU_DATA_BUF_SIZE - SZ_1K ;
91
96
92
97
// Validate the file
93
98
if (!fit_check_format (fit )) {
@@ -108,7 +113,7 @@ int update_mmc(char * file, void * load_addr, char * dev_num)
108
113
}
109
114
110
115
fit_image_name = (char * )fit_get_name (fit , noffset , NULL );
111
- printf ("Processing update '%s' :\n " , fit_image_name );
116
+ printf ("Processing update '%s' :" , fit_image_name );
112
117
113
118
// Get the update entity's size and offset
114
119
int update_offset , update_size ;
@@ -148,6 +153,8 @@ int update_mmc(char * file, void * load_addr, char * dev_num)
148
153
continue ;
149
154
}
150
155
156
+ printf ("\n" );
157
+
151
158
if (fit_image_check_type (fit , noffset ,
152
159
IH_TYPE_FIRMWARE )) {
153
160
ret = dfu_tftp_write (fit_image_name , (unsigned int ) data_addr ,
0 commit comments