目前官方提供CW32L083只提供了MDK、IAR下的固件庫、啟動(dòng)文件。我有過成功CW32L083的項(xiàng)目移植的經(jīng)驗(yàn),現(xiàn)在成功的把CW32L031的工程移植到ubuntu下面,實(shí)現(xiàn)了VSCODE的GCC工程模版?,F(xiàn)在將移植的過程與結(jié)果分享如下:
- CW32L031與CW32L083同屬arm-cortex-M0+系列,通對(duì)比MDK下的啟動(dòng)匯編程序,發(fā)現(xiàn)除flsh與內(nèi)存大小不同之外,中斷、外設(shè)基本差不多。因此,我只需要修改。cw32L031、startup_cw32l031_gcc.s、CW32L031_FLASH.ld這三個(gè)文件就可以了。
- 同時(shí)將相關(guān)的外設(shè)驅(qū)動(dòng)庫更換成cw32l031更換過來就實(shí)現(xiàn)了工程的移植。
- 在ubuntu下面還需要安裝wch-link的驅(qū)動(dòng)。
3、移植好后,修改makefile的固件名稱、路徑就可以實(shí)現(xiàn)工程的編譯、下載、以及GDB調(diào)試。
結(jié)果:
- 編譯:
lugl@lugl-virtual-machine:~/CW32L/cw32l083_gcc$ make
[CC] Core/app/app_main.c
[CC] Core/app/interrupts_cw32l031.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_atim.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_dma.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_digitalsign.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_debug.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_rtc.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_pwr.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_systick.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_i2c.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_wwdt.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_awt.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_uart.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_rcc.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_flash.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_iwdt.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_btim.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_crc.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_lvd.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_gtim.c
[CC] Libraries/CW32L031_StdLib/src/system_cw32l031.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_adc.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_spi.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_vc.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_gpio.c
[CC] Libraries/CW32L031_StdLib/src/cw32l031_ram.c
[AS] Libraries/CMSIS/Device/startup_cw32l031_gcc.s
[LD] build_exec/template.elf
[HEX] build_exec/template.elf - > build_exec/template.hex
[BIN] build_exec/template.elf - > build_exec/template.bin
[DUMP] build_exec/template.elf - > build_exec/template.s
[SIZE] build_exec/template.elf
text data bss dec hex filename
1544 20 1572 3136 c40 build_exec/template.elf
2、下載:
lugl@lugl-virtual-machine:~/CW32L/cw32l083_gcc$ make flash
-e Start pyOCD
0000430 I Loading /home/lugl/CW32L/cw32l083_gcc/build_exec/template.elf [load_cmd]
[==================================================] 100%
3、調(diào)試:
Waiting for gdb server to start...[2023-06-25T13:04:50.107Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
pyocd gdbserver --port 50000 --telnet-port 50001
0000446 I Target type is cw32l031c8 [board]
0000529 I DP IDR = 0x0bc11477 (v1 MINDP rev0) [dap]
0000557 I AHB-AP#0 IDR = 0x04770031 (AHB-AP var3 rev0) [discovery]
0000580 I AHB-AP#0 Class 0x1 ROM table #0 @ 0xe00ff000 (designer=43b:Arm part=4c0) [rom_table]
0000590 I [0]< e000e000:SCS v6-M class=14 designer=43b:Arm part=008 > [rom_table]
0000595 I [1]< e0001000:DWT v6-M class=14 designer=43b:Arm part=00a > [rom_table]
0000601 I [2]< e0002000:BPU v6-M class=14 designer=43b:Arm part=00b > [rom_table]
0000607 I CPU core #0 is Cortex-M0+ r0p1 [cortex_m]
0000610 I Setting core #0 (Cortex-M0+) default reset sequence to ResetSystem [pack_target]
0000616 I 2 hardware watchpoints [dwt]
0000620 I 4 hardware breakpoints, 0 literal comparators [fpb]
0000635 I Semihost server started on port 50001 (core 0) [server]
0000752 I GDB server started on port 50000 (core 0) [gdbserver]
0000757 I Client connected to port 50000! [gdbserver]
0000883 I Attempting to load RTOS plugins [gdbserver]
[---|---|---|---|---|---|---|---|---|----]
[========================================]
0001608 I Erased 0 bytes (0 sectors), programmed 0 bytes (0 pages), skipped 2048 bytes (4 pages) at 3.44 kB/s [loader]
附工程包:
-
GCC
+關(guān)注
關(guān)注
0文章
107瀏覽量
24835 -
Ubuntu
+關(guān)注
關(guān)注
5文章
563瀏覽量
29703 -
MDK
+關(guān)注
關(guān)注
4文章
209瀏覽量
32063 -
vscode
+關(guān)注
關(guān)注
1文章
155瀏覽量
7696 -
CW32
+關(guān)注
關(guān)注
1文章
203瀏覽量
626
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論