-
Notifications
You must be signed in to change notification settings - Fork 128
/
project.build
111 lines (95 loc) · 3.61 KB
/
project.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# avoid 'Entering|Leaving directory' messages
ifndef VERBOSE
MAKEFLAGS += --no-print-directory
endif
command_flash = $(BL_FLASH_PROGRAM) --interface=uart --baudrate=$(BAUDRATE) \
--port=$(COMX) --chipname=$(CHIP) --cpu_id=$(CPU_ID) --config=flash_prog_cfg.ini
command_efuse = $(BL_FLASH_PROGRAM) --interface=uart --baudrate=$(BAUDRATE) \
--port=$(COMX) --chipname=$(CHIP) --efuse=build/build_out/efusedata.bin
command_puncover = $(PUNCOVER_PROGRAM) \
--elf_file ./build/build_out/*.elf --map_file ./build/build_out/*.map \
--build_dir ./build --src_root ${BL_SDK_BASE} --port 5001
ifeq ($(OS),Windows_NT)
CMAKE = $(BL_SDK_BASE)/tools/cmake/bin/cmake.exe
BL_FLASH_PROGRAM = ${BL_SDK_BASE}/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand.exe
PUNCOVER_PROGRAM = puncover_riscv.exe
cmake_generator = "MinGW Makefiles"
else
ifeq ($(shell uname),Darwin)
CMAKE = cmake # use user cmake
BL_FLASH_PROGRAM = ${BL_SDK_BASE}/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand-macos
PUNCOVER_PROGRAM = puncover_riscv
cmake_generator = "Unix Makefiles"
else ifeq ($(shell uname),FreeBSD)
CMAKE = cmake # use user cmake
BL_FLASH_PROGRAM = ${BL_SDK_BASE}/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand-freebsd
PUNCOVER_PROGRAM = puncover_riscv
cmake_generator = "Unix Makefiles"
else ifeq ($(shell arch),aarch64)
CMAKE = cmake # use user cmake
BL_FLASH_PROGRAM = ${BL_SDK_BASE}/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand-arm
PUNCOVER_PROGRAM = puncover_riscv
cmake_generator = "Unix Makefiles"
else ifeq ($(patsubst %WSL2,WSL2,$(shell uname -r)), WSL2)
PS_PROGRAM = /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
CMAKE = $(BL_SDK_BASE)/tools/cmake/bin/cmake
command_flash = $(PS_PROGRAM) make flash CHIP=$(CHIP) CPU_ID=$(CPU_ID) COMX=$(COMX) BAUDRATE=$(BAUDRATE)
command_efuse = $(PS_PROGRAM) make efuse CHIP=$(CHIP) CPU_ID=$(CPU_ID) COMX=$(COMX) BAUDRATE=$(BAUDRATE)
PUNCOVER_PROGRAM = puncover_riscv
cmake_generator = "Unix Makefiles"
else
CMAKE = $(BL_SDK_BASE)/tools/cmake/bin/cmake
BL_FLASH_PROGRAM = ${BL_SDK_BASE}/tools/bflb_tools/bouffalo_flash_cube/BLFlashCommand-ubuntu
PUNCOVER_PROGRAM = puncover_riscv
cmake_generator = "Unix Makefiles"
endif
endif
# The command to remove a file.
RM = $(CMAKE) -E remove_directory
CPU_ID ?=
CONFIG_USB_HS ?=y
CONFIG_ROMAPI ?=y
CONFIG_DEBUG ?=y
CONFIG_TLSF ?=y
CONFIG_COREDUMP ?=y
COMX ?=COM5
BAUDRATE ?=2000000
BOARD_DIR ?=
#cmake definition config
cmake_definition+= -DCROSS_COMPILE=${CROSS_COMPILE}
cmake_definition+= -DCHIP=$(CHIP)
cmake_definition+= -DCPU_ID=$(CPU_ID)
cmake_definition+= -DBOARD=$(BOARD)
cmake_definition+= -DBOARD_DIR=$(BOARD_DIR)
cmake_definition+= -DCONFIG_DEBUG=$(CONFIG_DEBUG)
cmake_definition+= -DCONFIG_ROMAPI=$(CONFIG_ROMAPI)
cmake_definition+= -DCONFIG_USB_HS=$(CONFIG_USB_HS)
cmake_definition+= -DCONFIG_COMX=$(COMX)
cmake_definition+= -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF
cmake_definition+= -DCONFIG_TLSF=$(CONFIG_TLSF)
cmake_definition+= -DCONFIG_COREDUMP=$(CONFIG_COREDUMP)
build:Makefile
$(CMAKE) -S . -B build -G $(cmake_generator) $(cmake_definition)
$(MAKE) -C build -j8
$(MAKE) -C build combine
ninja:Makefile
$(CMAKE) -S . -B build -G Ninja $(cmake_definition)
cd build && ninja && ninja combine
clean::
$(RM) build
# Pack built outs and clean
pack_clean::
proj_name=`find . -name "*.elf" | xargs basename -s .elf`; \
tar czvf $${proj_name}_imgs.tar.gz build/build_out/$${proj_name}.*;
$(RM) build
menuconfig::
python $(BL_SDK_BASE)/tools/kconfig/menuconfig.py
flash:
$(command_flash)
efuse:
$(command_efuse)
puncover:
$(command_puncover)
size:
$(MAKE) -C build size_report
.PHONY:build clean menuconfig ninja flash efuse puncover size