首创ubuntu下cw32l031的vscode+gcc工程创建、下载、调试 2023-07-14

 目前官方提供CW32L083只提供了MDK、IAR下的固件库、启动文件。我有过成功CW32L083的项目移植的经验,现在成功的把CW32L031的工程移植到ubuntu下面,实现了VSCODE的GCC工程模版。现在将移植的过程与结果分享如下:
1. CW32L031与CW32L083同属arm-cortex-M0+系列,通对比MDK下的启动汇编程序,发现除flsh与内存大小不同之外,中断、外设基本差不多。因此,我只需要修改。cw32L031、startup_cw32l031_gcc.s、CW32L031_FLASH.ld这三个文件就可以了。
2. 同时将相关的外设驱动库更换成cw32l031更换过来就实现了工程的移植。
3. 在ubuntu下面还需要安装wch-link的驱动。
3、移植好后,修改makefile的固件名称、路径就可以实现工程的编译、下载、以及GDB调试。
结果:
1. 编译:

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、调试:

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 [url=home.php?mod=space&uid=72445]@[/url] 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]


附工程包:
 cw32l030_gcc.zip (624.29 KB)


勘误纠正/技术交流/采购需求/批量供应(Correction/Technical/Perchase/Wholesale)(共0条评论)
  • 暂无评论
E-mail:
AA:
Contents:
  Code: captcha