From 91c617d0b26760b95463ac9161d643eb8e61f69c Mon Sep 17 00:00:00 2001 From: Amit Mahajan Date: Tue, 27 Oct 2009 15:35:37 +0530 Subject: [PATCH] Removed hard coded values of toolchain and gcc cpu flags --- SConstruct | 21 +++++++------- SConstruct.loader | 7 +++-- SConstruct.userlibs | 18 ++++++------ config/configuration.py | 25 +++++++++++++++++ config/lib.py | 1 + conts/bare_src/SConstruct | 32 +++++++++++----------- conts/libl4/SConscript | 5 +++- conts/libl4/SConstruct | 3 +- conts/libmem/SConscript | 5 +++- conts/libmem/SConstruct | 6 ++-- conts/posix/SConstruct | 3 +- conts/posix/bootdesc/SConscript | 6 ++-- conts/posix/bootdesc/SConstruct | 4 ++- conts/posix/libposix/SConstruct | 5 +++- conts/posix/mm0/SConstruct | 4 +-- conts/posix/mm0/tools/generate_bootdesc.py | 6 ++-- conts/posix/test0/SConstruct | 9 ++++-- loader/libs/c/SConstruct | 15 ++++++---- loader/libs/elf/SConstruct | 8 ++++-- scripts/conts/pack.py | 18 ++++++++---- scripts/conts/packall.py | 10 ++++--- scripts/linux/build_atags.py | 9 ++++-- scripts/linux/build_linux.py | 12 +++++--- scripts/linux/build_rootfs.py | 10 ++++--- scripts/loader/generate_loader_asm.py | 8 ++++-- tools/pyelf/lmamove.py | 1 + 26 files changed, 162 insertions(+), 89 deletions(-) diff --git a/SConstruct b/SConstruct index 8982459..ea3a84e 100644 --- a/SConstruct +++ b/SConstruct @@ -9,11 +9,18 @@ import configure from configure import * from os.path import * -env = Environment(CC = 'arm-none-eabi-gcc', +config = configuration_retrieve() +arch = config.arch +subarch = config.subarch +platform = config.platform +gcc_cpu_flag = config.gcc_cpu_flag +all_syms = config.all + +env = Environment(CC = config.kernel_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). - CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \ - '-std=gnu99', '-Wall', '-Werror'], + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \ + '-Werror', ('-mcpu=' + gcc_cpu_flag)], LINKFLAGS = ['-nostdlib', '-T' + "include/l4/arch/arm/linker.lds"], ASFLAGS = ['-D__ASSEMBLY__'], PROGSUFFIX = '.elf', # The suffix to use for final executable @@ -22,13 +29,6 @@ env = Environment(CC = 'arm-none-eabi-gcc', CPPPATH = "#include", CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__') - -config = configuration_retrieve() -arch = config.arch -subarch = config.subarch -platform = config.platform -all_syms = config.all - objects = [] objects += SConscript('src/drivers/SConscript', exports = {'symbols' : all_syms, 'env' : env}) objects += SConscript('src/generic/SConscript',exports = {'symbols' : all_syms, 'env' : env}) @@ -42,3 +42,4 @@ objects += SConscript('src/api/SConscript', exports = {'symbols' : all_syms, 'en kernel_elf = env.Program(BUILDDIR + '/kernel.elf', objects) Alias('kernel', kernel_elf) Depends(kernel_elf, 'include/l4/config.h') + diff --git a/SConstruct.loader b/SConstruct.loader index 83e7e9b..7f96a78 100644 --- a/SConstruct.loader +++ b/SConstruct.loader @@ -13,6 +13,7 @@ from config.projpaths import * config = configuration_retrieve() arch = config.arch platform = config.platform +gcc_cpu_flag = config.gcc_cpu_flag # Locally important paths are here LIBC_PATH = 'loader/libs/c' @@ -24,11 +25,11 @@ LIBELF_PATH = 'loader/libs/elf' LIBELF_LIBPATH = LIBELF_PATH LIBELF_INCPATH = '#' + join(LIBELF_PATH, 'include') -env = Environment(CC = 'arm-none-eabi-gcc', +env = Environment(CC = config.kernel_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). - CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \ - '-std=gnu99', '-Wall', '-Werror'], + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \ + '-Werror', ('-mcpu=' + gcc_cpu_flag)], LINKFLAGS = ['-nostdlib', '-T' + join(BUILDDIR, 'loader/linker.lds'), "-u_start"], ASFLAGS = ['-D__ASSEMBLY__'], PROGSUFFIX = '.elf', diff --git a/SConstruct.userlibs b/SConstruct.userlibs index 9a97f62..330883b 100644 --- a/SConstruct.userlibs +++ b/SConstruct.userlibs @@ -9,11 +9,18 @@ import configure from configure import * from os.path import * -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +config = configuration_retrieve() +arch = config.arch +subarcn = config.subarch +platform = config.platform +gcc_cpu_flag = config.gcc_cpu_flag +all_syms = config.all + +env = Environment(CC = config.user_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). - CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \ - '-std=gnu99', '-Wall', '-Werror'], + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \ + '-Werror', ('-mcpu=' + gcc_cpu_flag)], LINKFLAGS = ['-nostdlib'], ASFLAGS = ['-D__ASSEMBLY__'], ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path @@ -21,11 +28,6 @@ env = Environment(CC = 'arm-none-linux-gnueabi-gcc', CPPPATH = "#include", CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') -config = configuration_retrieve() -arch = config.arch -subarch = config.subarch -platform = config.platform -all_syms = config.all libl4 = SConscript('conts/libl4/SConscript', \ diff --git a/config/configuration.py b/config/configuration.py index 2ac59d1..4bd89b5 100644 --- a/config/configuration.py +++ b/config/configuration.py @@ -52,9 +52,24 @@ class Container: class configuration: def __init__(self): + # Mapping between platform selected and gcc flags for it + self.cpu_to_gcc_flag = (['PB926', 'arm926ej-s'], + ['CORTEXA8', 'cortex-a8'], + ['ARM11MPCORE', 'mpcore'], + ['CORTEXA9', 'cortex-a9'], + ['ARM1136', 'arm1136jf-s'], + ['ARM1176', 'arm1176jz-s'],) + + # Mapping between the processor architecture and toolchain + self.toolchain_kernel = (['ARM', 'arm-none-eabi-'],) + self.toolchain_user = (['ARM', 'arm-none-linux-gnueabi-'],) + self.arch = None self.subarch = None self.platform = None + self.gcc_cpu_flag = None + self.user_toolchain = None + self.kernel_toolchain = None self.all = [] self.containers = [] self.ncontainers = 0 @@ -72,10 +87,17 @@ class configuration: return None # Extract architecture from a name value pair + # And based on this define the toolchains to be used def get_arch(self, name, val): if name[:len("CONFIG_ARCH_")] == "CONFIG_ARCH_": parts = name.split("_", 3) self.arch = parts[2].lower() + for i in self.toolchain_kernel: + if i[0] == parts[2]: + self.kernel_toolchain = i[1] + for i in self.toolchain_user: + if i[0] == parts[2]: + self.user_toolchain = i[1] # Extract subarch from a name value pair def get_subarch(self, name, val): @@ -88,6 +110,9 @@ class configuration: if name[:len("CONFIG_PLATFORM_")] == "CONFIG_PLATFORM_": parts = name.split("_", 3) self.platform = parts[2].lower() + for i in self.cpu_to_gcc_flag: + if i[0] == parts[2]: + self.gcc_cpu_flag = i[1] # Extract number of containers def get_ncontainers(self, name, val): diff --git a/config/lib.py b/config/lib.py index 6fbda20..e3ce7eb 100644 --- a/config/lib.py +++ b/config/lib.py @@ -7,3 +7,4 @@ def conv_hex(val): if hexval[-1:] == 'L': hexval = hexval[:-1] return hexval + diff --git a/conts/bare_src/SConstruct b/conts/bare_src/SConstruct index 8f741a3..3bd1575 100644 --- a/conts/bare_src/SConstruct +++ b/conts/bare_src/SConstruct @@ -13,11 +13,11 @@ sys.path.append(PROJRELROOT) from config.projpaths import * from config.configuration import * - +from configure import * config = configuration_retrieve() - arch = config.arch +gcc_cpu_flag = config.gcc_cpu_flag # Wrapper library for system calls LIBL4_RELDIR = 'conts/libl4' @@ -38,20 +38,20 @@ LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) LIBMEM_INCLUDE = LIBMEM_DIR -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', - # We don't use -nostdinc because sometimes we need standard headers, - # such as stdarg.h e.g. for variable args, as in printk(). - CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \ - '-std=gnu99', '-Wall', '-Werror'], - LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", "-u_start"], - ASFLAGS = ['-D__ASSEMBLY__'], - PROGSUFFIX = '.elf', # The suffix to use for final executable - ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path - LIBS = ['gcc', 'libl4', 'c-userspace', 'libmm', 'libmc', 'libmalloc', \ - 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') +env = Environment(CC = config.user_toolchain + 'gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \ + '-Werror', ('-mcpu=' + gcc_cpu_flag)], \ + LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", "-u_start"],\ + ASFLAGS = ['-D__ASSEMBLY__'], \ + PROGSUFFIX = '.elf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = ['gcc', 'libl4', 'c-userspace', 'libmm', 'libmc', 'libmalloc', \ + 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBC_INCLUDE, LIBMEM_INCLUDE], + LIBPATH = [LIBL4_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') src = Glob('*.[cS]') src += Glob('src/*.[cS]') diff --git a/conts/libl4/SConscript b/conts/libl4/SConscript index 7cefdeb..7d3a5d0 100644 --- a/conts/libl4/SConscript +++ b/conts/libl4/SConscript @@ -24,10 +24,13 @@ PROJRELROOT = '../..' sys.path.append(PROJRELROOT) from config.projpaths import * +from configure import * Import('arch') -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +config = configuration_retrieve() + +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdlib', '-ffreestanding'], LINKFLAGS = ['-nostdlib'], ASFLAGS = ['-D__ASSEMBLY__'], diff --git a/conts/libl4/SConstruct b/conts/libl4/SConstruct index 8e48160..14c8ab0 100644 --- a/conts/libl4/SConstruct +++ b/conts/libl4/SConstruct @@ -14,10 +14,9 @@ from config.projpaths import * from config.configuration import * config = configuration_retrieve() - arch = config.arch -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdlib', '-ffreestanding'], LINKFLAGS = ['-nostdlib'], ASFLAGS = ['-D__ASSEMBLY__'], diff --git a/conts/libmem/SConscript b/conts/libmem/SConscript index 3c755e9..de74643 100644 --- a/conts/libmem/SConscript +++ b/conts/libmem/SConscript @@ -10,6 +10,9 @@ PROJRELROOT = '../..' sys.path.append(PROJRELROOT) from config.projpaths import * +from configure import * + +config = configuration_retrieve() KERNEL_INCLUDE = join(PROJROOT, 'include') LIBL4_RELDIR = 'conts/libl4' @@ -17,7 +20,7 @@ LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) LIBL4_INCLUDE = join(LIBL4_DIR, 'include') LIBL4_LIBPATH = join(BUILDDIR, LIBL4_RELDIR) -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdlib', '-ffreestanding'], LINKFLAGS = ['-nostdlib'], ASFLAGS = ['-D__ASSEMBLY__'], diff --git a/conts/libmem/SConstruct b/conts/libmem/SConstruct index 5a32b21..f6b5732 100644 --- a/conts/libmem/SConstruct +++ b/conts/libmem/SConstruct @@ -7,6 +7,9 @@ import glob import sys from os.path import join from string import split +from configure import * + +config = configuration_retrieve() project_root = "../.." headers_root = join(project_root, "include/l4") @@ -33,8 +36,7 @@ test_env = Environment(CC = 'gcc -m32', LIBPATH = ['#'], CPPPATH = ['#include', join(project_root, "include"), "#", libl4_headers]) - -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdlib', '-Wall', '-Werror', '-ffreestanding', '-std=gnu99'], LINKFLAGS = ['-nostdlib'], ENV = {'PATH' : os.environ['PATH']}, diff --git a/conts/posix/SConstruct b/conts/posix/SConstruct index 32a9b00..41effcc 100644 --- a/conts/posix/SConstruct +++ b/conts/posix/SConstruct @@ -19,7 +19,6 @@ from config.lib import * config = configuration_retrieve() arch = config.arch - LIBL4_RELDIR = 'conts/libl4' KERNEL_INCLUDE = join(PROJROOT, 'include') LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) @@ -44,7 +43,7 @@ LIBPOSIX_INCLUDE_SERVER = join(LIBPOSIX_DIR, 'include') LIBPOSIX_INCLUDE_USERSPACE = join(LIBPOSIX_DIR, 'include/posix') LIBPOSIX_LIBPATH = join(BUILDDIR, LIBPOSIX_RELDIR) -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', \ '-std=gnu99', '-Wall', '-Werror'], LINKFLAGS = ['-nostdlib'], diff --git a/conts/posix/bootdesc/SConscript b/conts/posix/bootdesc/SConscript index 230397f..77875af 100644 --- a/conts/posix/bootdesc/SConscript +++ b/conts/posix/bootdesc/SConscript @@ -23,6 +23,8 @@ from config.projpaths import * from config.configuration import * from tools.pyelf import elf +config = configuration_retrieve() + bootdesc_template = \ ''' /* This file is autogenerated, do not edit by hand. */ @@ -95,8 +97,8 @@ def relocate_bootdesc(target, source, env): images = source[1:] mm0 = images[0] start, end = image_lma_start_end(mm0.path) - print "arm-none-linux-gnueabi-objcopy --adjust-section-vma .data=" + conv_hex(end) + " " + bootdesc_raw.path - os.system("arm-none-linux-gnueabi-objcopy --adjust-section-vma .data=" + conv_hex(end) + " " + bootdesc_raw.path) + print config.user_toolchain + "objcopy --adjust-section-vma .data=" + conv_hex(end) + " " + bootdesc_raw.path + os.system(config.user_toolchain + "objcopy --adjust-section-vma .data=" + conv_hex(end) + " " + bootdesc_raw.path) shutil.copyfile(bootdesc_raw.path, target[0].path) bootdesc_c = e.Command('bootdesc.c', images, generate_bootdesc) diff --git a/conts/posix/bootdesc/SConstruct b/conts/posix/bootdesc/SConstruct index b38e15c..641b15f 100644 --- a/conts/posix/bootdesc/SConstruct +++ b/conts/posix/bootdesc/SConstruct @@ -7,10 +7,12 @@ import os import sys import shutil from os.path import join +from configure import * +config = configuration_retrieve() builddir = ARGUMENTS.get('builddir', 'build/conts/posix') -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], LINKFLAGS = ['-nostdlib','-Tlinker.lds'], ASFLAGS = ['-D__ASSEMBLY__'], diff --git a/conts/posix/libposix/SConstruct b/conts/posix/libposix/SConstruct index 352c734..1423aca 100644 --- a/conts/posix/libposix/SConstruct +++ b/conts/posix/libposix/SConstruct @@ -7,13 +7,16 @@ import glob import sys from os.path import join from string import split +from configure import * + +config = configuration_retrieve() project_root = "../.." kernel_headers = join(project_root, "include") l4lib_headers = join(project_root, "tasks/libl4/include") config_h = join(project_root, "include/l4/config.h") -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-std=gnu99', '-nostdlib', '-ffreestanding'], LINKFLAGS = ['-nostdlib'], CPPPATH = ['#include'], diff --git a/conts/posix/mm0/SConstruct b/conts/posix/mm0/SConstruct index 75cf22a..b9579c8 100644 --- a/conts/posix/mm0/SConstruct +++ b/conts/posix/mm0/SConstruct @@ -14,7 +14,6 @@ sys.path.append(PROJRELROOT) from config.projpaths import * from config.configuration import * - config = configuration_retrieve() arch = config.arch @@ -31,8 +30,7 @@ LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR) LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \ join(LIBC_DIR, 'include/arch' + '/' + arch)] - -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', \ diff --git a/conts/posix/mm0/tools/generate_bootdesc.py b/conts/posix/mm0/tools/generate_bootdesc.py index fcd8e89..04b0d86 100755 --- a/conts/posix/mm0/tools/generate_bootdesc.py +++ b/conts/posix/mm0/tools/generate_bootdesc.py @@ -2,7 +2,9 @@ import os import sys -compiler_prefix = "arm-none-linux-gnueabi-" +from configure import * +config = configuration_retrieve() + objdump = "objdump" command = "-t" image_name = "inittask.axf" @@ -10,7 +12,7 @@ linkoutput_file_suffix = "-linkinfo.txt" linkoutput_file = image_name + linkoutput_file_suffix def generate_bootdesc(): - command = compiler_prefix + objdump + " -t " + image_name + " > " + linkoutput_file + command = config.user_toolchain + objdump + " -t " + image_name + " > " + linkoutput_file print command os.system(command) f = open(linkoutput_file, "r") diff --git a/conts/posix/test0/SConstruct b/conts/posix/test0/SConstruct index 8be9ec7..bc197e4 100644 --- a/conts/posix/test0/SConstruct +++ b/conts/posix/test0/SConstruct @@ -8,6 +8,9 @@ import sys import shutil from os.path import join from glob import glob +from configure import * + +config = configuration_retrieve() task_name = "test0" @@ -54,8 +57,8 @@ def get_physical_base(source, target, env): os.system(join(tools_root, "pyelf/readelf.py --first-free-page " + \ prev_image + " >> " + physical_base_ld_script)) -# The kernel build environment: -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +# The kernel build environment +env = Environment(CC = config.user_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], @@ -71,7 +74,7 @@ env = Environment(CC = 'arm-none-linux-gnueabi-gcc', test_exec_ld_script = "include/test_exec_linker.lds" # The kernel build environment: -test_exec_env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +test_exec_env = Environment(CC = config.user_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). CCFLAGS = ['-O3', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], diff --git a/loader/libs/c/SConstruct b/loader/libs/c/SConstruct index 48da97a..7d07b7b 100644 --- a/loader/libs/c/SConstruct +++ b/loader/libs/c/SConstruct @@ -5,17 +5,20 @@ # Copyright © 2009 B Labs Ltd import os, sys, shelve +from configure import * -arch = 'arm' -subarch = 'v5' -platform = 'pb926' variant = "baremetal" +config = configuration_retrieve() +arch = config.arch +subarch = config.subarch +platform = config.platform +gcc_cpu_flag = config.gcc_cpu_flag -env = Environment(CC = 'arm-none-eabi-gcc', +env = Environment(CC = config.kernel_toolchain + 'gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). - CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \ - '-std=gnu99', '-Wall', '-Werror'], + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \ + '-Werror', ('-mcpu=' + gcc_cpu_flag)], LINKFLAGS = ['-nostdlib', '-T' + "include/l4/arch/arm/linker.lds"], ASFLAGS = ['-D__ASSEMBLY__'], PROGSUFFIX = '.elf', # The suffix to use for final executable diff --git a/loader/libs/elf/SConstruct b/loader/libs/elf/SConstruct index 8d177a8..995c8ba 100644 --- a/loader/libs/elf/SConstruct +++ b/loader/libs/elf/SConstruct @@ -6,9 +6,11 @@ import os, sys, shelve from os.path import join +from configure import * -arch = 'arm' -platform = 'pb926' +config = configuration_retrieve() +arch = config.arch +platform = config.platform # Get global paths PROJRELROOT="../../../" @@ -19,7 +21,7 @@ LIBC_LIBPATH = LIBC_PATH LIBC_INCPATH = [join(LIBC_PATH, 'include'), \ join(LIBC_PATH, 'include/arch/' + arch)] -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', +env = Environment(CC = config.user_toolchain + 'gcc', CCFLAGS = ['-g', '-nostdinc', '-nostdlib', '-ffreestanding'], LINKFLAGS = ['-nostdlib'], ENV = {'PATH' : os.environ['PATH']}, diff --git a/scripts/conts/pack.py b/scripts/conts/pack.py index 7a41819..39c5206 100755 --- a/scripts/conts/pack.py +++ b/scripts/conts/pack.py @@ -92,15 +92,18 @@ class LinuxContainerPacker: f.close() def pack_container(self): + # TODO: Need to sort this, we cannot call it in global space + # as configuration file is not presnt in beginning + config = configuration_retrieve() + self.generate_container_lds([self.kernel_image_in, \ self.rootfs_elf_in, \ self.atags_elf_in]) self.generate_container_assembler([self.kernel_image_in, \ self.rootfs_elf_in, \ self.atags_elf_in]) - os.system("arm-none-linux-gnueabi-gcc " + "-nostdlib -o %s -T%s %s" \ - % (self.container_elf_out, \ - self.container_lds_out, + os.system(config.user_toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \ + % (self.container_elf_out, self.container_lds_out, \ self.container_S_out)) # Final file is returned so that the final packer needn't # get the packer object for this information @@ -156,11 +159,14 @@ class DefaultContainerPacker: f.close() def pack_container(self): + # TODO: Need to sort this, we cannot call it in global space + # as configuration file is not presnt in beginning + config = configuration_retrieve() + self.generate_container_lds(self.images_in) self.generate_container_assembler(self.images_in) - os.system("arm-none-linux-gnueabi-gcc " + "-nostdlib -o %s -T%s %s" \ - % (self.container_elf_out, \ - self.container_lds_out, + os.system(config.user_toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \ + % (self.container_elf_out, self.container_lds_out, \ self.container_S_out)) # Final file is returned so that the final packer needn't # get the packer object for this information diff --git a/scripts/conts/packall.py b/scripts/conts/packall.py index 8271d3b..5d58fa2 100755 --- a/scripts/conts/packall.py +++ b/scripts/conts/packall.py @@ -16,7 +16,6 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELR from config.projpaths import * from config.configuration import * - containers_assembler_body = \ ''' .align 4 @@ -78,11 +77,14 @@ class AllContainerPacker: f.write(file_body) def pack_all(self): + # TODO: Need to sort this, we cannot call it in global space + # as configuration file is not presnt in beginning + config = configuration_retrieve() + self.generate_container_lds(self.containers_lds_out) self.generate_container_S(self.containers_S_out) - os.system("arm-none-linux-gnueabi-gcc " + "-nostdlib -o %s -T%s %s" \ - % (self.containers_elf_out, \ - self.containers_lds_out, + os.system(config.user_toolchain + "gcc " + "-nostdlib -o %s -T%s %s" \ + % (self.containers_elf_out, self.containers_lds_out, \ self.containers_S_out)) # Return the final image to calling script diff --git a/scripts/linux/build_atags.py b/scripts/linux/build_atags.py index 43e278d..d8a158b 100755 --- a/scripts/linux/build_atags.py +++ b/scripts/linux/build_atags.py @@ -51,8 +51,11 @@ class AtagsBuilder: def build_atags(self): print 'Building Atags for linux kenel...' - # IO files from this build + # TODO: Need to sort this, we cannot call it in global space + # as configuration file is not presnt in beginning + config = configuration_retrieve() + # IO files from this build os.chdir(LINUX_ATAGSDIR) if not os.path.exists(self.LINUX_ATAGS_BUILDDIR): os.makedirs(self.LINUX_ATAGS_BUILDDIR) @@ -65,7 +68,7 @@ class AtagsBuilder: with open(self.atags_h_in, 'r') as input: output.write(input.read() % {'cn' : self.cont_id}) - os.system("arm-none-linux-gnueabi-cpp -I%s -P %s > %s" % \ + os.system(config.user_toolchain + "cpp -I%s -P %s > %s" % \ (self.LINUX_ATAGS_BUILDDIR, self.atags_lds_in, \ self.atags_lds_out)) @@ -73,7 +76,7 @@ class AtagsBuilder: with open(self.atags_c_in, 'r') as input: output.write(input.read() % {'cn' : self.cont_id}) - os.system("arm-none-linux-gnueabi-gcc " + \ + os.system(config.user_toolchain + "gcc " + \ "-g -ffreestanding -std=gnu99 -Wall -Werror " + \ "-nostdlib -o %s -T%s %s" % \ (self.atags_elf_out, self.atags_lds_out, self.atags_c_out)) diff --git a/scripts/linux/build_linux.py b/scripts/linux/build_linux.py index 0cf3ac1..c64c5fe 100755 --- a/scripts/linux/build_linux.py +++ b/scripts/linux/build_linux.py @@ -66,7 +66,7 @@ class LinuxUpdateKernel: break if flag == 0: - print 'Warning: No match found for the parameter' + #print 'Warning: No match found for the parameter' return else: # Prevent recompilation in case kernel parameter is same @@ -205,6 +205,10 @@ class LinuxBuilder: def build_linux(self): print '\nBuilding the linux kernel...' + # TODO: Need to sort this, we cannot call it in global space + # as configuration file is not presnt in beginning + config = configuration_retrieve() + os.chdir(self.LINUX_KERNELDIR) if not os.path.exists(self.LINUX_KERNEL_BUILDDIR): os.makedirs(self.LINUX_KERNEL_BUILDDIR) @@ -215,7 +219,7 @@ class LinuxBuilder: os.system("make defconfig ARCH=arm O=" + self.LINUX_KERNEL_BUILDDIR) os.system("make ARCH=arm " + \ - "CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \ + "CROSS_COMPILE=" + config.user_toolchain + " O=" + \ self.LINUX_KERNEL_BUILDDIR) with open(self.linux_h_out, 'w+') as output: @@ -227,10 +231,10 @@ class LinuxBuilder: content = input.read() % self.kernel_binary_image output.write(content) - os.system("arm-none-linux-gnueabi-cpp -I%s -P %s > %s" % \ + os.system(config.user_toolchain + "cpp -I%s -P %s > %s" % \ (self.LINUX_KERNEL_BUILDDIR, self.linux_lds_in, \ self.linux_lds_out)) - os.system("arm-none-linux-gnueabi-gcc -nostdlib -o %s -T%s %s" % \ + os.system(config.user_toolchain + "gcc -nostdlib -o %s -T%s %s" % \ (self.linux_elf_out, self.linux_lds_out, self.linux_S_out)) # Get the kernel image path diff --git a/scripts/linux/build_rootfs.py b/scripts/linux/build_rootfs.py index 2f57ae6..ffe217c 100755 --- a/scripts/linux/build_rootfs.py +++ b/scripts/linux/build_rootfs.py @@ -15,7 +15,6 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELR from config.projpaths import * from config.configuration import * - # Create linux kernel build directory path as: # conts/linux -> build/cont[0-9]/linux def source_to_builddir(srcdir, id): @@ -43,8 +42,11 @@ class RootfsBuilder: def build_rootfs(self): print 'Building the root filesystem...' - # IO files from this build + # TODO: Need to sort this, we cannot call it in global space + # as configuration file is not presnt in beginning + config = configuration_retrieve() + # IO files from this build os.chdir(LINUX_ROOTFSDIR) if not os.path.exists(self.LINUX_ROOTFS_BUILDDIR): os.makedirs(self.LINUX_ROOTFS_BUILDDIR) @@ -53,10 +55,10 @@ class RootfsBuilder: with open(self.rootfs_h_in, 'r') as input: output.write(input.read() % {'cn' : self.cont_id}) - os.system("arm-none-linux-gnueabi-cpp -I%s -P %s > %s" % \ + os.system(config.user_toolchain + "cpp -I%s -P %s > %s" % \ (self.LINUX_ROOTFS_BUILDDIR, self.rootfs_lds_in, \ self.rootfs_lds_out)) - os.system("arm-none-linux-gnueabi-gcc " + \ + os.system(config.user_toolchain + "gcc " + \ "-nostdlib -o %s -T%s rootfs.S" % (self.rootfs_elf_out, \ self.rootfs_lds_out)) print "Done..." diff --git a/scripts/loader/generate_loader_asm.py b/scripts/loader/generate_loader_asm.py index a55199e..e30698f 100755 --- a/scripts/loader/generate_loader_asm.py +++ b/scripts/loader/generate_loader_asm.py @@ -7,6 +7,7 @@ # import os, sys, shelve, subprocess from os.path import join +from configure import * PROJRELROOT = '../../' @@ -16,6 +17,8 @@ from config.projpaths import * from config.configuration import * from config.lib import * +config = configuration_retrieve() + # Convert address from python literal to numeric value def address_remove_literal(address): value = hex(int(address, 16) - 0xf0000000) @@ -49,8 +52,9 @@ def generate_ksym_to_loader(target_path, source_path): with open(target_path, 'w') as asm_file: asm_file.write(ksym_header % (target_path, source_path, sys.argv[0])) for symbol in symbols: - process = subprocess.Popen('arm-none-eabi-objdump -d ' + \ - source_path + ' | grep "<' + \ + process = \ + subprocess.Popen(config.kernel_toolchain + 'objdump -d ' + \ + source_path + ' | grep "<' + \ symbol + '>"', shell=True, \ stdout=subprocess.PIPE) assert process.wait() == 0 diff --git a/tools/pyelf/lmamove.py b/tools/pyelf/lmamove.py index 0e20b48..5d8af69 100755 --- a/tools/pyelf/lmamove.py +++ b/tools/pyelf/lmamove.py @@ -3,6 +3,7 @@ import re, elf, sys, os from optparse import OptionParser +# May need to do something about this toolprefix = "arm-none-linux-gnueabi-" objdump = toolprefix + "objdump" objcopy = toolprefix + "objcopy"