aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortcsullivan <tullivan99@gmail.com>2018-12-02 14:18:36 -0500
committertcsullivan <tullivan99@gmail.com>2018-12-02 14:18:36 -0500
commit02d0bbc0a1d04afa97e560c2707129909aaf2625 (patch)
tree64a8d25fc3151dbf5a91e5c434a197b61b6b0b17
parent42eff60714a32942b307d6b139aa400ca0df296a (diff)
working toochain build script
-rw-r--r--.gitignore2
-rw-r--r--arm-stmos/README.md28
-rwxr-xr-xarm-stmos/create-toolchain.sh104
-rwxr-xr-xsrc/initrd/files/initbin12788 -> 12788 bytes
-rw-r--r--src/pdclib/Makefile2
-rw-r--r--src/pdclib/include/pdclib/_PDCLIB_int.h2
-rw-r--r--src/pdclib/platform/stmos/include/pdclib/_PDCLIB_config.h2
-rw-r--r--src/pdclib/platform/stmos/include/sys/types.h2
-rw-r--r--src/pdclib/platform/stmos/include/unistd.h6
9 files changed, 111 insertions, 37 deletions
diff --git a/.gitignore b/.gitignore
index 56b48db..7998dab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
*.swo
initrd.img
main.elf
+arm-stmos/gcc-8.2.0
+arm-stmos/binutils-2.31.1
diff --git a/arm-stmos/README.md b/arm-stmos/README.md
new file mode 100644
index 0000000..ba234f7
--- /dev/null
+++ b/arm-stmos/README.md
@@ -0,0 +1,28 @@
+# The arm-stmos toolchain
+
+A special binutils/gcc toolchain is necessary to build stmos and associated
+programs. For convenience, a bash script has been written to attempt to automate
+the majority of the compilation/installation process. This process is based of
+off various tutorials from [osdev.org](wiki.osdev.org).
+
+Some programs are required for the build process. A list can be found [here]
+(https://wiki.osdev.org/GCC_Cross-Compiler#Installing_Dependencies). Once
+installed, just run the script:
+```
+./create-toolchain.sh
+```
+It should be safe to re-run the script, if necessary.
+
+After successful installation, be sure to add the toolchain to your path ($HOME
+/arm-stmos/bin). Then, follow these steps to build pdclib and the crt0:
+* Cd to src/pdclib
+* Make sure the Makefile does not have the ```-g``` flag set under CFLAGS
+* Build pdclib (make)
+* Copy pdclib.a to ~/arm-stmos/lib/gcc/arm-stmos/8.2.0/libc.a
+* Add the ```-g``` flag to CFLAGS in the Makefile; Rebuild pdclib
+* Copy pdclib.a to ~/arm-stmos/lib/gcc/arm-stmos/8.2.0/libg.a
+* Cd to the stmos root directory; run ```make crt```
+* Copy crt0.o ~/arm-stmos/lib/gcc/arm-stmos/8.2.0/crt0.o
+
+Now everything should be ready. Build stmos, run it, hope it works.
+
diff --git a/arm-stmos/create-toolchain.sh b/arm-stmos/create-toolchain.sh
index 1df12ee..c197b2a 100755
--- a/arm-stmos/create-toolchain.sh
+++ b/arm-stmos/create-toolchain.sh
@@ -13,47 +13,83 @@
# libmpfr-dev
# Get sources
-wget https://ftp.gnu.org/gnu/binutils/binutils-2.31.1.tar.xz
-wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz
-tar xfv ./binutils-2.31.1.tar.xz
-tar xfv ./gcc-8.2.0.tar.xz
+if [ ! -d ./binutils-2.31.1 ]; then
+ wget https://ftp.gnu.org/gnu/binutils/binutils-2.31.1.tar.xz
+ tar xf ./binutils-2.31.1.tar.xz
+ rm ./binutils-2.31.1.tar.xz
+
+ # Apply binutils changes
+ for file in $(find ./binutils-files -name '*.*'); do
+ cp -v $file $(echo $file | sed s/binutils-files/binutils-2.31.1/)
+ done
+fi
+if [ ! -d ./gcc-8.2.0 ]; then
+ wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz
+ tar xf ./gcc-8.2.0.tar.xz
+ rm ./gcc-8.2.0.tar.xz
+
+ # Apply gcc changes
+ for file in $(find ./gcc-files -name '*.*'); do
+ cp -v $file $(echo $file | sed s/gcc-files/gcc-8.2.0/)
+ done
+fi
-# Apply binutils changes
-for file in $(find ./binutils-files -name '*.*'); do
- cp -v $file $(echo $file | sed s/binutils-files/binutils-2.31.1/)
-done
-# Apply gcc changes
-for file in $(find ./gcc-files -name '*.*'); do
- cp -v $file $(echo $file | sed s/gcc-files/gcc-8.2.0/)
-done
# Prepare
export TARGET=arm-stmos
-mkdir -p $HOME/$TARGET
-export PATH="$HOME/$TARGET/bin:$PATH"
+export PREFIX=$HOME/$TARGET
+mkdir -p $PREFIX
+export PATH="$PREFIX/bin:$PATH"
# Build binutils
-cd ./binutils-2.31.1/ld
-automake
-
-mkdir ../build
-cd ../build
-echo "Configure binutils... (../configure)"
-bash
-echo "Building binutils..."
-make -j8
-make install
+if ! [ -x "$(command -v $TARGET-as)" ]; then
+ echo "Starting binutils..."
+ cd ./binutils-2.31.1/ld
+ aclocal
+ automake
+
+ mkdir ../build
+ cd ../build
+ echo "Configuring binutils..."
+ ../configure --prefix=$PREFIX --target=$TARGET --with-sysroot --disable-nls
+ echo "Building binutils..."
+ make -j8
+ make install
+
+ echo "Binutils installed. Test if it works? (Ctrl+D to continue with gcc)"
+ bash
+else
+ echo "Binutils found, skipping..."
+ cd binutils-2.31.1/build
+fi
# Build gcc
-cd ../../gcc-8.2.0/libstdc++-v3/
-autoconf
-
-mkdir ../build
-cd ../build
-echo "Configure gcc... (../configure)"
-bash
-echo "Building gcc..."
-make -j8
-make install
+if ! [ -x "$(command -v $TARGET-gcc)" ]; then
+ if [ ! -d "$PREFIX/usr/include" ]; then
+ # Control will enter here if $DIRECTORY doesn't exist.
+ echo "Installing pdclib includes..."
+ mkdir -p $PREFIX/usr/include
+ cp -Rv ../../../src/pdclib/include/* $PREFIX/usr/include
+ cp -Rv ../../../src/pdclib/platform/stmos/include/* \
+ $PREFIX/usr/include
+ fi
+
+ cd ../../gcc-8.2.0/libstdc++-v3/
+ autoreconf
+ autoconf
+
+ mkdir ../build
+ cd ../build
+ echo "Configuring gcc..."
+ ../configure --prefix=$PREFIX --target=$TARGET --with-sysroot=$PREFIX \
+ --disable-nls --enable-languages=c,c++
+ echo "Building gcc..."
+ make all-gcc all-target-libgcc -j8
+ make install-gcc install-target-libgcc -j8
+else
+ echo "gcc found, skipping..."
+fi
+
+echo "All done :) enjoy"
diff --git a/src/initrd/files/init b/src/initrd/files/init
index 13ce410..7226a70 100755
--- a/src/initrd/files/init
+++ b/src/initrd/files/init
Binary files differ
diff --git a/src/pdclib/Makefile b/src/pdclib/Makefile
index 5d75638..0669c1a 100644
--- a/src/pdclib/Makefile
+++ b/src/pdclib/Makefile
@@ -27,7 +27,7 @@ ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
CC = arm-stmos-gcc -mcpu=cortex-m4 -mthumb -fsigned-char
WARNINGS := -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wuninitialized -Wstrict-prototypes -Wdeclaration-after-statement
-CFLAGS := -fPIC -Os -ffreestanding -std=c99 -I./testing -I./platform/stmos/include $(WARNINGS) $(USERFLAGS)
+CFLAGS := -fPIC -Os -g -ffreestanding -std=c99 -I./testing -I./platform/stmos/include $(WARNINGS) $(USERFLAGS)
.PHONY: all clean srcdist tests testdrivers regtests regtestdrivers todos fixmes help
diff --git a/src/pdclib/include/pdclib/_PDCLIB_int.h b/src/pdclib/include/pdclib/_PDCLIB_int.h
index 6eaded1..20f3a1f 100644
--- a/src/pdclib/include/pdclib/_PDCLIB_int.h
+++ b/src/pdclib/include/pdclib/_PDCLIB_int.h
@@ -12,7 +12,7 @@
/* would be considered a bug / missing feature: notify the author(s). */
/* -------------------------------------------------------------------------- */
-#include <stdbool.h>
+//#include <stdbool.h>
#include "pdclib/_PDCLIB_config.h"
#include "pdclib/_PDCLIB_aux.h"
diff --git a/src/pdclib/platform/stmos/include/pdclib/_PDCLIB_config.h b/src/pdclib/platform/stmos/include/pdclib/_PDCLIB_config.h
index 9731f86..3733edb 100644
--- a/src/pdclib/platform/stmos/include/pdclib/_PDCLIB_config.h
+++ b/src/pdclib/platform/stmos/include/pdclib/_PDCLIB_config.h
@@ -143,7 +143,7 @@ struct _PDCLIB_lldiv_t
#define _PDCLIB_SIG_ATOMIC INT
/* Result type of the 'sizeof' operator (must be unsigned) */
-#define _PDCLIB_size unsigned long
+#define _PDCLIB_size unsigned int
#define _PDCLIB_SIZE ULONG
/* Large enough an integer to hold all character codes of the largest supported
diff --git a/src/pdclib/platform/stmos/include/sys/types.h b/src/pdclib/platform/stmos/include/sys/types.h
new file mode 100644
index 0000000..53c0fe2
--- /dev/null
+++ b/src/pdclib/platform/stmos/include/sys/types.h
@@ -0,0 +1,2 @@
+// placeholder for gcc compilation
+
diff --git a/src/pdclib/platform/stmos/include/unistd.h b/src/pdclib/platform/stmos/include/unistd.h
new file mode 100644
index 0000000..4003d7c
--- /dev/null
+++ b/src/pdclib/platform/stmos/include/unistd.h
@@ -0,0 +1,6 @@
+#ifndef UNISTD_H_
+#define UNISTD_H_
+
+typedef int pid_t;
+
+#endif // UNISTD_H_