Program to create files .ELF in Linux ??

Discussion in 'Sony Programming and Development' started by crosi, Dec 25, 2011.

Thread Status:
Not open for further replies.
  1. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    What kind of program I use to create file.ELF in Linux?
     
  2. PS2Guy

    PS2Guy Lost in the neverending abyss.

    Joined:
    Jan 18, 2011
    Messages:
    552
    Likes Received:
    2
    Do you know how to code??
     
  3. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    What I need is a program to write the code and save it as. ELF to be sent to TOOL.

    I am a bit novice ..
     
  4. PS2Guy

    PS2Guy Lost in the neverending abyss.

    Joined:
    Jan 18, 2011
    Messages:
    552
    Likes Received:
    2
    Codewarrior man.

    I don't know much about programming yet myself, (we're learning that this year at tech), but one of my teachers told me you need to know MIPS programming which is a different kettle of fish apparently??

    I don't know what the differences are yet, but to make an .ELF looks pretty straight forward to me.
     
  5. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    I saw that there are different versions of Codewarriors, which is what you use?
     
  6. PS2Guy

    PS2Guy Lost in the neverending abyss.

    Joined:
    Jan 18, 2011
    Messages:
    552
    Likes Received:
    2
    I've got Version 3.01 from the SDK download.
     
  7. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    runs on Linux?
     
  8. PS2Guy

    PS2Guy Lost in the neverending abyss.

    Joined:
    Jan 18, 2011
    Messages:
    552
    Likes Received:
    2
    Nah XP, there should already be programming tools that come with Linux. What version of CentOS did you install??
     
  9. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    CentOS 5.7
     
  10. l_oliveira

    l_oliveira Officer at Arms

    Joined:
    Nov 24, 2007
    Messages:
    3,879
    Likes Received:
    245
    What you use to create elfs is the SDK toolchain.

    Codewarrior is an IDE (it tells the toolchain to take the C source files you wrote) and do some voodoo with the libraries and header files, from that it makes an executable and linkable file (ELF). :nod:

    Same thing as you type make on a directory where all stuff is ready made (in this case make will perform the compile script and build your ELF file).

    So Codewarrior alone will not take you anywhere. :shrug:
     
  11. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    The problem is that I do not know what to use, then save everything. ELF
     
  12. SilverBull

    SilverBull Site Supporter 2010,2011,2013,2014,2015.SitePatron

    Joined:
    Jun 12, 2008
    Messages:
    385
    Likes Received:
    6
    Good luck :thumbsup:. I'm sure you'll have a lot of fun, and I really don't want to foil your enthusiasm, but please don't expect that you can "learn programming" in one year. Or, for that matter, any timeframe close to that. Depending on what you want to do in the field, it can take years. And advances you make in one area (like, say, application development) may either not help or completely poison your way of thinking for doing something different (e.g., systems-level programming).

    Just see it as a kind of sport. You can get the basics in a reasonable amount of time, but it takes a lot of hard training to get good at. No pain, no gain.
    [And I can't believe it was me who just did a sports comparison... :lol:]

    It is a question of which underlying system (or "layer") you want to work on; i.e., what your "programming model" (see it as a description of the environment your program runs in) is.

    If programming end-user applications in something like Java or .NET, you usually need not care on which machine architecture (single core, multi-core with shared memory, multi-core without shared memory, ...) you will be running. Your "programming model" will be what your runtime system has to offer (JVM, CLR, ...).

    In other environments, you may need to care on which machine type you run, what your instruction set has to offer (particularly for low-level operating system stuff like drivers), and sometimes even what particular kind of processor you are running on ("Is that weird semi-documented CPU bug, that I first heard about when eating a pizza with one of the hardware guys last week, also responsible for our program's crashes?").

    Now the bad news: there seems to be a tendency (at least from what I have heard) to educate students towards developing in high-level languages (like Java, .NET, Ruby, Python, HTML [yikes!] and JavaScript [!!YIKES!!] and so on). While I don't have anything against these languages or the people using them (To each his own), I think these languages are everything but ideal for beginners, at least not for every sub-field of software development imaginable.
    If you never have to worry about memory management (a common misconception of beginning Java and .NET developers), there is a certain chance you'll never get it right in languages like C where you absolutely need to do so, or your program goes ballistic. Likewise, if you are accustomed only to shared-memory multi-threaded programs, programming for really big clusters (= message-passing environments) will be extremely difficult. And there will still be issues your programming language and environment does not abstract away, which may also depend on your actual processor or programming environment; and this stuff will bite you eventually :evil: (just two keywords: double-checked locking in Java, and [beware of acute brain damage; read at your own risk] Memory Consistency Models).

    Comming back to the PS2: yes, the system uses a MIPS CPU (actually two of them, one accompanied by custom vector processors), but again depending on what you want to do, you may never need to come into contact with MIPS assembly language. I'd expect most applications on the PS2 being coded entirely in C, with absolutely no MIPS assembly written by the average programmer. There will be some parts of dvp assembler (sorry, no C for the vector units), but its nothing to worry about.

    What will be something to worry about (and you may have already interpreted that into some of the lines written above) is computer architecture. Like any embedded system, the PS2 differs in some key parts from regular machines, even those using MIPS processors: the way the CPU interacts with other components. Its no "standard MIPS" with some custom hardware thrown in for good measure, but the way this custom hardware is wired to the rest dictates what you can and need to do in software. You can get away with just ignoring that and hacking away (and for the first "Hello, World"-style programs, I actually encourage you to do so, even if it is just to come into contact with the more obscure aspects of the system), but please do not expect any decent performance then. The CPUs are too slow to do every data-type conversion on-the-fly; there is a reason that resources (such as textures, 3D models, sounds and so on) are delivered in pre-processed form on game discs, as it frees up valuable CPU time for more important things (enemy AI :rolleyes:).

    To create your ELFs: write your code (in C, MIPS ASM, DVP ASM, whatever), compile, link, run. Simple :Rock:.
    There are gcc versions (both from the Sony and homebrew SDK, the latter at ps2dev.org) for the PS2, and there is plenty of sample code available.
    I strongly suggest reading the official documentation (not the one for the Sony libraries, but the hardware docs), which if I remember correctly has also been included in a fairly recent edition (5th out of 6th?) in the official Linux kit; and this stuff should also be floating all around the net.

    Your Sony PS2 SDK has "sample" folders under both the EE and IOP branch, and each sample should have a readme with instructions on how to build and run it on the TOOL.

    Happy coding :033:.
     
    l_oliveira likes this.
  13. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    This is exactly what I was trying to do right now, but without success.


    ======================================================================
    EE Sample Program Compilation/Execution
    ----------------------------------------------------------------------
    By executing the following command under sce/ee/sample, all the sample
    program compilation is available. For individual compilation, please
    execute the make command under the directory where the program exists.

    $ make

    By executing the following command, the sample execution is available.

    $ make run

    Note:
    Some sample programs might not be executed by the command above.
    Refer to the respective readme_e.txt files for execution procedure.

    Also, the dsedb command is used to run the program. The dsedb command is
    originally for a debugger, but it is also used only to run the program.
    When the execute form file is sample.elf, for instance, input as follows:

    $ dsedb -d targetname (or IP address) -r run sample.elf

    To run the program by starting the debugger, input the following:

    $ dsedb -d targetname (or IP address)
    dsedb (Version x.x.xx................)
    *** Resetting...
    (type 'help' for getting help)

    dsedb > run sample.elf



    ======================================================================


    When I give the command make run basic3d (for example) gives me these errors:



    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample19.c | \
    sed 's/\(sample19\)\.o[ :]*/\1.o sample19.d :/g' > sample19.d; \
    [ -s sample19.d ] || rm -f sample19.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample18.c | \
    sed 's/\(sample18\)\.o[ :]*/\1.o sample18.d :/g' > sample18.d; \
    [ -s sample18.d ] || rm -f sample18.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample17.c | \
    sed 's/\(sample17\)\.o[ :]*/\1.o sample17.d :/g' > sample17.d; \
    [ -s sample17.d ] || rm -f sample17.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample16.c | \
    sed 's/\(sample16\)\.o[ :]*/\1.o sample16.d :/g' > sample16.d; \
    [ -s sample16.d ] || rm -f sample16.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample15.c | \
    sed 's/\(sample15\)\.o[ :]*/\1.o sample15.d :/g' > sample15.d; \
    [ -s sample15.d ] || rm -f sample15.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample14.c | \
    sed 's/\(sample14\)\.o[ :]*/\1.o sample14.d :/g' > sample14.d; \
    [ -s sample14.d ] || rm -f sample14.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample13.c | \
    sed 's/\(sample13\)\.o[ :]*/\1.o sample13.d :/g' > sample13.d; \
    [ -s sample13.d ] || rm -f sample13.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample12.c | \
    sed 's/\(sample12\)\.o[ :]*/\1.o sample12.d :/g' > sample12.d; \
    [ -s sample12.d ] || rm -f sample12.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample11.c | \
    sed 's/\(sample11\)\.o[ :]*/\1.o sample11.d :/g' > sample11.d; \
    [ -s sample11.d ] || rm -f sample11.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample10.c | \
    sed 's/\(sample10\)\.o[ :]*/\1.o sample10.d :/g' > sample10.d; \
    [ -s sample10.d ] || rm -f sample10.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample9.c | \
    sed 's/\(sample9\)\.o[ :]*/\1.o sample9.d :/g' > sample9.d; \
    [ -s sample9.d ] || rm -f sample9.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample8.c | \
    sed 's/\(sample8\)\.o[ :]*/\1.o sample8.d :/g' > sample8.d; \
    [ -s sample8.d ] || rm -f sample8.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample7.c | \
    sed 's/\(sample7\)\.o[ :]*/\1.o sample7.d :/g' > sample7.d; \
    [ -s sample7.d ] || rm -f sample7.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
    set -e
    ../../../gcc/bin/ee-gcc -M -I. -I../../../include -I../../../include sample6.c | \
    sed 's/\(sample6\)\.o[ :]*/\1.o sample6.d :/g' > sample6.d; \
    [ -s sample6.d ] || rm -f sample6.d
    /bin/sh: ../../../gcc/bin/ee-gcc: Permission denied
     
    Last edited: Dec 25, 2011
  14. l_oliveira

    l_oliveira Officer at Arms

    Joined:
    Nov 24, 2007
    Messages:
    3,879
    Likes Received:
    245
    Apparently you're running from an user account which is not authorized to access the directories where the toolchain is installed.

    I don't know much of UNIX so I can't really tell you how to fix, but I can tell you that each file on UNIX has a sort of tag which tell the system who has rights to access each file.

    If you're desperate, you could try to run make again but using the "superuser" account (root) but again, people will mostly advice you to do not as you can easily and mistakenly issue commands which can cause massive data loss. :nod:
     
  15. SilverBull

    SilverBull Site Supporter 2010,2011,2013,2014,2015.SitePatron

    Joined:
    Jun 12, 2008
    Messages:
    385
    Likes Received:
    6
    Summary: each user belongs to a list of groups, and each file and directory has RWX bits for exactly one user, group, and "all others".

    Try this:

    1. su -
    2. (Enter root password)
    3. cd /usr/local/sce
    4. chown -R <user>:<user> .
    5. exit
    That should change the ownership information for the entire /usr/local/sce tree to <user>, which you should replace by the user account name you want to use (e.g., if your regular user name is "crosi" without the quotes, issue "chown -R crosi:crosi").


    You are running make on the development PC, NOT on the TOOL, right?

    To list file owners and access rights, run "ls -lisa" (easy to remember, right? ;-)). You basically get 10 bits of flags+access rights for each file, for example: "-rwxr.xr.x". From left to right, these are:

    • One character: file type. "-" is a file, "d" a directory. There are others as well, but these are the most common.
    • 3 characters for the owning user, primary group and "all others" each.
    In each of the 3-character sets, it indicates Read, Write, and eXecute access. If you are the file owner (e.g., set via chown), the first set applies to you; if you are not the owner, but a member of the primary group of the file, the second set applies. Otherwise, the last one.


    Indeed. Be extremely careful what you enter in a root shell, you can easily destroy your entire installation if you issue a wrong command.
     
  16. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    I did everything you wrote above but I get the same error as before, it seems it does not run the Makefile.
    Then I did not understand how I can give the command to run dsedb which is contained in the / bin directory and sample files in the / ee / sample..come do you catch them from the directory without specifying the path?
     
  17. SilverBull

    SilverBull Site Supporter 2010,2011,2013,2014,2015.SitePatron

    Joined:
    Jun 12, 2008
    Messages:
    385
    Likes Received:
    6
    It does interpret the makefile, otherwise make would not know that it needs to run ee-gcc.

    Can you please issue the following commands (using the same user account with which compilation fails) and paste the output here?

    • whoami
    • groups
    • ls -lisa /usr/local/sce/ee/gcc/bin
    Insert something like this at the end of ~/.bash_profile of the respective user account:
    This appends the /bin directories from the PS2 SDK to your PATH variable, so they are searched whenever you enter a command.
    By setting DSNETM to your TOOL's IP address, you can avoid having to specify the -d parameter to SDK utilities. You can also use a name instead of an IP address if you have a suitable resolver like BIND running.
     
  18. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    [roberto@Host-001 /]$ whoami
    roberto
    [roberto@Host-001 /]$ groups
    roberto
    [roberto@Host-001 /]$ ls -lisa /usr/local/sce/ee/gcc/bin
    totale 47136
    1180722 8 drwxrwxrwx 2 roberto roberto 4096 22 dic 01:55 .
    1180721 8 drwxr-xr-x 10 roberto root 4096 22 dic 01:56 ..
    1180723 264 -rw-r--r-- 1 roberto roberto 260593 17 gen 2002 bison
    1180724 212 -rw-r--r-- 1 roberto roberto 207918 17 gen 2002 byacc
    1180725 80 -rw-r--r-- 1 roberto roberto 71688 17 gen 2002 cmp
    1180726 240 -rw-r--r-- 1 roberto roberto 237042 17 gen 2002 diff
    1180727 96 -rw-r--r-- 1 roberto roberto 89240 17 gen 2002 diff3
    1180728 1364 -rw-r--r-- 1 roberto roberto 1388229 17 gen 2002 ee-addr2line
    1180729 1296 -rw-r--r-- 1 roberto roberto 1318352 17 gen 2002 ee-ar
    1180730 2128 -rw-r--r-- 1 roberto roberto 2169068 17 gen 2002 ee-as
    1180732 340 -rw-r--r-- 1 roberto roberto 337854 17 gen 2002 ee-c++
    1180733 196 -rw-r--r-- 1 roberto roberto 189497 17 gen 2002 ee-c++filt
    1180731 340 -rw-r--r-- 1 roberto roberto 338613 17 gen 2002 ee-cpp
    1180734 1904 -rw-r--r-- 1 roberto roberto 1941389 17 gen 2002 ee-dvp-as
    1180735 252 -rw-r--r-- 1 roberto roberto 247291 17 gen 2002 ee-dvp-gasp
    1180739 340 -rw-r--r-- 1 roberto roberto 337854 17 gen 2002 ee-g++
    1180736 252 -rw-r--r-- 1 roberto roberto 247883 17 gen 2002 ee-gasp
    1180737 336 -rw-r--r-- 1 roberto roberto 333402 17 gen 2002 ee-gcc
    1180738 9304 -rw-r--r-- 1 roberto roberto 9505921 17 gen 2002 ee-gdb
    1180740 1800 -rw-r--r-- 1 roberto roberto 1833080 17 gen 2002 ee-ld
    1180741 1376 -rw-r--r-- 1 roberto roberto 1398719 17 gen 2002 ee-nm
    1180742 1812 -rw-r--r-- 1 roberto roberto 1846576 17 gen 2002 ee-objcopy
    1180743 2044 -rw-r--r-- 1 roberto roberto 2081848 17 gen 2002 ee-objdump
    1180744 1300 -rw-r--r-- 1 roberto roberto 1319347 17 gen 2002 ee-ranlib
    1180745 444 -rw-r--r-- 1 roberto roberto 443420 17 gen 2002 ee-readelf
    1180746 1228 -rw-r--r-- 1 roberto roberto 1248609 17 gen 2002 ee-size
    1180748 1228 -rw-r--r-- 1 roberto roberto 1245249 17 gen 2002 ee-strings
    1180747 1812 -rw-r--r-- 1 roberto roberto 1846571 17 gen 2002 ee-strip
    1180749 1480 -rw-r--r-- 1 roberto roberto 1506913 17 gen 2002 expect
    1180750 312 -rw-r--r-- 1 roberto roberto 307227 17 gen 2002 flex
    1180751 312 -rw-r--r-- 1 roberto roberto 307227 17 gen 2002 flex++
    1180752 20 -rw-r--r-- 1 roberto roberto 15135 17 gen 2002 gccbug
    1180753 184 -rw-r--r-- 1 roberto roberto 176369 17 gen 2002 gcov
    1180754 8 -rw-r--r-- 1 roberto roberto 2693 17 gen 2002 install-sid
    1180755 1384 -rw-r--r-- 1 roberto roberto 1406330 17 gen 2002 itclsh3.0
    1180756 3164 -rw-r--r-- 1 roberto roberto 3230017 17 gen 2002 itkwish3.0
    1180757 396 -rw-r--r-- 1 roberto roberto 396367 17 gen 2002 make
    1180758 212 -rw-r--r-- 1 roberto roberto 204937 17 gen 2002 patch
    1180759 8 -rw-r--r-- 1 roberto roberto 3002 17 gen 2002 runtest
    1180760 88 -rw-r--r-- 1 roberto roberto 80453 17 gen 2002 sdiff
    1180761 20 -rw-r--r-- 1 roberto roberto 14672 17 gen 2002 send-pr
    1180762 1160 -rw-r--r-- 1 roberto roberto 1176141 17 gen 2002 tclsh
    1180763 8 -rw-r--r-- 1 roberto roberto 2187 17 gen 2002 tixindex
    1180764 3556 -rw-r--r-- 1 roberto roberto 3629224 17 gen 2002 tixwish4.1.8.0
    1180765 2820 -rw-r--r-- 1 roberto roberto 2877422 17 gen 2002 wish
     
    Last edited: Dec 26, 2011
  19. SilverBull

    SilverBull Site Supporter 2010,2011,2013,2014,2015.SitePatron

    Joined:
    Jun 12, 2008
    Messages:
    385
    Likes Received:
    6
    Thanks. Did you notice that the "x" bit for all files is cleared? That's your problem, because Linux won't allow you to run them. Try this:

    chmod u+x -R /usr/local/sce
     
  20. crosi

    crosi Active Member

    Joined:
    Dec 21, 2011
    Messages:
    41
    Likes Received:
    0
    I ran both commands:

    1) chmod u+x -R /usr/local/sce
    2) # Location of Compilers and Utilities
    export PATH=$PATH:/usr/local/sce/bin:/usr/local/sce/ee/gcc/bin:/usr/local/sce/iop/gcc/bin
    # Hostname or IP Address of PS2 TOOL
    export DSNETM=ps2tool


    now what do I do to start from an example in the / ee?
     
Thread Status:
Not open for further replies.

Share This Page