42 #include <sys/types.h>
48 #include "avrmalloc.h"
63 static int flash_load_from_bin_file (Flash *flash,
char *file);
76 extern inline uint16_t
flash_read (Flash *flash,
int addr);
89 storage_writew ((Storage *)flash, addr * 2, val);
100 storage_writeb ((Storage *)flash, addr * 2 + 1, val);
111 storage_writeb ((Storage *)flash, addr * 2, val);
139 storage_construct ((Storage *)flash, base, size);
142 for (i = 0; i < size; i++)
143 storage_writeb ((Storage *)flash, i, 0xff);
158 storage_destroy (flash);
169 return flash_load_from_bin_file (flash, file);
180 flash_load_from_bin_file (Flash *flash,
char *file)
186 fd = open (file, O_RDONLY);
188 avr_error (
"Couldn't open binary flash image file: %s: %s", file,
191 while ((res = read (fd, &inst,
sizeof (inst))) != 0)
194 avr_error (
"Error reading binary flash image file: %s: %s", file,
212 return storage_get_size ((Storage *)flash);
225 int size = storage_get_size ((Storage *)flash) / 2;
233 line[0] = last_line[0] =
'\0';
235 fprintf (f_core,
"Program Flash Memory Dump:\n");
236 for (i = 0; i < size; i++)
238 if (((i % ndat) == 0) && strlen (line))
240 if (strncmp (line, last_line, 80) == 0)
247 fprintf (f_core,
" -- last line repeats --\n");
248 fprintf (f_core,
"%04x : %s\n", i - ndat, line);
251 strncpy (last_line, line, 80);
254 snprintf (buf, 80,
"%04x ",
flash_read (flash, i));
255 strncat (line, buf, 80 - strlen(line) - 1);
259 fprintf (f_core,
" -- last line repeats --\n");
260 fprintf (f_core,
"%04x : %s\n", i - ndat, line);