You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "lupyuen (via GitHub)" <gi...@apache.org> on 2023/05/10 02:34:11 UTC

[GitHub] [nuttx] lupyuen commented on pull request #9098: arm64: Updating ARCH_EARLY_PRINT support

lupyuen commented on PR #9098:
URL: https://github.com/apache/nuttx/pull/9098#issuecomment-1541203164

   Hi @qinwei2004: Allwinner A64 System Logging has a problem with Dropped Output, wonder if I can help to fix this problem in my upcoming PR...
   
   I'm now calling the System Log in my Allwinner A64 Bringup:
   
   ```text
   _info("Configure STATUS (PH9) for Input\n");
   _info("Status=%d\n", ...);
   _info("Configure PWR_BAT (PL7) for Output\n");
   _info("Set PWR_BAT (PL7) to High\n");
   _info("Status=%d\n", ...);
   ```
   
   [(Source)](https://github.com/lupyuen2/wip-pinephone-nuttx/blob/uart2/boards/arm64/a64/pinephone/src/pinephone_bringup.c#L208-L347)
   
   Previously the System Log appeared OK:
   
   ```text
   pinephone_modem_init: Configure STATUS (PH9) for Input
   pinephone_modem_init: Status=0
   pinephone_modem_init: Configure PWR_BAT (PL7) for Output
   pinephone_modem_init: Set PWR_BAT (PL7) to High
   pinephone_modem_init: Status=1
   ```
   
   [(Source)](https://gist.github.com/lupyuen/c6630b0a6e1616aada546143552fb113/0ffe0f16e9ad40082260544c00d6f6e4b2785cc9#file-uart-test-modem-log-L40-L74)
   
   But with the [recent update to `a64_serial.c`](https://github.com/apache/nuttx/commit/2eac660ff68a805cfcb02ca108b1e6cdac0f7d4e#diff-345b8952b508d50e2f214f8ba7b090cf826ad455aa3d175ed739f69eadf55fb0), the System Log now appears garbled with Dropped Output:
   
   ```text
   pinephone_modem_init: Configure STATUS (PH9) for Input
   pinephoneapinephone_modem_init: Status=1
   pinephone_modem_init: Configure Ppinephone_modem_init: Status=1
   ```
   
   [(Source)](https://gist.github.com/lupyuen/c6630b0a6e1616aada546143552fb113/f4b337c7bef9f5b69f208a753d8120bf2c57e322#file-uart-test-modem-log-L40-L46)
   
   I traced the Dropped Output to this modification:
   
   __Previously:__ `up_putc` calls `arm64_lowputc` to print the output:
   
   ```c
   int up_putc(int ch) {
     // arm64_lowputc waits for UART Ready before printing
     arm64_lowputc((uint8_t)ch);
   ```
   
   [(Source)](https://github.com/apache/nuttx/blob/e3f0f86514126afaf3726e330fbe5fd525ac9f09/arch/arm64/src/a64/a64_serial.c#L701-L714)
   
   And [`arm64_lowputc`](https://github.com/apache/nuttx/blob/2eac660ff68a805cfcb02ca108b1e6cdac0f7d4e/arch/arm64/src/a64/a64_lowputc.S#L86-L91) waits for UART Ready before wrting the output.
   
   __Now:__ `up_putc` calls `a64_uart_send` to print the output:
   
   ```c
   int up_putc(int ch) {
     // a64_uart_send doesn't wait for UART Ready before printing
     a64_uart_send(dev, ch);
   ```
   
   [(Source)](https://github.com/apache/nuttx/blob/2eac660ff68a805cfcb02ca108b1e6cdac0f7d4e/arch/arm64/src/a64/a64_serial.c#L635-L652)
   
   But [`a64_uart_send`](https://github.com/apache/nuttx/blob/2eac660ff68a805cfcb02ca108b1e6cdac0f7d4e/arch/arm64/src/a64/a64_serial.c#L424-L432) doesn't wait for UART Ready. That's why it drops the output.
   
   I can help to fix this, inside my upcoming PR for `a64_serial.c`:
   
   -   [Upcoming PR: Add support for Multiple UART Ports](https://github.com/lupyuen2/wip-pinephone-nuttx/pull/29)
   
   I will fix the Dropped Output by waiting for UART Ready, like this:
   
   ```c
   int up_putc(int ch) {
     // Wait for UART Ready
     while (!a64_uart_txready(dev)) {}
   
     // UART is now ready, OK to print
     a64_uart_send(dev, ch);
   ```
   
   [(`a64_uart_txready` is defined here)](https://github.com/apache/nuttx/blob/2eac660ff68a805cfcb02ca108b1e6cdac0f7d4e/arch/arm64/src/a64/a64_serial.c#L484-L492)
   
   Could you clarify if I understood the problem correctly?
   
   If you're OK, I shall fix this in my upcoming PR. Thanks :-)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org