查看: 3980|回复: 3

飞思卡尔BIN转S19软件

[复制链接]

该用户从未签到

7

主题

32

帖子

0

注册会员

Rank: 2

积分
66
最后登录
1970-1-1
发表于 2014-5-25 11:23:14 | 显示全部楼层 |阅读模式
 
谁有飞思卡尔BIN转S19软件,网上找到源程序,但不知道怎么弄;
 
#include
#include
#include
#include
 
#define LINE_BYTES                0x10
#define min(a, b)                ((a) < (b) ? (a) : (b))
 
static unsigned char data_buf[LINE_BYTES];
static char line_buf[64] = { 'S' };
 
static int str2hex(char *);
static void show_help(char *);
static int file_conv(FILE *, FILE *, unsigned long, size_t);
static int line_conv(size_t *, unsigned long);
 
int main(int argc, char **argv)
{
        int err;
        FILE *bin, *s19;
 
        if (argc < 5) {
                show_help(argv[0]);
                return EINVAL;
        }
 
        bin = fopen(argv[1], "rb");
        if (!bin) {
                err = errno;
                printf("cannot open file %s!\n", argv[1]);
                return err;
        }
 
        s19 = fopen(argv[4], "wb");
        if (!s19) {
                err = errno;
                printf("cannot open file %s!\n", argv[4]);
        } else {
                err = file_conv(bin, s19, str2hex(argv[2]), str2hex(argv[3]));
                fclose(s19);
        }
 
        fclose(bin);
        return err;
}
 
static int str2hex(char *s)
{
        int hex;
 
        sscanf(s, "%x", &hex);
        return hex;
}
 
static void show_help(char *app)
{
       printf("Usage:\n\t%s [bin-file] [offset] [size] [s19-file]\n", app);
}
 
static int file_conv(FILE *bin, FILE *s19, unsigned long offset, size_t size)
{
        int err;
        size_t rd_size;
 
        do {
 
                rd_size = fread(data_buf, 1, min(size, LINE_BYTES), bin);
                if (!rd_size)
                        break;
 
                err = line_conv(&rd_size, offset);
                size -= rd_size;
                offset += rd_size;
                fputs(line_buf, s19);
 
        } while (!err);
 
        return err;
}
 
static int line_conv(size_t *size, unsigned long offset)
{
        int i, err;
        size_t off_size;
        unsigned long checksum;
        char *p;
        unsigned char *off_buf;
 
        err = 0;
 
        if (offset + *size < *size) {
                printf("offset out of range!\n");
                err = EFBIG;
                *size = ~offset;
                if (!*size)
                        return err;
        }
 
        p = line_buf + 1;
 
        if (offset + *size > 0x1000000)
                off_size = 4;
        else if (offset + *size > 0x10000)
                off_size = 3;
        else
                off_size = 2;
 
        checksum = off_size + *size + 1;
 
        *p++ = '0' + off_size - 1;
        p += sprintf(p, "%02X", checksum);
 
        off_buf = (unsigned char *)(&offset);
        for (i = off_size - 1; i >= 0; i--) {
                p += sprintf(p, "%02X", off_buf);
                checksum += off_buf;
        }
 
        for (i = 0; i < *size; i++) {
                p += sprintf(p, "%02X", data_buf);
                checksum += data_buf;
        }
 
        checksum = ~checksum;
        p += sprintf(p, "%02X", checksum & 0xff);
 
        strcat(p, "\r\n");
 
        return err;
}
 
好像要用GCC编译什么的,

另外谁能提供个S19进行反汇编的软件啊,。。。。。。。。


QQ:595456785 
回复

使用道具 举报

该用户从未签到

16

主题

705

帖子

0

金牌会员

Rank: 6Rank: 6

积分
1745
最后登录
1970-1-1
发表于 2014-6-5 09:51:00 | 显示全部楼层

RE:飞思卡尔BIN转S19软件

bin 转S19,你装好CW后,根目录下就有一个burner软件,默认路径:
C:\Freescale\CW MCU v10.6\MCU\S12lisa_Tools\Build_Tools
具体操作你可以看这个链接:
https://www.nxpic.org.cn/bbs/article_412_195227.html
另外,关于反编译,看看这个链接,有个ppt,
https://www.eefocus.com/bbs/article_412_30617.html
回复 支持 反对

使用道具 举报

该用户从未签到

0

主题

88

帖子

0

注册会员

Rank: 2

积分
157
最后登录
2019-8-26
发表于 2014-6-19 15:01:47 | 显示全部楼层

RE:飞思卡尔BIN转S19软件

其实最好用的还是J-flash,打开一种格式,可以保存为其他任意的格式。
回复 支持 反对

使用道具 举报

该用户从未签到

3

主题

25

帖子

0

注册会员

Rank: 2

积分
132
最后登录
1970-1-1
发表于 2014-8-11 22:16:49 | 显示全部楼层

回复:飞思卡尔BIN转S19软件

回复第 3 楼 于2014-06-19 15:01:47发表:
其实最好用的还是J-flash,打开一种格式,可以保存为其他任意的格式。
 
 

确实,j-flash是免费工具,真好用
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2025-7-21 08:54 , Processed in 0.083242 second(s), 22 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表