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.

Compiler/am4377: Starterware fopen fails

Expert 1060 points
Part Number: AM4377
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI C/C++ Compiler

Dear experts,

 

I have in trouble with using fopen function.

I'm trying to change flash writer not to use MMCSD. so I need to change the file open path from sd card to C drive.

But when I open the file, it returns NULL.

 

file type doesn't matter. bin and txt returns NULL. I also suspected wrong file path and folder permission but it doesn't work.

 

this is my environments.

AP: am437x

CCS Version: 6.1.2.00015

SDK: sysbios_ind_sdk_02.01.03.02

compiler: GNU v4.8.4 (Linaro)

REF project: qspi_app_flash_writer C:\ti\sysbios_ind_sdk_02.01.03.02\sdk\starterware\examples\qspi\flash_writer

file located in c:/flash/boot, and boot.txt for testing.

 

I just add stdio.h. Even though it is simple file operation as below, I have any clue to solve it.

 

if( (fp = fopen("C:\\flash\\boot","rb")) == NULL)

{

CONSOLEUtilsPrintf("\r\n 1. Unable to open file %s \r\n", fileName);

status = E_FAIL;

}

else

CONSOLEUtilsPrintf("\r\n 1. success \r\n");

 

if( (fp = fopen("C:\\flash\\boot.txt","r")) == NULL)

{

CONSOLEUtilsPrintf("\r\n 7. Unable to open file %s \r\n", fileName);

status = E_FAIL;

}

else

CONSOLEUtilsPrintf("\r\n 7. success \r\n");

 

Both operation return NULL.

Please give any guide.

 

Best Regards,

Jay.

  • The software team have been notified. They will respond here.
  • Hi Jay,

    What is the extension of the file ? Is boot a file or folder ? Can you go to command prompt(In Windows start run->command or in start search for command prompt ) and to the folder that has files and try dir command
  • Hi Dwarakesh,

    Thank you for your help.

    it is a file in the flash directory.

    boot is binary file converted from bootloader_boot_qspi_a9host_release_ti.bin.

    boot.txt is a text file which I created for file type testing.

    Bst Regards,

    Jay.

  • Hi Jay,

    Have you tried a standalone file open code(simple C code ), not as a part of SDK ? Does it work in that case ?
  • Hi,

    Please do a power cycle or system reset of your board, then try the standalone C code with syntax like fopen("c:\\flash\\app", "rb") to see if it works.

    Regards, Eric
  • Hi Dwarakesh, Eric

    Thank you for your help.

    I create simple prj for testing. but it doen't work.

    This file also need to debug becaue this prj can't use printf.

    Anyway I check the fopen poblem with step-over in debug. And still fopen returns NULL.

    fopen.zip

    Best Regards,

    jay.

  • Hi,

    I looked at your bare metal code for A9, with linker and startup.s and linked libraries. I tried on AM437x GP EVM and it returned NULL for file open. I am not sure if bare metal supports file I/O or some libraries are missing.

    As there are flash writer utilities under sysbios_ind_sdk_2.1.1.2\sdk\starterware\tools\flash_writer to open a file, can you try if that works for you?

    Regards, Eric
  • I checked your project and it looks like you don`t have Semi-hosting support enabled. You need to link into librdimon to add semi-hosting support for IO. Can you confirm that the printf statements are generating an output on CCS Console? This is easy way to confirm semi-hosting is enabled.

    This is required for all OS and non-OS related projects. Check Step 4 in the following url to see how to add librdimon:
    processors.wiki.ti.com/.../BIOS_with_GCC_(CortexA)  [Step 4]

    Hope this helps.

    Regards,
    Rahul

  • hi Eric,Rahaul

    I will test it in 3 days after come back from business trip.

    thank you for your help.

    best regards

    jay

  • hi Eric,

    Could you please give the previous link?

    Ind sdk link always points to the new version and I couldn't find old version.

    http://downloads.ti.com/sitara_indus/esd/SYSBIOSSDK-IND-SITARA/latest/index_FDS.html

    hi Rahul,

    I add librdimon and the "pirntf" works.

    But fopen doesn't work.

    Please let me know what I need to try more.

    Best Regards,

    Jay.

  • Jay,

    For the sysbios_ind_sdk_02.01.03.02, there also has the NAND/SPI writer under ysbios_ind_sdk_02.01.03.02\sdk\starterware\tools\flash_writer\src, those tools run on ARM core and opens a binary file with fopen to flash it.

    Will those example works for you? I saw in the CCS project, libc.a is added in linked library. The linker command also has rtsv5_A_le_eabi.lib linked.

    Regards, Eric
  • Hi Eric,

    Yes fopen works without error. But there's some problem using TI v5.2.5.

    I've tried to change the tool chain of qspi_app-flash_writer.pjt but I faced a lot of error.

    You might know that this project has dependancy and it occurs lots of error especially soc.pjt with TI tool chain.

    And second picture hard to correct the error.

    So I would like to stay with existing tool chain. Does GNU v4.8.4 has problem?

    I can not believe that this tool chain doesn't support standard C I/O.

    Please help me to use it.

    Best Reagrds,

    jay.

  • Jay,

    From the SYSBIOS_Industrial_SDK_02.01.03_Release_Notes.pdf, the tool used for this:

    Code Composer Studio (www.ti.com/.../ccstudio) version CCS 6.1.2.00015
    SYS/BIOS 6.45.01.29 Real Time Operating System
    XDC Tool 3.32.00.06
    Compiler GNU v4.8.4 (Linaro)
    NDK 2.24.3.35

    So please use Compiler GNU v4.8.4 (Linaro) for this.

    Regards, Eric
  • Hi Eric,

    Yes I also use exactly same environment you reffered to above. You can confirm my environment from the first thread.

    But the problem is NAND/SPI writer. It seems dedicated project for AM335X with TI v5.2.5. This .prj doesn't have build configuration for AM437x.

    As you recommended I checked NAND/SPI writer, yes it seems that can use fopen with TI v5.2.5. Because why I tryed to change qspi writer pjt with TI v5.2.5 but I faced lots of error.

    I just want to use file I/O with GNU v4.8.4. but there's any clue.

    Best Regards,

    Jay.