freebsd-src icon indicating copy to clipboard operation
freebsd-src copied to clipboard

uart: patch for early putc ns8250 on arm/aarch64

Open Martinfx opened this issue 4 months ago • 10 comments

Hi, @bsdimp This is patch for early putc ns8250 on arm/aarch64 I tested on bananapi-r64

Martinfx avatar Aug 11 '25 13:08 Martinfx

Thank you for taking the time to contribute to FreeBSD! There is an issue that needs to be fixed:

  • Missing Signed-off-by lines (737714d3a08b1cddd160f59ad98cfa1cd8824ecf)

Please review CONTRIBUTING.md, then update and push your branch again.

github-actions[bot] avatar Aug 11 '25 13:08 github-actions[bot]

I think this is ready. There's no socdev_va/pa on other platofrms, so arm and arm64 is the complete list.

Ok. Thank you.

Martinfx avatar Aug 13 '25 21:08 Martinfx

Unfortunately, this only works for some UART implementations. It does not take into account the register layout and access restrictions of different UARTs ("reg-shift", "reg-io-width"). These are not available at an early stage, which is why we do not yet have the early_putc() function implemented. It should not be commited in this form.

strejda avatar Aug 26 '25 05:08 strejda

Unfortunately, this only works for some UART implementations. It does not take into account the register layout and access restrictions of different UARTs ("reg-shift", "reg-io-width"). These are not available at an early stage, which is why we do not yet have the early_putc() function implemented. It should not be commited in this form.

Ok. I thought it was okay.

Martinfx avatar Aug 26 '25 05:08 Martinfx

We could add options to set them, e.g. options EARLY_PRINTF_REG_SHIFT=2.

zxombie avatar Aug 26 '25 13:08 zxombie

We could add options to set them, e.g. options EARLY_PRINTF_REG_SHIFT=2.

Couldn't we just read the SPCR table to get these values as well?

bsdimp avatar Aug 26 '25 19:08 bsdimp

I would prefer to not depend on the SPCR/FDT so printf works before we parse them, e.g. we may need to call printf from within the parsing code to debug it.

zxombie avatar Aug 27 '25 11:08 zxombie

I would prefer to not depend on the SPCR/FDT so printf works before we parse them, e.g. we may need to call printf from within the parsing code to debug it.

Since we parse it in the boot loader, maybe it could provide adequate hints? Or do we have the same issue?

bsdimp avatar Aug 27 '25 20:08 bsdimp

IMHO, early_putc() should work from the first line of initarm(). I am afraid that the only viable solution is #define at compile time, runtime detection looks impossible.

strejda avatar Aug 29 '25 04:08 strejda

hi! Would someone please give @Martinfx a more concrete example of how we did this compile time stuff for other platforms? That way we can get this finished and landed. Thanks!

erikarn avatar Nov 30 '25 21:11 erikarn