📄 run
字号:
$ cd .../scratch $ gunzip < newlib-1.7.0.tar.gz | tar xf - New lib-1.7.0 had a few minor bugs (fixed in current): the header files float.h and ppc-asm.h were missing; the configure and Makefile's for the rs6000 (ppc) directory contained typos: $ cd .../scratch $ cd newlib-1.7.0 $ gunzip < ../newlib-1.7.0+float+ppc-asm.tar.gz | tar xvf - $ gunzip < ../newlib-1.7.0+ppc-fix.diff.gz | patch -p1 Finally copy the include files to where GCC will see them: $ cd .../scratch $ cd newlib-1.7.0/newlib/libc $ tar cf - include | \ ( cd /applications/psim/powerpc-unknown-eabi && tar xf - ) o Unpack/build gcc $ cd .../scratch $ gunzip < gcc-2.7.2,tar.gz | tar xf - $ cd gcc-2.7.2 $ ./configure --target=powerpc-unknown-eabi \ --prefix=/applications/psim $ make $ make install $ cd .. $ rm -rf gcc-2.7.2 Gcc likes to install its own dummy version of float that just returns an error. $ more /applications/psim/lib/gcc-lib/powerpc-unknown-eabi/2.7.2/include/float.h $ rm /applications/psim/lib/gcc-lib/powerpc-unknown-eabi/2.7.2/include/float.h o Finish building/installing newlib $ cd .../scratch $ cd newlib-1.7.0 $ ./configure --target=powerpc-unknown-eabi \ --prefix=/applications/psim Your path will need to include the recently installed gas/gcc when building. Either add it to your path or use: $ PATH=/applications/psim/bin:$PATH make $ PATH=/applications/psim/bin:$PATH make install o Finally, test out the build $ cat hello.c main() { printf("hello world\n"); } The binary is linked with an entry point less than 0x100000 (1mb) so that psim will recognize the binary as needing the BUG/OEA instead of the BSD/UEA runtime environment. $ powerpc-unknown-eabi-gcc -v -o hello \ -Wl,-Ttext,0x4000,-Tdata,0x10000 \ /applications/psim/powerpc-unknown-eabi/lib/mvme-crt0.o \ hello.c \ -lc -lmvme $ powerpc-unknown-eabi-objdump -h hello $ powerpc-unknown-eabi-run hello It is also possible to force psim to use a specific run-time environment using the -e option vis: $ powerpc-unknown-eabi-run -e bug hello ----------------------------------------------------------------------BUILDING A BSD/UEA DEVELOPMENT ENVIRONMENTBackground:For a UEA to be useful it needs a supporting run-time environment.PSIM implements a runtime environment based on the NetBSD system callinterface.More than any thing, this user level emulation was the firstimplemented because I happened to have the NetBSD source code lyingaround.Preparation:This requires the NetBSD-1.1 source tree online. It can either beobtained vi ftp: try http://www.netbsd.org or ftp://ftp.netbsd.orgAlternatively obtain one of the NetBSD cdrom's. Patches to this sourcetree that fill out much of the PowerPC code are available in: ftp://ftp.ci.com.au/pub/claytonFetch everything in that directory - diffs, tar archives and scripts.In addition patches to the bintuils and gcc are in: ftp://ftp.ci.com.au/pub/psim/binutils-2.6+note.diff.gz ftp://ftp.ci.com.au/pub/psim/gcc-2.7.2+sys-types.diff.gzwhile the compiler (gcc) and assember (binutils) can be found at yourfavorite gnu ftp site. I used versions: gcc-2.7.2.tar.gz binutils-2.6.tar.gzMethod:These notes are based on an installation performed on a Solaris2/x86host. For other hosts and other configurations, the below should beconsidered as a guideline only. o Sanity check I assume that you have already obtained the NetBSD-1.1 source code and unpacked it into the directory bsd-src. While the full NetBSD source tree may not be needed, things are easier if it is all online. $ cd .../scratch $ ls -1 binutils-2.6.tar.gz binutils-2.6+note.diff.gz clayton-include-960203.diff.gz clayton-lib-960203.diff.gz clayton-lib-960203.tar.gz clayton-sys-960203.diff.gz clayton-sys-960203.tar.gz clayton.chown.sh clayton.install.sh clayton.lorder.sh clayton.make.sh gcc-2.7.2.tar.gz gcc-2.7.2+sys-types.diff.gz make.tar.gz make.diff.gz o Prepare the destination directory ready for installation. Firstly create many of the needed directories (some are created automatically later): $ for d in \ /applications/psim \ /applications/psim/bsd-root \ /applications/psim/bsd-root/usr \ /applications/psim/bsd-root/usr/share \ /applications/psim/bsd-root/usr/share/doc \ /applications/psim/bsd-root/usr/share/doc/psd \ /applications/psim/bsd-root/usr/share/doc/psd/19.curses \ /applications/psim/bsd-root/usr/include \ /applications/psim/bsd-root/usr/lib \ /applications/psim/powerpc-unknown-eabi \ /applications/psim/powerpc-unknown-eabi/bin \ ; \ do test -d $d || mkdir $d ; done Next, link the BSD and GNU include directories together. GCC expects include files to be in one location while the bsd install expects them in a second. The link is in the direction below because bsd's install also insists on a directory (not a link) for its install destination. $ rm -rf /applications/psim/powerpc-unknown-eabi/include $ ln -s /applications/psim/bsd-root/usr/include \ /applications/psim/powerpc-unknown-eabi/include $ ls -l /applications/psim/powerpc-unknown-eabi/include lrwxr-xr-x 1 cagney wheel 39 Mar 21 18:09 /applications/psim/powerpc-unknown-eabi/include -> /applications/psim/bsd-root/usr/include o Build/install Berkeley make The tar archive make.tar.gz contains a recent snapshot of bmake from the NetBSD source tree. The notes below describe how to build/install it. If you have access to an even more recent version of bmake, use that. Unpack the source code: $ cd .../scratch $ gunzip < make.tar.gz | tar xf - $ cd make Apply the patch in make.diff.gz that fixes a minor problem with a build under Solaris (by now it should be fixed in the NetBSD-current source tree). $ gunzip < ../make.diff.gz | more $ gunzip < ../make.diff.gz | patch Build it $ make -f Makefile.boot 'CC=gcc -g -DPOSIX' With bmake built, install it into the target specific bin directory: $ cp bmake /applications/psim/powerpc-unknown-eabi/bin/make $ cd .. $ rm -rf make o Set up a number of wrapper scripts for bmake so that it works. In addition to needing BSD make the build process assumes a number of BSD specific commands. To get around this several wrapper scripts are available. powerpc-unknown-eabi-make (clayton.make.sh) Front end to Berkeley make setting it up for a cross compilation $ cp clayton.make.sh \ /applications/psim/bin/powerpc-unknown-eabi-make $ chmod a+x \ /applications/psim/bin/powerpc-unknown-eabi-make chown (clayton.chown.sh) Wrapper that does not do any thing. Avoids the need to be root when installing. $ cp clayton.chown.sh \ /applications/psim/powerpc-unknown-eabi/bin/chown $ chmod a+x \ /applications/psim/powerpc-unknown-eabi/bin/chown install (clayton.install.sh) Wrapper to strip away a number of bsd specific install arguments. $ cp clayton.install.sh \ /applications/psim/powerpc-unknown-eabi/bin/install $ chmod a+x \ /applications/psim/powerpc-unknown-eabi/bin/install lorder (clayton.lorder.sh) Tweaked lorder script that will use nm etc from binutils. $ cp clayton.lorder.sh \ /applications/psim/powerpc-unknown-eabi/bin/lorder $ chmod a+x \ /applications/psim/powerpc-unknown-eabi/bin/lorder printf (?) Some operating systems don't include the program printf. If you host doesn't have one, then a good source is the gnu sh-utils version. Again, if that program is missing, then I suggest installing it onto the powerpc specific program directory: /applications/psim/powerpc-unknown-eabi/bin o Unpack the bsd source code (if you haven't already) If you're short on disk space (like me) just unpack: sys, lib, share/mk, include, usr.sbin/config, usr.sbin/dbsym, gnu/lib/libg++/g++-include, usr.bin/lex Otherwize, assuming you have a CD-DRIVE: $ cd .../scratch $ mkdir bsd-src $ cd bsd-src $ for d in /cdrom/bsdisc_12_95_disc2/NetBSD-1.1/source/*11 do echo $d cat $d/*.?? | gunzip | tar xf - done Flatten the directory structure a little. $ mv usr/src/* . $ rmdir usr/src usr $ cd .. o Apply the clayton (PowerPC) patches to your constructed tree. $ cd .../scratch $ cd bsd-src Diffs are applied using something like: $ gunzip < ../clayton-include-960312.diff.gz | patch -p1 $ gunzip < ../clayton-lib-960203.diff.gz | patch -p1 $ gunzip < ../clayton-sys-960203.diff.gz | patch -p1 The patch to sys/dev/pci/ncr.c.rej might fail. The tar archives have a different problem, you need to remove the `src' prefix. I used $ ln -s . src $ gunzip < ../clayton-lib-960203.tar.gz | tar xvf - $ gunzip < ../clayton-sys-960203.tar.gz | tar xvf - So that src/xxx unpacked into ./xxx $ cd .. o install Berkeley make's include (mk) files. $ cd .../scrath $ cd bsd-src/share $ tar cf - mk | ( cd /applications/psim/bsd-root/usr/share \ && tar xvf - ) $ cd ../.. o Install the include files $ cd .../scratch $ cd bsd-src/include $ powerpc-unknown-eabi-make install $ cd ../.. o Install a few other include files. As discussed above in the section on building libnew, the build process can have chicken/egg problems. In the case of BSD's libc, it wants to use several include files (from the installed include directory) before they are installed. Just copy them in as seen below: $ cd .../scratch $ cd bsd-src $ cp gnu/lib/libg++/g++-include/values.h \ /applications/psim/powerpc-unknown-eabi/include $ cp lib/libcurses/curses.h \ /applications/psim/powerpc-unknown-eabi/include $ cd .. o Unpack/patch/build/install BINUTILS $ cd .../scratch $ gunzip < binutils-2.6.tar.gz | tar xf - gas (bfd) 2.6 didn't support the reading and writing of note sections. The patch binutils-2.6+note.diff.gz adds support for this. PowerPC/ELF boot files being loaded by OpenBoot ROM's should contain a PowerPC note section. $ cd .../scratch $ cd binutils-2.6/bfd $ gunzip < ../../binutils-2.6+note.diff.gz | more $ gunzip < ../../binutils-2.6+note.diff.gz | patch $ cd ../.. Then continue with the build $ cd .../scratch $ cd binutils-2.6 $ ./configure --target=powerpc-unknown-eabi \ --prefix=/applications/psim $ make $ make install $ cd .. $ rm -rf binutils-2.6 This has the intended side effect of partially populating the psim directory tree which makes follow on steps easier. o Unpack/patch/build/install GCC $ cd .../scratch $ gunzip < gcc-2.7.2.tar.gz | tar xf - $ cd gcc-2.7.2 GCC-2.7.2 and the BSD include files have a conflicting type declaration. The patch below gets around this problem (it may still be applicable to more recent versions of GCC): $ gunzip < ../gcc-2.7.2+sys-types.diff.gz | more $ gunzip < ../gcc-2.7.2+sys-types.diff.gz | patch If your version of GCC includes the file ginclude/ppc-asm.h then you should install that header file into the directory: /applications/psim/powerpc-unknown-eabi/include. More recent versions of GCC expect this file to be installed: $ test -r ginclude/ppc-asm.h \ && cp ginclude/ppc-asm.h \ /applications/psim/powerpc-unknown-eabi/include Other than that, assuming the include files installed okay, the rest should be fine .... $ ./configure --target=powerpc-unknown-eabi \ --prefix=/applications/psim $ make CC=gcc $ make CC=gcc install $ cd .. $ rm -rf gcc-2.7.2 o Build/install the Berkeley library: $ cd .../scratch $ cd bsd-src/lib $ powerpc-unknown-eabi-make $ powerpc-unknown-eabi-make install $ cd ../.. If you encounter problems check the following (each discussed above): o GCC and BSD have a common include directory o all the missing include files installed o all the wrapper programs installed o Build/run a simple BSD program $ cd .../scratch $ cd bsd-src/usr.bin/printenv $ powerpc-unknown-eabi-make $ powerpc-unknown-eabi-run printenv . . . ----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -