From c9897fe9b0f515b570237d790c0c2562f8eae5e2 Mon Sep 17 00:00:00 2001 From: Jesus Sanchez-Palencia Date: Mon, 23 Feb 2015 22:28:29 -0300 Subject: [PATCH] galileo: Add BSP files This patch creates the platform/galileo/bsp directory. This directory contain all files related to Galileo's Board Support Package (BSP). For now, the BSP consists of libc and bootloader. Within the BSP directory, we have the scripts build_newlib.sh and build_ grub.sh. These scripts provide an easy and quick way to build the newlib and the grub for the Galileo platform. --- .gitignore | 6 + platform/galileo/bsp/grub/build_grub.sh | 60 ++++++++++ platform/galileo/bsp/libc/build_newlib.sh | 105 ++++++++++++++++++ .../bsp/libc/patches/large64_files.patch | 11 ++ .../libc/patches/newlib_add_i586_elf.patch | 13 +++ 5 files changed, 195 insertions(+) create mode 100755 platform/galileo/bsp/grub/build_grub.sh create mode 100755 platform/galileo/bsp/libc/build_newlib.sh create mode 100644 platform/galileo/bsp/libc/patches/large64_files.patch create mode 100644 platform/galileo/bsp/libc/patches/newlib_add_i586_elf.patch diff --git a/.gitignore b/.gitignore index 0bccbc7b5..299193bae 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,9 @@ regression-tests/[0-9][0-9]-*/org/ # cscope files cscope.* + +# galileo bsp files +platform/galileo/bsp/libc/i586-elf/ +platform/galileo/bsp/libc/newlib-2.2.0-1* +platform/galileo/bsp/grub/src/ +platform/galileo/bsp/grub/bin/ diff --git a/platform/galileo/bsp/grub/build_grub.sh b/platform/galileo/bsp/grub/build_grub.sh new file mode 100755 index 000000000..6d33799e3 --- /dev/null +++ b/platform/galileo/bsp/grub/build_grub.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +JOBS=5 +HEAD="bac5d1a64ab4191058a8fd4c05f6b3b339e249e7" +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +prepare() { + if [[ ! -d ./src ]]; then + git clone git://git.savannah.gnu.org/grub.git src + fi + + pushd src + git checkout $HEAD + git clean -fdx + popd +} + +build() { + pushd src + + ./autogen.sh + ./configure --with-platform=efi --target=i386 + + make -j${JOBS} + + ./grub-mkimage -p /EFI/BOOT -d ./grub-core/ -O i386-efi -o grub.efi \ + boot efifwsetup efi_gop efinet efi_uga lsefimmap lsefi lsefisystab \ + exfat fat multiboot2 multiboot terminal part_msdos part_gpt normal \ + all_video aout configfile echo file fixvideo fshelp gfxterm gfxmenu \ + gfxterm_background gfxterm_menu legacycfg video_bochs video_cirrus \ + video_colors video_fb videoinfo video + + popd +} + +setup() { + mkdir -p bin + cp src/grub.efi bin/ +} + +cleanup() { + rm -rf ./src + rm -rf ./bin +} + +# This script will always run on its own basepath, no matter where you call it from. +pushd ${SCRIPT_DIR} + +case $1 in + -c | --cleanup) + cleanup + ;; + *) + prepare && build && setup + ;; +esac + +popd diff --git a/platform/galileo/bsp/libc/build_newlib.sh b/platform/galileo/bsp/libc/build_newlib.sh new file mode 100755 index 000000000..a187a7838 --- /dev/null +++ b/platform/galileo/bsp/libc/build_newlib.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +JOBS=5 +TARGET=i586-elf +VERSION=2.2.0-1 +MD5=94114fdc1d8391cdbc2653d89249cccf +TARBALL=newlib-${VERSION}.tar.gz + +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +# This script will always run on its own basepath, no matter where you call it from. +pushd ${SCRIPT_DIR} + +prepare() { + # If the source tarball doesn't exist of its md5 checksum doesn't match, download it. + if [ ! -e ./${TARBALL} ] || [ "$(md5sum ./${TARBALL} | cut -d' ' -f1)" != $MD5 ]; then + wget -c ftp://sources.redhat.com/pub/newlib/${TARBALL} + fi + + # Clean up the previous source dir, if any. + if [[ -d ./newlib-${VERSION} ]]; then + rm -rf ./newlib-${VERSION} + fi + + # Clean up the previous install dir, if any. + if [[ -d ./${VERSION} ]]; then + rm -rf ./${VERSION} + fi + + tar xf ${TARBALL} + cd newlib-${VERSION} + + for i in `ls ../patches/`; do patch -p0 < ../patches/${i}; done +} + + +build() { + export AR_FOR_TARGET=ar + export AS_FOR_TARGET=as + export CC_FOR_TARGET=cc + export GCC_FOR_TARGET=gcc + export CXX_FOR_TARGET=c++ + export RAW_CXX_FOR_TARGET=c++ + export GCJ_FOR_TARGET=gcj + export GFORTRAN_FOR_TARGET=gfortran + export GOC_FOR_TARGET=gccgo + export DLLTOOL_FOR_TARGET=dlltool + export LD_FOR_TARGET=ld + export LIPO_FOR_TARGET=lipo + export NM_FOR_TARGET=nm + export OBJDUMP_FOR_TARGET=objdump + export RANLIB_FOR_TARGET=ranlib + export READELF_FOR_TARGET=readelf + export STRIP_FOR_TARGET=strip + export WINDRES_FOR_TARGET=windres + export WINDMC_FOR_TARGET=windmc + export COMPILER_AS_FOR_TARGET=as + export COMPILER_LD_FOR_TARGET=ld + export COMPILER_NM_FOR_TARGET=nm + export CFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -DPREFER_SIZE_OVER_SPEED" + export CXXFLAGS_FOR_TARGET="-Os -m32 -march=i586 -mtune=i586 -DPREFER_SIZE_OVER_SPEED" + + mkdir -p install + ./configure --target=${TARGET} \ + --prefix=`pwd`/install \ + --enable-newlib-nano-formatted-io \ + --enable-newlib-nano-malloc \ + --enable-multithread \ + --disable-newlib-fvwrite-in-streamio \ + --disable-newlib-fseek-optimization \ + --disable-newlib-wide-orient \ + --disable-newlib-unbuf-stream-opt \ + --disable-libstdcxx \ + --disable-multilib \ + --disable-newlib-mb \ + --disable-newlib-supplied-syscalls + + make -j${JOBS} all && make install + cd .. +} + +setup() { + cp -r ./newlib-${VERSION}/install/${TARGET} . +} + +cleanup() { + rm -rf ./newlib-${VERSION}* +} + + +# By default we always call prepare, build and setup. +prepare && build && setup + +# But we only cleanup if -c is used. +case $1 in + -c | --cleanup) + cleanup + shift + ;; + *) + # unknown option + ;; +esac + +popd diff --git a/platform/galileo/bsp/libc/patches/large64_files.patch b/platform/galileo/bsp/libc/patches/large64_files.patch new file mode 100644 index 000000000..07d5aeeea --- /dev/null +++ b/platform/galileo/bsp/libc/patches/large64_files.patch @@ -0,0 +1,11 @@ +--- newlib/libc/include/sys/config.h 2015-01-14 07:25:15.000000000 -0200 ++++ newlib/libc/include/sys/config.h 2015-03-13 14:21:33.247980336 -0300 +@@ -94,9 +94,6 @@ + #define HAVE_GETDATE + #define _HAVE_SYSTYPES + #define _READ_WRITE_RETURN_TYPE _ssize_t +-#define __LARGE64_FILES 1 +-/* we use some glibc header files so turn on glibc large file feature */ +-#define _LARGEFILE64_SOURCE 1 + #endif + #endif diff --git a/platform/galileo/bsp/libc/patches/newlib_add_i586_elf.patch b/platform/galileo/bsp/libc/patches/newlib_add_i586_elf.patch new file mode 100644 index 000000000..20c444ba3 --- /dev/null +++ b/platform/galileo/bsp/libc/patches/newlib_add_i586_elf.patch @@ -0,0 +1,13 @@ +--- newlib/configure.host 2015-03-12 17:59:39.380318464 -0300 ++++ newlib/configure.host 2015-03-12 17:55:05.933645678 -0300 +@@ -810,6 +810,10 @@ + z8k-*-*) + syscall_dir=syscalls + ;; ++ i586-*-elf) ++ newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED" ++ syscall_dir=syscalls ++ ;; + *) + newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES" + syscall_dir=