Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1375561
  • 博文数量: 244
  • 博客积分: 10311
  • 博客等级: 上将
  • 技术积分: 3341
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-14 21:50
文章分类

全部博文(244)

文章存档

2013年(6)

2012年(5)

2011年(16)

2010年(11)

2009年(172)

2008年(34)

分类: LINUX

2009-09-15 23:17:49

Moving the console
From GumstixDocsWiki
Jump to: navigation, search
This page describes how to move the console from FFUART (ttyS0) to STUART (ttyS2).
Contents [hide]
1 Overview
2 Changing the console logon
3 Recovering from messing up inittab
4 Changinig the kernel console
5 Changing the serial port that u-boot uses

 
Overview
In order to move the console, there are 3 separate entities which need to be modified: u-boot, console, and getty. When the gumstix is first powered on u-boot is the first program which gains control. It prints out some information, and then boots the kernel. When the kernel starts it prints messages to the console. The final stages of booting involve running init, which starts getty, which prompts you for your username and password.
The serial port that u-boot uses is compiled in.
The serial port that the kernel uses is ttyS0 by default, and can be changed by adjusting the console= kernel command line option.
The serial port that getty uses is passed on it's command line, which can be found in /etc/inittab.
Changing the console logon
To change the serial port that getty uses, you need to modify the /etc/inittab file. Find the line that looks like this:
::respawn:/sbin/getty -L ttyS0 115200 vt100
and change ttyS0 to ttyS2, like this:
::respawn:/sbin/getty -L ttyS2 115200 vt100
If you reboot, you should see the u-boot messages and the initial kernel console messages on the FFUART, and the logon prompt should be on ttyS2.
Note: if you're using a single serial line on your PC and moving the serial cable from FFUART to STUART, the act of plugging in or unplugging the cable may create some noise which gets interpreted as characters.
If pressing the RETURN (or ENTER) key doesn't bring up a prompt, or the prompt is in call CAPS, then you should perform a BREAK (the exact way of doing this varies depending on your terminal program - it's Control-A F in minicom), and wait a few seconds. Then press RETURN a few times and do another break until you get a lowercase prompt. What's happening is that getty has some autobaud logic which can be triggered by the noise of cable insertion/removal.
For historical reasons, linux also has a mode which allows it to work with terminals which only send uppercase letters. When getty is in this mode, it presents the prompt in all uppercase, and converts characters you type to lowercase. You almost certainly don't want to be in this mode, so you should do the break/RETURN sequence to get out of it.
Recovering from messing up inittab
If you mistype something in inittab you can recover by using u-boot to modify the kernel command line and bypass the entire init process. See this section for details.
Changinig the kernel console
You can change the serial port used for the kernel console by adjusting the command line passed to the kernel.
In my u-boot (revision 13xx) the kernel command line looks like:
console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard
Changing the ttyS0 to ttyS2:
console=ttyS2,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard
will cause the kernel console to be on the STUART port, rather than the FFUART.
To change the kernel command line, you need to break into u-boot by pressing a key during the boot sequence and getting the
GUM>
prompt. Use the printenv command to view your environment. You should see a line like:
bootargs=console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard
To change the command line, type:
setenv bootargs console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard
Note that printenv puts an equals '=' character between the word bootargs and console. It's very important that this = (between bootargs and console) be missing when you use the setenv command (although you need to keep the rest of the equals on the command line.
You can test the console change by doing the setenv followed by a boot command. It will use the modified commandline for just that boot. If you do a saveenv, then it will become permannent.
Changing the serial port that u-boot uses
The serial port that u-boot uses is determined by defining one of the following:
CONFIG_FFUART (the default)
CONFIG_STUART
CONFIG_BTUART

If you only have a single serial cable and need to swtich back and forth, then I recommend that you also increase CONFIG_BOOTDELAY to 10 seconds. Both of these defines can be found in the include/configs/gumstix.h file within u-boot (u-boot can be found in gumstix-buildroot/build_arm_nofpu/u-boot-1.1.4)
To build your new u-boot, do the following:
cd gumstix-buildroot
rm build_arm_nofpu/u-boot-1.1.4/u-boot*
make u-boot
You can do the following to test our your new u-boot image before commiting it to flash. I have a netMMC card, so I copied my new u-boot.bin to my MMC card. You need to drop into u-boot (so you get the GUM> prompt).
setenv bootdelay 10 saveenv
The reasoning behind changing the bootdelay in gumstix.h and changng the environment goes something like this: u-boot will try to use the environment, and if the version of u-boot burned into your flash is compatible with the u-boot that you're testing then it will try to use the environment. If it doesn't like the environment then it should use the default compiled into gumstix.h.
I tested using the following commands:
mmcinit
fatload mmc 0 a2000000 u-boot.bin
go a2000000

Then I switched my serial cable over to the STUART port and saw the countdown and was able to interrupt it.
Once you're happy with the new u-boot, you can make it permanent by doing:
mmcinit
fatload mmc 0 a2000000 u-boot.bin
protect off 1:0-1
erase 1:0-1
cp.b a2000000 0 ${filesize}

It's VERY important that you don't mess up these commands. Once you've done the erase if something goes wrong, you'll essentially have bricked your gumstix.
阅读(1998) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~