From 83882c7ac204843be34de9df6b0c0577943a9443 Mon Sep 17 00:00:00 2001 From: andy <1414772332@qq.com> Date: Thu, 16 Jan 2025 19:52:28 +0800 Subject: [PATCH] =?UTF-8?q?build.gn=20=E5=8F=AF=E4=BB=A5=E7=BC=96=E8=AF=91?= =?UTF-8?q?=20=E9=93=BE=E6=8E=A5=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 13 +++++++++++++ ap/BUILD.gn | 2 ++ build/BUILD.gn | 1 + build/buildcfg.gni | 8 ++++++++ common/BUILD.gn | 2 ++ driver/src/hw3/clk.c | 10 ++++------ os/BUILD.gn | 4 +++- 7 files changed, 33 insertions(+), 7 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 5d2add2..f8eed29 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,6 +1,19 @@ import("//build/buildcfg.gni") + + + + + + + module_name = get_path_info(rebase_path("."), "name") + +executable("out"){ + deps=[":$module_name"] +} + + module_group(module_name) { modules = [ "ap", diff --git a/ap/BUILD.gn b/ap/BUILD.gn index 5814fa6..c2c3ca0 100644 --- a/ap/BUILD.gn +++ b/ap/BUILD.gn @@ -81,6 +81,8 @@ config("public") { "//import/wq_vtb/ext_inc", "//plc/inc", "//driver/inc", + "//os/freertos/src/include", + "//os/freertos/src/portable/RISCV", ] if (target == "kunlun3") { diff --git a/build/BUILD.gn b/build/BUILD.gn index e15ee10..d072256 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -12,6 +12,7 @@ config("compiler_defaults") { cflags = [ "-mabi=ilp32f", "-march=rv32imafc", + "-Os", "-falign-functions=2", "-msave-restore", "-fno-optimize-strlen", diff --git a/build/buildcfg.gni b/build/buildcfg.gni index 4c335e5..eb5d931 100644 --- a/build/buildcfg.gni +++ b/build/buildcfg.gni @@ -23,6 +23,7 @@ template("kernel_module") { } # 如果不存在module_group或group,则建立group + # 如果用其他名称创建module,则自动生成一个以目录名称命名的module 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" @@ -30,6 +31,7 @@ template("kernel_module") { exec_script("//build/run_shell_cmd.py", [ cmd ], "value") if (!has_current_dir_group && defined(auto_config)) { module_name = target_name + # print("auto create module $current_dir_name") group(current_dir_name) { public_deps = [ ":$module_name" ] } @@ -51,9 +53,13 @@ template("kernel_module") { what = "label_no_toolchain" if (get_label_info(cfg, what) == get_label_info(":public", what)) { included_public_config = true + print("$current_dir_name, $target_name true") + } else { + print("$current_dir_name, $target_name false") } } if (!included_public_config) { + print("include_public_config") public_configs += [ ":public" ] } } @@ -104,6 +110,8 @@ template("module_group") { # 使用这个模板时的默认配置 set_defaults("kernel_module"){ configs = [ + # 把这个目录的配置设置为公共配置 + "//ap:public" ] } diff --git a/common/BUILD.gn b/common/BUILD.gn index c9c8331..a9a633b 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -64,5 +64,7 @@ kernel_module(module_name) { "//import/mbedtls/include", "//common/lzma", "//common/plc_lib/inc", + "//import/lwip/lwip/src/include", + "//import/lwip/ports/include", ] } diff --git a/driver/src/hw3/clk.c b/driver/src/hw3/clk.c index 7b137c0..898b463 100755 --- a/driver/src/hw3/clk.c +++ b/driver/src/hw3/clk.c @@ -83,12 +83,10 @@ typedef struct _clk_div_gp_t { uint32_t g_cpu_freq = 150000000; -#define IRAM_ATTR2 __attribute__((section(".iram"))) - /* * Clock source selecte & div for each IP, refrence to clk_frq_group. */ -static clk_div_gp_t IRAM_ATTR2 clk_div_group[CLK_FRQ_GP_IDX_MAX] = +static clk_div_gp_t IRAM_ATTR clk_div_group[CLK_FRQ_GP_IDX_MAX] = { /* Core_sel APB_sel sfc_div smc_div apb_div rsv[3] */ {0, 0, 0, 0, 0, {0}}, /* disable plc */ @@ -101,7 +99,7 @@ static clk_div_gp_t IRAM_ATTR2 clk_div_group[CLK_FRQ_GP_IDX_MAX] = -static void IRAM_ATTR2 clk_system_calibration(void) +static void IRAM_ATTR clk_system_calibration(void) { if (!scratch_p_get_clk_calibration()) { ana_mdll_loopmode_set(0); @@ -113,7 +111,7 @@ static void IRAM_ATTR2 clk_system_calibration(void) ana_mdll_loopmode_set(1); } -static void IRAM_ATTR2 clk_system_set_all_xtal(void) +static void IRAM_ATTR clk_system_set_all_xtal(void) { /* APB/AHB select xtal 25M, APB div = 0. */ ahb_clk_clock_set(0, 0, 0); @@ -128,7 +126,7 @@ static void IRAM_ATTR2 clk_system_set_all_xtal(void) ahb_clk_mpll_set(0, 0); } -static void IRAM_ATTR2 clk_system_set_all_pll(uint32_t index) +static void IRAM_ATTR clk_system_set_all_pll(uint32_t index) { /* Do calibration. */ clk_system_calibration(); diff --git a/os/BUILD.gn b/os/BUILD.gn index f665b0f..577fc81 100644 --- a/os/BUILD.gn +++ b/os/BUILD.gn @@ -28,6 +28,8 @@ kernel_module(module_name) { "freertos/src/portable/MemMang/heap_5/heap_5.c" ] include_dirs = [ - "freertos/src/include", "freertos/src/portable/RISCV", "//startup/riscv/inc" + "//os/freertos/src/include", + "//os/freertos/src/portable/RISCV", + "//startup/riscv/inc", ] }