说明
本次改动, 可以在内核启动时打印出客制化的log信息, 对于后续问题分析和溯回都有帮助. 效仿 Linux 添加:
- 内核编译路径
- 内核编译时间
- 内核Git版本
- 公司或个人信息
- DTS文件名
效果图
修改源码
diff --git a/Makefile b/Makefile
old mode 100644
new mode 100755
index 3fdc0bf..8d394be
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,14 @@ ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
+ifeq ("$(origin DTS)", "command line")
+ KBUILD_DTS = $(DTS)
+endif
+ifndef KBUILD_DTS
+ KBUILD_DTS = "UNKNOWN"
+endif
+export KBUILD_DTS
+
# Call a source code checker (by default, "sparse") as part of the
# C compilation.
#
@@ -355,9 +363,10 @@ CHECK = sparse
# Use the wrapper for the compiler. This wrapper scans for new
# warnings and causes the build to stop upon encountering them.
-ifneq ($(wildcard $(srctree)/scripts/gcc-wrapper.py),)
-CC = $(srctree)/scripts/gcc-wrapper.py $(CROSS_COMPILE)gcc
-endif
+# Modify Tower 20181101, Remove compilation problems
+#ifneq ($(wildcard $(srctree)/scripts/gcc-wrapper.py),)
+#CC = $(srctree)/scripts/gcc-wrapper.py $(CROSS_COMPILE)gcc
+#endif
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void $(CF)
diff --git a/include/linux/printk.h b/include/linux/printk.h
old mode 100644
new mode 100755
index 708b8a8..ec7ffa5
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -8,6 +8,7 @@
extern const char linux_banner[];
extern const char linux_proc_banner[];
+extern const char sunchip_info[];
static inline int printk_get_level(const char *buffer)
{
diff --git a/init/Makefile b/init/Makefile
old mode 100644
new mode 100755
index 692b91f..2979efd
--- a/init/Makefile
+++ b/init/Makefile
@@ -30,4 +30,5 @@ silent_chk_compile.h = :
include/generated/compile.h: FORCE
@$($(quiet)chk_compile.h)
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
- "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)"
+ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)" \
+ "$(shell pwd)" "$(shell cd $(srctree) && git log -1 --oneline | awk '{print $$1}')" "$(KBUILD_DTS)"
diff --git a/init/main.c b/init/main.c
old mode 100644
new mode 100755
index 2132ffd..54a98d4
--- a/init/main.c
+++ b/init/main.c
@@ -499,6 +499,7 @@ asmlinkage void __init start_kernel(void)
boot_cpu_init();
page_address_init();
pr_notice("%s", linux_banner);
+ pr_notice("%s", sunchip_info);
setup_arch(&command_line);
mm_init_owner(&init_mm, &init_task);
mm_init_cpumask(&init_mm);
@@ -889,6 +890,7 @@ static noinline void __init kernel_init_freeable(void)
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");
+ pr_err("iFinelio Tower!");
(void) sys_dup(0);
(void) sys_dup(0);
/*
diff --git a/init/version.c b/init/version.c
old mode 100644
new mode 100755
index 1a4718e..d0e047e
--- a/init/version.c
+++ b/init/version.c
@@ -48,3 +48,7 @@ const char linux_proc_banner[] =
"%s version %s"
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
" (" LINUX_COMPILER ") %s\n";
+
+// Modify Tower 20190123
+const char sunchip_info[] =
+ "Sunchip version " SUNCHIP_INFO " - " SUNCHIP_DTS "\n";
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index f221ddf..a2518aa 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -59,6 +59,28 @@ if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
+# Modify Tower 20190114, add compile info
+LOCAL_DIR=$6
+LOCAL_GIT=$7
+LOCAL_DTS=$8
+if [ -z "$LOCAL_DIR" ]; then
+ SUNCHIP_INFO="(dir@UNKNOWN)"
+else
+ SUNCHIP_INFO="(dir@$LOCAL_DIR)"
+fi
+
+if [ -z "$LOCAL_GIT" ]; then
+ SUNCHIP_INFO+=" #UNKNOWN"
+else
+ SUNCHIP_INFO+=" #$LOCAL_GIT"
+fi
+
+if [ -z "$LOCAL_DTS" ]; then
+ SUNCHIP_DTS=" (DTS@UNKNON)"
+else
+ SUNCHIP_DTS=" (DTS@$LOCAL_DTS)"
+fi
+
# Truncate to maximum length
UTS_LEN=64
@@ -77,6 +99,10 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
+
+
+ echo \#define SUNCHIP_DTS \"`echo $SUNCHIP_DTS`\"
+ echo \#define SUNCHIP_INFO \"`echo $SUNCHIP_INFO`\"
) > .tmpcompile
# Only replace the real compile.h if the new one is different,