@@ -66,6 +66,7 @@ int usage(void)
66
66
" [ --base <address> ]\n"
67
67
" [ --pagesize <pagesize> ]\n"
68
68
" [ --ramdisk_offset <address> ]\n"
69
+ " [ --dt <filename> ]\n"
69
70
" -o|--output <filename>\n"
70
71
);
71
72
return 1 ;
@@ -106,6 +107,8 @@ int main(int argc, char **argv)
106
107
char * cmdline = "" ;
107
108
char * bootimg = 0 ;
108
109
char * board = "" ;
110
+ char * dt_fn = 0 ;
111
+ void * dt_data = 0 ;
109
112
unsigned pagesize = 2048 ;
110
113
int fd ;
111
114
SHA_CTX ctx ;
@@ -157,6 +160,8 @@ int main(int argc, char **argv)
157
160
fprintf (stderr ,"error: unsupported page size %d\n" , pagesize );
158
161
return -1 ;
159
162
}
163
+ } else if (!strcmp (arg , "--dt" )) {
164
+ dt_fn = val ;
160
165
} else {
161
166
return usage ();
162
167
}
@@ -223,6 +228,14 @@ int main(int argc, char **argv)
223
228
}
224
229
}
225
230
231
+ if (dt_fn ) {
232
+ dt_data = load_file (dt_fn , & hdr .dt_size );
233
+ if (dt_data == 0 ) {
234
+ fprintf (stderr ,"error: could not load device tree image '%s'\n" , dt_fn );
235
+ return 1 ;
236
+ }
237
+ }
238
+
226
239
/* put a hash of the contents in the header so boot images can be
227
240
* differentiated based on their first 2k.
228
241
*/
@@ -233,6 +246,10 @@ int main(int argc, char **argv)
233
246
SHA_update (& ctx , & hdr .ramdisk_size , sizeof (hdr .ramdisk_size ));
234
247
SHA_update (& ctx , second_data , hdr .second_size );
235
248
SHA_update (& ctx , & hdr .second_size , sizeof (hdr .second_size ));
249
+ if (dt_data ) {
250
+ SHA_update (& ctx , dt_data , hdr .dt_size );
251
+ SHA_update (& ctx , & hdr .dt_size , sizeof (hdr .dt_size ));
252
+ }
236
253
sha = SHA_final (& ctx );
237
254
memcpy (hdr .id , sha ,
238
255
SHA_DIGEST_SIZE > sizeof (hdr .id ) ? sizeof (hdr .id ) : SHA_DIGEST_SIZE );
@@ -257,6 +274,10 @@ int main(int argc, char **argv)
257
274
if (write_padding (fd , pagesize , hdr .ramdisk_size )) goto fail ;
258
275
}
259
276
277
+ if (dt_data ) {
278
+ if (write (fd , dt_data , hdr .dt_size ) != hdr .dt_size ) goto fail ;
279
+ if (write_padding (fd , pagesize , hdr .dt_size )) goto fail ;
280
+ }
260
281
return 0 ;
261
282
262
283
fail :
0 commit comments