|
11 | 11 | queue = env.AddLibraryQueue("lightning-ln882h") |
12 | 12 | env.ConfigureFamily() |
13 | 13 |
|
| 14 | +# Load chip config (CFG_SUPPORT_BLE, etc.) — same pattern as beken-72xx.py |
| 15 | +env.LoadConfig(join("$FAMILY_DIR", "base", "config", "proj_config.h")) |
| 16 | +# Merge any user overrides from custom_options.proj_config into CONFIG so |
| 17 | +# env.Cfg() reflects them (ParseCustomOptions already ran in base.py). |
| 18 | +_proj_overrides = ( |
| 19 | + env.PioPlatform().custom_opts.get("options", {}).get("proj_config#h", {}) |
| 20 | +) |
| 21 | +if _proj_overrides: |
| 22 | + env["CONFIG"].update( |
| 23 | + { |
| 24 | + k: int(v) if str(v).lstrip("-").isdigit() else v.encode() |
| 25 | + for k, v in _proj_overrides.items() |
| 26 | + } |
| 27 | + ) |
| 28 | + |
14 | 29 | # Flags |
15 | 30 | queue.AppendPublic( |
16 | 31 | CCFLAGS=[ |
|
178 | 193 | ), |
179 | 194 | ) |
180 | 195 |
|
| 196 | +# Sources - BLE SDK |
| 197 | +# Compiled when CFG_SUPPORT_BLE=1. libln882h_ble_full_stack.a is built with |
| 198 | +# -ffunction-sections, so --gc-sections removes all BLE functions that are not |
| 199 | +# reachable from the application entry point. A WiFi-only build with no BLE |
| 200 | +# application code adds only ~5 KB (startup hooks); a build with active BLE |
| 201 | +# usage retains all scanner/GAP/GATT code it calls. |
| 202 | +if env.Cfg("CFG_SUPPORT_BLE"): |
| 203 | + queue.AddLibrary( |
| 204 | + name="ln882h_ble", |
| 205 | + base_dir=join("$SDK_DIR", "components", "ble"), |
| 206 | + srcs=[ |
| 207 | + "+<ble_lib_import/ble_port.c>", |
| 208 | + "+<ble_arch/ble_arch_main.c>", |
| 209 | + "+<ble_profiles/prf_common/prf_ble.c>", |
| 210 | + "+<ble_profiles/prf_common/prf_utils.c>", |
| 211 | + "+<ble_app/ble_store/ln_ble_app_kv.c>", |
| 212 | + "+<ble_app/ble_event/ln_ble_event_manager.c>", |
| 213 | + "+<ble_app/ble_gap/gap_misc/ln_ble_gap.c>", |
| 214 | + "+<ble_app/ble_gap/gap_misc/ln_ble_gap_ind_handler.c>", |
| 215 | + "+<ble_app/ble_gap/gap_scan/ln_ble_scan.c>", |
| 216 | + "+<ble_app/ble_gap/gap_advertising/*.c>", |
| 217 | + "+<ble_app/ble_gatt/gatt_common/ln_ble_gatt.c>", |
| 218 | + "+<ble_app/ble_gatt/gatt_common/ln_ble_gatt_ind_handler.c>", |
| 219 | + "+<ble_app/ble_connection_manager/ln_ble_connection_manager.c>", |
| 220 | + "+<ble_app/ble_device_manager/*.c>", |
| 221 | + "+<ble_app/ble_smp/ln_ble_smp.c>", |
| 222 | + "+<ble_app/ble_import/ln_ble_rw_app_task.c>", |
| 223 | + ], |
| 224 | + includes=[ |
| 225 | + # base_dir itself so that #include "ble_arch/arch.h" resolves correctly |
| 226 | + "+<.>", |
| 227 | + "+<ble_arch>", |
| 228 | + "+<ble_lib_import>", |
| 229 | + "+<ble_profiles/prf_common>", |
| 230 | + "+<ble_app/ble_common>", |
| 231 | + "+<ble_app/ble_connection_manager>", |
| 232 | + "+<ble_app/ble_device_manager>", |
| 233 | + "+<ble_app/ble_event>", |
| 234 | + "+<ble_app/ble_gap/gap_advertising>", |
| 235 | + "+<ble_app/ble_gap/gap_misc>", |
| 236 | + "+<ble_app/ble_gap/gap_scan>", |
| 237 | + "+<ble_app/ble_gatt/gatt_client>", |
| 238 | + "+<ble_app/ble_gatt/gatt_common>", |
| 239 | + "+<ble_app/ble_gatt/gatt_server>", |
| 240 | + "+<ble_app/ble_import>", |
| 241 | + "+<ble_app/ble_smp>", |
| 242 | + "+<ble_app/ble_store>", |
| 243 | + "+<ble_app/ble_test>", |
| 244 | + "+<mac/ble/hl/api>", |
| 245 | + "+<mac/ble/hl/inc>", |
| 246 | + "+<mac/ble/ll/api>", |
| 247 | + "+<mac/ble/ll/import>", |
| 248 | + "+<mac/ble/ll/src>", |
| 249 | + "+<mac/ble/ll/src/llm>", |
| 250 | + "+<mac/em/api>", |
| 251 | + "+<mac/hci/api>", |
| 252 | + "+<mac/sch/api>", |
| 253 | + "+<mac/sch/import>", |
| 254 | + "+<modules/aes/api>", |
| 255 | + "+<modules/common/api>", |
| 256 | + "+<modules/dbg/api>", |
| 257 | + "+<modules/ecc_p256/api>", |
| 258 | + "+<modules/h4tl/api>", |
| 259 | + "+<modules/ke/api>", |
| 260 | + "+<modules/lib_ver/api>", |
| 261 | + "+<modules/nvds/api>", |
| 262 | + "+<modules/rf/api>", |
| 263 | + "+<modules/rwip/api>", |
| 264 | + ], |
| 265 | + options=dict( |
| 266 | + CPPDEFINES=["LN882H_SDK", "CFG_SUPPORT_BLE=1"], |
| 267 | + CFLAGS=["-w"], |
| 268 | + ), |
| 269 | + ) |
| 270 | + # Provide a default ble_app_user_cfg.h so the SDK compiles without an |
| 271 | + # application-supplied header. Application components (e.g. ln882h_ble_tracker) |
| 272 | + # that prepend their own include path will shadow this default automatically. |
| 273 | + queue.AppendPublic( |
| 274 | + CPPPATH=[join("$FAMILY_DIR", "ble")], |
| 275 | + ) |
| 276 | + queue.AppendPublic( |
| 277 | + CPPDEFINES=["CFG_SUPPORT_BLE=1"], |
| 278 | + LINKFLAGS=[ |
| 279 | + "-Wl,--whole-archive", |
| 280 | + "-lln882h_ble_full_stack", |
| 281 | + "-Wl,--no-whole-archive", |
| 282 | + ], |
| 283 | + ) |
| 284 | + |
181 | 285 |
|
182 | 286 | # Sources - FreeRTOS |
183 | 287 | env.Replace(FREERTOS_PORT=env["FAMILY_NAME"], FREERTOS_PORT_DEFINE="LIGHTNING_LN882H") |
|
0 commit comments