解决问题的过程中,好文章推荐,都保存在火狐
[email protected]记录中~~~~~~~~
grep -r "earlyprintk" kernel
kernel/Documentation/driver-model/platform.txt:should use early_platform_init("earlyprintk", &platform_driver).
./arch/sh/configs/sh2007_defconfig:CONFIG_CMDLINE="console=ttySC1,115200 ip=dhcp root=/dev/nfs rw nfsroot=/nfs/rootfs,rsize=1024,wsize=1024 earlyprintk=sh-sci.1"
./arch/sh/configs/rsk7203_defconfig:CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel"
./arch/sh/configs/migor_defconfig:CONFIG_CMDLINE="console=tty0 console=ttySC0,115200 earlyprintk=serial ip=on root=/dev/nfs ip=dhcp"
./arch/sh/configs/sdk7786_defconfig:CONFIG_CMDLINE="console=ttySC1,115200 earlyprintk=sh-sci.1,115200 root=/dev/sda1 nmi_debug=state,debounce rootdelay=5 pmb=iomap ignore_loglevel"
./arch/sh/configs/rsk7201_defconfig:CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ignore_loglevel"
./arch/sh/configs/shx3_defconfig:CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=bios ignore_loglevel"
/************************************
全盘搜索earlyprintk查看其调用过程
***************************************/
全盘搜索earlyprintk查看其调用过程
①在kernel-parameters.txt中有如下描述,看我们的对应哪个,
earlyprintk=
[X86,SH,BLACKFIN,ARM] earlyprintk=vga
earlyprintk=xen
earlyprintk=serial[,ttySn[,baudrate]]
earlyprintk=serial[,0x...[,baudrate]]
earlyprintk=ttySn[,baudrate]
earlyprintk=dbgp[debugController#]
最终我们调用的是:earlyprintk=msm_hsl_uart,0x078b0000 。 0x078b0000是uart2的基地址
/************************************
确定uart2的基地址:
***************************************/
cd /android/kernel/arch/arm64/boot/dts
grep -r "uart" . |grep 8916
看到一下几行
./qcom/msm8916.dtsi: pinctrl-0 = <&hsuart_sleep>;
./qcom/msm8916.dtsi: pinctrl-1 = <&hsuart_active>;
./qcom/msm8916.dtsi: blsp1_uart2: serial@78b0000 {
./qcom/msm8916.dtsi: compatible = "qcom,msm-lsuart-v14";
./qcom/msm8916.dtsi: clocks = <&clock_gcc clk_gcc_blsp1_uart2_apps_clk>,
这里的blsp1_uart2: serial@78b0000 中的78b0000就是基地址
手册中也可以查到这个 基地址
如果启动过程中没有相关的打印显示,则应打开必要的打印:
#CONFIG_SERIAL_MSM_HS=y
#CONFIG_SERIAL_MSM_HSL=y
#CONFIG_SERIAL_MSM_HSL_CONSOLE=y
CONFIG_CMDLINE的位置:
①android/device/qcom/msm8916_64/BoardConfig.mk /************/earlyprintk在这里设置后,./build.sh kernel后boot.img没有重新生成。。
②android/kernel/arch/arm/boot/dts/qcom/msm8939.dtsi 里搜索chosen{有bootargs的设置}
③android/bootable/bootloader/lk/app/aboot/aboot.c
内核中查看cmdlines
cat /proc/cmdlines
过程中遇到的问题:在改动①android/device/qcom/msm8916_64/BoardConfig.mk中的CMDLINE后,应该将生成目录中的/android/out目录重新删除,否则./build.sh kernel命令执行后不更新boot.img
打印的log中搜索earlyprink/earlycon/bootconsoles,看到有一下打印
在一下程序中找到:原因是只有CMDLINE+ earlyprintk,而没有给earlyprink赋值
if (!buf) {
pr_warning("No earlyprintk arguments passed.\n");
return 0;
}
kernel-parameters.txt中有如下描述
earlycon=
[KNL] Output early console device and options. uart[8250],io,
[,options]
uart[8250],mmio,[,options]
uart[8250],mmio32,[,options] Start an early, polled-mode console on the 8250/16550
UART at the specified I/O port or MMIO address.
MMIO inter-register address stride is either 8-bit
(mmio) or 32-bit (mmio32).
The options are the same as for ttyS, above.
*********************earlycon******************
earlycon根据其他的config文件中的设置一下
//grep -r “earlycon” *config
./drivers/tty/serial/8250/Kconfig:
"earlycon=uart8250,io,0x3f8,9600n8"
./drivers/tty/serial/8250/Kconfig:
"earlycon=uart8250,mmio,0xff5e0000,115200n8".
void __init parse_early_options(char *cmdline)
parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param);
parse_one(param, val, doing, params, num, min_level, max_level, unknown);
handle_unknown(param, val, doing); doing="early options"
另一种启动方式:
fastboot -c "earlyprintk=msm_hsl_uart,0x078b0000" boot boot.img可以通过fastboot启动指定内核。虽然启动没成功,但是大概命令应该没错~~~有待改进。。
google里搜索No earlyprintk arguments passed
https://lists.linaro.org/pipermail/linaro-kernel/2013-May/004416.html这篇文章好像可已解决问题
正常串口的设置: CMDLINE中的console=ttyHSL0,115200,n8 参数
platform_driver_register(&msm_hsl_platform_driver);
msm_hsl_platform_driver
msm_serial_hsl_probe
uart_add_one_port(&msm_hsl_uart_driver, port);
uport->cons = drv->cons;
uart_configure_port(drv, state, uport);
uart_configure_port(struct uart_driver *drv, struct uart_state *state,struct uart_port *port)
register_console(port->cons);
uart_add_one_port(&msm_hsl_uart_driver, port);
static struct uart_driver msm_hsl_uart_driver = {
.owner = THIS_MODULE,
.driver_name = "msm_serial_hsl",
.dev_name = "ttyHSL",
.nr = UART_NR,
.cons = msm_hsl_console,
};
static struct console msm_hsl_console = {
.name = "ttyHSL",
.write = msm_hsl_console_write,
.device = uart_console_device,
.setup = msm_hsl_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &msm_hsl_uart_driver,
};
uart_console_write(port, s, count, msm_hsl_console_putchar);
msm_hsl_console_putchar(struct uart_port *port, int ch)
msm_hsl_write(port, ch, regmap[vid][UARTDM_TF]);