-
Notifications
You must be signed in to change notification settings - Fork 55.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds Makefile and Kconfig files required for building a nios2 kernel. Signed-off-by: Ley Foon Tan <[email protected]>
- Loading branch information
Ley Foon Tan
committed
Dec 8, 2014
1 parent
9cce02e
commit 2fc8483
Showing
15 changed files
with
826 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
config NIOS2 | ||
def_bool y | ||
select ARCH_WANT_OPTIONAL_GPIOLIB | ||
select CLKSRC_OF | ||
select GENERIC_ATOMIC64 | ||
select GENERIC_CLOCKEVENTS | ||
select GENERIC_CPU_DEVICES | ||
select GENERIC_IRQ_PROBE | ||
select GENERIC_IRQ_SHOW | ||
select HAVE_ARCH_TRACEHOOK | ||
select IRQ_DOMAIN | ||
select MODULES_USE_ELF_RELA | ||
select OF | ||
select OF_EARLY_FLATTREE | ||
select SOC_BUS | ||
select SPARSE_IRQ | ||
select USB_ARCH_HAS_HCD if USB_SUPPORT | ||
|
||
config GENERIC_CSUM | ||
def_bool y | ||
|
||
config GENERIC_HWEIGHT | ||
def_bool y | ||
|
||
config GENERIC_CALIBRATE_DELAY | ||
def_bool y | ||
|
||
config NO_IOPORT_MAP | ||
def_bool y | ||
|
||
config HAS_DMA | ||
def_bool y | ||
|
||
config FPU | ||
def_bool n | ||
|
||
config SWAP | ||
def_bool n | ||
|
||
config RWSEM_GENERIC_SPINLOCK | ||
def_bool y | ||
|
||
config TRACE_IRQFLAGS_SUPPORT | ||
def_bool n | ||
|
||
source "init/Kconfig" | ||
|
||
menu "Kernel features" | ||
|
||
source "kernel/Kconfig.preempt" | ||
|
||
source "kernel/Kconfig.freezer" | ||
|
||
source "kernel/Kconfig.hz" | ||
|
||
source "mm/Kconfig" | ||
|
||
config FORCE_MAX_ZONEORDER | ||
int "Maximum zone order" | ||
range 9 20 | ||
default "11" | ||
help | ||
The kernel memory allocator divides physically contiguous memory | ||
blocks into "zones", where each zone is a power of two number of | ||
pages. This option selects the largest power of two that the kernel | ||
keeps in the memory allocator. If you need to allocate very large | ||
blocks of physically contiguous memory, then you may need to | ||
increase this value. | ||
|
||
This config option is actually maximum order plus one. For example, | ||
a value of 11 means that the largest free memory block is 2^10 pages. | ||
|
||
endmenu | ||
|
||
source "arch/nios2/platform/Kconfig.platform" | ||
|
||
menu "Processor type and features" | ||
|
||
config MMU | ||
def_bool y | ||
|
||
config NIOS2_ALIGNMENT_TRAP | ||
bool "Catch alignment trap" | ||
default y | ||
help | ||
Nios II CPUs cannot fetch/store data which is not bus aligned, | ||
i.e., a 2 or 4 byte fetch must start at an address divisible by | ||
2 or 4. Any non-aligned load/store instructions will be trapped and | ||
emulated in software if you say Y here, which has a performance | ||
impact. | ||
|
||
comment "Boot options" | ||
|
||
config CMDLINE_BOOL | ||
bool "Default bootloader kernel arguments" | ||
default y | ||
|
||
config CMDLINE | ||
string "Default kernel command string" | ||
default "" | ||
depends on CMDLINE_BOOL | ||
help | ||
On some platforms, there is currently no way for the boot loader to | ||
pass arguments to the kernel. For these platforms, you can supply | ||
some command-line options at build time by entering them here. In | ||
other cases you can specify kernel args so that you don't have | ||
to set them up in board prom initialization routines. | ||
|
||
config CMDLINE_FORCE | ||
bool "Force default kernel command string" | ||
depends on CMDLINE_BOOL | ||
help | ||
Set this to have arguments from the default kernel command string | ||
override those passed by the boot loader. | ||
|
||
config NIOS2_CMDLINE_IGNORE_DTB | ||
bool "Ignore kernel command string from DTB" | ||
depends on !CMDLINE_FORCE | ||
default y | ||
help | ||
Set this to ignore the bootargs property from the devicetree's | ||
chosen node and fall back to CMDLINE if nothing is passed. | ||
|
||
config NIOS2_PASS_CMDLINE | ||
bool "Passed kernel command line from u-boot" | ||
default n | ||
help | ||
Use bootargs env variable from u-boot for kernel command line. | ||
will override "Default kernel command string". | ||
Say N if you are unsure. | ||
|
||
endmenu | ||
|
||
menu "Advanced setup" | ||
|
||
config ADVANCED_OPTIONS | ||
bool "Prompt for advanced kernel configuration options" | ||
help | ||
|
||
comment "Default settings for advanced configuration options are used" | ||
depends on !ADVANCED_OPTIONS | ||
|
||
config NIOS2_KERNEL_MMU_REGION_BASE_BOOL | ||
bool "Set custom kernel MMU region base address" | ||
depends on ADVANCED_OPTIONS | ||
help | ||
This option allows you to set the virtual address of the kernel MMU region. | ||
|
||
Say N here unless you know what you are doing. | ||
|
||
config NIOS2_KERNEL_MMU_REGION_BASE | ||
hex "Virtual base address of the kernel MMU region " if NIOS2_KERNEL_MMU_REGION_BASE_BOOL | ||
default "0x80000000" | ||
help | ||
This option allows you to set the virtual base address of the kernel MMU region. | ||
|
||
config NIOS2_KERNEL_REGION_BASE_BOOL | ||
bool "Set custom kernel region base address" | ||
depends on ADVANCED_OPTIONS | ||
help | ||
This option allows you to set the virtual address of the kernel region. | ||
|
||
Say N here unless you know what you are doing. | ||
|
||
config NIOS2_KERNEL_REGION_BASE | ||
hex "Virtual base address of the kernel region " if NIOS2_KERNEL_REGION_BASE_BOOL | ||
default "0xc0000000" | ||
|
||
config NIOS2_IO_REGION_BASE_BOOL | ||
bool "Set custom I/O region base address" | ||
depends on ADVANCED_OPTIONS | ||
help | ||
This option allows you to set the virtual address of the I/O region. | ||
|
||
Say N here unless you know what you are doing. | ||
|
||
config NIOS2_IO_REGION_BASE | ||
hex "Virtual base address of the I/O region" if NIOS2_IO_REGION_BASE_BOOL | ||
default "0xe0000000" | ||
|
||
endmenu | ||
|
||
menu "Executable file formats" | ||
|
||
source "fs/Kconfig.binfmt" | ||
|
||
endmenu | ||
|
||
source "net/Kconfig" | ||
|
||
source "drivers/Kconfig" | ||
|
||
source "fs/Kconfig" | ||
|
||
source "arch/nios2/Kconfig.debug" | ||
|
||
source "security/Kconfig" | ||
|
||
source "crypto/Kconfig" | ||
|
||
source "lib/Kconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
menu "Kernel hacking" | ||
|
||
config TRACE_IRQFLAGS_SUPPORT | ||
def_bool y | ||
|
||
source "lib/Kconfig.debug" | ||
|
||
config DEBUG_STACK_USAGE | ||
bool "Enable stack utilization instrumentation" | ||
depends on DEBUG_KERNEL | ||
help | ||
Enables the display of the minimum amount of free stack which each | ||
task has ever had available in the sysrq-T and sysrq-P debug output. | ||
|
||
This option will slow down process creation somewhat. | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# | ||
# This file is subject to the terms and conditions of the GNU General Public | ||
# License. See the file "COPYING" in the main directory of this archive | ||
# for more details. | ||
# | ||
# Copyright (C) 2013 Altera Corporation | ||
# Copyright (C) 1994, 95, 96, 2003 by Wind River Systems | ||
# Written by Fredrik Markstrom | ||
# | ||
# This file is included by the global makefile so that you can add your own | ||
# architecture-specific flags and dependencies. Remember to do have actions | ||
# for "archclean" cleaning up for this architecture. | ||
# | ||
# Nios2 port by Wind River Systems Inc trough: | ||
# [email protected] and [email protected] | ||
|
||
UTS_SYSNAME = Linux | ||
|
||
export MMU | ||
|
||
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) | ||
|
||
KBUILD_CFLAGS += -pipe -D__linux__ -D__ELF__ | ||
KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MUL_SUPPORT),-mhw-mul,-mno-hw-mul) | ||
KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx) | ||
KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div) | ||
KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,) | ||
|
||
KBUILD_CFLAGS += -fno-optimize-sibling-calls | ||
KBUILD_CFLAGS += -DUTS_SYSNAME=\"$(UTS_SYSNAME)\" | ||
KBUILD_CFLAGS += -fno-builtin | ||
KBUILD_CFLAGS += -G 0 | ||
|
||
head-y := arch/nios2/kernel/head.o | ||
libs-y += arch/nios2/lib/ $(LIBGCC) | ||
core-y += arch/nios2/kernel/ arch/nios2/mm/ | ||
core-y += arch/nios2/platform/ | ||
|
||
INSTALL_PATH ?= /tftpboot | ||
nios2-boot := arch/$(ARCH)/boot | ||
BOOT_TARGETS = vmImage zImage | ||
PHONY += $(BOOT_TARGETS) install | ||
KBUILD_IMAGE := $(nios2-boot)/vmImage | ||
|
||
ifneq ($(CONFIG_NIOS2_DTB_SOURCE),"") | ||
core-y += $(nios2-boot)/ | ||
endif | ||
|
||
all: vmImage | ||
|
||
archclean: | ||
$(Q)$(MAKE) $(clean)=$(nios2-boot) | ||
|
||
%.dtb: | ||
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ | ||
|
||
dtbs: | ||
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ | ||
|
||
$(BOOT_TARGETS): vmlinux | ||
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ | ||
|
||
install: | ||
$(Q)$(MAKE) $(build)=$(nios2-boot) BOOTIMAGE=$(KBUILD_IMAGE) install | ||
|
||
define archhelp | ||
echo '* vmImage - Kernel-only image for U-Boot ($(KBUILD_IMAGE))' | ||
echo ' install - Install kernel using' | ||
echo ' (your) ~/bin/$(INSTALLKERNEL) or' | ||
echo ' (distribution) /sbin/$(INSTALLKERNEL) or' | ||
echo ' install to $$(INSTALL_PATH)' | ||
echo ' dtbs - Build device tree blobs for enabled boards' | ||
endef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# | ||
# arch/nios2/boot/Makefile | ||
# | ||
# This file is subject to the terms and conditions of the GNU General Public | ||
# License. See the file "COPYING" in the main directory of this archive | ||
# for more details. | ||
# | ||
|
||
UIMAGE_LOADADDR = $(shell $(NM) vmlinux | awk '$$NF == "_stext" {print $$1}') | ||
UIMAGE_ENTRYADDR = $(shell $(NM) vmlinux | awk '$$NF == "_start" {print $$1}') | ||
UIMAGE_COMPRESSION = gzip | ||
|
||
OBJCOPYFLAGS_vmlinux.bin := -O binary | ||
|
||
targets += vmlinux.bin vmlinux.gz vmImage | ||
|
||
$(obj)/vmlinux.bin: vmlinux FORCE | ||
$(call if_changed,objcopy) | ||
|
||
$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE | ||
$(call if_changed,gzip) | ||
|
||
$(obj)/vmImage: $(obj)/vmlinux.gz | ||
$(call if_changed,uimage) | ||
@$(kecho) 'Kernel: $@ is ready' | ||
|
||
# Rule to build device tree blobs | ||
DTB_SRC := $(patsubst "%",%,$(CONFIG_NIOS2_DTB_SOURCE)) | ||
|
||
# Make sure the generated dtb gets removed during clean | ||
extra-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += system.dtb | ||
|
||
$(obj)/system.dtb: $(DTB_SRC) FORCE | ||
$(call cmd,dtc) | ||
|
||
# Ensure system.dtb exists | ||
$(obj)/linked_dtb.o: $(obj)/system.dtb | ||
|
||
obj-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += linked_dtb.o | ||
|
||
targets += $(dtb-y) | ||
|
||
# Rule to build device tree blobs with make command | ||
$(obj)/%.dtb: $(src)/dts/%.dts FORCE | ||
$(call if_changed_dep,dtc) | ||
|
||
$(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y)) | ||
|
||
clean-files := *.dtb | ||
|
||
install: | ||
sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
# | ||
# This file is subject to the terms and conditions of the GNU General Public | ||
# License. See the file "COPYING" in the main directory of this archive | ||
# for more details. | ||
# | ||
# Copyright (C) 1995 by Linus Torvalds | ||
# | ||
# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin | ||
# | ||
# "make install" script for nios2 architecture | ||
# | ||
# Arguments: | ||
# $1 - kernel version | ||
# $2 - kernel image file | ||
# $3 - kernel map file | ||
# $4 - default install path (blank if root directory) | ||
# | ||
|
||
verify () { | ||
if [ ! -f "$1" ]; then | ||
echo "" 1>&2 | ||
echo " *** Missing file: $1" 1>&2 | ||
echo ' *** You need to run "make" before "make install".' 1>&2 | ||
echo "" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Make sure the files actually exist | ||
verify "$2" | ||
verify "$3" | ||
|
||
# User may have a custom install script | ||
|
||
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi | ||
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi | ||
|
||
# Default install - same as make zlilo | ||
|
||
if [ -f $4/vmlinuz ]; then | ||
mv $4/vmlinuz $4/vmlinuz.old | ||
fi | ||
|
||
if [ -f $4/System.map ]; then | ||
mv $4/System.map $4/System.old | ||
fi | ||
|
||
cat $2 > $4/vmlinuz | ||
cp $3 $4/System.map | ||
|
||
sync |
Oops, something went wrong.