cancel
Showing results for 
Search instead for 
Did you mean: 

Change default tf-a and u-boot serial linux console.

Lmoio.1
Senior

Hello, my main seriale console should be USART2 instead of UART4. I modified the kernel dts as follows:

	chosen {
		stdout-path = "serial0:115200n8";
	};
 
	aliases {
		ethernet0 = &ethernet0;
		mmc0 = &sdmmc1;
		mmc1 = &sdmmc2;
		serial0 = &usart2;
	};

and it configures correctly the kernel console.

If I try the same modification in tf-a and u-boot dts, at boot i see the log starting on uart4, but it blocks at this point

Preparing exit to normal world 
No serial driver found

Should I modify some boot env too?

1 ACCEPTED SOLUTION

Accepted Solutions
Lmoio.1
Senior

Hi,

For the uboot project , I added CONFIG_DEBUG_UART_BASE=0x4000E000 (usart2 base address) in the defconfig, I added

   chosen {

      stdout-path = "serial0:115200n8";

   };

   aliases {

      ethernet0 = &ethernet0;

      mmc0 = &sdmmc1;

      mmc1 = &sdmmc2;

      serial0 = &usart2;

      serial1 = &uart4;

   };

&pinctrl {

   usart2_pins_d: usart2-2 {

      pins1 {

         pinmux = <STM32_PINMUX('D', 5, AF7)>; /* USART2_TX */

         bias-disable;

         drive-push-pull;

         slew-rate = <3>;

      };

      pins2 {

         pinmux = <STM32_PINMUX('D', 6, AF7)>; /* USART2_RX */

         bias-disable;

         bias-pull-up;

      };

   };

   usart2_idle_pins_d: usart2-idle-2 {

      pins1 {

         pinmux = <STM32_PINMUX('D', 5, ANALOG)>; /* USART2_TX */

      };

      pins2 {

         pinmux = <STM32_PINMUX('D', 6, AF7)>; /* USART2_RX */

         bias-disable;

      };

   };

   usart2_sleep_pins_d: usart2-sleep-2 {

      pins {

         pinmux = <STM32_PINMUX('D', 5, ANALOG)>, /* USART2_TX */

            <STM32_PINMUX('D', 6, ANALOG)>; /* USART2_RX */

      };

   };

};

&usart2 {

   pinctrl-names = "default", "sleep", "idle";

   pinctrl-0 = <&usart2_pins_d>;

   pinctrl-1 = <&usart2_sleep_pins_d>;

   pinctrl-2 = <&usart2_idle_pins_d>;

   status = "okay";

};

in the .dts.

I added this part also in the dts of the tf-a project.

Then i generated the fip bianary file. When flashing, I see cubeprogrammer Logs on usart2.

View solution in original post

22 REPLIES 22
Kevin HUBER
ST Employee

Hi @Lmoio.1​ ,

You do not only need to change serial0 from uart4 to usart2. You have also to be sure that usart2 is defined in the DT (Device Tree) and is enabled:

	status = "okay";

and that the pins are configured.

Please verify in the tf-a and u-boot dts that it is the case

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

yes, i added

&pinctrl {
	
	m4_adc12_pins_a: m4-adc12-pins-0 {
		pins {
			pinmux =  <STM32_PINMUX('F', 13, RSVD)>, /* ADC2 in2 */
				  <STM32_PINMUX('A', 6, RSVD)>,/* ADC2 in3 */
				  <STM32_PINMUX('F', 14, RSVD)>, /* ADC2 in6 */
				  <STM32_PINMUX('C', 0, RSVD)>; /* ADC12 in10 */
		};
	};
 
	usart2_pins_d: usart2-2 {
		pins1 {
			pinmux = <STM32_PINMUX('D', 5, AF7)>; /* USART2_TX */
			bias-disable;
			drive-push-pull;
			slew-rate = <3>;
		};
		pins2 {
			pinmux = <STM32_PINMUX('D', 6, AF7)>; /* USART2_RX */
			bias-disable;
		};
	};
 
	usart2_idle_pins_d: usart2-idle-2 {
		pins1 {
			pinmux = <STM32_PINMUX('D', 5, ANALOG)>; /* USART2_TX */
		};
		pins2 {
			pinmux = <STM32_PINMUX('D', 6, AF7)>; /* USART2_RX */
			bias-disable;
		};
	};
 
	usart2_sleep_pins_d: usart2-sleep-2 {
		pins {
			pinmux = <STM32_PINMUX('D', 5, ANALOG)>, /* USART2_TX */
				 <STM32_PINMUX('D', 6, ANALOG)>; /* USART2_RX */
		};
	};
};
 
&uart4 {
	status = "disabled";
};
 
&usart2 {
	pinctrl-names = "default", "sleep", "idle";
	pinctrl-0 = <&usart2_pins_d>;
	pinctrl-1 = <&usart2_sleep_pins_d>;
	pinctrl-2 = <&usart2_idle_pins_d>;
	
	status = "okay";
 
};

but it still starts on uart4 and prints "no serial driver found" when launching uboot.

Should I modify CONFIG_DEBUG_UART_BASE= in the .config file?

Kevin HUBER
ST Employee

Hi @Lmoio.1​ ,

I do not think this error is due to CONFIG_DEBUG_UART_BASE.

Please can you send me:

  • DT of your tf-a
  • DT of your uboot
  • DT of your linux

To check if I find an error.

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Lmoio.1
Senior

Kernel and uboot dts are equal.

Lmoio.1
Senior
 
Lmoio.1
Senior

Another question, I noticed that if I don't connect a TTL cable to the uart4 that i'm trying to use, kernel does not start, whereas if i connect a cable (it can also be not connected to a pc) the kernel starts. Should I remove from the u-boot defconfig CONFIG_REQUIRE_SERIAL_CONSOLE option?

Kevin HUBER
ST Employee

Hello @Lmoio.1​ ,

You forgot in the tf-a dts to add the USART2 in etzpc node. Please can you add this line in etzpc node:

	DECPROT(STM32MP1_ETZPC_USART2_ID, DECPROT_NS_RW, DECPROT_UNLOCK)

As explained in the wiki https://wiki.st.com/stm32mpu/wiki/ETZPC_device_tree_configuration#DT_bindings_documentation

The ETZPC binding assigns the peripheral to the desired CORE, so in your case, you must specify the USART2 and assign it to the non secure linux.

Hope it helps,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

I added your suggestion, but STprogrammer fails at downloading because it cannot reconnect to the device.

  09:50:40 : Time elapsed during download operation: 00:00:01.194
  09:50:40 : RUNNING Program ... 
  09:50:40 :   PartID:      :0x03 
  09:50:40 : Reconnecting the device ...
  09:51:10 : Error: Unable to reconnect the target device: time out expired
  09:51:10 : Error: Start operation failed at partition 0x03
  09:51:10 : Error: TSV flashing service failed
  09:51:10 : Warning: Connection to device 0x500 is lost
  09:51:10 : Disconnected from device.

Kevin HUBER
ST Employee

hello @Lmoio.1​ ,

Did you have some logs on your usart2? Maybe your TF-A or u-boot is crashing and prevent the flashing operation.

If you have logs can you send them please.

And then can you run the STM32CubeProgrammer from the console and please share with me the log too:

https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer#How_to_flash_with_STM32CubeProgrammer

You have to run the STM32_Programmer_CLI:

STM32_Programmer_CLI -c port=<DEVICE_PORT_LOCATION> -w [<file.tsv>]

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.