This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好:
我们用的EVM板子是6678的, 想通过SPI NORFLASH直接加载. 我们根据SPI boot的例程的步骤对CCSv5.5生成的.out文件进行操作.第一步能通过hex6x的工具成功转换为btbl的格式.到了第二步要用b2i2c工具转换成.btbl.i2c格式的时候,b2i2c提示"Max input array size exceeded".我们用的.out文件大小为5,607KB,生成的.btbl文件大小为1757KB.
问题:b2i2c工具对于文件输入大小限制可否自行修改?如不能,该如何操作呢?
谢谢
注:我换成较小的.out 文件是可以成功boot 的
该工具支持最大的size应该为2M,我附上源码,你可以自己尝试修改max array size,重新编译做测试。
/* Create an ascii hex i2c data file */ #include <stdio.h> #include <malloc.h> unsigned onesComplementAdd (unsigned value1, unsigned value2) { unsigned result; result = (unsigned)value1 + (unsigned)value2; result = (result >> 16) + (result & 0xFFFF); /* add in carry */ result += (result >> 16); /* maybe one more */ result = (result & 0xffff); return (unsigned)result; } /* end of beth_ones_complement_add() */ int asciiByte (unsigned char c) { if ((c >= '0') && (c <= '9')) return (1); if ((c >= 'A') && (c <= 'F')) return (1); return (0); } int toNum (unsigned char c) { if ((c >= '0') && (c <= '9')) return (c - '0'); return (c - 'A' + 10); } void stripLine (FILE *s) { char iline[132]; fgets (iline, 131, s); } /* Read a .b file. */ unsigned long readBFile (FILE *s, unsigned char *data, unsigned long maxSize) { unsigned char x, y; unsigned long byteCount = 0; /* Strip the 1st two lines */ stripLine (s); stripLine (s); for (;;) { /* read the 1st ascii char */ do { x = fgetc (s); if (x == (unsigned char)EOF) return (byteCount); } while (!asciiByte(x)); /* Read the next ascii char */ y = fgetc (s); if (y == (unsigned char)EOF) return (byteCount); if (asciiByte(y)) data[byteCount++] = (toNum(x) << 4) | toNum (y); if (byteCount >= maxSize) { fprintf (stderr, "Max input array size exceeded\n"); return (-1); } } } int copyBlock (unsigned char *source, unsigned long idx, unsigned long maxSize, unsigned char *dest, unsigned long count) { unsigned long i; for (i = 0; i < count; i++) { if (idx >= maxSize) break; dest[i] = source[idx++]; } return (i); } void blockCheckSum (unsigned char *block, unsigned long blockSize) { unsigned checksum = 0; unsigned value; unsigned long i; if (blockSize & 0x0001) { fprintf (stderr, "program requires an even blocksize\n"); exit (-1); } for (i = 0; i < blockSize; i += 2) { value = (block[i] << 8) | block[i+1]; checksum = onesComplementAdd (checksum, value); } /* Put the checksum into the block starting at byte 2. Use big endian */ checksum = ~checksum; block[3] = checksum & 0xff; block[2] = (checksum >> 8) & 0xff; } #define SIZE (1024 * 1024 * 2) /* max array size 2MB */ int main (int argc, char *argv[]) { FILE *strin; FILE *strout; unsigned char *dataSet1; unsigned char *dataSet2; unsigned char block[128]; unsigned blockSize; unsigned long pIn; unsigned long pOut; unsigned long inSize; unsigned long i; /* Arg check */ if (argc != 3) { fprintf (stderr, "usage: %s infile outfile\n", argv[0]); return (-1); } /* Open the input file */ strin = fopen (argv[1], "r"); if (strin == NULL) { fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]); return (-1); } /* Allocate the two data set memories */ dataSet1 = malloc (SIZE * sizeof (unsigned char)); dataSet2 = malloc (SIZE * sizeof (unsigned char)); if ((dataSet1 == NULL) || (dataSet2 == NULL)) { fprintf (stderr, "%s: Malloc failure\n", argv[0]); return (-1); } /* Read the data into the byte stream */ if ((inSize = readBFile (strin, dataSet1, SIZE)) < 0) return (inSize); fclose (strin); /* Perform the i2c block formatting. The block size will be fixed at 128 bytes, * 2 bytes of length, 2 bytes checksum, 124 bytes of data. */ pIn = 0; pOut = 0; do { /* Copy the block, leave 4 bytes at the top */ blockSize = copyBlock (dataSet1, pIn, inSize, &block[4], 124); pIn += blockSize; /* advance to next data in source */ if (blockSize) { blockSize += 4; /* Add room for the header - big endian */ block[1] = blockSize & 0xff; block[0] = (blockSize >> 8) & 0xff; block[2] = block[3] = 0; /* Checksum the block */ blockCheckSum (block, blockSize); /* Copy the results to the destination block */ if ((pOut + blockSize) >= SIZE) { fprintf (stderr, "%s: destination array size exceeded\n", argv[0]); return (-1); } for (i = 0; i < blockSize; i++) dataSet2[pOut++] = block[i]; } } while (blockSize == 128); /* Copy the resulting data set into the output file in ccs format */ strout = fopen (argv[2], "w"); if (strout == NULL) { fprintf (stderr, "%s: Could not open %s for writing\n", argv[0], argv[2]); return (-1); } /* Write the two line header */ fprintf (strout, "%c\n$A000000\n", (unsigned char)2); /* Write out the data */ for (i = 0; i < pOut; i++) { if ( ((i+1)%24) ) fprintf (strout, "%02X ", dataSet2[i]); else fprintf (strout, "%02X\n", dataSet2[i]); } /* Write the close character */ fprintf (strout, "\n%c", (unsigned char)3); fclose (strout); return (0); }
你好 请问你的 norflash能启动码
我的启动不了,我用了工具转换链的 .bat批处理 转换成的.dat文件,在用my_spi_modify烧写工程
烧写过程:
1.转换.dat文件
2.断电,拨码开关设为noboot 模式 SW3~SW6 1000 0000 0000 1100 (0 对应on 1对应off)
3.上电,进入烧写工程,烧写
4.退出仿真器,断电,设为spi-boot模式,SW3~SW6:1011 0000 0010 1000 (0 对应on 1对应off)
结果起不来啊,能留个QQ:625477784