Will the开发者_JAVA技巧 UBoot baud rate parameter for the console argument affect a standalone program accessing the serial port when /sbin/getty
is not running?
Thanks in advance,
Bert
Possibly if nothing changes the serial baud rate for that UART, U-boot's setting might remain in effect. But it could easily be over-ridden by the linux driver startup process or by a request from the user-mode client program access the serial port.
Personally, I'd make sure my program specifically requested whatever baud rate was expected; that's safest since it avoids making assumptions, and is most compatible with porting to another embedded linux flavor or even non-linux embedded O/S.
If you find that U-boot's setting is surviving and you decide to rely on it (perhaps so it can be customized for both bootloader and normal operation just by changing U-Boot parameters) I'd put a comment in the user-mode code where it opens the serial port to remind yourself or inform a future maintainer/porter that you are counting on U-boot having already set the baud rate.
There's not enough information here to answer your question. The answer entirely depends on how you are setting things up.
It is possible to have it so that u-boot determines the baud rate for the console serial port and that information is passed to the kernel on boot. And it can be done in a way so that any changes in u-boot's baud rate will get propagated to the kernel and an application using the serial port.
Is your system configured that way? We have no way of knowing that.
It's also possible for each of the 3 - u-boot, kernel, and program - specify the baud rate independently.
In u-boot, you can set the environment variable baudrate
to specify the console baud rate. When you boot the kernel, you can have u-boot pass the kernel contents of the bootargs
environment variable. That becomes the kernel command line. In that, you can set the kernel's console's baud rate. Most systems I've seen have something like this: bootargs=console=ttyS1,115200n8 ...
That sets the baud rate independently of u-boot. If, you instead had something like bootargs=console=ttyS1,${baudrate}n8 ...
, then the kernel would get the same baud rate as u-boot is using.
Now, this information only applies if we are talking about the UART used by both u-boot and the kernel as the console. If you are using a different UART than that, all of this is irrelevant.
精彩评论