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
Glad to hear that it works on your side as well.
Quick addition: if you'd rather not touch the startup file at all, you can fix it from the linker script side instead. Keep the startup's STACK/HEAP areas and __user_initial_stackheap as they are, and just tell the default scatter file to place them instead of reserving its own:
// replace ARM_LIB_HEAP / ARM_LIB_STACK with: STARTUP_HEAP AlignExpr(+0, 8) { *(HEAP) } STARTUP_STACK AlignExpr(+0, 8) { *(STACK) }
Either way, pick one place (startup code or linker script) to manage them and keep it consistent.