Skip to content

Add UART printing on qemu_riscv64#343

Merged
han-jiang277 merged 4 commits intovivoblueos:mainfrom
YinhuaChen-cloud:feature-riscv-uart
Mar 6, 2026
Merged

Add UART printing on qemu_riscv64#343
han-jiang277 merged 4 commits intovivoblueos:mainfrom
YinhuaChen-cloud:feature-riscv-uart

Conversation

@YinhuaChen-cloud
Copy link
Contributor

@YinhuaChen-cloud YinhuaChen-cloud commented Mar 5, 2026

Add UART printing on qemu_riscv64

Fixes #339

@CLAassistant
Copy link

CLAassistant commented Mar 5, 2026

CLA assistant check
All committers have signed the CLA.

@YinhuaChen-cloud
Copy link
Contributor Author

build_prs #343

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

#[cfg(target_chip = "gd32vw55x")]
pub mod gd32vw55x;
pub mod ns16650;
pub mod ns16550a;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between ns16550a and ns16550?

Copy link
Contributor Author

@YinhuaChen-cloud YinhuaChen-cloud Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see wiki: (https://en.wikipedia.org/wiki/16550_UART). The "Issue with the buffer" section.
"""
The original 16550 had a bug that prevented this FIFO from being used. National Semiconductor later released the 16550A which corrected this issue.
"""

@@ -0,0 +1,154 @@
// Copyright (c) 2025 vivo Mobile Communication Co., Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright (c) 2025 vivo Mobile Communication Co., Ltd.
// Copyright (c) 2026 vivo Mobile Communication Co., Ltd.

@@ -17,5 +17,5 @@
use crate::arch::irq::IrqNumber;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this driver work on qemu_riscv32?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet, but I can make it work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qemu_riscv32 is supported

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

❌ Job failed. Failed jobs: check_format (failure), build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/22700766319.

#[cfg(target_chip = "gd32vw55x")]
pub mod gd32vw55x;
pub mod ns16650;
pub mod ns16550a;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check whether the ns16550 driver can be reused between the two platforms via modification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what you're asking is whether the ns16650 can be reused (ns16650 differs from ns16550 by just one digit).

The current only board which uses ns16650 is rk3568.

google "rk3568 TRM", see https://opensource.rock-chips.com/wiki_File:Rockchip_RK3568_TRM_Part1_V1.3-20220930P.PDF
At 25.4.2 Registers Summary, it says that each register of the rk3568 UART occupies a 4-byte MMIO space.
If rk3568 is using ns16650 UART, then it means that each register of ns16650 occupies a 4-byte MMIO space.

The manual of ns16550a is here: https://uart16550.readthedocs.io/en/latest/uart16550doc.html#registers
It says that most registers of ns16550a occupies a 1-byte MMIO space.

Therefore, the drivers for ns16550a and ns16650 are not compatible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there’s no real difference in the operation logic; the only difference is that one is 4-byte and the other is 1-byte. Is it possible to reuse the same operation logic via conditional compilation?

@lawkai-vivo lawkai-vivo changed the title Add UART printing on qemu_riscv64 (#339) Add UART printing on qemu_riscv64 Mar 5, 2026
change 2025 -> 2026 in driver/src/uart/ns16550a.rs

add uart support for riscv32

rename NS16550A_UART0_IRQ as NS16550A_UART0_IRQNUM
@YinhuaChen-cloud
Copy link
Contributor Author

build_prs #343

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

@YinhuaChen-cloud
Copy link
Contributor Author

build_prs #343

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

❌ Job failed. Failed jobs: check_format (failure), see https://github.com/vivoblueos/kernel/actions/runs/22707911821.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/22708554673.

@YinhuaChen-cloud
Copy link
Contributor Author

build_prs #343

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/22708903012.

@YinhuaChen-cloud
Copy link
Contributor Author

build_prs #343

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/22709330284.

Copy link
Contributor

@lawkai-vivo lawkai-vivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I don't have strong opinion of merging ns16550a and ns16550. Please wait for @xuchang-vivo 's feedback.

}
}

impl HasInterruptReg for Ns16550a<'static> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add default impl in trait HasInterruptReg to reduce code duplication

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

add default impl for:
 - Has8bitDataReg
 - HasLineStatusReg
 - HasFifo
 - HasInterruptReg
 - PlatPeri
@YinhuaChen-cloud
Copy link
Contributor Author

build_prs #343

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/22746863647.

@han-jiang277 han-jiang277 merged commit fdd5f27 into vivoblueos:main Mar 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UART support for qemu_riscv boards

5 participants