Linux 51单片机开发环境搭建

检查连接

  • 检查单片机是否已经成功和计算机连接

    lsusb | grep "CH340"
    
    # 如果得到类似输出那么到/dev/文件夹下就可以找到一个叫ttyUSB0的文件.那么说明连接成功了
    Bus 001 Device 007: ID 1a86:7523 QinHeng Electronics CH340 serial converter
    

安装编译器

  • SDCC(smell Devic C Compiler)
  • Arch/Manjaro 下安装

    yay -S sdcc
    

安装烧写工具

  • Arch Linux

    yay stcflash
    

烧写程序

  • 写个Makefile

    # OBJS specifes which files to compile as part of the project
    OBJS = c51.c
    
    # CC specifies which compiler we're using
    CC = sdcc
    
    all: $(OBJS)
    	$(CC) $(OBJS)
    
    clean:
    	rm *.lst *.mem *.rst *.lk *.map *.rel *.sym
    
  • 编译

    make
    
    make clean
    
  • 烧写到单片机上【stcflash可以直接烧录.ihx文件】

    sudo stcflash -p /dev/ttyUSB0 running_lights.ihx
    
posted @ 2021-03-03 19:03  南方与南  阅读(628)  评论(0)    收藏  举报