Part Number:EVMK2G
Tool/software: Code Composer Studio
Hi,
I Am trying to open an AAC file in binary mode and try reading a block of 2048 bytes. But, fread reads only 948 bytes. After that feof says file as reached end returning true.
I tried opening another AAC file binary mode reading block size of 2048 bytes now it read 1038 bytes, again it says it reached end of file. However both the file size in few 10's of KB's.
I tried opening normal text file in binary mode then read block of 2048 bytes then read was proper it was not eof since file had still much more content.
Even using file I/O seek SEEK_END file sizes returned are proper. When I checked content of respective files 948 and 1038 offsets I find character 0x1A (Ctrl+Z).
This behavior of interpreting Ctrl+Z as end of file is expected in when file is open in text mode. But, not sure Y this can happen in binary mode.
I am using CCSV8 and GCC version 6.
Below is code,
#include <stdio.h> int main(void) { FILE *infile = NULL; char buf[2048]; if ((infile = fopen("file.ac3","rb")) == NULL) { fprintf(stderr, "FIO: error opening input file\n"); return 1; } /* determine file length */ fseek(infile, 0, SEEK_END); printf("file size :%ld\n",ftell(infile)); rewind(infile); fread(buf, 1, 2048, infile); printf("file size :%ld\n",ftell(infile)); if(feof(infile)) { printf("file reached end of file\n"); } return 0; }
Below is my Makefile,
SYSBIOS=c:\ti\bios_6_73_00_12 XDCTOOLS=c:\ti\xdctools_3_50_08_24_core XDCPATH = $(SYSBIOS)/packages CONFIGURO = $(XDCTOOLS)/xs --xdcpath="$(XDCPATH)" xdc.tools.configuro -b config.bld TARGET = gnu.targets.arm.A15F PLATFORM = ti.platforms.evmTCI66AK2G02 CC = $(A15TOOLS)/bin/arm-none-eabi-gcc LDFLAGS = -nostartfiles -static -Wl,--gc-sections -Wl,-T,sysbios/linker.cmd -Wl,-Map,task.map -mfloat-abi=hard --specs=nosys.specs LDLIBS = -lgcc -lc -lm -lrdimon -L$(SYSBIOS)/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard --specs=nano.specs" linker.cmd : sysbios.cfg $(CONFIGURO) -c $(A15TOOLS) -t $(TARGET) -p $(PLATFORM) -r release $< all: linker.cmd $(CC) file_io.c @sysbios/compiler.opt $(LDFLAGS) -o file.out $(LDLIBS)
By XDC config file(sysbios.cfg) as enabled host mode support.
K2GEVM has XDS200 onboard JTAG, I would like to know flow of these file I/O over JTAG so that I can try out few more experiments to isolate cause of problem