📄 genublapptext.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned int Uint32;
typedef unsigned char Uint8;
#define MAX_APP_SIZE (0x400000)
FILE *fOut;
FILE *fIn;
void genFiles(char* outFileName, Uint32 fileSize, Uint32 entryOffset, Uint32 flag, Uint8 *buffer) {
fOut = fopen(outFileName,"wb");
if (!fOut) {
fprintf(stderr,"coud not open %s\n",outFileName);
return;
}
fwrite(" ACK", (sizeof(char)),7,fOut);
fprintf(fOut,"%08x",fileSize);
fprintf(fOut,"%08x",entryOffset);
fprintf(fOut,"%08x",flag);
fwrite("0", (sizeof(char)),1,fOut);// 4 bytes of 0
fwrite("0", (sizeof(char)),1,fOut);
fwrite("0", (sizeof(char)),1,fOut);
fwrite("0", (sizeof(char)),1,fOut);
if(fileSize != fwrite(buffer, 1, fileSize, fOut))
{
printf("Error writing to Output File\n");
}
fclose(fOut);
}
int main(int argc, char **argv) {
int count;
unsigned char *ptr;
Uint32 flag;
Uint32 offset;
if(argc != 4)
{
printf("Usage: %s <Input File> <Entry Offset> <Flag>\n", argv[0]);
return -1;
}
printf("%s","Creating UBL UART mode Application Download File\n");
/* Open the input Image */
fIn = fopen (argv[1], "rb");
if(fIn == NULL)
{
printf("Unable to open %s\n", argv[1]);
return -1;
}
count = 0;
ptr = (unsigned char *) malloc (MAX_APP_SIZE);
if(ptr == NULL)
{
printf("Memory allocation failed\n");
fclose (fIn);
return -1;
}
offset = strtoul(argv[2], NULL, 16);
flag = strtoul(argv[3], NULL, 16);
while (!feof(fIn))
{
fread (&ptr[count], 1, 1, fIn);
count ++;
}
count --;
fclose (fIn);
genFiles("UBLAppFile.txt", count, offset, flag, ptr);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -