这个是我早期在mtk 修改的 禁止uart 串口打印功能。不论什么版本 都是大同小异 思路万古不变。
这个 修改主要在 Android 系统中修改了 bootloader 和 kernel 的相关代码,使得系统在启动时不再通过 UART 输出日志。
修改的文件:
bootable/bootloader/lk/app/mt_boot/mt_boot.c
bootable/bootloader/preloader/custom/btf8735_mp12/cust_bldr.mak
bootable/bootloader/preloader/platform/mt6735/default.mak
kernel-3.10/arch/arm64/configs/btf8735_mp12_defconfig
kernel-3.10/kernel/printk.c
system/core/rootdir/init.rc
文件修改说明:
mt_boot.c
: 修改了启动参数,使得 printk 不再通过 UART 输出。cust_bldr.mak
和default.mak
: 修改了 UART 的配置,使得 bootloader 不再通过 UART 输出日志。btf8735_mp12_defconfig
: 修改了 kernel 的配置,使得 printk 不再通过 UART 输出。printk.c
: 修改了文件权限,可能是为了禁止其他用户修改此文件。init.rc
: 修改了 Android 的 init 脚本,使得在系统启动时不再启动 console 服务,从而禁止了通过 UART 输出日志。
--- bootable/bootloader/lk/app/mt_boot/mt_boot.c | 8 ++++---- bootable/bootloader/preloader/custom/btf8735_mp12/cust_bldr.mak | 4 ++-- bootable/bootloader/preloader/platform/mt6735/default.mak | 4 ++-- kernel-3.10/arch/arm64/configs/btf8735_mp12_defconfig | 2 +- kernel-3.10/kernel/printk.c | 0 system/core/rootdir/init.rc | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) mode change 100644 => 100755 kernel-3.10/kernel/printk.c diff --git a/bootable/bootloader/lk/app/mt_boot/mt_boot.c b/bootable/bootloader/lk/app/mt_boot/mt_boot.c index e960fe7..eca25ae 100755 --- a/bootable/bootloader/lk/app/mt_boot/mt_boot.c +++ b/bootable/bootloader/lk/app/mt_boot/mt_boot.c @@ -572,9 +572,9 @@ int boot_linux_fdt(void *kernel, unsigned *tags, if (!has_set_p2u) { #ifdef USER_BUILD - sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=0"); + sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=1"); #else - sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=0 ddebug_query=\"file *mediatek* +p ; file *gpu* =_\""); + sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=1 ddebug_query=\"file *mediatek* +p ; file *gpu* =_\""); #endif /*Append pre-loader boot time to kernel command line*/ @@ -779,9 +779,9 @@ void boot_linux(void *kernel, unsigned *tags, #endif if (!has_set_p2u) { #ifdef USER_BUILD - sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=0"); + sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=1"); #else - sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=0 ddebug_query=\"file *mediatek* +p ; file *gpu* =_\""); + sprintf(cmdline,"%s%s",cmdline," printk.disable_uart=1 ddebug_query=\"file *mediatek* +p ; file *gpu* =_\""); #endif } /*Append pre-loader boot reason to kernel command line*/ diff --git a/bootable/bootloader/preloader/custom/btf8735_mp12/cust_bldr.mak b/bootable/bootloader/preloader/custom/btf8735_mp12/cust_bldr.mak index 72aeced..d250f81 100755 --- a/bootable/bootloader/preloader/custom/btf8735_mp12/cust_bldr.mak +++ b/bootable/bootloader/preloader/custom/btf8735_mp12/cust_bldr.mak @@ -9,6 +9,6 @@ else CFG_BOOT_DEV :=BOOTDEV_NAND endif -CFG_UART_LOG :=UART2 -CFG_UART_META :=UART2 +CFG_UART_LOG :=UART1 +CFG_UART_META :=UART1 CFG_APWDT_DISABLE :=1 \ No newline at end of file diff --git a/bootable/bootloader/preloader/platform/mt6735/default.mak b/bootable/bootloader/preloader/platform/mt6735/default.mak index 6576a26..51b8a11 100755 --- a/bootable/bootloader/preloader/platform/mt6735/default.mak +++ b/bootable/bootloader/preloader/platform/mt6735/default.mak @@ -24,8 +24,8 @@ CFG_USB_TOOL_HANDSHAKE :=1 CFG_USB_DOWNLOAD :=1 CFG_LOG_BAUDRATE :=921600 CFG_META_BAUDRATE :=115200 -CFG_UART_LOG :=UART2 -CFG_UART_META :=UART2 +CFG_UART_LOG :=UART1 +CFG_UART_META :=UART1 #only enable in eng mode ifeq ("$(TARGET_BUILD_VARIANT)","eng") diff --git a/kernel-3.10/arch/arm64/configs/btf8735_mp12_defconfig b/kernel-3.10/arch/arm64/configs/btf8735_mp12_defconfig index 5d66cc4..a69b56a 100755 --- a/kernel-3.10/arch/arm64/configs/btf8735_mp12_defconfig +++ b/kernel-3.10/arch/arm64/configs/btf8735_mp12_defconfig @@ -1098,7 +1098,7 @@ CONFIG_MTK_RAM_CONSOLE_DRAM_ADDR=0x43F00000 # CONFIG_MT_CHRDEV_REG is not set # CONFIG_MT_LOCK_DEBUG is not set CONFIG_PRINTK_PROCESS_INFO=y -CONFIG_MT_PRINTK_UART_CONSOLE=y +# CONFIG_MT_PRINTK_UART_CONSOLE=y # CONFIG_MT_ENG_BUILD is not set CONFIG_RAMDISK_OFFSET=0xF00000 # CONFIG_EARLY_LINUX_PORTING is not set diff --git a/kernel-3.10/kernel/printk.c b/kernel-3.10/kernel/printk.c old mode 100644 new mode 100755 diff --git a/system/core/rootdir/init.rc b/system/core/rootdir/init.rc index bda0094..b0fd4f8 100755 --- a/system/core/rootdir/init.rc +++ b/system/core/rootdir/init.rc @@ -500,11 +500,11 @@ service console /system/bin/sh # user shell # seclabel u:r:shell:s0 -on property:ro.debuggable=1 - start console +#on property:ro.debuggable=1 +# start console -on property:ro.debuggable=0 - start console +#on property:ro.debuggable=0 +# start console # adbd is controlled via property triggers in init.<platform>.usb.rc service adbd /sbin/adbd --root_seclabel=u:r:su:s0 -- 1.9.1