Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdio/stderr UART initialization #317

Open
GregAC opened this issue Oct 17, 2024 · 1 comment
Open

stdio/stderr UART initialization #317

GregAC opened this issue Oct 17, 2024 · 1 comment

Comments

@GregAC
Copy link

GregAC commented Oct 17, 2024

I just ran into a hang running the test suite on Sonata with reduced UART FIFO sizes (we're moving to small FIFOs to save on FPGA resources). The core issue was a write to stderr which goes to uart1 if it exists (which it does on Sonata).

#if DEVICE_EXISTS(uart1)
# define stderr MMIO_CAPABILITY(void, uart1)
#elif defined(stdout)
# define stderr stdout
#endif

The problem is uart1 never get initialised so our small transmit FIFO fills up and the test hangs. stdout goes to uart or uart0 which gets initialised in the loader:

auto uart =
build<volatile Uart,
Root::Type::RWGlobal,
PermissionSet{
Permission::Load, Permission::Store, Permission::Global}>(
LA_ABS(__export_mem_uart));
// Initialise the UART so that we can use it for debugging.
uart->init();

But there's no initialisation for uart1.

Clearly I can just initialize uart1 in the same place but is that the most appropriate place for it? In particular that's aiming to initialise the UART used for debug logs which has the happy side effect of initialising the UART used for stdout as they're the same UART. So mixing in initialisation for stdio specific things doesn't clearly fit there.

We may want stdout and stderr to both go to uart on Sonata anyway so I can sidestep the problem that way but nevertheless there should be some defined stdio or UART init this can all be properly handled in.

@davidchisnall
Copy link
Collaborator

This is closely related to #275

I would like to add a device-initialisation phase that can run on the scheduler's stack before we start the scheduler. This is the right place to do UART initialisation and would also be a good place to configure the revoker. The allocator should be able to have a capability that excludes the registers that configure the revokable range of memory and have early initialisation code set this.

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

No branches or pull requests

2 participants