# Serial console speed setting -- 11.1 ARM R-Pi



## gardner (Nov 9, 2017)

I have an application where I want to use the serial console for booting but the speed must be 19200 or less.
The documented loader.conf options for this don't work.  Since the ARM architecture looks to be using U-Boot I thought I could configure the console via the /boot/msdos/config.txt:

```
console=serial0,19200
```
But this did not change things.  I have run into a couple of threads about the u-boot serial console, but nothing that explains how to set a non-default serial speed.

As things sit, the u-boot loader detects the presence of the RxD it seems, and enables the console (at 115200 I guess) and will not recognize the USB keyboard, instead wanting input from the serial keyboard.  This will be a problem since the connected device is 19200 or less.  If I could prevent u-boot from detecting the serial console, or disable it entirely during the loader, that would be okay.  Best would be to get it to run at 19200 and have it work normally.

Any experts on u-boot, RPi and FreeBSD 11.1 know what I'm missing?


----------



## aragats (Nov 9, 2017)

I believe that _console_ variable is for the kernel, not for u-boot. According to u-boot documentation you'll need to set _baudrate_ variable in config.txt file.


----------



## gardner (Nov 9, 2017)

Thanks, yes, I think you're right.  That was mentioned as belonging in the cmdline.txt which is passed to a Linux kernel during boot.  Presumably the situation would be different in FreeBSD.

The U-boot documentation doesn't talk about the config.txt.  I have seen a thread discussing config.txt and init_uart_baud here:

https://raspberrypi.stackexchange.com/questions/47461/how-to-set-non-standard-serial-port-speed

But I am still unclear where the settings in config.txt are actually documented and how they are loaded and used by U-boot in FreeBSD/arm.  In any event, I have something to try when I am next in front of the project in question.


----------



## aragats (Nov 9, 2017)

Haven't checked the very recent FreeBSD images, but they used to include a pretty old u-boot version. I was able to boot FreeBSD with the latest u-boot which has much more features, but I did it manually by entering commands for u-boot using a serial console, never had a chance to put everything in a config file, which is either /uEnv.txt or /boot/uEnv.txt. If you want to run a script from that config file, you have to use the first option /uEnv.txt. However, keep in mind that u-boot doesn't understand UFS, so you need the first partition to be FAT.


----------



## gardner (Nov 9, 2017)

I started with a freebsd/arm image that included the FAT partition and the complete UFS.  The FAT partition mounts under /boot/msdos and has a config.txt that looks to be modeled on a Linux one.  I believe this is the image.

ftp://ftp.freebsd.org/pub/FreeBSD/s...TABLE-arm-armv6-RPI-B-20170925-r323968.img.xz

What we have in the MSDOSFS boot partition is:


```
bootcode.bin
config.txt
fixup.dat
fixup_cd.dat
rpi.dtb
start.elf
start_cd.elf
u-boot.img
ubldr
ubldr.bin
```

It doesn't look like there is a uEnv.txt.

config.txt says:


```
gpu_mem=32
device_tree=rpi.dtb
device_tree_address=0x100
disable_commandline_tags=1
kernel=u-boot.img
```

The settings in here do correspond with what's documented in https://elinux.org/RPiconfig so I guess I will have a bash at the UART configs from there and see what happens.


----------



## aragats (Nov 9, 2017)

I've just created uEnv.txt on the FAT partition and added to it:
	
	



```
baudrate=19200
console=ttyu0,19200
```
I'm on BeagleBone Black, so use your serial port instead of ttyu0.
Imagine, it works! So you can see some junk output until u-boot and kernel switch to the desired baudrate:
	
	



```
Oj]ÿ9}=/Kc¯¯Yü°½líYÿ=8Z5å+ïJÿZÿÿRµÿb7±!'Ø   SCÄÒÿÚ9[!ic   K
                                s#=9ËKYY
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found FreeBSD U-Boot Loader (bin)
reading ubldr.bin
234640 bytes read in 29 ms (7.7 MiB/s)
## Starting application at 0x82000000 ...
-Ýÿo=I=ozI±Å-y'=8Rí5ÿc71!'Ø   ScÄèÿÚ1!)=3±)#}?Z
                   ê=±ÿJÿ=/s£)   »y9i-ÿswitch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found FreeBSD U-Boot Loader (bin)
reading ubldr.bin
234640 bytes read in 29 ms (7.7 MiB/s)
## Starting application at 0x82000000 ...
Consoles: U-Boot console 
Compatible U-Boot API signature found @0x9df30c58

FreeBSD/armv6 U-Boot loader, Revision 1.2
(Fri Jul 21 10:16:29 UTC 2017 root@releng2.nyi.freebsd.org)
. . . .
```
I can login using my serial console now.


----------



## gardner (Nov 10, 2017)

aragats said:


> I've just created uEnv.txt on the FAT partition



This worked for me.  There are some problems that likely can only be fixed by building U-Boot and the kernel from scratch, but I think the basic usability is there.  Thank you.

Because the console starts at 115200 there is some output prior to loading uEnv.txt that remains unintelligible, but not too much.

When the kernel starts, it initializes ttyu0 (the console UART) back to 115200.  I may be able to attack this with a device hints or something, but -S19200 doesn't seem to do it.

Worst case the /etc/rc (rc.d/serial) can fix the settings before too much goes by.


----------



## aragats (Nov 10, 2017)

Have you checked whether your kernel uses namely ttyu0? It could be different in RPi (as I mentioned above).
U-boot passes the second line "console=..." to the kernel, and it works for me.


----------



## gardner (Nov 10, 2017)

It is ttyu0 on a R-Pi B.  The kernel uses the Primecell PL011 UART.  It's not clear whether U-Boot is using that or the mini-UART, but both devices are mapped to the same pins on the GPIO bus on a Pi.


----------

