Code Monkey home page Code Monkey logo

c51-sdcc's Introduction

arch linux 下单片机的烧写

工具:

1. sdcc 编译器
	shell yay -S sdcc	
	
2. 烧录器stcflash(基于python环境)
	shell yay -S stcflash

教程:

  • 在工作目录下编写main.c

  • 编译

	sdcc main.c
	编译后会生成许多main.* 文件
	我们需要main.ihx 文件
  • 文件转换 由于单片烧录需要hex文件,我们需要将ihx文件转换并重定向到hex文件

    packihx main.ihx > main.hex
    
    
    
    
  • 烧录到单片机 stcflash运行需要root权限

    sudo stcflash main.hex
    
  • 多文件的烧录

    	sdcc -c tool1.c
    	sdcc -c tool2.c
    	sdcc main.c too1.rel tool2.rel   -> main.ihx
    

make脚本:


编写makefile文件

test.hex : test.c
	    sdcc test.c
 		packihx test.ihx > test.hex
 clean:
 	  	rm -rf *asm *.lst *.mem *.rst *.lnk *.rel *.sym *.ihx *.map
 Writein:
  	    sudo stcflash test.hex

值得注意的是:

linux 下头文件略有不同 头文件: 放在此目录 自行查看

/usr/share/sdcc/include/mcs51/8051.h

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.