01-24-2021 09:55 AM - edited 01-26-2021 09:54 AM
The problem I am having is that once I add an AXI Uart Lite in the PL, the petalinux tools seems to get confused about the PS UART baudrate used for console.
Guessing there is a reused variable somewhere in the Petalinux Scripts causing this issue for the PS UART
I have found a hack fix, but it is ugly, and entails extra petalinux-build and petalinux-config, editing of files (only some of which are user editable), and doesn't seem right.
Scenario:
Using serial0 /dev/ttyPS0 for console at 115200n8, all is good.
Add an AXI Uart Lite to PL for other purposes, baudrate is different but customized to be 2400, the exact value doesn't matter as long as it is not 115200.
During boot, earlycon uses the correct 115200.
Once embedded Linux boots, /dev/ttyPS0 gets set to the baud rate selected in the AXI Uart Lite customization. (This is crazy)
If I check petalinux-config > Subsystem AUTO Hardware Settings > Serial Settings --->System stdin/stdout baudrate for pus_uart_0 is set to the AXI Uart Lite baud rate, not the 115200
If I tray to change it in petalinux-config, the one fixed baud rate for UART0 is the baudrate the AXI Lite UART was customized to have. Clearly this is a bug.
If I select help, it points to build/misc/config/Kconfig.syshw:194
If I Inspect build/misc/config/Kconfig.syshw:194 in my favorite text editor, I see this:
choice prompt "System stdin/stdout baudrate for psu_uart_0" default SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200 config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_2400 bool "2400" endchoice
However, before I added the AXI Lite UART, it was this:
choice
prompt "System stdin/stdout baudrate for psu_uart_0"
default SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_600
bool "600"
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_9600
bool "9600"
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_28800
bool "28800"
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200
bool "115200"
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_230400
bool "230400"
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_460800
bool "460800"
config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_921600
bool "921600"
endchoice
Poking around in other files, I stumble across system-top.dts file in device tree, where I notice this:
chosen { bootargs = "earlycon clk_ignore_unused"; stdout-path = "serial0:115200n8"; };
So I edit the system-user.dtsi in the meta-user/... folder (editable) and add:
chosen { bootargs = "earlycon console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio"; stdout-path = "serial0:115200n8"; };
And I do another build. But I open build/misc/config/Kconfig.syshw in my favorite text editor, and still see:
choice prompt "System stdin/stdout baudrate for psu_uart_0" default SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200 config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_2400 bool "2400" endchoice
It appears that once there is an AXI Uart Lite in the PL, for some reason the settings get screwed up.
I have verified that if I edit the build/misc/config/Kconfig.syshw file as follows, keep the stdout-path = "serial0:115200n8"; in the system-user.dtsi, and rerun petalinux-config and select the only option (115200 now that I hacked it), I can hack it to work, and the PS UART0 will use the desired 115200 baud even if an AXI Uart Lite is configured in the PL with a different baud rate. This seems to be the minimum set of changes necessary to get it to work in 2020.1 Petalinux tools.
choice prompt "System stdin/stdout baudrate for psu_uart_0" default SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200 config SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200 bool "115200" endchoice
It appears that somebody in the Petalinux group reused a variable, and then reused it again after it was used for the AXI Uartlite in the PL, to determine possible baud rates for the PS UART.
But my understanding is that I should not edit Kconfig.syshw file.
Again, the symptom seems to be consistent with somebody responsible for Petalinux reusing a baud rate variable, and this bug only shows up when you add an AXI Uart Lite to the PL and its baud rate is different than the baud rate desired to run on the UART0 in the PS for console.
Is my minimum set of changes the necessary changes (i.e., do I need to edite build/misc/config/Kconfig.syshw, or am I right that there is a variable reuse bug in the Petalinux 2020.1 tools?
Is there already an answer record for this? If so please provide a link. If not, please start working on one.
01-26-2021 01:44 AM
A search would have given you this topic:
And yes, I qualify this as a bug.
01-26-2021 01:44 AM
A search would have given you this topic:
And yes, I qualify this as a bug.
01-26-2021 01:59 AM - edited 01-26-2021 01:59 AM
Ill check with the plnx team to see if this is a known issue. If not, ill file a CR to have it fixed.
Can you let me know if you can use the same workaround that @vanmierlo used in his post?
01-26-2021 08:01 AM - edited 01-26-2021 09:57 AM
Thanks for the response, @stephenm . I did not try @vanmierlo solution in that other post, but it looks a lot cleaner than my solution which required too much hacking. I'll give it a try when I need it next, and in the meantime, I've marked @vanmierlo answer as a solution to this.
Thanks guys!
Update: I just confirmed that adding:
# See https://forums.xilinx.com/t5/Embedded-Linux/Console-PS-UART0-baud-rate-bug-when-a-different-AXI-Uart-Lite/m-p/1199502
# See https://forums.xilinx.com/t5/Embedded-Linux/ttyPS0-baudrate-locked-when-uartlite-is-present/m-p/1181302
SERIAL_CONSOLES = "115200;ttyPS0"
to the project-spec/meta-user/conf/petalinix.conf file (A use editable file) works, and is more elegant that my initial workaround.
However, this is still a bug, in that Kconfig.syshw for ttyPS0 gets mucked up when a fixed baud rate AXI UARTLite is instantiated in IPI.