linux命令 重定向%3e,linux输出信息调试信息重定向
在運行l(wèi)inux的時候有所有的調(diào)試信息可以分為三個部分
1、bootloader輸出信息
U-Boot 1.3.2(Nov 19 2016 - 22:02:08)
DRAM: 64 MB
Flash: 512 kB
NAND: 64 MiB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
[yqliu2410 #] tftp
Found DM9000 ID:90000a46 at address 10000000 !
DM9000 work in 16 bus width
bd->bi_entaddr: 08:00:3e:26:0a:5b
[eth_init]MAC:8:0:3e:26:a:5b:
TFTP from server 192.168.1.152; ourIP address is 192.168.1.155
Filename 'uImage'.
Load address: 0x30008000
Loading: T T#######################################################done
Bytes transferred = 1617316 (18ada4 hex)
[up-tech2410 #] bootm
## Booting image at 30008000 ...
Image Name: Linux-2.6.24.4
Created: 2016-11-19 14:05:29 UTC
Image Type: ARM Linux Kernel Image(uncompressed)
Data Size: 1617252 Bytes= 1.5 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
Starting kernel ...
2、linux低級調(diào)試信息輸出
Uncompressing Linux............................................................. done, booting the kernel.
3、linux調(diào)試信息輸出
Linux version 2.6.24.4(root@vm-dev)(gcc version 3.4.6) #100 Sat Nov 19 07:47:35 CST 2016
CPU: ARM920T [41129200] revision 0(ARMv4T), cr=00007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32byte lines, 8sets
CPU0: D cache: 16384 bytes, associativity 64, 32byte lines, 8sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: root=/dev/mtdblock2 noinitrd console=ttySAC1,115200
irq: clearing subpending status 00000010
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c
Console: colour dummy device 80x30
console [ttySAC1] enabled
............................
現(xiàn)在要將所有的調(diào)試信息輸出到別的串口。以com1為例(從com0開始計算)!
一、將bootloader的輸出信息輸出到com1
這里以u-boot1.3.2為例:很簡單只需要修改一個宏定義就ok
Vi inlcude/configs/xxxconfig.h(xxx為你定義的開發(fā)板的名字)
更改原有的宏
/*
* select serial console configuration
*/
//#define CONFIG_SERIAL1 1 /* we use SERIAL 1 on SMDK2410*/
//modify for xxx2410
//by lyj_uptech
#define CONFIG_SERIAL2 1 /* we use SERIAL 2 on SMDK2410*/
二、將low_level的調(diào)試信息輸出到com1
在改之前我們先分析一下在linux啟動之前它是如何使用串口的(以linux-2.6.24為例)。
1、在arch/arm/boot/compressed/misc.c文件中有定義
staticvoid putstr(constchar *ptr)
{
char c;
while ((c= *ptr++)!= '\0') {
if (c =='\n')
putc('\r');
putc(c);
}
flush();
}
2、arch/arm/boot/compressed/misc.中的函數(shù)decompress_kernel就是使用的putstr來打印的如下輸出信息:
Uncompressing Linux............................................................. done, booting the kernel
3、追根溯源,putstr函數(shù)最終調(diào)用的是putc(請注意這里的putc不是在misc.c函數(shù)中定義的icedcc_putc,因為沒有CONFIG_CPU_V6宏定義),真正的底層操作在文件include/asm-arm/plat-s3c/uncompress.h
4、 解析該文件
/* we can deal with the case the UARTs are being run
* in FIFO mode, so that we don't hold up our execution
* waiting for tx to happen...
*/
static voidputc(int ch)
{
if (uart_rd(S3C2410_UFCON)& S3C2410_UFCON_FIFOMODE){
int level;
while (1) {
level = uart_rd(S3C2410_UFSTAT);
level &= fifo_mask;
if (level < fifo_max)
break;
}
} else{
/* not using fifos */
while ((uart_rd(S3C2410_UTRSTAT)& S3C2410_UTRSTAT_TXE)!= S3C2410_UTRSTAT_TXE)
barrier();
}
/* write byte to transmission register */
uart_wr(S3C2410_UTXH, ch);
}
該函數(shù)中調(diào)用的兩個函數(shù),uart_rd uart_wr在同一個文件中定義
#define uart_base S3C24XX_PA_UART+ (0x4000*CONFIG_S3C_LOWLEVEL_UART_PORT)
static __inline__void
uart_wr(unsignedint reg, unsigned int val)
{
volatile unsignedint *ptr;
ptr = (volatileunsigned int*)(reg+ uart_base);
*ptr = val;
}
static __inline__unsigned int
uart_rd(unsignedint reg)
{
volatile unsignedint *ptr;
ptr = (volatileunsigned int*)(reg+ uart_base);
return *ptr;
}
從宏定義uart_base中就可以清楚的看到,當(dāng)CONFIG_S3C_LOWLEVEL_UART_PORT為0時,uart_base的值為0x50000000,也就是uart0的控制寄存器基地址。如果要使用uart1的話就把CONFIG_S3C_LOWLEVEL_UART_PORT賦值為1就可以了。
5、真正更改的地方只有一個
下級目錄
修改為1就ok!
6、需要注意的地方(你使用的串口初始化了么)
我在整個內(nèi)核中找遍了解壓內(nèi)核之前運行的代碼,都找不到關(guān)于串口初始化的代碼。所以說,linux在啟動之前的串口初始化是依賴bootloader的,要想正常的輸出,就必須使用你的bootloader使用的串口,因為在bootloader中進(jìn)行了對要使用的串口進(jìn)行了初始化。要保證你的bootloader兼容性很好,那就在bootloader中把所有的串口都初始化一遍。
如果你沒有初始化串口,一旦調(diào)用putstr,程序就死掉了!
三、將linux的信息輸出到com1
將linux運行的信息輸出到com1就太簡單了,直接到bootloader里面改linux的傳遞參數(shù)就可以了。
setenv bootargs root=/dev/mtdblock2 noinitrd console=ttySAC1,115200
saveenv
現(xiàn)在啟動一切ok!
感謝yqliu29的支持,沒有他的調(diào)試程序,我始終的無法知道linux的內(nèi)核是否正確調(diào)用,也無法定位問題!
這里附上他給我的程序(這里的三個燈分別對應(yīng)的io管腳是GPF5/6/7)
#if 0
asm volatile(
"ldr r6, =0x5400\n\r"
"ldr r7, =0x56000020\n\r"
"str r6, [r7]\n\r"
"ldr r6, =0xC0\n\r"
"ldr r7, =0x56000024\n\r"
"str r6, [r7]");
#endif
include/s3c6410.h 里
#define ELFIN_UART_BASE 0x7F005000 // Assembly 階段吃這里
#define ELFIN_UART0_OFFSET 0x0000
#define ELFIN_UART1_OFFSET 0x0400
#define ELFIN_UART2_OFFSET 0x0800
#ifdef CONFIG_SERIAL1 // 這一句在 include/config/smdk6410.h
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART0_OFFSET)
#elif defined(CONFIG_SERIAL2)
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART1_OFFSET)
#else
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART0_OFFSET)
#endif
文章來自:http://blog.csdn.net/longtian635241/article/details/7867730
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的linux命令 重定向%3e,linux输出信息调试信息重定向的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 泰森多边形法函数属性理解(
- 下一篇: Argus