3 * Author : Robin Krens <robin@robinkrens.nl>
5 * Last Modified Date: 04.06.2022
6 * Last Modified By : Robin Krens <robin@robinkrens.nl>
15 #define SEGMENT_SIZE 0x10000
17 /* simple tool to pad 0xFF and to add ROM header
18 * romheader structure is as follows: */
20 struct __attribute__((__packed__)) rom_header {
36 static struct rom_header header = {
53 /* open for appending, so seek postion is at end */
54 fp = fopen("test.wsc", "a");
56 perror("can not open file");
60 unsigned pos = ftell(fp);
61 int gap = (SEGMENT_SIZE - pos) - sizeof(struct rom_header);
65 char dummy[SEGMENT_SIZE + 1];
66 memset(dummy, 0xFF, SEGMENT_SIZE);
68 unsigned wc = fwrite(dummy, sizeof(char), gap, fp);
69 wc += fwrite(&header, sizeof(char), sizeof(struct rom_header), fp);
72 printf("size of struct: %ld\n", sizeof(struct rom_header));
73 printf("pos: %d, gap to fill: %d\n", pos, gap);
74 printf("written %d\n", wc);