Skip to main content
Lmoio.1
Senior
October 25, 2021
Solved

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

  • October 25, 2021
  • 15 replies
  • 11018 views

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?

This topic has been closed for replies.
Best answer by Lmoio.1

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.

15 replies

Kevin HUBER
ST Employee
October 25, 2021

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 'Best answer' on the reply which solved your issue or answered your question.
Lmoio.1
Lmoio.1Author
Senior
October 26, 2021

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
October 26, 2021

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 'Best answer' on the reply which solved your issue or answered your question.
Lmoio.1
Lmoio.1Author
Senior
October 26, 2021

Kernel and uboot dts are equal.

Lmoio.1
Lmoio.1Author
Senior
October 26, 2021
Lmoio.1
Lmoio.1Author
Senior
October 26, 2021

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
October 26, 2021

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 'Best answer' on the reply which solved your issue or answered your question.
Lmoio.1
Lmoio.1Author
Senior
October 27, 2021

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
October 28, 2021

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 'Best answer' on the reply which solved your issue or answered your question.
Lmoio.1
Lmoio.1Author
Senior
October 28, 2021

Hi, I have this log on uart4 (even if it should be disabled)

NOTICE: CPU: STM32MP157CAA Rev.Z
NOTICE: Model: STMicroelectronics STM32MP157C eval daughter on eval mother
INFO: Reset reason (0x14):
INFO: Pad Reset from NRST
INFO: PMIC version = 0x21
INFO: FCONF: Reading TB_FW firmware configuration file from: 0x2ffe3000
INFO: FCONF: Reading firmware configuration information for: stm32mp_io
INFO: Using USB
INFO: Instance 2
INFO: Boot used partition fsbl1
NOTICE: BL2: v2.4-r1.0(debug):4d81224-dirty
NOTICE: BL2: Built : 13:23:30, Jun 15 2021
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-DDR3L 32bits 533000Khz
WARNING: Couldn't find property st,phy-cal in dtb
INFO: Memory size = 0x40000000 (1024 MB)
INFO: DFU USB START...
INFO: phase ID :0, Manifestation 0 at c0000244
INFO: phase ID :3, Manifestation 3 at c8101006
INFO: Send detach request
INFO: Receive DFU Detach
INFO: DFU USB STOP...
INFO: BL2: Loading image id 31
INFO: Loading image id=31 at address 0x2ffff000
INFO: Image id=31 loaded: 0x2ffff000 - 0x2ffff226
INFO: FCONF: Reading FW_CONFIG firmware configuration file from: 0x2ffff000
INFO: FCONF: Reading firmware configuration information for: dyn_cfg
INFO: FCONF: Reading firmware configuration information for: stm32mp1_firewall
INFO: BL2: Loading image id 4
INFO: Loading image id=4 at address 0x2ffc5000
INFO: Image id=4 loaded: 0x2ffc5000 - 0x2ffd847c
WARNING: Not a known TEE, use default loading options.
INFO: BL2: Skip loading image id 21
INFO: BL2: Skip loading image id 22
INFO: BL2: Loading image id 23
INFO: Loading image id=23 at address 0xc0500000
INFO: Image id=23 loaded: 0xc0500000 - 0xc051e86c
INFO: BL2: Loading image id 26
INFO: Loading image id=26 at address 0x2ffc0000
INFO: Image id=26 loaded: 0x2ffc0000 - 0x2ffc47f8
INFO: BL2: Loading image id 5
INFO: Loading image id=5 at address 0xc0100000
INFO: Image id=5 loaded: 0xc0100000 - 0xc01ca800
NOTICE: BL2: Booting BL32
INFO: Entry point address = 0x2ffc5000
INFO: SPSR = 0x1d3

this is the log of the programmer cli:

 -------------------------------------------------------------------
 STM32CubeProgrammer v2.7.0
 -------------------------------------------------------------------
 
 
 
USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
SN : 003400463030510139393639
FW version : 0x0110
Device ID : 0x0500
Device name : STM32MP1
Device type : MPU
Device CPU : Cortex-A7
 
 
Start Embedded Flashing service
 
 
 
Memory Programming ...
Opening and parsing file: debug-tf-a-stm32mp157c-ev1-usb.stm32
 File : debug-tf-a-stm32mp157c-ev1-usb.stm32
 Size : 225656 Bytes
 Partition ID : 0x01
 
Download in Progress:
██████████████████████████████████████████████████ 100%
 
File download complete
Time elapsed during download operation: 00:00:00.486
 
RUNNING Program ...
 PartID: :0x01
Start operation done successfully at partition 0x01
 
Flashlayout Programming ...
██████████████████████████████████████████████████ 100%
Running Flashlayout Partition ...
Flashlayout partition started successfully
 
 
Memory Programming ...
Opening and parsing file: stm32mp157c_eutron_mtb_fip.bin
 File : stm32mp157c_eutron_mtb_fip.bin
 Size : 1052678 Bytes
 Partition ID : 0x03
 
Download in Progress:
██████████████████████████████████████████████████ 100%
 
File download complete
Time elapsed during download operation: 00:00:01.395
 
RUNNING Program ...
 PartID: :0x03
 
Reconnecting the device ...
 
Error:
Unable to reconnect the target device: time out expired
 
 
Error: Start operation failed at partition 0x03
Error: TSV flashing service failed

Kevin HUBER
ST Employee
October 28, 2021

Hello,

Can I have your .tsv file please?

And did you replace the tf-a used inside your tsv, by the new one generated with the developer package?

Because the name of the tf-a downloaded: debug-tf-a-stm32mp157c-ev1-usb.stm32 looks like the default binary delivered by the starter package.

Just a reminder to how to use the tsv file: https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#Updating_partitions

Did you have some traces on USART2, too?

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
Kevin HUBER
ST Employee
November 10, 2021

Hello @Lmoio.1​ ,

Did you fix your problem with CubeProgrammer?

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
gianlucarenzi
Associate II
November 12, 2021

Hello,

I have the same issue in my new board with STM32MP151aaaa SoC.

We decided to use the USART1 as DEBUG console, so the device-tree generated by STMCubeMX (with slightly adaption [i.e. some includes and a specific chosen=... node and u-boot,dm-pre-reloc]) and write over an SD Card to boot up from it.

Enabling the USART1 in the SPL mode:

#ifdef CONFIG_DEBUG_UART_BOARD_INIT
void board_debug_uart_init(void)
{
#if (CONFIG_DEBUG_UART_BASE == STM32_USART1_BASE)
/* On EUREK EK440 Board we are using USART1_TX and USART1_RX with PINS
 * Uart1 TX = Z7
 * Uart1 RX = Z6
 */
#define RCC_MP_APB5ENSETR (STM32_RCC_BASE + 0x0208)
#define RCC_MP_AHB5ENSETR (STM32_RCC_BASE + 0x0210)
 
	/* UART1 clock enable */
	setbits_le32(RCC_MP_APB5ENSETR, BIT(4));
 
#define GPIOZ_BASE 0x54004000
	/* GPIOZ clock enable */
	writel(BIT(0), RCC_MP_AHB5ENSETR);
	/* GPIO configuration for EUREK EK440 boards: Uart1 TX = Z7, RX = Z6 */
	/* GPIOx_MODER Z6 and Z7 = 31..0
	 * 1111 1111 1111 1111
	 * 1010 1111 1111 1111 --> MODER7 & MODER6 (Z7 and Z6)
	 */
	writel(0xffffafff, GPIOZ_BASE + 0x00);
 
	/* GPIOZ GPIOx_AFRL AFR7 for PIN 7 & PIN 6
	 * 0111 0111 0000 0000 ---> AFR7 and AFR6
	 * 0000 0000 0000 0000
	 */
	writel(0x77000000, GPIOZ_BASE + 0x20);
 
#else
 
#error("CONFIG_DEBUG_UART_BASE: not supported value")
 
#endif
}
#endif

and adding the correct setup in .dts file as:

	aliases {
		u-boot,dm-pre-reloc;
		ethernet0 = &ethernet0;
		serial0 = &XX_DEBUG_UART_XX;
		serial1 = &usart2;
		serial2 = &XX_NORMAL_UART_XX;
		serial3 = &uart4;
	};
 
	chosen {
		u-boot,dm-pre-reloc;
		stdout-path = "serial0:115200n8";
	};

Where XX_DEBUG_UART_XX is usart1 and XX_NORMAL_UART_XX is usart3

On serial debug (i.e. over a usart1 adapter over an FTDI 232RL Chip) I am able to see the SPL running on boot as I can see:

pinctrl_stm32 pin-controller@50002000: periph->name = serial@5c000000

serial_stm32 serial@5c000000: prop pinctrl-0 index 0 invalid phandle

clk id 148 not found

serial_stm32 serial@5c000000: failed to enable clock

And after that, I can see the following (I suppose it is u-boot SSBL or something different from above, because last two lines)

pinctrl_stm32 pin-controller@50002000: periph->name = serial@5c000000

serial_stm32 serial@5c000000: prop pinctrl-0 index 0 invalid phandle

clk id 148 not found

serial_stm32 serial@5c000000: failed to enable clock

No serial driver found

resetting ...

And it loops forever.

I have already checked the rcc node is under the u-boot,dm-pre-reloc because I am suspecting the phandle of pinctrl-0 clk 148 is not in the device-tree node somewhere...

Can you explain that?

Regards,

Gianluca

Lmoio.1
Lmoio.1AuthorBest answer
Senior
November 12, 2021

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.