unable to run compiled C code on minimorph

Home Forums MIPS Insider Meta Insider unable to run compiled C code on minimorph

This topic contains 9 replies, has 2 voices, and was last updated by  Sean 4 years, 7 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #64663



    I’m having trouble running software that I have written for the minimorph in C. The program is stored on the SD card, when I navigate to “/mnt” using the terminal on my linux mint host pc connected to the minimorph and run my code using “./c_code” (c_code being the name of the file), the output I get is ” line 1: syntax error: unexpected “(” “. When I try to run the code using the codescape debugger, I get “Error: Cannot open Program File”.

    I have tried running the program having booted the board from the SPI flash and with the “vmlinux.ub” file on the SD card and have had the same result.

    I wrote a simple Hello, World application and compiled it using the meta-linux gcc and was able to run that just fine.

    Do you know what could be wrong with my setup?



    that does sound slightly strange.

    When you say “compiled it using the meta-linux gcc and was able to run that just fine“, where did you run this?

    On your host, please let me know the output of
    $ file c_code



    I ran the “Hello, World” application through the terminal as well using:
    $ ./code_test

    The output of “file c_code” is:
    -sh: file: not found
    The same output is returned if i type “file filename.ext” for any file in the “/mnt” directory.



    So I can better understand your situation, please could you answer all of the following questions…

    1. Can you list the files in /mnt from a terminal on the minimorph?
    2. If you do a long listing (ls -l /mnt/), is there a filesize associated with the files?
    3. If you edit the file using vi, is it binary or text in the file.
      With a bracket on line 1, it sounds like it’s not been compiled correctly.
    4. Can you confirm that you compiled code_test or are you running the one provided in the SDK?
    5. What version of SDK do you have?




    The result of ” ls -l” is:
    -rwxr-xr-x 1 root root 27144 Sep 25 2013 X.bin
    -rwxr-xr-x 1 root root 2412975 Sep 25 2013 Y.bin
    -rwxr-xr-x 1 root root 16619 Oct 13 2013 c_code
    -rwxr-xr-x 1 root root 9264 Oct 13 2013 code_test
    -rwxr-xr-x 1 root root 897484 Sep 25 2013 test.bin
    -rwxr-xr-x 1 root root 6392605 Feb 7 2013 vmlinux.ub

    (The files “X.bin”, “Y.bin” and “test.bin” are files that will be used by my program.)
    If I type:
    $ vi c_code
    Into the terminal, the output is an unintelligible sequence of symbols so (definitely not a text file)

    I did not compile “code_test” from the SDK. The version of “code_test” I downloaded had no main function so I wrote my own and compiled it using the same make file (and kept the output name). My simple program uses “printf” to print “Hello, World” on the screen.

    I am using V1.9 of the SDK.



    Thanks for that – all looks good.

    With a copy of the c_code binary on your host system, use the file program (as discussed earlier) on your host system to identify the file type.

    I really need to know this information to proceed.




    The result of “file c_code” is:
    c_code: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x67cf02c22552ee09655a5e985f15aaad78c54c6f, not stripped



    Ok, so that’s the answer – if you run that on the included pre-compiled hello example, you’ll see something like the following:
    $ file hello
    hello: ELF 32-bit LSB executable, META, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

    Your example is compiled for x86-64, not Meta.

    You need to make sure you’ve got the CROSS_COMPILE variable setup if you are using a version of the make file detailed in the docs or ensure you run the meta gcc, not the one for building applications for your host system.




    I rebuilt my toolchain then re-registered the CROSS_COMPILE environment variable and was able to successfully compile my code and run it on the minimorph.

    Thank you. 🙂



    Great – good to hear you are up and running.



Viewing 10 posts - 1 through 10 (of 10 total)

Forums are currently locked.