keil有点古典 记录一下在vscode上操作oneos工程.
现在的程度是打make调用keil的armcc来编译, 没用gcc
make install 调用stm32cube programmer来下载flash
环境不一致可能不好使, 我的实验的环境是:
win10
vscode v1.63.2
keil: 5.33.0.0
第一步, vscode浏览代码不报红线
编辑vscode的json文件
贴入或者按需修改
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\**",
".\\application",
".\\board",
".\\board\\CubeMX_Config\\Inc",
//".\\board\\packages",
".\\board\\ports",
"..\\..\\arch\\arm\\armv7m\\include",
"..\\..\\common\\include",
"..\\..\\components\\cli\\include",
"..\\..\\components\\diagnose\\stack_trace",
"..\\..\\components\\dlog\\include",
"..\\..\\components\\fs\\include",
"..\\..\\components\\fs\\include\\fatfs",
"..\\..\\components\\position",
"..\\..\\components\\position\\gnss_pos",
"..\\..\\components\\position\\gnss_pos\\prot",
"..\\..\\components\\position\\gnss_pos\\rcvr",
"..\\..\\components\\position\\net_pos",
"..\\..\\components\\shell\\include",
"..\\..\\drivers",
"..\\..\\drivers\\audio",
"..\\..\\drivers\\boot\\cotex-m",
"..\\..\\drivers\\bus",
"..\\..\\drivers\\can",
"..\\..\\drivers\\console",
"..\\..\\drivers\\dma",
"..\\..\\drivers\\fal",
"..\\..\\drivers\\graphic",
"..\\..\\drivers\\hal\\st\\STM32L4xx_HAL\\CMSIS\\Device\\ST\\STM32L4xx\\Include",
"..\\..\\drivers\\hal\\st\\STM32L4xx_HAL\\CMSIS\\Include",
"..\\..\\drivers\\hal\\st\\STM32L4xx_HAL\\STM32L4xx_HAL_Driver\\Inc",
"..\\..\\drivers\\hal\\st\\devices",
"..\\..\\drivers\\hal\\st\\drivers",
//"..\\..\\drivers\\hal\\st\\drivers\\config",
"..\\..\\drivers\\hwcrypto",
"..\\..\\drivers\\i2c",
"..\\..\\drivers\\infrared",
"..\\..\\drivers\\misc",
"..\\..\\drivers\\mtd",
"..\\..\\drivers\\pin",
"..\\..\\drivers\\rtc",
"..\\..\\drivers\\sensors",
"..\\..\\drivers\\serial",
"..\\..\\drivers\\spi",
"..\\..\\drivers\\spi\\sfud\\inc",
"..\\..\\drivers\\timer",
"..\\..\\drivers\\usb\\usb_device",
"..\\..\\drivers\\usb\\usb_device\\Class\\CDC\\Inc",
"..\\..\\drivers\\usb\\usb_device\\Core\\Inc",
"..\\..\\drivers\\watchdog",
"..\\..\\kernel\\include",
"..\\..\\libc\\include",
"..\\..\\libc\\include\\armlibc",
"..\\..\\libc\\include\\extension",
"..\\..\\thirdparty\\mpu6xxx\\inc"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"USE_HAL_DRIVER",
"OS_TASK_SWITCH_NOTIFY",
"STM32L475xx"
],
"compilerPath": "C:\\Keil_v5\\ARM\\ARMCC\\bin\\armcc.exe",
"cStandard": "c99",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86"
}
],
"version": 4
}
第二步, 建立makefile文件, keil的路径注意看实际位置修改
make编译, make install 下载到MCU, make cube打开one os cube
KEIL="C:\Keil_v5\UV4\UV4.exe"
PROJX=".\project.uvprojx"
LOG=".\keil_build.log"
CBMXP="C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe"
BIN=build\keil\Obj\project.axf
CUBE=D:\10_Special_Project\OneOS\OneOS-Cube-V1.3.3\components\cmder\OneOS-Cube.exe
# Will prevent it from exiting even when somehing failied
all:
-$(KEIL) -j0 -b $(PROJX) -o keil_build.log
@type $(LOG)
erase:
-$(CBMXP) -c port=SWD freq=4000 -e all
install:
-$(CBMXP) -c port=SWD freq=4000 -e all -d $(BIN) 0x80000000 -v -s 0x08000000
cube:
-$(CUBE)
clean:
-del $(BIN)
dist-clean:
-rm oneos.bin
-$(KEIL) -j0 -c $(PROJX) -o keil_build.log
@type $(LOG)
效果:
鼠标悬停信息和代码补全都来了
make install 下载