diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_common.c b/bsp/stm32/libraries/HAL_Drivers/drv_common.c index 82ec1f8985..74007b6e88 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_common.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_common.c @@ -168,7 +168,7 @@ RT_WEAK void rt_hw_board_init() #endif /* Set the shell console output device */ -#ifdef RT_USING_CONSOLE +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_common.h b/bsp/stm32/libraries/HAL_Drivers/drv_common.h index c45041129d..83ef259308 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_common.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_common.h @@ -13,7 +13,9 @@ #include #include +#ifdef RT_USING_DEVICE #include +#endif #ifdef __cplusplus extern "C" {