From 639024a1a66affdf529a2ddb5c3611f7bcf2251a Mon Sep 17 00:00:00 2001 From: andy <1414772332@qq.com> Date: Thu, 16 Jan 2025 15:44:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0BUILD.gn=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=20=E8=83=BD=E7=94=9F=E6=88=90ninja=E8=84=9A=E6=9C=AC=20?= =?UTF-8?q?=E4=BD=86=E7=BC=96=E8=AF=91=E4=B8=8D=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gn | 2 +- BUILD.gn | 18 +++ ap/BUILD.gn | 287 +++++++++++++++++++++++++++++++++++++++ app/BUILD.gn | 25 ++++ app/smart_grid/BUILD.gn | 129 ++++++++++++++++++ app/sniffer/BUILD.gn | 24 ++++ build/BUILD.gn | 33 ++++- build/BUILDCONFIG.gn | 2 +- build/buildcfg.gni | 110 +++++++++++++++ build/config.gn | 17 --- build/config.gni | 33 +++++ build/run_shell_cmd.py | 27 ++++ cli/BUILD.gn | 63 +++++++++ common/BUILD.gn | 68 ++++++++++ driver/BUILD.gn | 160 ++++++++++++++++++++++ ftm/BUILD.gn | 103 ++++++++++++++ import/BUILD.gn | 49 +++++++ os/BUILD.gn | 33 +++++ pib/BUILD.gn | 25 ++++ plc/BUILD.gn | 293 ++++++++++++++++++++++++++++++++++++++++ startup/BUILD.gn | 41 ++++++ 21 files changed, 1522 insertions(+), 20 deletions(-) create mode 100644 BUILD.gn create mode 100644 ap/BUILD.gn create mode 100644 app/BUILD.gn create mode 100644 app/smart_grid/BUILD.gn create mode 100644 app/sniffer/BUILD.gn create mode 100644 build/buildcfg.gni delete mode 100644 build/config.gn create mode 100644 build/config.gni create mode 100755 build/run_shell_cmd.py create mode 100644 cli/BUILD.gn create mode 100644 common/BUILD.gn create mode 100644 driver/BUILD.gn create mode 100644 ftm/BUILD.gn create mode 100644 import/BUILD.gn create mode 100644 os/BUILD.gn create mode 100644 pib/BUILD.gn create mode 100644 plc/BUILD.gn create mode 100644 startup/BUILD.gn diff --git a/.gn b/.gn index d5211bf..df7a306 100644 --- a/.gn +++ b/.gn @@ -4,7 +4,7 @@ buildconfig = "//build/BUILDCONFIG.gn" -root = "//mfgtool" +# root = "//" script_executable = "/usr/bin/env" diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..5d2add2 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,18 @@ +import("//build/buildcfg.gni") + +module_name = get_path_info(rebase_path("."), "name") +module_group(module_name) { + modules = [ + "ap", + "app", + "startup", + "driver", + "common", + "os", + "plc", + "ftm", + "pib", + "cli", + "import" + ] +} \ No newline at end of file diff --git a/ap/BUILD.gn b/ap/BUILD.gn new file mode 100644 index 0000000..5814fa6 --- /dev/null +++ b/ap/BUILD.gn @@ -0,0 +1,287 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = get_path_info(rebase_path("."), "name") +kernel_module(module_name) { + sources = [ + "src/main.c", + ] + + include_dirs = [ + "include", + "../fs/littlefs/include", + ] + + + +} + +config("public") { + include_dirs = [ + ".", + "include", + "//inc", + "//inc/config", + "//inc/utils", + "//inc/hw", + "//inc/hw/reg", + "//inc/io_lib", + "//inc/plc_lib", + "//inc/pib", + "//inc/uart", + "//inc/os_shim", + "//inc/crypto", + "//inc/compiler", + "//inc/compiler/gcc", + "//inc/ipc", + "//inc/app", + "//inc/pkt", + "//inc/cli", + "//inc/cli/plc", + "//inc/dbglog", + "//inc/dbglog/plc", + "//inc/driver", + "//inc/socket", + "//inc/driver/flash", + "//export/inc", + "//export/inc/app", + "//export/inc/config", + "//export/inc/socket", + "//export/inc/pib", + "//export/inc/uart", + "//export/inc/utils", + "//export/inc/gpio", + "//export/inc/io_lib", + "//export/inc/gp_timer", + "//export/inc/os_shim", + "//export/inc/crypto", + "//export/inc/bsp", + "//export/inc/ipc", + "//export/inc/sg_lib", + "//export/inc/upgrade", + "//export/inc/compiler", + "//export/inc/compiler/gcc", + "//export/inc/plc_lib", + "//export/inc/pkt", + "//export/inc/cli", + "//export/inc/dbglog", + "//cli/communicator", + "//common/io_lib/inc", + "//os/liteos_m/src/include", + "//import/wq_vtb/ext_inc", + "//plc/inc", + "//driver/inc", + ] + + if (target == "kunlun3") { + include_dirs += [ + "//inc/hw/reg/riscv3", + "//inc/hw/reg/riscv3/2", + "//inc/hw/reg/riscv3/2/plc/mac/parse_reg", + "//inc/hw/reg/riscv3/2/plc/phy/parse_reg", + "//inc/hw/reg/riscv3/2/soc/macro", + "//inc/hw/reg/riscv3/2/soc/struct", + "//startup/riscv3/inc", + "//driver/src/hw3/inc", + ] + } + + defines = [ + "typeof=__typeof__", + "asm=__asm", + ] + ldflags = [ + "-Wl,-T" + rebase_path("${kl_ld_script}"), + "-Wl,-u_printf_float", + ] + + if (target == "kunlun3") { + if (sec_cpu_enable == "1") { + defines += ["IOT_SEC_CPU_SUPPORT=1"] + } else { + defines += ["IOT_SEC_CPU_SUPPORT=0"] + } + } + if (mpu_enable == "1") { + defines += ["MPU_ENABLE"] + } + if (disable_print == "1") { + defines += ["DISABLE_PRINT"] + } + if (rf_enable == "1") { + defines += ["HPLC_RF_SUPPORT=1"] + } + if (dual_enable == "1") { + defines += ["HPLC_RF_DEV_SUPPORT=1"] + } else { + defines += ["HPLC_RF_DEV_SUPPORT=0"] + } + if (PROTO_TYPE == "p1901") { + defines += ["SUPPORT_IEEE_1901=1"] + } + if(defined(new_type_cco)) { + if (new_type_cco == "1") { + defines += ["INCLUDE_VIRTUAL_CHANNEL=1"] + } + } + if (defined(smart_cco_sta)) { + if (smart_cco_sta != "") { + defines += ["IOT_SMART_CONFIG=${smart_cco_sta}"] + } else { + defines += ["IOT_SMART_CONFIG=0"] + smart_cco_sta = "0" + } + } else { + defines += ["IOT_SMART_CONFIG=0"] + smart_cco_sta = "0" + } + if (psram_enable == "1") { + defines += ["RUN_IN_PSRAM=1","IOT_PSRAM_ENABLE=1"] + if (defined(psram_size)) { + defines += ["IOT_PSRAM_SIZE=${psram_size}"] + } else { + if (cco == "1"){ + defines += ["IOT_PSRAM_SIZE=4"] + } else { + defines += ["IOT_PSRAM_SIZE=2"] + } + } + } else { + defines += [ + "RUN_IN_PSRAM=0", + "IOT_PSRAM_ENABLE=0", + "IOT_PSRAM_SIZE=0" + ] + } + if (product_line == "PLC") { + if (ftm_build == "1") { + defines += [ + "PLC_SUPPORT_CCO_ROLE=0", + "IOT_FTM_SUPPORT=1", + "IOT_MP_SUPPORT=0" + ] + } else { + if (cco == "1") { + defines += [ + "PLC_SUPPORT_CCO_ROLE=1", + "IOT_FTM_SUPPORT=1", + "IOT_MP_SUPPORT=1" + ] + } else { + defines += [ + "PLC_SUPPORT_CCO_ROLE=0", + "IOT_FTM_SUPPORT=1", + "IOT_MP_SUPPORT=1" + ] + } + } + } + + if (cpu1_build == "1"){ + defines += ["RUN_ON_CPU_1=1"] + } + if (hw_platform_ver != "") { + defines += ["HW_PLATFORM_VER=${hw_platform_ver}"] + } else { + if (target == "kunlun3") { + defines += ["HW_PLATFORM_VER=2"] + } else { + defines += ["HW_PLATFORM_VER=15"] + } + } + if (build_amp_type == "1") { + defines += ["BUILD_AMP_TYPE=1"] + } else { + if (build_amp_type == "2") { + defines += ["BUILD_AMP_TYPE=2"] + } else { + defines += ["BUILD_AMP_TYPE=0"] + } + } + if (fastboot_mode == "1") { + defines += ["BUILD_FASTBOOT_MODE=1"] + } + if (layout_index != "") { + defines += ["FLASH_LAYOUT_INDEX=${layout_index}"] + } + if (smart_cco_sta != "0") { + defines += ["ENABLE_WDT_DEFAULT=1", "IOT_FLASH_BUILD=1"] + } else { + if (flash_build == "1") { + defines += ["ENABLE_WDT_DEFAULT=1", "IOT_FLASH_BUILD=1"] + } else { + defines += ["SHARE_IRQ_ENABLE"] + } + } + if (product_line == "PLC") { + defines += ["IOT_PRODUCT_LINE=0"] + } else { + assert(false,"product_line value error.") + } + + if (gcc == "riscv") { + defines += ["RISCV"] + } + if (PLATFORM == "") { + defines += ["HW_PLATFORM=1"] + } else if (PLATFORM == "FPGA") { + defines += ["HW_PLATFORM=1"] + } else if (PLATFORM == "CHIP") { + defines += ["HW_PLATFORM=2"] + } + if (!defined(HW_CHIP_ID)) { + HW_CHIP_ID = "HZ" + } + if (HW_CHIP_ID == "HZ") { + defines += ["HW_CHIP_ID=1"] + } else if (HW_CHIP_ID == "WQ") { + defines += ["HW_CHIP_ID=2"] + } else { + defines += ["HW_CHIP_ID=3"] + } + if (product_line == "PLC") { + if (APP == "") { + defines += ["IOT_APP_SELECTION=0"] + } else { + defines += ["IOT_APP_SELECTION=${APP}"] + } + } + if (FLASH_SIZE == "") { + defines += ["IOT_FLASH_SIZE=1"] + } else { + defines += ["IOT_FLASH_SIZE=${FLASH_SIZE}"] + } + if (!defined(PLC_SUPPORT_3_PHASE)) { + if (cco == "1") { + defines += ["PLC_SUPPORT_3_PHASE=1"] + } + } else { + defines += ["PLC_SUPPORT_3_PHASE=${PLC_SUPPORT_3_PHASE}"] + } + if (target == "kunlun2") { + defines += ["TARGET_VERSION=2"] + } else if (target == "kunlun3") { + defines += ["TARGET_VERSION=3"] + } else { + defines += ["TARGET_VERSION=1"] + } + + + + + libs = [ + "c", + "m", + "nosys", + ] +} diff --git a/app/BUILD.gn b/app/BUILD.gn new file mode 100644 index 0000000..6eb9162 --- /dev/null +++ b/app/BUILD.gn @@ -0,0 +1,25 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = get_path_info(rebase_path("."), "name") +module_group(module_name) { + if (APP == "0") { + modules = [ + "smart_grid", + ] + } else if (APP == "15") { + modules = [ + "sniffer", + ] + } +} diff --git a/app/smart_grid/BUILD.gn b/app/smart_grid/BUILD.gn new file mode 100644 index 0000000..c163a90 --- /dev/null +++ b/app/smart_grid/BUILD.gn @@ -0,0 +1,129 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "cco/iot_sg_cco_min_clct_v28.c", + "cco/iot_sg_ext_cco.c", + "cco/iot_sg_cco_net_info.c", + "cco/iot_sg_cco_buf.c", + # "cco/iot_sg_cco_sw_branch_detect.c", + "cco/iot_sg_cco_active_qr.c", + "cco/iot_cco_buf.c", + "cco/iot_sg_cco_pw_tsfm.c", + "cco/iot_sg_cco_pm_score.c", + "cco/iot_sg_cco.c", + "cco/iot_gw_app_cco.c", + "cco/iot_sg_cco_x4.c", + "cco/iot_sg_cco_clock_manage.c", + "cco/iot_sg_cco_lp_meter.c", + "cco/iot_sg_cco_cmd.c", + "cco/iot_sg_cco_upgrade.c", + "cco/iot_sg_cco_acm.c", + # "cco/iot_sg_cco_bd_common.c", + "cco/iot_sg_cco_addr_map.c", + "cco/iot_sg_cco_cli.c", + "cco/iot_sg_cco_predict_mr.c", + "cco/iot_sg_cco_qr_cnt.c", + "cco/iot_sg_cco_branch_detect.c", + # "cco/iot_sg_cco_optics.c", + "cco/iot_sg_cco_nli_cfg.c", + "cco/iot_sg_cco_flash.c", + "cco/iot_sg_cco_edge_computing.c", + "cco/iot_nw_app_cco.c", + "cco/iot_sg_cco_bd_id_map.c", + "cco/iot_conn_less_app_cco.c", + # "cco/iot_sg_cco_min_clct_nw.c", + "common/iot_sg_ext.c", + "common/iot_sg.c", + "common/swc_lib/iot_swc_lib.c", + "common/swc_lib/iot_swc_api.c", + "common/swc_lib/iot_swc_api_cco.c", + "common/flash/iot_sg_flash.c", + "driver/sta/iot_sg_sta_drv_hx_pm.c", + "driver/sta/iot_sg_sta_drv_pm.c", + "driver/sta/iot_sg_sta_drv_hx_dlms_pm.c", + "driver/sta/iot_sg_sta_drv_wapper_pm.c", + "driver/sta/iot_sg_sta_drv_iec_pm.c", + "driver/sta/iot_sg_sta_drv_collector_i.c", + "driver/sta/iot_sg_sta_drv_ct2_proto_irext_spg.c", + "driver/sta/iot_sg_sta_drv_nw_collector_i.c", + "driver/sta/iot_sg_sta_drv_qsxj.c", + "driver/sta/iot_sg_sta_drv_test.c", + "driver/sta/iot_sg_sta_drv_collector_ii.c", + "driver/sta/iot_sg_sta_drv_ct2_proto_irext.c", + "driver/sta/iot_sg_sta_drv_1662_pm.c", + "driver/cco/iot_sg_cco_drv.c", + "driver/cco/iot_gw_drv_fj.c", + "driver/cco/iot_gw_drv_cli.c", + "driver/cco/iot_nw_drv_cctt.c", + "driver/cco/iot_gw_drv_cctt.c", + "protocol/proto_69845.c", + "protocol/proto_wapper.c", + "protocol/proto_645_fj.c", + "protocol/proto_iec_yj.c", + "protocol/proto_645_topo.c", + "protocol/proto_mwc.c", + "protocol/proto_3762.c", + "protocol/proto_69845_vendor.c", + "protocol/proto_645_vendor.c", + "protocol/proto_hx_dlms.c", + "protocol/proto_645.c", + "protocol/proto_1662.c", + "protocol/proto_qsxj.c", + "protocol/proto_spg.c", + "protocol/proto_dlms.c", + "protocol/proto_acm.c", + "protocol/proto_3761.c", + "protocol/proto_188.c", + "protocol/tools/proto_crc16.c", + "sta/iot_sg_sta_ext_ec.c", + # "sta/iot_sg_sta_ext_sm_done_evt.c", + "sta/iot_sg_sta.c", + # "sta/iot_sg_sta_drv.c", + "sta/iot_sg_sta_ext_js.c", + "sta/iot_sg_sta_gw_v28.c", + "sta/iot_sg_sta_ext.c", + "sta/iot_sg_sta_tsfm.c", + "sta/iot_sg_sta_zc.c", + "sta/iot_sg_sta_ext_x4.c", + "sta/iot_sg_sta_nw.c", + "sta/iot_sg_sta_ext_upgrade.c", + "sta/iot_sg_sta_flash.c", + "sta/iot_sg_ext_sta.c", + "sta/iot_sg_sta_ext_nli.c", + "sta/iot_sg_sta_topo.c", + "sta/iot_sg_sta_ext_nw.c", + "sta/iot_sg_sta_ext_mf.c", + "sta/iot_sg_sta_ext_fj.c", + "sta/iot_sg_sta_upgrade.c", + "sta/iot_sg_sta_gw.c", + # "sta/iot_sg_sta_ext_pm_score.c", + # "sta/iot_sg_sta_ext_sta_score.c", + "sta/iot_sg_sta_ext_ai.c", + "sta/iot_sg_sta_ext_gw.c", + "sta/iot_sg_sta_ext_lr.c", + "sta/iot_sg_sta_ext_comm.c", + "sta/iot_sg_sta_conn_less.c", + "sta/iot_sg_sta_ext_tm.c", + "sta/iot_sg_sta_cfg_flash.c", + ] + include_dirs = [ + "//app/smart_grid/inc", + "//app/smart_grid/inc/internal", + "//app/smart_grid/inc/export", + "//export/inc/swc_lib", + ] +} diff --git a/app/sniffer/BUILD.gn b/app/sniffer/BUILD.gn new file mode 100644 index 0000000..6740cdb --- /dev/null +++ b/app/sniffer/BUILD.gn @@ -0,0 +1,24 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "src/iot_ckb_sniffer.c", + "src/iot_sniffer.c", + ] + include_dirs = [ + "//app/sniffer/inc", + ] +} diff --git a/build/BUILD.gn b/build/BUILD.gn index cc3f948..e15ee10 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -3,11 +3,40 @@ # found in the LICENSE file. config("compiler_defaults") { - if (current_os == "linux") { + if (board_toolchain == "gcc") { cflags = [ "-fPIC", "-pthread", ] + } else if (board_toolchain == "riscv-gcc"){ + cflags = [ + "-mabi=ilp32f", + "-march=rv32imafc", + "-falign-functions=2", + "-msave-restore", + "-fno-optimize-strlen", + "-freorder-blocks-algorithm=simple", + "-fno-schedule-insns", + "-fno-inline-small-functions", + "-mtune=size", + "-mno-small-data-limit=0", + "-fno-aggressive-loop-optimizations", + "-Wpointer-arith", + "-ffunction-sections", + "-fdata-sections", + "-fno-exceptions", + "-fno-short-enums", + "-D__LITEOS__M", + "-nostartfiles", + "-mstrict-align", + "-Wno-error=unused-function", + "-Wno-error=unused-but-set-variable", + "-ffast-math", + ] + cflags_cc = cflags + ldflags = cflags + asmflags = cflags + } } @@ -19,3 +48,5 @@ config("executable_ldconfig") { ] } } + + diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn index 25ff84c..72d86f6 100755 --- a/build/BUILDCONFIG.gn +++ b/build/BUILDCONFIG.gn @@ -10,7 +10,7 @@ if (!defined(board_toolchain)){ - board_toolchain="gcc" + board_toolchain="riscv-gcc" } if (board_toolchain=="riscv-gcc"){ diff --git a/build/buildcfg.gni b/build/buildcfg.gni new file mode 100644 index 0000000..4c335e5 --- /dev/null +++ b/build/buildcfg.gni @@ -0,0 +1,110 @@ + + +import("//build/config.gni") + + +template("kernel_module") { + build_gn = rebase_path("BUILD.gn") + # 如果只存在一个kernel_module,则auto_config=true + cmd = "grep -c '^\s*\(kernel_module\|hdf_driver\)\s*(\s*\S*\s*)\s*{\s*\$' $build_gn" + modules_count = exec_script("//build/run_shell_cmd.py", [ cmd ], "value") + if (modules_count == 1) { + auto_config = true + } + + # 如果不存在config("public")或者module_group,则创建config("public") + cmd = "if grep -q '^\s*\(config\s*(\s*\"public\"\s*)\|module_group\s*(\s*\"\S*\"\s*)\)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" + has_public_config = + exec_script("//build/run_shell_cmd.py", [ cmd ], "value") + if (!has_public_config && defined(auto_config)) { + config("public") { + configs = [] + } + } + + # 如果不存在module_group或group,则建立group + current_dir_name = get_path_info(rebase_path("."), "file") + if (target_name != current_dir_name) { + cmd = "if grep -q '^\s*\(module_group\|group\)\s*(\s*\"$current_dir_name\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" + has_current_dir_group = + exec_script("//build/run_shell_cmd.py", [ cmd ], "value") + if (!has_current_dir_group && defined(auto_config)) { + module_name = target_name + group(current_dir_name) { + public_deps = [ ":$module_name" ] + } + } + } + + if (defined(invoker.module_switch) && !invoker.module_switch) { + group(target_name) { + not_needed(invoker, "*") + } + } else { + source_set(target_name) { + public_configs = [] + forward_variables_from(invoker, "*", [ "configs" ]) + configs += invoker.configs + if (has_public_config) { + included_public_config = false + foreach(cfg, public_configs) { + what = "label_no_toolchain" + if (get_label_info(cfg, what) == get_label_info(":public", what)) { + included_public_config = true + } + } + if (!included_public_config) { + public_configs += [ ":public" ] + } + } + } + } + not_needed([ "auto_config" ]) +} + + + +template("config") { + config(target_name) { + # 如果定义了module_switch 并且 module_switch为false 并且 配置名称为 "public" + if (defined(invoker.module_switch) && !invoker.module_switch && + target_name == "public") { + # 忽略调用者的所有变量,定义任意变量不会导致错误 + not_needed(invoker, "*") + # 将调用者的 configs 变量复制到当前 + forward_variables_from(invoker, [ "configs" ]) + } else { + forward_variables_from(invoker, "*") + } + } +} + +template("module_group") { + assert(defined(invoker.modules), "modules are must") + group(target_name) { + deps = [] + foreach(m, invoker.modules) { + deps += [ m ] + } + if (defined(invoker.deps)) { + deps += invoker.deps + } + } + config("public") { + configs = [] + foreach(m, invoker.modules) { + configs += [ "$m:public" ] + } + if (defined(invoker.configs)) { + configs += invoker.configs + } + } +} + +# 使用这个模板时的默认配置 +set_defaults("kernel_module"){ + configs = [ + ] +} + + diff --git a/build/config.gn b/build/config.gn deleted file mode 100644 index ae243ad..0000000 --- a/build/config.gn +++ /dev/null @@ -1,17 +0,0 @@ - - -if (target_cpu == ""){ - target_cpu = "x64" -} -if (target_os == ""){ - target_os = "linux" -} -if (current_cpu == ""){ - current_cpu = target_cpu -} -if (current_os == ""){ - current_os = target_os -} - -set_default_toolchain(":gcc") - diff --git a/build/config.gni b/build/config.gni new file mode 100644 index 0000000..22864ae --- /dev/null +++ b/build/config.gni @@ -0,0 +1,33 @@ +fastboot_mode="" +flash_size="4" +psram_enable="1" +psram_size="8" +layout_index="8" +HW_CHIP_ID="HZ" +PROTO_TYPE="p12087" +rf_enable="1" +dual_enable="1" +build_amp_type="0" +sec_cpu_enable="1" +cco="1" +os_type="freertos" +new_type_cco="" +soft_float_enable="" +smart_cco_sta="" +ckb="" +gdb_debug_enable="" +disable_print="0" +hw_platform_ver="2" +gcc="riscv" +target="kunlun3" +ftm_build="0" +opt_build="1" +flash_build="1" +cpu1_build="0" +mpu_enable="0" +release_build="0" +product_line="PLC" +PLATFORM="CHIP" +APP="0" +FLASH_SIZE="4" +kl_ld_script="//startup/ldscripts/riscv3/link_psram_8m_cco_plc_only.ld" diff --git a/build/run_shell_cmd.py b/build/run_shell_cmd.py new file mode 100755 index 0000000..adcfed5 --- /dev/null +++ b/build/run_shell_cmd.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2020 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import subprocess +import sys + + +def main(): + return subprocess.Popen(' '.join(sys.argv[1:]), shell=True).wait() + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/cli/BUILD.gn b/cli/BUILD.gn new file mode 100644 index 0000000..d6f8fb5 --- /dev/null +++ b/cli/BUILD.gn @@ -0,0 +1,63 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "cli/iot_cli.c", + "communicator/communicator.c", + "communicator/iot_cli_tx_rx.c", + "communicator/cli_lwip_api.c", + "communicator/plc/iot_cli_bt_communicator.c", + "communicator/plc/iot_cli_plc_tx_rx.c", + "host_interface/iot_cli_flash_log.c", + "host_interface/iot_cli_dbg_log.c", + "host_interface/iot_cli_plc_mgr_alive.c", + "host_interface/iot_cli_ul_buf.c", + "host_interface/iot_cli_msg_entry.c", + "host_interface/iot_cli_basic_operation.c", + "host_interface/iot_cli_host_interface.c", + "host_interface/iot_cli_ram_operation.c", + "host_interface/iot_cli_oem.c", + "host_interface/iot_cli_host_pib.c", + "host_interface/plc/iot_cli_plc_nw.c", + "host_interface/plc/iot_cli_module_msg_entry.c", + "host_interface/plc/iot_cli_cco_upgrade.c", + "host_interface/plc/iot_cli_discovery.c", + "host_interface/plc/iot_cli_sg.c", + "host_interface/plc/iot_cli_plc_function.c", + "host_interface/plc/iot_cli_ada_dump.c", + "host_interface/plc/iot_cli_host_rate_test.c", + "host_interface/plc/iot_cli_ping.c", + "host_interface/plc/iot_cli_set_info.c", + "host_interface/plc/iot_cli_ckb.c", + "host_interface/plc/iot_cli_sta_upgrade.c", + "host_interface/plc/iot_cli_plc_module.c", + "host_interface/plc/iot_cli_mac_test.c", + "host_interface/plc/iot_cli_host_upgrade.c", + "host_interface/plc/iot_cli_hw_ver.c", + "host_interface/plc/iot_cli_tput.c", + "host_interface/plc/iot_cli_ckq.c", + ] + include_dirs = [ + "//cli/cli/inc", + "//cli/communicator", + "//cli/communicator/plc", + "//inc/host_interface", + "//inc/host_interface/plc", + "//app/tput", + "//import/lwip/lwip/src/include", + "//import/lwip/ports/include", + ] +} diff --git a/common/BUILD.gn b/common/BUILD.gn new file mode 100644 index 0000000..c9c8331 --- /dev/null +++ b/common/BUILD.gn @@ -0,0 +1,68 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "app/src/iot_app.c", + "compiler/gcc/src/cpl_utils.c", + "io_lib/src/iot_printf.c", + "io_lib/src/iot_string.c", + "io_lib/src/iot_mem.c", + "io_lib/src/iot_strformat.c", + "io_lib/src/iot_sprintf.c", + "io_lib/src/iot_snprintf.c", + "os_shim/freertos/src/os_mem.c", + "os_shim/freertos/src/os_malloc.c", + "os_shim/freertos/src/os_lock.c", + "os_shim/freertos/src/os_event.c", + "os_shim/freertos/src/os_timer.c", + "os_shim/freertos/src/os_utils.c", + "os_shim/freertos/src/os_task.c", + "share_task/iot_share_task.c", + "socket/iot_socket_api.c", + "pkt/iot_pkt.c", + "utils/iot_mem_pool.c", + "utils/iot_frame_parse.c", + "utils/iot_queue.c", + # "utils/iot_version.c", + "utils/iot_crc.c", + "utils/iot_utils.c", + "utils/iot_bitmap.c", + "utils/iot_meter_addr_hash_table.c", + "utils/iot_sha1.c", + "utils/iot_ntoh.c", + "utils/iot_bitops.c", + "utils/iot_ringbuf.c", + "utils/iot_task.c", + "utils/iot_addr_hash_table.c", + # "utils/iot_hook.c", + "lzma/decomp.c", + "lzma/7zAlloc.c", + "lzma/LzmaTools.c", + "lzma/LzmaDec.c", + "dbglog/iot_dbglog.c", + "dbglog/plc/iot_plc_dbglog_module_entry.c", + "ipc/itc/src/iot_ipc.c", + "plc_lib/src/iot_plc_api.c", + "plc_lib/src/iot_plc_api_cco.c", + "plc_lib/src/iot_plc_api_sta.c", + "plc_lib/src/iot_plc_lib.c", + ] + include_dirs = [ + "//import/mbedtls/include", + "//common/lzma", + "//common/plc_lib/inc", + ] +} diff --git a/driver/BUILD.gn b/driver/BUILD.gn new file mode 100644 index 0000000..c526f22 --- /dev/null +++ b/driver/BUILD.gn @@ -0,0 +1,160 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + # "src/hal/iot_bus.c", + "src/hal/afft.c", + "src/hal/vfs_uart.c", + "src/hal/iot_dma_sw.c", + "src/hal/iot_busmon.c", + "src/hal/nand_flash.c", + "src/hal/dbg_msg_stash.c", + "src/hal/mtd_part.c", + "src/hal/iot_uart_h.c", + "src/hal/system.c", + "src/hal/iot_gpio.c", + "src/hal/iot_eth.c", + "src/hal/iot_crypto_async.c", + "src/hal/led.c", + "src/hal/iot_spi.c", + "src/hal/iot_plc_pm_cus.c", + "src/hal/iot_plc_led_cus.c", + "src/hal/energe_meter.c", + "src/hal/math_matrix.c", + "src/hal/board_info.c", + "src/hal/rtc.c", + "src/hal/osif_dma_uart.c", + "src/hal/i2c.c", + "src/hal/iot_crypto_share.c", + "src/hal/iot_spinlock.c", + "src/hal/i2s.c", + "src/hal/mtd.c", + "src/hal/iot_dma_hw.c", + "src/hal/usb_dev.c", + "src/hal/nor_flash.c", + "src/hal/iot_plc_led.c", + "src/hal/iot_pwm.c", + "src/hal/iot_crypto_mbedtls_lib.c", + "src/hal/iot_efuse.c", + "src/hal/irq.c", + "src/hal/mailbox.c", + "src/hal/iot_crypto.c", + "src/hal/iot_plc_pm.c", + "src/hal/iot_gp_timer.c", + "src/hal/diag.c", + "src/hal/upgrade.c", + "src/hal/iot_plc_hw_tsfm.c", + "src/hal/sram.c", + "src/hal/sd_card.c", + "src/hal/clock.c", + "src/hal/flash.c", + "src/hal/dbg_msg_pop.c", + "src/hal/iot_crypto_internal.c", + "src/hal/iot_i2c_slave.c", + "src/hal/spi_flash.c", + "src/hal/iot_wdg.c", + "src/hal/iot_crypto_lock.c", + "src/hal/debug_uart.c", + "src/hal/dma_i2s.c", + "src/hal/osif_uart.c", + "src/hal/adc.c", + "src/hal/power_mgmt.c", + "src/hal/iot_mic_array.c", + "src/hal/iot_flash_layout.c", + "src/hal/iot_plc_hw_topo.c", + "extern/bluetooth/src/iot_bt_ext_upgrade_img.c", + "extern/bluetooth/src/iot_bt_ext_upgrade.c", + "extern/bluetooth/src/iot_bt_ext_upgrade_img_mgr.c", + "extern/bluetooth/src/iot_bt_ext_dev_mgmt.c", + "extern/bluetooth/src/iot_bt_ext.c", + "extern/em/src/iot_em_ext.c", + "extern/em/src/iot_em_ext_calibration.c", + "extern/em/src/iot_em_ext_chip_att.c", + ] + if (target == "kunlun3") { + sources += [ + "src/hw3/dma_sw.c", + "src/hw3/intc.c", + "src/hw3/cpu.c", + "src/hw3/i2c_hw.c", + "src/hw3/pmu.c", + "src/hw3/gpio_mtx.c", + "src/hw3/smc.c", + "src/hw3/system_hw.c", + "src/hw3/pmp.c", + "src/hw3/em_hw.c", + "src/hw3/efuse.c", + "src/hw3/ndfc.c", + "src/hw3/ahb_busmon.c", + "src/hw3/board_info_hw.c", + "src/hw3/pwm.c", + "src/hw3/topo_adc_adp.c", + "src/hw3/ledc.c", + "src/hw3/gp_timer.c", + "src/hw3/pmp_hw.c", + "src/hw3/ana.c", + "src/hw3/i2c_slv_hw.c", + "src/hw3/afft_hw.c", + "src/hw3/gpio_hw.c", + "src/hw3/mtx_hw.c", + "src/hw3/dwc_eth.c", + "src/hw3/dma_hw.c", + "src/hw3/rtc_hw.c", + "src/hw3/rom_patch_hw.c", + "src/hw3/simd.c", + "src/hw3/sadc_pwm.c", + "src/hw3/sha512_hw.c", + "src/hw3/sec_glb.c", + "src/hw3/dw_apb_ssi.c", + "src/hw3/mailbox_hw.c", + "src/hw3/snapshot.c", + "src/hw3/sadc.c", + "src/hw3/uart_e.c", + "src/hw3/apb.c", + "src/hw3/clk.c", + "src/hw3/ahb.c", + "src/hw3/ada.c", + "src/hw3/ddrc.c", + "src/hw3/mmon.c", + "src/hw3/wdg.c", + "src/hw3/mon_hw.c", + "src/hw3/i2s_hw.c", + "src/hw3/dma.c", + "src/hw3/sfc.c", + "src/hw3/power_mgmt_hw.c", + "src/hw3/dma_uart_hw.c", + "src/hw3/pll_cal.c", + "src/hw3/sha256_hw.c", + "src/hw3/sec_sys.c", + "src/hw3/dev_spinlock.c", + "src/hw3/dbg_msg_ring_hw.c", + "src/hw3/mbedtls/aes_patch_alt.c", + "src/hw3/mbedtls/bignum_patch_alt.c", + "src/hw3/mbedtls/hardware_entropy_patch_alt.c", + "src/hw3/mbedtls/sha256_patch_alt.c", + "src/hw3/mbedtls/sha512_patch_alt.c", + ] + } + include_dirs = [ + "//rom/riscv3/romlib/crypto/iotelic/inc", + "//rom/riscv3/romlib/crypto/iotelic/inc/mbedtls", + "//import/mbedtls/include", + "//import/mbedtls/include/psa", + "//driver/inc/mbedtls", + "//driver/extern/bluetooth/inc", + "//driver/extern/em/inc", + ] +} diff --git a/ftm/BUILD.gn b/ftm/BUILD.gn new file mode 100644 index 0000000..fdafa4f --- /dev/null +++ b/ftm/BUILD.gn @@ -0,0 +1,103 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "src/iot_ftm_case.c", + "src/iot_ftm_cmd.c", + "src/iot_ftm.c", + "mp/iot_pt_func.c", + "mp/zero_cross_detec.c", + "mp/iot_pt_rf_func.c", + "mp/voltage_detec.c", + "mp/mp_mode.c", + "mp/cli/cli_rf_ic_tool.c", + "mp/cli/cli_plc_ic_tool.c", + "mp/cli/cli_ic_tool.c", + "cus/iot_ftm_cus_cmd.c", + "../bb_cpu/bb/bb_rf_tone_tbl.c", + "../bb_cpu/bb/bb_rf_hw_tbl.c", + "../bb_cpu/common/rf_spi_api.c", + "../bb_cpu/common/bb_cpu_utils.c", + "../bb_cpu/common/bb_cpu_timer.c", + ] + include_dirs = [ + "//ftm/inc", + "//ftm/mp/cli", + "//ftm/mp/pt_board/inc", + "//bb_cpu/inc", + "//dtest/ate_test", + "//plc/inc", + "//plc/common/inc", + "//plc/halmac/inc", + "//plc/halmac/test/inc", + "//plc/halphy/inc", + "//plc/halphy/test/inc", + ] + if (target == "kunlun3") { + sources += [ + # "../bb_cpu/bb/v1/bb_rf_cfg.c", + # "../bb_cpu/bb/v1/bb_init.c", + "../dtest/dtest3/mac_rx_test/hal/hal_rx.c", + "../dtest/dtest3/mac_tx_test/hw3/hw_tx.c", + "../dtest/dtest3/mac_tx_test/hw3/tx_entry.c", + "../dtest/dtest3/mac_rx_test/hw3/rx_entry.c", + "../dtest/dtest3/mac_rx_test/hw3/hw_rx.c", + "../dtest/dtest3/mac_phy/rf_mac/rf_mac_rx.c", + "../dtest/dtest3/mac_phy/rf_mac/mac_ntb_wrap_test.c", + "../dtest/dtest3/mac_phy/rf_mac/rf_mac_tx.c", + "../dtest/dtest3/mac_phy/rf_mac/mac_zc_dtest.c", + "../dtest/dtest3/mac_phy/rf_mac/rf_bb_isr_test.c", + "../dtest/dtest3/mac_phy/rf_mac/rf_mac_isr_test.c", + "../dtest/dtest3/mac_phy/rf_mac/rf_mac_main.c", + "../dtest/dtest3/mac_phy/rf_mac/rf_bb_main.c", + "../dtest/dtest3/mac_phy/rf_phy/rf_phy_rx.c", + "../dtest/dtest3/mac_phy/rf_phy/rf_phy_tx.c", + "../dtest/dtest3/mac_phy/common/rf_mac_common.c", + ] + if (ftm_build == "1") { + sources += [ + "../dtest/dtest3/mac_phy/double_cpu/kl3_core0/kl3_core0_test.c", + ] + } + include_dirs += [ + "//plc/halmac/hw3/plc_inc/desc", + "//plc/halmac/hw3/plc_inc", + "//plc/halmac/hw3/rf_inc/desc", + "//plc/halmac/hw3/rf_inc", + "//plc/halmac/hw3/inc", + "//plc/halmac/hw3/inc/desc", + "//plc/halmac/hw_common_v1/inc", + "//plc/halphy/hw_common_v1/inc", + "//plc/halphy/hw3/plc/inc", + "//plc/halphy/hw3/rf/inc", + "//plc/halphy/hw3/plc/inc", + "//plc/halphy/hw3/rf/inc", + "//plc/halphy/hw3/inc", + "//plc/halphy/test/hw3/inc", + "//startup/riscv3/inc", + "//dtest/dtest3/mac_rx_test/hw3/inc", + "//dtest/dtest3/mac_tx_test/hw3/inc", + "//dtest/dtest3/mac_rx_test/hal/inc", + "//dtest/dtest3/mac_rx_test/inc", + "//dtest/dtest3/mac_tx_test/inc", + "//dtest/dtest3/mac_phy/inc", + "//dtest/dtest3/mac_phy/common", + "//dtest/dtest3/mac_phy/rf_mac/inc", + "//dtest/dtest3/mac_phy/rf_phy/inc", + "//dtest/dtest3/mac_phy/double_cpu/kl3_core0", + ] + } +} diff --git a/import/BUILD.gn b/import/BUILD.gn new file mode 100644 index 0000000..61e5e99 --- /dev/null +++ b/import/BUILD.gn @@ -0,0 +1,49 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "wq_vtb/src/bit.c", + "wq_vtb/src/conv_decode.c", + "wq_vtb/src/conv_encode.c", + "wq_vtb/src/convolutional.c", + "wq_vtb/src/crc_check.c", + "wq_vtb/src/crc_generator.c", + "wq_vtb/src/deinterleaver.c", + "wq_vtb/src/descrambler.c", + "wq_vtb/src/disturbance_detection.c", + "wq_vtb/src/error_buffer.c", + "wq_vtb/src/fec_shim.c", + "wq_vtb/src/history_buffer.c", + "wq_vtb/src/interleaver.c", + "wq_vtb/src/lookup.c", + "wq_vtb/src/metric.c", + "wq_vtb/src/polynomial.c", + "wq_vtb/src/preamble_generator.c", + "wq_vtb/src/reed-solomon.c", + "wq_vtb/src/rs_decode.c", + "wq_vtb/src/rs_encode.c", + "wq_vtb/src/scramble.c", + "wq_vtb/src/syncronizaiton.c", + "wq_vtb/src/wq_vtb_bit_rec.c", + "wq_vtb/src/wq_vtb_data_to_bit.c", + "wq_vtb/src/wq_vtb_topo_rec.c", + ] + + include_dirs = [ + "//import/wq_vtb/inc", + "//import/wq_vtb/ext_inc", + ] +} diff --git a/os/BUILD.gn b/os/BUILD.gn new file mode 100644 index 0000000..f665b0f --- /dev/null +++ b/os/BUILD.gn @@ -0,0 +1,33 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "freertos/src/croutine.c", + "freertos/src/event_groups.c", + "freertos/src/hook.c", + "freertos/src/list.c", + "freertos/src/queue.c", + "freertos/src/tasks.c", + "freertos/src/timers.c", + "freertos/src/version.c", + "freertos/src/portable/RISCV/port.c", + "freertos/src/portable/RISCV/portasm.S", + "freertos/src/portable/MemMang/heap_5/heap_5.c" + ] + include_dirs = [ + "freertos/src/include", "freertos/src/portable/RISCV", "//startup/riscv/inc" + ] +} diff --git a/pib/BUILD.gn b/pib/BUILD.gn new file mode 100644 index 0000000..a933aa7 --- /dev/null +++ b/pib/BUILD.gn @@ -0,0 +1,25 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "src/iot_cal_data.c", + "src/iot_oem.c", + "src/iot_pib.c", + ] + include_dirs = [ + "//inc/pib", + ] +} diff --git a/plc/BUILD.gn b/plc/BUILD.gn new file mode 100644 index 0000000..87d17d3 --- /dev/null +++ b/plc/BUILD.gn @@ -0,0 +1,293 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "common/src/plc_mpdu_header.c", + "common/src/plc_rf_scan_tbl.c", + "common/src/plc_scan_tbl.c", + "cvg/bwm/src/cvg_bwm.c", + "cvg/bwm/src/cvg_bwm_cco.c", + "cvg/bwm/src/cvg_bwm_rf.c", + "cvg/common/src/cvg.c", + "cvg/common/src/cvg_app.c", + "cvg/common/src/cvg_app_sg.c", + "cvg/common/src/cvg_app_spg.c", + "cvg/common/src/cvg_beacon_sg.c", + "cvg/common/src/cvg_beacon_spg.c", + "cvg/common/src/cvg_task.c", + "cvg/common/src/cvg_zc.c", + # "cvg/min_clct/src/cvg_min_clct.c", + # "cvg/min_clct/src/cvg_min_clct_cache.c", + # "cvg/min_clct/src/cvg_min_clct_cco.c", + # "cvg/min_clct/src/cvg_min_clct_sta.c", + # "cvg/min_clct/src/cvg_min_clct_sta_spg.c", + "cvg/nwm/src/cvg_nwm.c", + "cvg/nwm/src/cvg_nwm_cco.c", + "cvg/nwm/src/cvg_nwm_cco_app_filter.c", + "cvg/nwm/src/cvg_nwm_cco_ctrl_proto.c", + "cvg/nwm/src/cvg_nwm_cco_rf.c", + "cvg/nwm/src/cvg_nwm_cco_sg.c", + "cvg/nwm/src/cvg_nwm_cco_spg.c", + "cvg/nwm/src/cvg_nwm_cco_zc.c", + "cvg/nwm/src/cvg_nwm_ctrl_proto.c", + "cvg/nwm/src/cvg_nwm_ctrl_proto_sg.c", + "cvg/nwm/src/cvg_nwm_ctrl_proto_spg.c", + "cvg/nwm/src/cvg_nwm_sg.c", + "cvg/nwm/src/cvg_nwm_spg.c", + "cvg/nwm/src/cvg_nwm_sta.c", + "cvg/nwm/src/cvg_nwm_sta_app_filter.c", + "cvg/nwm/src/cvg_nwm_sta_ctrl_proto.c", + "cvg/nwm/src/cvg_nwm_sta_rf.c", + "cvg/nwm/src/cvg_nwm_sta_rf_sg.c", + "cvg/nwm/src/cvg_nwm_sta_rf_spg.c", + "cvg/nwm/src/cvg_nwm_sta_sg.c", + "cvg/nwm/src/cvg_nwm_sta_spg.c", + "cvg/nwm/src/cvg_nwm_sta_zc.c", + "cvg/prm/src/cvg_prm.c", + # "cvg/prm/src/cvg_prm_feature.c", + "cvg/prm/src/cvg_prm_matm.c", + "cvg/rt/src/cvg_rt.c", + "cvg/rt/src/cvg_rt_cco.c", + "cvg/rt/src/cvg_rt_cco_rf.c", + "cvg/rt/src/cvg_rt_rf.c", + "cvg/rt/src/cvg_rt_rf_sg.c", + "cvg/rt/src/cvg_rt_rf_spg.c", + "cvg/rt/src/cvg_rt_sg.c", + "cvg/rt/src/cvg_rt_spg.c", + "cvg/rt/src/cvg_rt_sta.c", + "cvg/rt/src/cvg_rt_sta_rf.c", + "cvg/rt/src/cvg_rt_sta_sg.c", + "cvg/rt/src/cvg_rt_sta_spg.c", + "cvg/security/src/cvg_sec_auth.c", + "cvg/security/src/cvg_sec_auth_ca.c", + "cvg/security/src/cvg_sec_auth_ca_cco.c", + "cvg/security/src/cvg_sec_auth_ca_cco_sg.c", + "cvg/security/src/cvg_sec_auth_ca_sta.c", + "cvg/security/src/cvg_sec_auth_ca_sta_sg.c", + "cvg/security/src/cvg_sec_auth_dak.c", + "cvg/security/src/cvg_sec_auth_dak_cco.c", + "cvg/security/src/cvg_sec_auth_dak_sta.c", + "cvg/security/src/cvg_sec_sign_cache.c", + "cvg/security/src/cvg_sec_wl.c", + "cvg/security/src/cvg_security.c", + "halmac/avln/mac_avln.c", + "halmac/beacon/beacon_frame.c", + "halmac/beacon/rf_beacon_frame.c", + "halmac/channel/mac_channel.c", + "halmac/channel_tools/mac_channel_tools.c", + "halmac/channel_tools/mac_mm_sniffer.c", + "halmac/crc/mac_crc.c", + "halmac/crypto/mac_crypto.c", + "halmac/data/mac_data.c", + "halmac/data/mac_rf_data.c", + "halmac/dbg_pkt_mode/mac_dbg_pkt_mode.c", + "halmac/desc/mac_desc_eng.c", + "halmac/hplc_ext/mac_hplc_ext.c", + "halmac/htbus/beacon_frame_htbus.c", + "halmac/hw_desc/hw_rf_rx_mpdu.c", + "halmac/hw_desc/hw_rf_tx_mpdu.c", + "halmac/hw_desc/hw_rx_mpdu.c", + "halmac/hw_desc/hw_tx_mpdu.c", + # "halmac/hw_desc/mac_trx_desc_cmn.c", + # "halmac/hw_desc/mac_rx_buf_ring.c", + "halmac/init/mac_init.c", + "halmac/init/plc_init.c", + "halmac/key/mac_key.c", + "halmac/mac_cfg/mac_cfg.c", + "halmac/mac_check_spur/mac_che_spur_cco.c", + "halmac/mac_check_spur/mac_che_spur_sta.c", + "halmac/mac_check_spur/mac_check_spur.c", + "halmac/mac_hw_tsfm/mac_hw_tsfm.c", + "halmac/msdu/mac_msdu.c", + "halmac/msdu/mac_rf_msdu.c", + "halmac/multi_nid_sync/multi_nid_sync.c", + "halmac/nn_cco/nn_cco.c", + "halmac/pdev/mac_pdev.c", + "halmac/pdev/mac_rf_pdev.c", + "halmac/peer/mac_peer.c", + "halmac/pm/mac_pm.c", + "halmac/ppm_scan/mac_ppm_scan.c", + "halmac/ppm_scan/mac_rf_scan.c", + "halmac/rate/rate_control.c", + "halmac/rate/rf_rate_control.c", + "halmac/rf/mac_rf.c", + "halmac/rx/rx_pb_reorder.c", + "halmac/sched/mac_rf_sched.c", + "halmac/sched/mac_sched.c", + "halmac/status/mac_status.c", + "halmac/stream/mac_stream.c", + "halmac/sw_queue/mac_hwq_mgr.c", + "halmac/sw_queue/mac_rf_hwq_mgr.c", + "halmac/sw_sched/sw_sched.c", + "halmac/task/mac_dsr.c", + "halmac/task/mac_msg.c", + "halmac/task/mac_task.c", + "halmac/tx_power/mac_rf_tx_power.c", + "halmac/tx_power/mac_tx_power.c", + "halmac/utils/mac_utils.c", + "halmac/vdev/mac_rf_vdev.c", + "halmac/vdev/mac_vdev.c", + "halmac/zc/mac_zc_cmn.c", + "halmac/zc/zc_2/mac_zc.c", + "halmac/test/mac_cert_test.c", + "halmac/test/mac_rf_cert_test.c", + "halmac/test/rf_tx_test_lib.c", + "halmac/test/mac_cert_sec_lib.c", + "halmac/test/tx_test_lib.c", + # "halmac/rf_ext/mac_rf_ext.c", + "halphy/multi_ppm/phy_multi_ppm.c", + "halphy/phy_api.c", + "halphy/phy_bbai_calu.c", + "halphy/phy_bbai_calu_2.c", + "halphy/phy_cfg.c", + "halphy/phy_chn.c", + "halphy/phy_data.c", + "halphy/phy_data_ckb.c", + "halphy/phy_init.c", + "halphy/phy_math_tb.c", + "halphy/phy_overstress.c", + "halphy/phy_perf.c", + "halphy/phy_rf_chn.c", + "halphy/phy_rf_init.c", + "halphy/phy_txrx_pwr.c", + "halphy/rf_tone_map.c", + "halphy/tone_map.c", + "halphy/tone_mask.c", + "halphy/test/phy_test_api.c", + "htbus/src/cco/htbus_cco.c", + "htbus/src/htbus.c", + "htbus/src/htbus_test.c", + "htbus/src/sta/htbus_sta.c", + ] + if (target == "kunlun3") { + sources += [ + "halmac/hw3/common/mac_rf_common_hw.c", + "halmac/hw3/common/mac_rf_timer.c", + "halmac/hw3/isr/mac_isr.c", + "halmac/hw3/isr/mac_rf_isr.c", + "halmac/hw3/key/mac_key_hw.c", + "halmac/hw3/misc/mac_hw_misc.c", + "halmac/hw3/rawdata/mac_rawdata_hw.c", + "halmac/hw3/reset/mac_reset.c", + "halmac/hw3/rx/mac_rf_rx_buf_ring.c", + "halmac/hw3/rx/mac_rf_rx_hw.c", + # "halmac/hw3/rx/mac_rx_buf_ring_hw.c", + "halmac/hw3/rx/mac_rx_hw.c", + "halmac/hw3/sched/mac_rf_sched_hw.c", + "halmac/hw3/sched/mac_sched_hw.c", + "halmac/hw3/tx/mac_rf_tx_hw.c", + "halmac/hw3/tx/mac_rf_txq_hw.c", + "halmac/hw3/tx/mac_tx_hw.c", + "halmac/hw3/tx/mac_txq_hw.c", + "halmac/hw3/zc/mac_zc_hw.c", + # "halmac/hw_common_v1/src/mac_status_v.c", + # "halmac/hw_common_v1/src/mac_check_spur_v.c", + # "halphy/hw_common_v1/src/phy_hw_cmn_v.c", + # "halphy/hw_common_v1/src/phy_perf_v.c", + # "halphy/hw_common_v1/src/phy_api_v.c", + # "halphy/hw_common_v1/src/phy_tools_v.c", + "halphy/hw3/plc/chip/phy_ana_plf.c", + "halphy/hw3/plc/hw_phy_perf.c", + "halphy/hw3/plc/hw_phy_txrx_pwr.c", + "halphy/hw3/plc/phy_ada_dump.c", + "halphy/hw3/plc/phy_agc.c", + "halphy/hw3/plc/phy_ana.c", + "halphy/hw3/plc/phy_bb.c", + "halphy/hw3/plc/phy_cal.c", + "halphy/hw3/plc/phy_dump.c", + "halphy/hw3/plc/phy_gain_table_cal.c", + "halphy/hw3/plc/phy_gepde_gpio.c", + "halphy/hw3/plc/phy_isr.c", + "halphy/hw3/plc/phy_mix.c", + "halphy/hw3/plc/phy_nf.c", + "halphy/hw3/plc/phy_phase.c", + "halphy/hw3/plc/phy_pm.c", + "halphy/hw3/plc/phy_ppm.c", + "halphy/hw3/plc/phy_status.c", + "halphy/hw3/plc/phy_temperature.c", + "halphy/hw3/plc/phy_tmap.c", + ] + } + include_dirs = [ + "//", + "//cli/communicator", + "//common/os_shim/arm/inc", + "//common/os_shim/inc", + "//driver/inc", + "//export/inc/socket", + "//ftm/inc", + "//inc", + "//inc/cli", + "//inc/cli/plc", + "//inc/compiler/gcc", + "//inc/crypto", + "//inc/dbglog", + "//inc/driver", + "//inc/io_lib", + "//inc/io_lib/", + "//inc/ipc", + "//inc/os_shim", + "//inc/os_shim/", + "//inc/pib", + "//inc/pkt", + "//inc/plc_lib", + "//inc/socket", + "//inc/swc_lib", + "//inc/uart", + "//inc/utils", + "//os/freertos/src/portable/RISCV", + "//plc/common/bwm/inc", + "//plc/common/inc", + "//plc/common/plc_cli/include", + "//plc/common/plc_dbglog/include", + "//plc/cvg/bwm/inc", + "//plc/cvg/common/inc", + "//plc/cvg/min_clct/inc", + "//plc/cvg/nwm/inc", + "//plc/cvg/prm/inc", + "//plc/cvg/rt/inc", + "//plc/cvg/security/inc", + "//plc/halmac/inc", + "//plc/halmac/test/inc", + "//plc/halphy/inc", + "//plc/halphy/test/inc", + "//plc/htbus/inc", + "//plc/inc", + "//plc/inc/mme", + "//plc/os_shim/arm/inc", + "//plc/os_shim/inc", + ] + if (target == "kunlun3") { + include_dirs += [ + "//driver/src/hw3/inc", + "//plc/halmac/hw3/inc", + "//plc/halmac/hw3/inc/desc", + "//plc/halmac/hw3/inc/reg", + "//plc/halmac/hw3/plc_inc", + "//plc/halmac/hw3/plc_inc/desc", + "//plc/halmac/hw3/rf_inc", + "//plc/halmac/hw3/rf_inc/desc", + "//plc/halmac/hw_common_v1/inc", + "//plc/halphy/hw_common_v1/inc", + "//plc/halphy/hw3/inc", + "//plc/halphy/hw3/plc/chip/inc", + "//plc/halphy/hw3/plc/inc", + "//plc/halphy/hw3/rf/inc", + "//plc/halphy/test/hw3/inc", + ] + } + +} diff --git a/startup/BUILD.gn b/startup/BUILD.gn new file mode 100644 index 0000000..a6c528e --- /dev/null +++ b/startup/BUILD.gn @@ -0,0 +1,41 @@ +#Copyright(c) 2024 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. + +#This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT +#be copied by any method or incorporated into another program without +#the express written consent of Aerospace C.Power. This Information or any portion +#thereof remains the property of Aerospace C.Power. The Information contained herein +#is believed to be accurate and Aerospace C.Power assumes no responsibility or +#liability for its use in any way and conveys no license or title under +#any patent or copyright and makes no representation or warranty that this +#Information is free from patent or copyright infringement. + +import("//build/buildcfg.gni") + +module_name = "kl_sdk" + +kernel_module(module_name) { + sources = [ + "misc/main.c", + "misc/plc/plc_main.c", + ] + if (target == "kunlun3") { + sources += [ + "riscv3/src/start.S", + "riscv3/src/entry_def.S", + "riscv3/src/startup_init.c", + "riscv3/src/exception.c", + "riscv3/src/platform.c", + ] + include_dirs = [ + "//inc/ftm", + "//inc/lwip", + "//ftm/inc", + "//plc/inc/mme", + "//plc/common/inc", + "//plc/halphy/inc", + "//plc/halphy/hw3/plc/inc", + "//plc/halphy/hw_common_v1/inc", + "//plc/halmac/inc", + ] + } +}