完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
基于arm-none-eabi-gcc和jlink如何去实现STM32f103c8t6程序的编译?
如何去实现基于arm-none-eabi-gcc和jlink的stm32f103c8t6程序烧写呢? |
|
相关推荐
3个回答
|
|
|
|
|
|
6、编写工程makefile
工程的makefile文件如下: #工程的名称及最后生成文件的名字 TARGET = project #设定临时性环境变量 export CC = arm-none-eabi-gcc export AS = arm-none-eabi-as export LD = arm-none-eabi-ld export OBJCOPY = arm-none-eabi-objcopy #读取当前工作目录 TOP=$(shell pwd) #设定包含文件目录 INC_FLAGS= -I $(TOP)/CORE -I $(TOP)/CODE/COMMON/INC -I $(TOP)/CODE/PROCESS/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_ADC1/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_DEFINE/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_KEY/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_NRF24L01/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_SET/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_STRUCT/INC -I $(TOP)/CODE/REMOTE_CONTROLER/REMOTE_CONTROLER_USART1/INC -I $(TOP)/FWLIB/INC -I $(TOP)/IT/INC -I $(TOP)/SYSTEM/INC # CFLAGS = -W -Wall -g -mcpu=cortex-m3 -mthumb -D STM32F10X_MD -D USE_STDPERIPH_DRIVER $(INC_FLAGS) -O0 -std=gnu11 C_SRC=$(shell find ./ -name '*.c') C_OBJ=$(C_SRC:%.c=%.o) # # ASFLAGS= -W -Wall -g -Wall -mcpu=cortex-m3 -mthumb ASM_SRC=$(shell find ./ -name '*.s') ASM_OBJ=$(ASM_SRC:%.s=%.o) # # .PHONY: all clean update # # all:$(C_OBJ) $(ASM_OBJ) $(CC) $(C_OBJ) $(ASM_OBJ) -T Linker.ld -o $(TARGET).elf -mthumb -mcpu=cortex-m3 -Wl,--start-group -lc -lm -Wl,--end-group -specs=nano.specs -specs=nosys.specs -static -Wl,-cref,-u,Reset_Handler -Wl,-Map=Project.map -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x80 $(OBJCOPY) $(TARGET).elf $(TARGET).bin -Obinary $(OBJCOPY) $(TARGET).elf $(TARGET).hex -Oihex # # $(C_OBJ):%.o:%.c $(CC) -c $(CFLAGS) -o $@ $< # # $(ASM_OBJ):%.o:%.s $(AS) -c $(ASFLAGS) -o $@ $< # # clean: rm -f $(shell find ./ -name '*.o') rm -f $(shell find ./ -name '*.d') rm -f $(shell find ./ -name '*.map') rm -f $(shell find ./ -name '*.elf') rm -f $(shell find ./ -name '*.bin') rm -f $(shell find ./ -name '*.hex') rm -f $(shell find ./ -name '*.cdep') 这里makefile的主要功能就是把工程里的所有.c和.s文件编译生成.o文件,然后根据链接文件把生成的.o文件链接生成目的文件,也就是最后用来下载的.hex和.bin文件。 7、使用make进行编译链接并生成.bin和.hex文件 从现在开始就是激动人心的时刻了,在终端进入makefile所在目录,执行make命令,如果你看到终端很流畅的输出一坨又一坨的内容,并最终执行完毕,没有错误,然后你再makefile同级目录多出来了一个.hex文件和一个.bin文件,那么恭喜你,离成功不远了,准确的说应该是离成功就差下载一步了。博主走到这一步时,别提有多开心了。 8、使用jlink对芯片进行烧录 走到这一步就是见证奇迹的时刻了,在终端输入以下命令进入JLink工作目录: $ cd /opt/SEGGER/JLink/ 如果你没有这个目录,那么很不幸,JLink没有安装成功,请移步第二步。 如果有,接下来确定硬件连接正确,然后把USB连到虚拟机上,在终端执行命令: $ ./JLinkExe 出现以下画面证明连接成功并进入工作区: 然后按照提示输入: connect 出现下面结果,提示输入设备型号: 由于我们用的c8t6系列,所以输入: STM32F103C8 执行后会让选择连接模式:SWD/JTAG 这里博主用的时SWD,所以输入SWD: 然后让选通信速率,这里博主选的4000,问题不大,建议不要选太大。 出现以上的结果证明配置成功了,接下来就是下载了: 输入: loadbin <.bin文件所在目录> <下载起始地址> 得到下面的结果证明下载成功了,奇迹见证完毕: |
|
|
|
这里下载后板子不会自动执行,分别输入r命令和go命令对板子进行复位和启动,板子就执行了。
最后,附上JLink常用命令(可以输入问号获取): J-Link>? Available commands are: ---------------------- f Firmware info h halt g go Sleep Waits the given time (in milliseconds). Syntax: Sleep s Single step the target chip st Show hardware status hwinfo Show hardware info mem Read memory. Syntax: mem [ mem8 Read 8-bit items. Syntax: mem8 [ mem16 Read 16-bit items. Syntax: mem16 [ mem32 Read 32-bit items. Syntax: mem32 [ w1 Write 8-bit items. Syntax: w1 [ w2 Write 16-bit items. Syntax: w2 [ w4 Write 32-bit items. Syntax: w4 [ erase Erase internal flash of selected device. Syntax: Erase wm Write test words. Syntax: wm is Identify length of scan chain select register ms Measure length of scan chain. Syntax: ms mr Measure RTCK react time. Syntax: mr q Quit qc Close JLink connection and quit r Reset target (RESET) rx Reset target (RESET). Syntax: rx RSetType Set the current reset type. Syntax: RSetType Regs Display contents of registers wreg Write register. Syntax: wreg moe Shows mode-of-entry, meaning: Reason why CPU is halted SetBP Set breakpoint. Syntax: SetBP SetWP Set Watchpoint. Syntax: ClrBP Clear breakpoint. Syntax: ClrBP ClrWP Clear watchpoint. Syntax: ClrWP VCatch Write vector catch. Syntax: VCatch loadfile Load data file into target memory. Syntax: loadfile Supported extensions: *.bin, *.mot, *.hex, *.srec loadbin Load *.bin file into target memory. Syntax: loadbin savebin Saves target memory into binary file. Syntax: savebin verifybin Verfies if the specified binary is already in the target memory at the specified address. Syntax: verifybin SetPC Set the PC to specified value. Syntax: SetPC le Change to little endian mode be Change to big endian mode log Enables log to file. Syntax: log unlock Unlocks a device. Syntax: unlock Type unlock without of supported device names. nRESET has to be connected term Test command to visualize _ReportOutf output from the target device, using DCC (SEGGER DCC handler running on target) ReadAP Reads a CoreSight AP register. Note: First read returns the data of the previous read. An additional read of DP reg 3 is necessary to get the data. ReadDP Reads a CoreSight DP register. Note: For SWD data is returned immediately. For JTAG the data of the previous read is returned. An additional read of DP reg 3 is necessary to get the data. WriteAP Writes a CoreSight AP register. WriteDP Writes a CoreSight DP register. SWDSelect Selects SWD as interface and outputs the JTAG -> SWD switching sequence. SWDReadAP Reads a CoreSight AP register via SWD. Note: First read returns the data of the previous read. An additional read of DP reg 3 is necessary to get the data. SWDReadDP Reads a CoreSight DP register via SWD. Note: Correct data is returned immediately. SWDWriteAP Writes a CoreSight AP register via SWD. SWDWriteDP Writes a CoreSight DP register via SWD. Device Selects a specific device J-Link shall connect to and performs a reconnect. In most cases explicit selection of the device is not necessary. Selecting a device enables the user to make use of the J-Link flash programming functionality as well as using unlimited breakpoints in flash memory. For some devices explicit device selection is mandatory in order to allow the DLL to perform special handling needed by the device. ExpDevList Exports the device names from the DLL internal device list to a text file Syntax: ExpDevList PowerTrace Perform power trace (not supported by all models) Syntax: PowerTrace 1: Number of bytes transmitted on SWO ---- CP15 ------------ rce Read CP15. Syntax: rce wce Write CP15. Syntax: wce ---- ICE ------------- Ice Show state of the embedded ice macrocell (ICE breaker) ri Read Ice reg. Syntax: ri wi Write Ice reg. Syntax: wi ---- TRACE ----------- TClear TRACE - Clear buffer TSetSize TRACE - Set Size of trace buffer TSetFormat TRACE - SetFormat TSR TRACE - Show Regions (and analyze trace buffer) TStart TRACE - Start TStop TRACE - Stop ---- SWO ------------- SWOSpeed SWO - Show supported speeds SWOStart SWO - Start SWOStop SWO - Stop SWOStat SWO - Display SWO status SWORead SWO - Read and display SWO data SWOShow SWO - Read and analyze SWO data SWOFlush SWO - Flush data SWOView SWO - View terminal data ---- PERIODIC -------- PERConf PERIODIC - Configure PERStart PERIODIC - Start PERStop PERIODIC - Stop PERStat PERIODIC - Display status PERRead PERIODIC - Read and display data PERShow PERIODIC - Read and analyze data ---- File I/O -------- fwrite Write file to emulator fread Read file from emulator fshow Read and display file from emulator fdelete Delete file on emulator fsize Display size of file on emulator flist List directory on emulator SecureArea Creates/Removes secure area on probe ---- Test ------------ TestHaltGo Run go/halt 1000 times TestStep Run step 1000 times TestCSpeed Measure CPU speed. Parameters: [ TestWSpeed Measure download speed into target memory. Parameters: [ TestRSpeed Measure upload speed from target memory. Parameters: [ TestNWSpeed Measure network download speed. Parameters: [ TestNRSpeed Measure network upload speed. Parameters: [ ---- JTAG ------------ Config Set number of IR/DR bits before ARM device. Syntax: Config speed Set target interface speed. Syntax: speed i Read JTAG Id (Host CPU) wjc Write JTAG command (IR). Syntax: wjc (hex) wjd Write JTAG data (DR). Syntax: wjd RTAP Reset TAP Controller using state machine (111110) wjraw Write Raw JTAG data. Syntax: wjraw rt Reset TAP Controller (nTRST) ---- JTAG-Hardware --- c00 Create clock with TDI = TMS = 0 c Clock tck0 Clear TCK tck1 Set TCK 0 Clear TDI 1 Set TDI t0 Clear TMS t1 Set TMS trst0 Clear TRST trst1 Set TRST r0 Clear RESET r1 Set RESET ---- Connection ------ u*** Connect to J-Link via USB. Syntax: u*** ip Connect to J-Link ARM Pro or J-Link TCP/IP Server via TCP/IP. Syntax: ip ---- Configuration --- si Select target interface. Syntax: si where power Switch power supply for target. Syntax: power where State is either On or Off. Example: power on perm wconf Write configuration byte. Syntax: wconf rconf Read configuration bytes. Syntax: rconf license Shows a list of all available license commands ipaddr Show/Assign IP address and subnetmask of/to the connected J-Link. gwaddr Show/Assign network gateway address of/to the connected J-Link. dnsaddr Show/Assign network DNS server address of/to the connected J-Link. conf Show configuration of the connected J-Link. ecp Enable the J-Link control panel. calibrate Calibrate the target current measurement. selemu Select a emulator to communicate with, from a list of all emulators which are connected to the host The interfaces to search on, can be specified Syntax: selemu [ ShowEmuList Shows a list of all emulators which are connected to the host. The interfaces to search on, can be specified. Syntax: ShowEmuList [ ---------------------- |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1617 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1543 浏览 1 评论
977 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
683 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1595 浏览 2 评论
1863浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
644浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
515浏览 3评论
531浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
504浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 02:13 , Processed in 1.960144 second(s), Total 82, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号