OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ucos-ii/] [2.91/] [utils/] [bin2srec.c] - Blame information for rev 785

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 471 julius
#include <stdio.h>
2
 
3
#define SMARK "S214"
4
#define SADDR 0x000000
5
#define INIT_ADDR 0x100000
6
#define SCHKSUM 0xff
7
 
8
int main(int argc, char **argv)
9
{
10
 
11
        FILE  *fd;
12
        int c, i, j;
13
        unsigned long addr = INIT_ADDR;
14
        unsigned char chksum;
15
 
16
        if(argc < 2)
17
                error("no input file specified");
18
 
19
        fd = fopen( argv[1], "r" );
20
 
21
        while (!feof(fd)) {
22
                j = 0;
23
                chksum = SCHKSUM;
24
                printf("%s%.6lx", SMARK, addr);
25
                while (j < 16) {
26
                        c = fgetc(fd);
27
                        if (c == EOF) {
28
                                c = 0;
29
                        }
30
                        printf("%.2lx", c);
31
                        chksum -= c;
32
                        j++;
33
                }
34
 
35
                chksum -= addr & 0xff;
36
                chksum -= (addr >> 8) & 0xff;
37
                chksum -= (addr >> 16) & 0xff;
38
                chksum -= 0x14;
39
                printf("%.2lx\r\n", chksum);
40
                addr += 16;
41
        }
42
        return 0;
43
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.