Can GP12/GP13 be pinmuxed before the cores try to boot?

Hello,

I’m trying to use GP12 as a GPIO. While I can pinmux the gpio from linux I have found that the Duo256mm (and I assume the Duo64m) can’t boot up with peripherals attached to the either GP12 or GP12.
My assumption is that this is due to the attached peripherals messing with the UART so I would like to pinmux those pins before any core tries to use that UART but so far I have found no reference in the buildroot-sdk declaring when those pins get declared as UART0.

1 Like

You can choose between UART and GPIO functions. If you use GP12 as a normal GPIO port to start peripheral devices, and then reuse GP12 as a serial port and start the serial port, your peripheral devices will also be terminated.

1 Like

I know that it is possible to choose between those functions but my question is aimed towards switching the functions before any booting occurs because as-is the pins are unusable for GPIO as the device can not boot with something attached to them and I never need the UART.

1 Like

You can configure GP12 as GPIO in u-boot. Taking Duo256M as an example, the gpio initialization file of u-boot is:

build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c
diff --git a/build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c b/build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c
index c9c722236..1338462d9 100644
--- a/build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c
+++ b/build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c
@@ -6,6 +6,10 @@ int cvi_board_init(void)
        PINMUX_CONFIG(PAD_MIPI_TXP0, CAM_MCLK0);   // Sensor MCLK
        PINMUX_CONFIG(PAD_MIPI_TXP2, XGPIOC_17);   // Sensor RESET
 
+       // UART0 to GPIO
+       PINMUX_CONFIG(UART0_TX, XGPIOA_16);        // GP12
+       PINMUX_CONFIG(UART0_RX, XGPIOA_17);        // GP13
+
        // UART1
        PINMUX_CONFIG(IIC0_SCL, UART1_TX);         // GP0
        PINMUX_CONFIG(IIC0_SDA, UART1_RX);         // GP1
@@ -43,4 +47,4 @@ int cvi_board_init(void)
        PINMUX_CONFIG(USB_VBUS_DET, XGPIOB_6);     // GP27 (ADC2)
 
        return 0;

After recompiling and generating the image, the Uart0 port will no longer print logs when booting into u-boot. Check the pinmux status in the system and you will find that GP12 is already GPIO.

1 Like

Thank you for the instructions :smiley:

I’ve compiled an image accordingly although I only swapped fip.bin so I don’t have to reconfigure the software.

While the change did indeed work it sadly didn’t fix the issue of the duo being unable to boot with the pins connected to GPIO peripherals so I have to investigate the issue further.

1 Like