[U-Boot] Raspberry Pi Compute Module 1 mini-UART

Hi,
I'm working on a project that uses the Raspberry Pi Compute Module 1. Much like the CM 3, the CM 1 has two UART interfaces - the main UART at ttyAMA0, and a second "mini-UART" at ttyS0. The project uses the main UART since it works better at high speeds, so the console has been bumped over to the mini-UART. This works fine for kernel messages and as a TTY console for logging in and interacting with the device, however I've been unable to get u-boot to present it's console over the mini-UART.
I've worked deep enough into this to know that u-boot doesn't use the device tree that is set-up in config.txt, so the parameters that I've put in there to activate and remap the mini-UART (UART1 in dts files) to pins 40/41 doesn't apply to u-boot. I'm using the bcm2835-rpi-b dts file currently since it's the best fit for the hardware, but it leaves the mini-UART port disabled. I've tried playing around with the dts files to enable/remap the mini-UART port however I've been unsuccessful.
Can anyone give me any pointers as to how I modify the dts files to enable and map the second UART for u-boot to be able to use it?
Kindest regards, Ed
-- Sent from: http://u-boot.10912.n7.nabble.com/

Hi Ed,
On 25/11/2019 21:47, edrose wrote:
Hi,
I'm working on a project that uses the Raspberry Pi Compute Module 1. Much like the CM 3, the CM 1 has two UART interfaces - the main UART at ttyAMA0, and a second "mini-UART" at ttyS0. The project uses the main UART since it works better at high speeds, so the console has been bumped over to the mini-UART. This works fine for kernel messages and as a TTY console for logging in and interacting with the device, however I've been unable to get u-boot to present it's console over the mini-UART.
I've worked deep enough into this to know that u-boot doesn't use the device tree that is set-up in config.txt, so the parameters that I've put in there to activate and remap the mini-UART (UART1 in dts files) to pins 40/41 doesn't apply to u-boot. I'm using the bcm2835-rpi-b dts file currently since it's the best fit for the hardware, but it leaves the mini-UART port disabled. I've tried playing around with the dts files to enable/remap the mini-UART port however I've been unsuccessful.
Can anyone give me any pointers as to how I modify the dts files to enable and map the second UART for u-boot to be able to use it?
Basically there are two ways.
1) as you found out U-Boot is using an embedded device tree. The device tree it uses is specified in configs/rpi_* I suppose you are using rpi_3_defconfig, so your device-tree is: bcm2837-rpi-3-b You can find the device-tree files in arch/arm/dts where you can change the files.
2) you can update the config to use CONFIG_OF_BOARD instead of CONFIG_OF_EMBED. This will take the device-tree from the file specified in config.txt (or to be correct the RPi FW will pass this device-tree to U-Boot in a register at startup).
Good luck!
Matthias
Kindest regards, Ed
-- Sent from: http://u-boot.10912.n7.nabble.com/ _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

Hi Matthias,
Thank you very much for your help. Unfortunately I'm still a little stuck.
Matthias Brugger wrote
- as you found out U-Boot is using an embedded device tree. The device
tree it uses is specified in configs/rpi_* I suppose you are using rpi_3_defconfig, so your device-tree is: bcm2837-rpi-3-b You can find the device-tree files in arch/arm/dts where you can change the files.
I had a go at this, but with little success. The Compute Module 1 is actually based off the hardware of the original 256Mb Raspberry Pi 1. I've tried using the bcm2837-rpi-3-b device-tree, but I just get (what I've come to call) the Rainbow Screen of Death and nothing boots. Using the bcm2835-rpi-b tree allows it to boot.
I tried modifying the file to include the second UART port, by adding the following lines to the end (underneath the definition for &uart0), but unfortunately it doesn't seem to work:
&uart1 { pinctrl-names = "default"; pinctrl-0 = <&uart1_gpio40>; status = "okay"; };
I'm testing this by calling `coninfo` in the uboot prompt. Two serial ports show, however only one has an address next to it and it's the address of the main serial port. It looks like the following:
List of available devices: serial@7e201000 00000007 IO serial 00000003 IO stdin nulldev 00000003 IO vidconsole 00000002 .O stdout stderr
Am I interpreting that correctly? Or is the serial port somehow enabled without an address?
'Matthias Brugger" wrote
- you can update the config to use CONFIG_OF_BOARD instead of
CONFIG_OF_EMBED. This will take the device-tree from the file specified in config.txt (or to be correct the RPi FW will pass this device-tree to U-Boot in a register at startup).
Doing this (but leaving the default device tree the same) results in no changes to the output of `coninfo`. Is there something I need to do to tell uboot where in memory the device-tree is stored?
I've also tried playing around with CONFIG_SPECIFY_CONSOLE_INDEX but that had no effect either. Is there something that needs adding to the header file to specify the serial port?
Thanks once again for your help, Ed
-- Sent from: http://u-boot.10912.n7.nabble.com/

I've done some more digging, and have made a bit of progress (I think).
After fiddling with the device-tree, I've managed to get the serial port to show up when running `dm tree`. I appended this block to the end of bcm2835-rpi-b.dts:
&uart1 { pinctrl-names = "default"; pinctrl-0 = <&uart1_gpio40>; status = "okay"; };
And the relevant output of `dm tree is:
Class index Probed Driver Name ----------------------------------------- ... pinconfig 32 [ + ] pinconfig | | |-- uart0_gpio14 ... pinconfig 42 [ ] pinconfig | | |-- uart1_gpio40 ... serial 0 [ + ] bcm283x_pl | |-- serial@7e201000 serial 1 [ ] serial_bcm | |-- serial@7e215040
So that indicates that it sees the serial port, knows which driver to use, and has the correct address. However it has not probed the device, nor has it probed the pinconfig that MUXes it to the pin I've set in the dts file.
It also appears to have an index , however specifying CONFIG_CONS_INDEX doesn't change the port that is used, nor does it change the output of `dm-tree`.
So I'm still a bit stuck. How do I force uboot to use a different (already known) serial port for the console? The drivers are there, it sees the port, it just doesn't want to use it...
-- Sent from: http://u-boot.10912.n7.nabble.com/

I've done a little more work on this. I've been able to swap the UART pins around to a certain extent, but it's still being stubborn. I've been able to move the console output from the main UART from GPIO14 to GPIO32. I've somehow also managed to get the main UART to output to both GPIO32 and GPIO14 simultaneously (although it wouldn't RX anything when that was happening)! However I still can't get it to simply move the console over to using the mini-UART.
I've worked out that the serial port seems to be selected by the status of the pin multiplexers. It checks to see whether GPIO15 is multiplexed to the main port. If not, it checks to see whether GPIO15 is multiplexed to the alternate port. I tried forcing it to think that the secondary UART was multiplexed by forcing a return value in the is_serial_muxed() functions to be false for the main UART and true for the mini-UART, however it just gives me a rainbow splash screen of death.
Can I have some pointers as to how I debug what's causing the Pi to fail to boot when I try forcing the mini-UART? Clearly something is wrong and causing it to fail. Will it output anything over the early debug UART and, if so, what values do I need to put into the config for that to work? I tried adding the register addresses I found in the datasheet, however I couldn't get anything out of it.
Kindest regards, Ed
-- Sent from: http://u-boot.10912.n7.nabble.com/
participants (2)
-
edrose
-
Matthias Brugger