Skip to content
New issue

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

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

Already on GitHub? # to your account

Add dynamic mux for UARTBone / normal UART #1959

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jwise
Copy link
Contributor

@jwise jwise commented May 21, 2024

One problem with debugging a single-UART system is that the system will always block if a UARTBone client is not connected. This is particularly annoying if, for instance, your vendor's RAM update tools do not work right (I'm looking at you, Efinix...), and you need the UARTBone to iterate on firmware -- but, once you have a build, you would like to have a UART that does not block. (In my system, I have two FPGAs talking to each other, and I am probably developing one or the other at a time, and I would like to be able to distribute a bitstream to the customer that just happily boots without any drama, for instance.)

This PR solves this by modifying the UARTCrossover to have a debug_en CSR, and a pad_phy input. When debug_en is turned on (the default, on reset), then the system behaves exactly like it previously did. However, switching off debug_en means that the crossover internal UART and UARTbone are disconnected, and the UARTCrossover's source and sink are actually connected to the pads of the outer world -- basically, passing the UART straight through.

To use this, I do something like this:

int main(void)
{
#ifdef CONFIG_CPU_HAS_INTERRUPT
        irq_setmask(0);
        irq_setie(1);
#endif
        // As soon as the CPU is running, before we try to write to the UART
        // (and potentially block the system), then we disable uart_debug_en.
        // Now, just connect to the system with picocom to get a console.
        uart_debug_en_write(0);
/* ... system setup ... */

/* ... main loop ... */
        str = readstr();
        if(str == NULL) return;
        token = get_token(&str);
/* ... */
        // Have a CLI command to reenable the uartbone.  As soon as this
        // command is issued, you will need to start up a litex-server and
        // litex-term.
        else if(strcmp(token, "debug") == 0) 
                uart_debug_en_write(1);

There is a little bit of WIP here: the simplest way to wire this up was through the old crossover+uartbone path that is now deprecated. I undeprecate this by commenting out the deprecation! But obviously I would like feedback on what you think the better way is to do this.

…ll-bandwidth UART, but enable debuggability as needed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant