def system_build(system): inc_path_args = ['-I%s' % i for i in system.include_paths] common_flags = ['-mthumb', '-g3', '-mlittle-endian', '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16'] a_flags = common_flags c_flags = common_flags + ['-Os'] all_input_files = system.c_files + system.asm_files all_input_files = [os.path.normpath(os.path.abspath(path)) for path in all_input_files] common_parent_path = commonpath(all_input_files) # Compile all C files. c_obj_files = [os.path.join(system.output, os.path.relpath(os.path.abspath(c_file_path.replace('.c', '.o')), common_parent_path)) for c_file_path in system.c_files] for c_file_path, obj_file_path in zip(system.c_files, c_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['arm-none-eabi-gcc', '-ffreestanding', '-c', c_file_path, '-o', obj_file_path, '-Wall', '-Werror'] + c_flags + inc_path_args) # Assemble all asm files. asm_obj_files = [os.path.join(system.output, os.path.relpath(os.path.abspath(asm_file_path.replace('.s', '.o')), common_parent_path)) for asm_file_path in system.asm_files] for asm_file_path, obj_file_path in zip(system.asm_files, asm_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['arm-none-eabi-as', '-o', obj_file_path, asm_file_path] + a_flags + inc_path_args) # Perform final link obj_files = asm_obj_files + c_obj_files execute(['arm-none-eabi-ld', '-T', system.linker_script, '-o', system.output_file] + obj_files)
def system_build(system): inc_path_args = ['-I%s' % i for i in system.include_paths] common_flags = [ '-mthumb', '-g3', '-mlittle-endian', '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16' ] a_flags = common_flags c_flags = common_flags + [ '-O0', '-fdata-sections', '-fno-common', '-fno-zero-initialized-in-bss' ] # '--print-memory-usage' is a very useful flag here if you are # memory-constrained, but only works with recent versions of ld ld_flags = [] all_input_files = system.c_files + system.asm_files all_input_files = [ os.path.normpath(os.path.abspath(path)) for path in all_input_files ] common_parent_path = commonpath(all_input_files) # Compile all C files. c_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(c_file_path.replace('.c', '.o')), common_parent_path)) for c_file_path in system.c_files ] for c_path, obj_path in zip(system.c_files, c_obj_files): os.makedirs(os.path.dirname(obj_path), exist_ok=True) execute([ 'arm-none-eabi-gcc', '-ffreestanding', '-c', c_path, '-o', obj_path, '-Wall', '-Werror' ] + c_flags + inc_path_args) # Assemble all asm files. asm_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(asm_file_path.replace('.s', '.o')), common_parent_path)) for asm_file_path in system.asm_files ] for asm_file_path, obj_file_path in zip(system.asm_files, asm_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['arm-none-eabi-as', '-o', obj_file_path, asm_file_path] + a_flags + inc_path_args) # Perform final link obj_files = asm_obj_files + c_obj_files execute([ 'arm-none-eabi-ld', '-T', system.linker_script, '-o', system.output_file ] + ld_flags + obj_files)
def system_build(system): inc_path_args = ['-I%s' % i for i in system.include_paths] # The device we emulate does not implement FPU instructions, however # ctxt-switch-preempt.s requires them. So, 'fake' a hardware FPU. # Qemu will gracefully ignore the FPU instructions. common_flags = [ '-mthumb', '-g3', '-mlittle-endian', '-mcpu=cortex-m3', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16' ] a_flags = common_flags c_flags = common_flags + ['-Os'] all_input_files = system.c_files + system.asm_files all_input_files = [ os.path.normpath(os.path.abspath(path)) for path in all_input_files ] common_parent_path = commonpath(all_input_files) # Compile all C files. c_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(c_file_path.replace('.c', '.o')), common_parent_path)) for c_file_path in system.c_files ] for c_path, obj_path in zip(system.c_files, c_obj_files): os.makedirs(os.path.dirname(obj_path), exist_ok=True) execute([ 'arm-none-eabi-gcc', '-ffreestanding', '-c', c_path, '-o', obj_path, '-Wall', '-Werror' ] + c_flags + inc_path_args) # Assemble all asm files. asm_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(asm_file_path.replace('.s', '.o')), common_parent_path)) for asm_file_path in system.asm_files ] for asm_file_path, obj_file_path in zip(system.asm_files, asm_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['arm-none-eabi-as', '-o', obj_file_path, asm_file_path] + a_flags + inc_path_args) # Perform final link obj_files = asm_obj_files + c_obj_files execute([ 'arm-none-eabi-ld', '-T', system.linker_script, '-o', system.output_file ] + obj_files)
def system_build(system): inc_path_args = ['-I%s' % i for i in system.include_paths] common_flags = ['-g3'] a_flags = common_flags c_flags = common_flags all_input_files = system.c_files + system.asm_files all_input_files = [ os.path.normpath(os.path.abspath(path)) for path in all_input_files ] common_parent_path = commonpath(all_input_files) # Compile all C files. c_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(c_file_path.replace('.c', '.o')), common_parent_path)) for c_file_path in system.c_files ] for c_file_path, obj_file_path in zip(system.c_files, c_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) # gcc options for the PowerPC e500 execute([ 'powerpc-linux-gnu-gcc', '-mcpu=8548', '-mfloat-gprs=double', '-meabi', '-mno-sdata', '-G', '0', '-ffreestanding', '-c', c_file_path, '-o', obj_file_path, '-Wall', '-Werror' ] + c_flags + inc_path_args) # Assemble all asm files. asm_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(asm_file_path.replace('.s', '.o')), common_parent_path)) for asm_file_path in system.asm_files ] for asm_file_path, obj_file_path in zip(system.asm_files, asm_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute([ 'powerpc-linux-gnu-as', '-me500', '-o', obj_file_path, asm_file_path ] + a_flags + inc_path_args) # Perform final link obj_files = asm_obj_files + c_obj_files execute([ 'powerpc-linux-gnu-ld', '-G', '0', '-T', system.linker_script, '-o', system.output_file ] + obj_files)
def system_build(system): inc_path_args = ['-I%s' % i for i in system.include_paths] common_flags = [ '-mthumb', '-mcpu=cortex-m23', '-march=armv8-m.base', '-g3' ] a_flags = common_flags # c_flags = common_flags + ['-Os'] + ['-D__SAML10E16A__'] c_flags = common_flags + ['-Og'] + ['-D__SAML10E16A__', '-std=gnu99'] ld_flags = ['-mthumb', '-mcpu=cortex-m23', \ '-march=armv8-m.base', '-Wl,--gc-sections', \ '-T', './share/packages/saml10/saml10e16a.ld'] all_input_files = system.c_files + system.asm_files all_input_files = [ os.path.normpath(os.path.abspath(path)) for path in all_input_files ] common_parent_path = commonpath(all_input_files) # Compile all C files. c_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(c_file_path.replace('.c', '.o')), common_parent_path)) for c_file_path in system.c_files ] for c_path, obj_path in zip(system.c_files, c_obj_files): os.makedirs(os.path.dirname(obj_path), exist_ok=True) execute([ 'arm-none-eabi-gcc', '-c', c_path, '-o', obj_path, '-Wall', '-Werror' ] + c_flags + inc_path_args) # Assemble all asm files. asm_obj_files = [ os.path.join( system.output, os.path.relpath(os.path.abspath(asm_file_path.replace('.s', '.o')), common_parent_path)) for asm_file_path in system.asm_files ] for asm_file_path, obj_file_path in zip(system.asm_files, asm_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['arm-none-eabi-as', '-o', obj_file_path, asm_file_path] + a_flags + inc_path_args) # Perform final link obj_files = asm_obj_files + c_obj_files execute(['arm-none-eabi-gcc', '-o', system.output_file] + ld_flags + obj_files)
def system_build(system, prx_config=None): if prx_config is None: prx_config = {} inc_path_args = ['-I%s' % i for i in system.include_paths] common_flags = ['-g3'] a_flags = common_flags c_flags = common_flags if prx_config.get('double_precision_fp'): c_float_gprs_flag = '-mfloat-gprs=double' else: c_float_gprs_flag = '-mfloat-gprs=single' all_input_files = system.c_files + system.asm_files all_input_files = [os.path.normpath(os.path.abspath(path)) for path in all_input_files] common_parent_path = commonpath(all_input_files) # Compile all C files. c_obj_files = [os.path.join(system.output, os.path.relpath(os.path.abspath(c_file_path.replace('.c', '.o')), common_parent_path)) for c_file_path in system.c_files] for c_file_path, obj_file_path in zip(system.c_files, c_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['powerpc-eabispe-gcc', '-mcpu=8548', c_float_gprs_flag, '-meabi', '-mno-sdata', '-G', '0', '-mabi=spe', '-mspe', '-ffreestanding', '-c', c_file_path, '-o', obj_file_path, '-Wall', '-Werror'] + c_flags + inc_path_args) # Assemble all asm files. asm_obj_files = [os.path.join(system.output, os.path.relpath(os.path.abspath(asm_file_path.replace('.s', '.o')), common_parent_path)) for asm_file_path in system.asm_files] for asm_file_path, obj_file_path in zip(system.asm_files, asm_obj_files): os.makedirs(os.path.dirname(obj_file_path), exist_ok=True) execute(['powerpc-eabispe-as', '-me500', '-mspe', '-o', obj_file_path, asm_file_path] + a_flags + inc_path_args) # Perform final link obj_files = asm_obj_files + c_obj_files execute(['powerpc-eabispe-ld', '-G', '0', '-T', system.linker_script, '-o', system.output_file] + obj_files)