I create a STM32CubeMX based STM32F407VET project, and try to use printf in project:
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); /* USER CODE BEGIN 2 */ printf("Hello semihosting!\n"); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ printf("Hello semihosting!\n"); /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
# List different hardware targets that are used to deploy the solution. target-types: - type: STM32F407VETx device: STM32F407VETx target-set: - set: images: - project-context: Project.Debug debugger: name: ST-Link@pyOCD clock: 4000000 protocol: swd telnet: - mode: monitor
20 11 03 00 08 a9 2a 00 08 79 2a 00 08 a5 2a 00 08 39 1f
Thanks! The problem is the User Stack and Heap initialization part in startup_stm32f407xx.s, it can output correctly if I remove this part.