Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
gcc
pyocd
环境搭建
PY32 Ubuntu GCC 和Vscode开发环境搭建
发布于 2023-03-13 16:39:37 浏览:1223
订阅该版
[tocm] ## PY32 Ubuntu GCC 和Vscode开发环境搭建 今天和大家分享一下我这两天玩的py32f003,仅需6毛钱,提供HAL库和LL库,支持MDK和IAR开发 同时github上面也有gcc的模板程序,本次就介绍一下linux下基于gcc+pyocd的环境搭建 ![1678696397824.png](https://oss-club.rt-thread.org/uploads/20230313/3c997a6b3598eb460a07cf14dfaa332e.png.webp) 这个理论上其实是可以对接RT-Thread Nano的,这里先画一个饼,有空的时候可以试着对接一下🐶 #### 1. 安装 GNU Arm Embedded Toolchain 建议在实体机内下载后,传到虚拟机之中,再进行下面的解压等操作 ``` sudo mkdir -p /opt/gcc-arm/ sudo tar xvf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt/gcc-arm/ cd /opt/gcc-arm/ sudo chown -R root:root arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/ ``` #### 2. 安装 PyOCD 官方建议从pip安装PyOCD,不要用自带apt仓库,不然版本太低,无法识别JLink OB ``` pip uninstall pyocd /home/[user]/.local/bin/pyocd /home/[user]/.local/bin/pyocd-gdbserver /home/[user]/.local/lib/python3.10/site-packages/pyocd-0.34.2.dist-info/* /home/[user]/.local/lib/python3.10/site-packages/pyocd/* source ~/.profile ``` #### 3. 克隆py32的 template ``` git clone https://github.com/IOsetting/py32f0-template.git ``` #### 4. Edit Makefile 根据自己需要编辑Makefile 可以控制使用LL库,HAL库,FreeRTOS等 这里是针对py32f003x6型号,使用DAPLink烧录的。 ```makefile ##### Project ##### PROJECT ?= app # The path for generated files BUILD_DIR = Build ##### Options ##### # Use LL library instead of HAL, y:yes, n:no USE_LL_LIB ?= n # Enable printf float %f support, y:yes, n:no ENABLE_PRINTF_FLOAT ?= n # Build with FreeRTOS, y:yes, n:no USE_FREERTOS ?= n # Build with CMSIS DSP functions, y:yes, n:no USE_DSP ?= n # Build with Waveshare e-paper lib, y:yes, n:no USE_EPAPER ?= n # Programmer, jlink or pyocd FLASH_PROGRM ?= pyocd ##### Toolchains ####### #ARM_TOOCHAIN ?= /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin #ARM_TOOCHAIN ?= /opt/gcc-arm/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin ARM_TOOCHAIN ?= /opt/gcc-arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin # path to JLinkExe JLINKEXE ?= /opt/SEGGER/JLink/JLinkExe # JLink device type, options: # PY32F002AX5, PY32F002X5, # PY32F003X4, PY32F003X6, PY32F003X8, # PY32F030X4, PY32F030X6, PY32F030X7, PY32F030X8 JLINK_DEVICE ?= PY32F003X6 # path to PyOCD, PYOCD_EXE ?= pyocd # PyOCD device type, options: # py32f002ax5, py32f002x5, # py32f003x4, py32f003x6, py32f003x8, # py32f030x3, py32f030x4, py32f030x6, py32f030x7, py32f030x8 # py32f072xb PYOCD_DEVICE ?= py32f003x6 ##### Paths ############ # Link descript file: py32f002x5.ld, py32f003x6.ld, py32f003x8.ld, py32f030x6.ld, py32f030x8.ld LDSCRIPT = Libraries/LDScripts/py32f003x6.ld # Library build flags: # PY32F002x5, PY32F002Ax5, # PY32F003x4, PY32F003x6, PY32F003x8, # PY32F030x3, PY32F030x4, PY32F030x6, PY32F030x7, PY32F030x8, # PY32F072xB LIB_FLAGS = PY32F003x6 # C source folders CDIRS := User \ Libraries/CMSIS/Device/PY32F0xx/Source # C source files (if there are any single ones) CFILES := # ASM source folders ADIRS := User # ASM single files AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f003.s # Include paths INCLUDES := Libraries/CMSIS/Core/Include \ Libraries/CMSIS/Device/PY32F0xx/Include \ User ifeq ($(USE_LL_LIB),y) CDIRS += Libraries/PY32F0xx_LL_Driver/Src \ Libraries/BSP_LL/Src INCLUDES += Libraries/PY32F0xx_LL_Driver/Inc \ Libraries/BSP_LL/Inc LIB_FLAGS += USE_FULL_LL_DRIVER else CDIRS += Libraries/PY32F0xx_HAL_Driver/Src INCLUDES += Libraries/PY32F0xx_HAL_Driver/Inc endif ifeq ($(USE_FREERTOS),y) CDIRS += Libraries/FreeRTOS \ Libraries/FreeRTOS/portable/GCC/ARM_CM0 CFILES += Libraries/FreeRTOS/portable/MemMang/heap_4.c INCLUDES += Libraries/FreeRTOS/include \ Libraries/FreeRTOS/portable/GCC/ARM_CM0 endif ifeq ($(USE_DSP),y) CFILES += Libraries/CMSIS/DSP/Source/BasicMathFunctions/BasicMathFunctions.c \ Libraries/CMSIS/DSP/Source/BayesFunctions/BayesFunctions.c \ Libraries/CMSIS/DSP/Source/CommonTables/CommonTables.c \ Libraries/CMSIS/DSP/Source/ComplexMathFunctions/ComplexMathFunctions.c \ Libraries/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c \ Libraries/CMSIS/DSP/Source/DistanceFunctions/DistanceFunctions.c \ Libraries/CMSIS/DSP/Source/FastMathFunctions/FastMathFunctions.c \ Libraries/CMSIS/DSP/Source/FilteringFunctions/FilteringFunctions.c \ Libraries/CMSIS/DSP/Source/InterpolationFunctions/InterpolationFunctions.c \ Libraries/CMSIS/DSP/Source/MatrixFunctions/MatrixFunctions.c \ Libraries/CMSIS/DSP/Source/QuaternionMathFunctions/QuaternionMathFunctions.c \ Libraries/CMSIS/DSP/Source/StatisticsFunctions/StatisticsFunctions.c \ Libraries/CMSIS/DSP/Source/SupportFunctions/SupportFunctions.c \ Libraries/CMSIS/DSP/Source/SVMFunctions/SVMFunctions.c \ Libraries/CMSIS/DSP/Source/TransformFunctions/TransformFunctions.c INCLUDES += Libraries/CMSIS/DSP/Include \ Libraries/CMSIS/DSP/PrivateInclude endif ifeq ($(USE_EPAPER),y) CDIRS += Libraries/EPaper/Lib \ Libraries/EPaper/Examples \ Libraries/EPaper/Fonts \ Libraries/EPaper/GUI INCLUDES += Libraries/EPaper/Lib \ Libraries/EPaper/Examples \ Libraries/EPaper/Fonts \ Libraries/EPaper/GUI endif include ./rules.mk ``` #### 5. 尝试编译,烧录 ``` # clean source code make clean # build make # or make with verbose output V=1 make # flash make flash ``` #### 6. Vscode配置 c_cpp_properties.json 这个要是没有写的话会报include出错,虽然编译烧录起来都没有问题,但是代码提示功能就基本没有了。 ```json { "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "${workspaceFolder}/User/**", "${workspaceFolder}/Libraries/CMSIS/Core", "/opt/gcc-arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/arm-none-eabi/include", "/opt/gcc-arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/12.2.1/include" ], "defines": [ "PY32F003x6" ], "compilerPath": "/opt/gcc-arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc", "cStandard": "gnu99", "cppStandard": "gnu++14", "intelliSenseMode": "gcc-arm" } ], "version": 4 } ``` #### OA ****** **识别不到DAPLink怎么办?** 实际发现有时候运行make flash,会一直在等待debug probe connect这时候可以试试拔插DAPLINK,重连一下,以及检查是不是连接到主机了而不是实体机中。
6
条评论
默认排序
按发布时间排序
登录
注册新账号
关于作者
goldengrandpa
这家伙很懒,什么也没写!
文章
11
回答
19
被采纳
2
关注TA
发私信
相关文章
1
gcc编译不能链接超过 2MB
2
Studio默认的工具链为什么那么老,支持用新的吗?
3
studio 字节对齐问题求解
4
BSP(zynq7000)例程是否没有做过gcc 9的编译测试?
5
环境搭建问题和AT软件包的问题
6
arm-none-eabi-gcc下编译utest变量未定义
7
rtconfig.py 下编译标志解释
8
关于GCC和ARMCC编译后生成BIN,文件的大小
9
gcc环境 libc 使用, code size 优化请教
10
rt-thread使用win32API
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
I2C_IIC
ESP8266
UART
WIZnet_W5500
ota在线升级
cubemx
PWM
flash
freemodbus
BSP
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
flashDB
GD32
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
SFUD
msh
keil_MDK
ulog
C++_cpp
MicroPython
本月问答贡献
出出啊
1518
个答案
343
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
813
个答案
177
次被采纳
crystal266
547
个答案
161
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
出出啊
1
篇文章
5
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
3
次点赞
crystal266
2
篇文章
2
次点赞
whj467467222
2
篇文章
2
次点赞
回到
顶部
发布
问题
投诉
建议
回到
底部