Run Command during Pre-Initialization (early chance to disable UART1)

Windows 11, WSL2, NCS2, VSCode

Hi, I believe there's some way to run code during pre-initiliazation, I think by tagging certain .text areas in the code with pre-processors.  Is that how Zephyr does it for some BLE stuff for example?

Ultimately I am trying to avoid a parasitic draw on the serial TX line by a component who is powered off during startup.  Meaning, I have my nRF52840, and its UART1 TX is connected to another device's UART RX, and that device is powered off.  However, the device seems to be drawing 10mA+ of power through that serial connection.

I want to avoid that power draw by having the UART1 device powered off at startup.

Here is a scope of what the nRF52840's RX and TX lines look like in this condition.

If I set the devicetree UART1 to status="disabled" this completely breaks my code, I'm seemingly no longer able to operate UART1.

I am perfectly capable of enabling/disabling UART1 in software during runtime using the UARTE1 registers, and that works fine.

My specific concern is the span of time between the startup of the module and when my code runs.  Given some debugging statements of lower-level Zephyr libs, this can take quite a while, leaving my system in a state of power being drawn from the UART1 TX pin for nearly a second.

Here is a scope of the startup condition.

I want to avoid that long condition by running code as early as possible in the startup sequence, before many Zephyr libraries if possible.

What are my options?

Thanks.

Related