我把功能模塊的代碼編譯成庫,這樣每次編譯就不需要都重新編譯。
然后程序代碼就調(diào)用庫文件鏈接生成程序。這樣編譯速度快而且直觀,配
全openOCD或winiap,可以很方便開發(fā)調(diào)試程序。不想寫makefile,可以
直接用腳本或批處理實(shí)編譯,也就是固定的命令行。
/tmp/wch003_hal$ make
CC ch32v00x_adc.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_adc.o.d -c ch32v00x_adc.c -o /tmp/wch003_hal_obj/ch32v00x_adc.o
CC ch32v00x_dbgmcu.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_dbgmcu.o.d -c ch32v00x_dbgmcu.c -o /tmp/wch003_hal_obj/ch32v00x_dbgmcu.o
CC ch32v00x_dma.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_dma.o.d -c ch32v00x_dma.c -o /tmp/wch003_hal_obj/ch32v00x_dma.o
CC ch32v00x_exti.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_exti.o.d -c ch32v00x_exti.c -o /tmp/wch003_hal_obj/ch32v00x_exti.o
CC ch32v00x_flash.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_flash.o.d -c ch32v00x_flash.c -o /tmp/wch003_hal_obj/ch32v00x_flash.o
CC ch32v00x_gpio.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_gpio.o.d -c ch32v00x_gpio.c -o /tmp/wch003_hal_obj/ch32v00x_gpio.o
CC ch32v00x_i2c.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_i2c.o.d -c ch32v00x_i2c.c -o /tmp/wch003_hal_obj/ch32v00x_i2c.o
CC ch32v00x_it.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_it.o.d -c ch32v00x_it.c -o /tmp/wch003_hal_obj/ch32v00x_it.o
CC ch32v00x_iwdg.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_iwdg.o.d -c ch32v00x_iwdg.c -o /tmp/wch003_hal_obj/ch32v00x_iwdg.o
CC ch32v00x_misc.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_misc.o.d -c ch32v00x_misc.c -o /tmp/wch003_hal_obj/ch32v00x_misc.o
CC ch32v00x_opa.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_opa.o.d -c ch32v00x_opa.c -o /tmp/wch003_hal_obj/ch32v00x_opa.o
CC ch32v00x_pwr.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_pwr.o.d -c ch32v00x_pwr.c -o /tmp/wch003_hal_obj/ch32v00x_pwr.o
CC ch32v00x_rcc.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_rcc.o.d -c ch32v00x_rcc.c -o /tmp/wch003_hal_obj/ch32v00x_rcc.o
CC ch32v00x_spi.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_spi.o.d -c ch32v00x_spi.c -o /tmp/wch003_hal_obj/ch32v00x_spi.o
CC ch32v00x_tim.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_tim.o.d -c ch32v00x_tim.c -o /tmp/wch003_hal_obj/ch32v00x_tim.o
CC ch32v00x_usart.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_usart.o.d -c ch32v00x_usart.c -o /tmp/wch003_hal_obj/ch32v00x_usart.o
CC ch32v00x_wwdg.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
h32v00x_wwdg.o.d -c ch32v00x_wwdg.c -o /tmp/wch003_hal_obj/ch32v00x_wwdg.o
CC core_riscv.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/c
ore_riscv.o.d -c core_riscv.c -o /tmp/wch003_hal_obj/core_riscv.o
CC debug.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/d
ebug.o.d -c debug.c -o /tmp/wch003_hal_obj/debug.o
CC system_ch32v00x.c
riscv-none-embed-gcc -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore -g -Os -fmes
sage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -funsigned-bitfields
-Wall -Wunused -Wuninitialized ?-Wundef -std=gnu99 ?-I./ -MD -MP -MF /tmp/wch003_hal_obj/.dep/s
ystem_ch32v00x.o.d -c system_ch32v00x.c -o /tmp/wch003_hal_obj/system_ch32v00x.o
AR file /tmp/wch003_hal_obj/wch003_hal.a
riscv-none-embed-ar cru ?/tmp/wch003_hal_obj/wch003_hal.a /tmp/wch003_hal_obj/ch32v00x_adc.o /tm
p/wch003_hal_obj/ch32v00x_dbgmcu.o /tmp/wch003_hal_obj/ch32v00x_dma.o /tmp/wch003_hal_obj/ch32v0
0x_exti.o /tmp/wch003_hal_obj/ch32v00x_flash.o /tmp/wch003_hal_obj/ch32v00x_gpio.o /tmp/wch003_h
al_obj/ch32v00x_i2c.o /tmp/wch003_hal_obj/ch32v00x_it.o /tmp/wch003_hal_obj/ch32v00x_iwdg.o /tmp
/wch003_hal_obj/ch32v00x_misc.o /tmp/wch003_hal_obj/ch32v00x_opa.o /tmp/wch003_hal_obj/ch32v00x_
pwr.o /tmp/wch003_hal_obj/ch32v00x_rcc.o /tmp/wch003_hal_obj/ch32v00x_spi.o /tmp/wch003_hal_obj/
ch32v00x_tim.o /tmp/wch003_hal_obj/ch32v00x_usart.o /tmp/wch003_hal_obj/ch32v00x_wwdg.o /tmp/wch
003_hal_obj/core_riscv.o /tmp/wch003_hal_obj/debug.o /tmp/wch003_hal_obj/system_ch32v00x.o
###############################################################################
/tmp/app_demo$ make
-------- begin --------
Compiling C: main.c
riscv-none-embed-gcc -c -I. -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore ?-g ?
-DF_CPU=48000000UL -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno
-common -Wall -Wunused -Wuninitialized -Wundef -Wa,-adhlns=/tmp/mf_demo_obj/main.lst -I./ -I/mnt
/lj/test/wch/wch003_hal -std=gnu99 -ffunction-sections -Wundef -MMD -MP -MF /tmp/mf_demo_obj/.de
p/main.o.d main.c -o /tmp/mf_demo_obj/main.o??
Assembling: startup_ch32v00x.S
riscv-none-embed-gcc -I. -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore ?-g ?-DF
_CPU=48000000UL -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-co
mmon -Wall -Wunused -Wuninitialized -Wundef -Wa,-adhlns=startup_ch32v00x.S -I./ -I/mnt/lj/test/w
ch/wch003_hal -std=gnu99 -ffunction-sections -Wundef -MMD -MP -MF /tmp/mf_demo_obj/.dep/startup_
ch32v00x.o.d -c -I. -x assembler-with-cpp ?-Wa,-adhlns=/tmp/mf_demo_obj/startup_ch32v00x.lst,-g
startup_ch32v00x.S -o /tmp/mf_demo_obj/startup_ch32v00x.o
Linking: /tmp/mf_demo_obj/mf_demo.elf
riscv-none-embed-gcc -I. -march=rv32ec -mabi=ilp32e -msmall-data-limit=0 -msave-restore ?-g ?-DF
_CPU=48000000UL -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-co
mmon -Wall -Wunused -Wuninitialized -Wundef -Wa,-adhlns=/tmp/mf_demo_obj/main.o -I./ -I/mnt/lj/t
est/wch/wch003_hal -std=gnu99 -ffunction-sections -Wundef -MMD -MP -MF /tmp/mf_demo_obj/.dep/mf_
demo.elf.d /tmp/mf_demo_obj/main.o /tmp/mf_demo_obj/startup_ch32v00x.o --output /tmp/mf_demo_obj
/mf_demo.elf -Wl,-Map=/tmp/mf_demo_obj/mf_demo.map,--cref -T "./Link.ld" -nostartfiles -Xlinker
--gc-sections --specs=nano.specs --specs=nosys.specs ?-Wl,-gc-sections -Wl,--relax -L /mnt/lj/te
st/wch/wch003_hal -lwch003_hal ?
Creating load file for Flash: /tmp/mf_demo_obj/mf_demo.hex
riscv-none-embed-objcopy -O ihex /tmp/mf_demo_obj/mf_demo.elf /tmp/mf_demo_obj/mf_demo.hex
Size after:
??text ???data ????bss ????dec ????hex filename
??7028 ????168 ????276 ???7472 ???1d30 /tmp/mf_demo_obj/mf_demo.elf
-------- end --------