mirror of
https://github.com/marqs85/ossc
synced 2025-04-09 22:56:34 +03:00
change compiler and libc to optimize size
This commit is contained in:
parent
9af171947a
commit
2725351039
@ -190,7 +190,7 @@ CREATE_ELF_DERIVED_FILES := 0
|
||||
CREATE_LINKER_MAP := 1
|
||||
|
||||
# Common arguments for ALT_CFLAGSs
|
||||
APP_CFLAGS_DEFINED_SYMBOLS :=
|
||||
APP_CFLAGS_DEFINED_SYMBOLS := -DPICOLIBC_INTEGER_PRINTF_SCANF
|
||||
ifeq ($(ENABLE_AUDIO),y)
|
||||
APP_CFLAGS_DEFINED_SYMBOLS += -DENABLE_AUDIO
|
||||
endif
|
||||
@ -216,6 +216,7 @@ SYS_LIB :=
|
||||
BSP_ROOT_DIR := ../sys_controller_bsp/
|
||||
|
||||
# List of application specific include directories, library directories and library names
|
||||
APP_INCLUDE_DIRS += /usr/lib/picolibc/riscv64-unknown-elf/include
|
||||
APP_INCLUDE_DIRS += it6613
|
||||
APP_INCLUDE_DIRS += tvp7002
|
||||
APP_INCLUDE_DIRS += ths7353
|
||||
@ -396,7 +397,7 @@ APP_ASFLAGS := $(APP_ASM_INC_DIRS) \
|
||||
$(ASFLAGS)
|
||||
|
||||
# Arguments only for the linker.
|
||||
APP_LDFLAGS := $(APP_LDFLAGS_USER) --specs=nano.specs -nostartfiles
|
||||
APP_LDFLAGS := $(APP_LDFLAGS_USER) --specs=picolibc.specs -nostartfiles
|
||||
|
||||
ifneq ($(LINKER_SCRIPT),)
|
||||
APP_LDFLAGS += -T'$(LINKER_SCRIPT)'
|
||||
@ -657,11 +658,11 @@ build_post_process :
|
||||
# included makefile fragment.
|
||||
#
|
||||
ifeq ($(DEFAULT_CROSS_COMPILE),)
|
||||
DEFAULT_CROSS_COMPILE := riscv32-unknown-elf-
|
||||
DEFAULT_CROSS_COMPILE := riscv64-unknown-elf-
|
||||
endif
|
||||
|
||||
ifeq ($(DEFAULT_STACKREPORT),)
|
||||
DEFAULT_STACKREPORT := riscv32-unknown-elf-size
|
||||
DEFAULT_STACKREPORT := riscv64-unknown-elf-size
|
||||
endif
|
||||
|
||||
ifeq ($(DEFAULT_DOWNLOAD),)
|
||||
@ -715,7 +716,7 @@ AR := $(CROSS_COMPILE)ar
|
||||
endif
|
||||
|
||||
ifeq ($(origin LD),default)
|
||||
LD := $(CROSS_COMPILE)g++
|
||||
LD := $(CROSS_COMPILE)gcc
|
||||
endif
|
||||
|
||||
ifeq ($(origin RM),default)
|
||||
@ -760,7 +761,7 @@ ifeq ($(MKDIR),)
|
||||
MKDIR := $(DEFAULT_MKDIR)
|
||||
endif
|
||||
|
||||
RV_OBJCOPY = riscv32-unknown-elf-objcopy
|
||||
RV_OBJCOPY = riscv64-unknown-elf-objcopy
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# PATTERN RULES TO BUILD OBJECTS
|
||||
|
@ -2,6 +2,6 @@
|
||||
OUTPUT_ARCH(riscv)
|
||||
|
||||
/* required to correctly link newlib */
|
||||
GROUP( -lc -lgloss -lgcc -lsupc++ )
|
||||
GROUP( -lc -lgcc )
|
||||
|
||||
INCLUDE link.common.ld
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define SD_SPI_BASE I2C_OPENCORES_1_BASE
|
||||
|
||||
#ifndef DEBUG
|
||||
#include <stdio.h>
|
||||
#define OS_PRINTF(...)
|
||||
#define ErrorF(...)
|
||||
#define printf(...)
|
||||
@ -38,6 +39,8 @@
|
||||
#define printf dd_printf
|
||||
#endif
|
||||
|
||||
#define sniprintf snprintf
|
||||
|
||||
#define WAITLOOP_SLEEP_US 10000
|
||||
|
||||
#endif /* SYSCONFIG_H_ */
|
||||
|
@ -40,28 +40,28 @@
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* errno is defined in <errno.h> so that it uses the thread local version
|
||||
* stored in the location pointed to by "_impure_ptr". This means that the
|
||||
* accesses to errno within the HAL library can cause the entirety of
|
||||
* of the structure pointed to by "_impure_ptr" to be added to the
|
||||
* errno is defined in <errno.h> so that it uses the thread local version
|
||||
* stored in the location pointed to by "_impure_ptr". This means that the
|
||||
* accesses to errno within the HAL library can cause the entirety of
|
||||
* of the structure pointed to by "_impure_ptr" to be added to the
|
||||
* users application. This can be undesirable in very small footprint systems.
|
||||
*
|
||||
* To avoid this happening, the HAL uses the macro ALT_ERRNO, defined below,
|
||||
* to access errno, rather than accessing it directly. This macro will only
|
||||
* use the thread local version if some other code has already caused it to be
|
||||
* to access errno, rather than accessing it directly. This macro will only
|
||||
* use the thread local version if some other code has already caused it to be
|
||||
* included into the system, otherwise it will use the global errno value.
|
||||
*
|
||||
* This causes a slight increases in code size where errno is accessed, but
|
||||
* can lead to significant overall benefits in very small systems. The
|
||||
* This causes a slight increases in code size where errno is accessed, but
|
||||
* can lead to significant overall benefits in very small systems. The
|
||||
* increase is inconsequential when compared to the size of the structure
|
||||
* pointed to by _impure_ptr.
|
||||
*
|
||||
* Note that this macro accesses __errno() using an externally declared
|
||||
* Note that this macro accesses __errno() using an externally declared
|
||||
* function pointer (alt_errno). This is done so that the function call uses the
|
||||
* subroutine call instruction via a register rather than an immediate address.
|
||||
* This is important in the case that the code has been linked for a high
|
||||
* address, but __errno() is not being used. In this case the weak linkage
|
||||
* would have resulted in the instruction: "call 0" which would fail to link.
|
||||
* would have resulted in the instruction: "call 0" which would fail to link.
|
||||
*/
|
||||
|
||||
extern int* (*alt_errno) (void);
|
||||
@ -73,9 +73,9 @@ extern int* (*alt_errno) (void);
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
#undef errno
|
||||
/*#undef errno
|
||||
|
||||
extern int errno;
|
||||
extern int errno;*/
|
||||
|
||||
static ALT_INLINE int* alt_get_errno(void)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ SPACE := $(empty) $(empty)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# The adjust-path macro
|
||||
#
|
||||
#
|
||||
# If COMSPEC is defined, Make is launched from Windows through
|
||||
# Cygwin. This adjust-path macro will call 'cygpath -u' on all
|
||||
# paths to ensure they are readable by Make.
|
||||
@ -78,26 +78,26 @@ OBJ_DIR := ./obj
|
||||
# utilize the BSP settings mechanism to do so.
|
||||
#
|
||||
# Note that most variable assignments in this section have a corresponding BSP
|
||||
# setting that can be changed by using the nios2-bsp-create-settings or
|
||||
# nios2-bsp-update-settings command before nios2-bsp-generate-files; if you
|
||||
# want any variable set to a specific value when this Makefile is re-generated
|
||||
# (to prevent hand-edits from being over-written), use the BSP settings
|
||||
# setting that can be changed by using the nios2-bsp-create-settings or
|
||||
# nios2-bsp-update-settings command before nios2-bsp-generate-files; if you
|
||||
# want any variable set to a specific value when this Makefile is re-generated
|
||||
# (to prevent hand-edits from being over-written), use the BSP settings
|
||||
# facilities above.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#START MANAGED
|
||||
|
||||
# The following TYPE comment allows tools to identify the 'type' of target this
|
||||
# makefile is associated with.
|
||||
# The following TYPE comment allows tools to identify the 'type' of target this
|
||||
# makefile is associated with.
|
||||
# TYPE: BSP_PRIVATE_MAKEFILE
|
||||
|
||||
# This following VERSION comment indicates the version of the tool used to
|
||||
# generate this makefile. A makefile variable is provided for VERSION as well.
|
||||
# This following VERSION comment indicates the version of the tool used to
|
||||
# generate this makefile. A makefile variable is provided for VERSION as well.
|
||||
# ACDS_VERSION: 17.1
|
||||
ACDS_VERSION := 17.1
|
||||
|
||||
# This following BUILD_NUMBER comment indicates the build number of the tool
|
||||
# used to generate this makefile.
|
||||
# This following BUILD_NUMBER comment indicates the build number of the tool
|
||||
# used to generate this makefile.
|
||||
# BUILD_NUMBER: 590
|
||||
|
||||
SETTINGS_FILE := settings.bsp
|
||||
@ -105,52 +105,52 @@ SOPC_FILE := ../../sys.sopcinfo
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# TOOL & COMMAND DEFINITIONS
|
||||
#
|
||||
#
|
||||
# The base command for each build operation are expressed here. Additional
|
||||
# switches may be expressed here. They will run for all instances of the
|
||||
# switches may be expressed here. They will run for all instances of the
|
||||
# utility.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Archiver command. Creates library files.
|
||||
AR = riscv32-unknown-elf-ar
|
||||
# Archiver command. Creates library files.
|
||||
AR = riscv64-unknown-elf-ar
|
||||
|
||||
# Assembler command. Note that CC is used for .S files.
|
||||
AS = riscv32-unknown-elf-gcc
|
||||
# Assembler command. Note that CC is used for .S files.
|
||||
AS = riscv64-unknown-elf-gcc
|
||||
|
||||
# Custom flags only passed to the archiver. This content of this variable is
|
||||
# directly passed to the archiver rather than the more standard "ARFLAGS". The
|
||||
# reason for this is that GNU Make assumes some default content in ARFLAGS.
|
||||
# This setting defines the value of BSP_ARFLAGS in Makefile.
|
||||
# Custom flags only passed to the archiver. This content of this variable is
|
||||
# directly passed to the archiver rather than the more standard "ARFLAGS". The
|
||||
# reason for this is that GNU Make assumes some default content in ARFLAGS.
|
||||
# This setting defines the value of BSP_ARFLAGS in Makefile.
|
||||
BSP_ARFLAGS = -src
|
||||
|
||||
# Custom flags only passed to the assembler. This setting defines the value of
|
||||
# BSP_ASFLAGS in Makefile.
|
||||
# Custom flags only passed to the assembler. This setting defines the value of
|
||||
# BSP_ASFLAGS in Makefile.
|
||||
BSP_ASFLAGS = -Wa,-gdwarf2
|
||||
|
||||
# C/C++ compiler optimization level. "-O0" = no optimization,"-O2" = "normal"
|
||||
# optimization, etc. "-O0" is recommended for code that you want to debug since
|
||||
# compiler optimization can remove variables and produce non-sequential
|
||||
# execution of code while debugging. This setting defines the value of
|
||||
# BSP_CFLAGS_OPTIMIZATION in Makefile.
|
||||
# C/C++ compiler optimization level. "-O0" = no optimization,"-O2" = "normal"
|
||||
# optimization, etc. "-O0" is recommended for code that you want to debug since
|
||||
# compiler optimization can remove variables and produce non-sequential
|
||||
# execution of code while debugging. This setting defines the value of
|
||||
# BSP_CFLAGS_OPTIMIZATION in Makefile.
|
||||
BSP_CFLAGS_OPTIMIZATION = -Os
|
||||
|
||||
# C/C++ compiler warning level. "-Wall" is commonly used.This setting defines
|
||||
# the value of BSP_CFLAGS_WARNINGS in Makefile.
|
||||
# C/C++ compiler warning level. "-Wall" is commonly used.This setting defines
|
||||
# the value of BSP_CFLAGS_WARNINGS in Makefile.
|
||||
BSP_CFLAGS_WARNINGS = -Wall
|
||||
|
||||
# C compiler command.
|
||||
CC = riscv32-unknown-elf-gcc -xc
|
||||
# C compiler command.
|
||||
CC = riscv64-unknown-elf-gcc -xc
|
||||
|
||||
# C++ compiler command.
|
||||
CXX = riscv32-unknown-elf-gcc -xc++
|
||||
# C++ compiler command.
|
||||
CXX = riscv64-unknown-elf-gcc -xc++
|
||||
|
||||
# Command used to remove files during 'clean' target.
|
||||
# Command used to remove files during 'clean' target.
|
||||
RM = rm -f
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# BUILD PRE & POST PROCESS COMMANDS
|
||||
#
|
||||
#
|
||||
# The following variables are treated as shell commands in the rule
|
||||
# definitions for each file-type associated with the BSP build, as well as
|
||||
# commands run at the beginning and end of the entire BSP build operation.
|
||||
@ -158,7 +158,7 @@ RM = rm -f
|
||||
# a command defined in the "CC_PRE_PROCESS" variable executes before the C
|
||||
# compiler for building .c files), while post-process commands are executed
|
||||
# immediately afterwards.
|
||||
#
|
||||
#
|
||||
# You can view each pre/post-process command in the "Build Rules: All &
|
||||
# Clean", "Pattern Rules to Build Objects", and "Library Rules" sections of
|
||||
# this Makefile.
|
||||
@ -167,33 +167,33 @@ RM = rm -f
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# BSP SOURCE BUILD SETTINGS (FLAG GENERATION)
|
||||
#
|
||||
#
|
||||
# Software build settings such as compiler optimization, debug level, warning
|
||||
# flags, etc., may be defined in the following variables. The variables below
|
||||
# are concatenated together in the 'Flags' section of this Makefile to form
|
||||
# final variables of flags passed to the build tools.
|
||||
#
|
||||
#
|
||||
# These settings are considered private to the BSP and apply to all library &
|
||||
# driver files in it; they do NOT automatically propagate to, for example, the
|
||||
# build settings for an application.
|
||||
# # For additional detail and syntax requirements, please refer to GCC help
|
||||
# (example: "nios2-elf-gcc --help --verbose").
|
||||
#
|
||||
#
|
||||
# Unless indicated otherwise, multiple entries in each variable should be
|
||||
# space-separated.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Altera HAL alt_sys_init.c generated source file
|
||||
# Altera HAL alt_sys_init.c generated source file
|
||||
GENERATED_C_FILES := $(ABS_BSP_ROOT)/alt_sys_init.c
|
||||
GENERATED_C_LIB_SRCS += alt_sys_init.c
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# BSP SOURCE FILE LISTING
|
||||
#
|
||||
# All source files that comprise the BSP are listed here, along with path
|
||||
# information to each file expressed relative to the BSP root. The precise
|
||||
# list and location of each file is derived from the driver, operating system,
|
||||
#
|
||||
# All source files that comprise the BSP are listed here, along with path
|
||||
# information to each file expressed relative to the BSP root. The precise
|
||||
# list and location of each file is derived from the driver, operating system,
|
||||
# or software package source file declarations.
|
||||
#
|
||||
# Following specification of the source files for each component, driver, etc.,
|
||||
@ -202,10 +202,10 @@ GENERATED_C_LIB_SRCS += alt_sys_init.c
|
||||
# used to build each file.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# altera_avalon_jtag_uart_driver sources root
|
||||
# altera_avalon_jtag_uart_driver sources root
|
||||
altera_avalon_jtag_uart_driver_SRCS_ROOT := drivers
|
||||
|
||||
# altera_avalon_jtag_uart_driver sources
|
||||
# altera_avalon_jtag_uart_driver sources
|
||||
altera_avalon_jtag_uart_driver_C_LIB_SRCS := \
|
||||
$(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_init.c \
|
||||
$(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_read.c \
|
||||
@ -213,14 +213,14 @@ altera_avalon_jtag_uart_driver_C_LIB_SRCS := \
|
||||
$(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_ioctl.c \
|
||||
$(altera_avalon_jtag_uart_driver_SRCS_ROOT)/src/altera_avalon_jtag_uart_fd.c
|
||||
|
||||
# altera_avalon_pio_driver sources root
|
||||
# altera_avalon_pio_driver sources root
|
||||
altera_avalon_pio_driver_SRCS_ROOT := drivers
|
||||
|
||||
# altera_avalon_pio_driver sources
|
||||
# altera_avalon_timer_driver sources root
|
||||
# altera_avalon_pio_driver sources
|
||||
# altera_avalon_timer_driver sources root
|
||||
altera_avalon_timer_driver_SRCS_ROOT := drivers
|
||||
|
||||
# altera_avalon_timer_driver sources
|
||||
# altera_avalon_timer_driver sources
|
||||
altera_avalon_timer_driver_C_LIB_SRCS := \
|
||||
$(altera_avalon_timer_driver_SRCS_ROOT)/src/altera_avalon_timer_ts.c \
|
||||
$(altera_avalon_timer_driver_SRCS_ROOT)/src/altera_avalon_timer_vars.c
|
||||
@ -232,10 +232,10 @@ altera_epcq_controller2_driver_SRCS_ROOT := drivers
|
||||
altera_epcq_controller2_driver_C_LIB_SRCS := \
|
||||
$(altera_epcq_controller2_driver_SRCS_ROOT)/src/altera_epcq_controller2.c
|
||||
|
||||
# altera_nios2_gen2_hal_driver sources root
|
||||
# altera_nios2_gen2_hal_driver sources root
|
||||
altera_nios2_gen2_hal_driver_SRCS_ROOT := HAL
|
||||
|
||||
# altera_nios2_gen2_hal_driver sources
|
||||
# altera_nios2_gen2_hal_driver sources
|
||||
altera_nios2_gen2_hal_driver_C_LIB_SRCS := \
|
||||
$(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_usleep.c \
|
||||
$(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_printf.c \
|
||||
@ -251,28 +251,28 @@ altera_nios2_gen2_hal_driver_C_LIB_SRCS := \
|
||||
$(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_do_ctors.c \
|
||||
$(altera_nios2_gen2_hal_driver_SRCS_ROOT)/src/alt_do_dtors.c
|
||||
|
||||
# hal sources root
|
||||
# hal sources root
|
||||
hal_SRCS_ROOT := HAL
|
||||
|
||||
# hal sources
|
||||
# hal sources
|
||||
hal_C_LIB_SRCS := \
|
||||
$(hal_SRCS_ROOT)/src/alt_dev_llist_insert.c \
|
||||
$(hal_SRCS_ROOT)/src/alt_errno.c \
|
||||
$(hal_SRCS_ROOT)/src/alt_flash_dev.c \
|
||||
$(hal_SRCS_ROOT)/src/alt_main.c
|
||||
|
||||
# i2c_opencores_driver sources root
|
||||
# i2c_opencores_driver sources root
|
||||
i2c_opencores_driver_SRCS_ROOT := drivers
|
||||
|
||||
# i2c_opencores_driver sources
|
||||
# i2c_opencores_driver sources
|
||||
i2c_opencores_driver_C_LIB_SRCS := \
|
||||
$(i2c_opencores_driver_SRCS_ROOT)/src/i2c_opencores.c
|
||||
|
||||
# nios2_hw_crc32_driver sources root
|
||||
# nios2_hw_crc32_driver sources root
|
||||
nios2_hw_crc32_driver_SRCS_ROOT := drivers
|
||||
|
||||
|
||||
# Assemble all component C source files
|
||||
# Assemble all component C source files
|
||||
COMPONENT_C_LIB_SRCS += \
|
||||
$(altera_avalon_jtag_uart_driver_C_LIB_SRCS) \
|
||||
$(altera_avalon_timer_driver_C_LIB_SRCS) \
|
||||
@ -282,11 +282,11 @@ COMPONENT_C_LIB_SRCS += \
|
||||
$(i2c_opencores_driver_C_LIB_SRCS) \
|
||||
$(nios2_hw_crc32_driver_C_LIB_SRCS)
|
||||
|
||||
# Assemble all component assembly source files
|
||||
# Assemble all component assembly source files
|
||||
COMPONENT_ASM_LIB_SRCS += \
|
||||
$(altera_nios2_gen2_hal_driver_ASM_LIB_SRCS)
|
||||
|
||||
# Assemble all component C++ source files
|
||||
# Assemble all component C++ source files
|
||||
COMPONENT_CPP_LIB_SRCS += \
|
||||
|
||||
#END MANAGED
|
||||
@ -306,7 +306,7 @@ COMPONENT_CPP_LIB_SRCS += \
|
||||
# purpose of this variable is to allow an external Makefile to append on
|
||||
# path information to precisely locate paths expressed in public.mk
|
||||
# Since this is the BSP Makefile, we set ALT_LIBRARY_ROOT_DIR to point right
|
||||
# here ("."), at the BSP root.
|
||||
# here ("."), at the BSP root.
|
||||
#
|
||||
# ALT_LIBRARY_ROOT_DIR must always be set before public.mk is included.
|
||||
#------------------------------------------------------------------------------
|
||||
@ -332,13 +332,14 @@ BSP_CFLAGS += \
|
||||
$(BSP_CFLAGS_WARNINGS) \
|
||||
$(BSP_CFLAGS_USER_FLAGS) \
|
||||
$(ALT_CFLAGS) \
|
||||
$(CFLAGS)
|
||||
$(CFLAGS)
|
||||
|
||||
# Make ready the final list of include directories and other C pre-processor
|
||||
# flags. Each include path is made ready by prefixing it with "-I".
|
||||
BSP_CPPFLAGS += \
|
||||
$(addprefix -I, $(BSP_INC_DIRS)) \
|
||||
$(addprefix -I, $(ALT_INCLUDE_DIRS)) \
|
||||
$(addprefix -I, /usr/lib/picolibc/riscv64-unknown-elf/include) \
|
||||
$(ALT_CPPFLAGS) \
|
||||
$(CPPFLAGS)
|
||||
|
||||
@ -408,7 +409,7 @@ DEPS = $(OBJS:.o=.d)
|
||||
|
||||
|
||||
# Rules to force your project to rebuild or relink
|
||||
# .force_relink file will cause any application that depends on this project to relink
|
||||
# .force_relink file will cause any application that depends on this project to relink
|
||||
# .force_rebuild file will cause this project to rebuild object files
|
||||
# .force_rebuild_all file will cause this project and any project that depends on this project to rebuild object files
|
||||
|
||||
@ -691,7 +692,7 @@ endif
|
||||
ifneq ($(NEWLIB_DIR),)
|
||||
$(NEWLIB_DIR):
|
||||
@$(ECHO) Creating $(NEWLIB_DIR)...
|
||||
nios2-newlib-gen --no-multilib $(NEWLIB_DIR)-build-tmp $(NEWLIB_DIR) --custom "$(NEWLIB_FLAGS)"
|
||||
nios2-newlib-gen --no-multilib $(NEWLIB_DIR)-build-tmp $(NEWLIB_DIR) --custom "$(NEWLIB_FLAGS)"
|
||||
@$(ECHO) Removing $(NEWLIB_DIR)-build-tmp...
|
||||
@$(RM) -rf $(NEWLIB_DIR)-build-tmp
|
||||
endif
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user