Skip to content

Commit f62334c

Browse files
committed
Merge branch 'feature/add_doc_and_trace_menuconfig' into 'main'
gmf_app_utils: Add custom board doc and stack trace records setting See merge request adf/multimedia/esp-gmf!101
2 parents 6ed7116 + 4750e15 commit f62334c

File tree

5 files changed

+91
-1
lines changed

5 files changed

+91
-1
lines changed

packages/gmf_app_utils/Kconfig.projbuild

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ menu "Unit Test"
7878
int "Critical leak for UT which use LWIP component"
7979
default 4095
8080

81+
config UNITY_HEAP_TRACE_RECORDS
82+
int "Number of heap trace records to allocate for Unity test"
83+
default 200
84+
8185
endmenu
8286

8387
endmenu

packages/gmf_app_utils/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ The `gmf_app_utils` component also provides configuration options via **menuconf
3131
- SD card initialization and mounting
3232
- Connectivity management
3333
- Wi-Fi initialization and connection
34+
- Use menuconfig to select supported board
35+
- For other board support see [Other Board Support](#other-board-support) section
3436

3537
### System Tools (`esp_gmf_app_sys.h`)
3638
Provides start/stop functionality for system resource monitoring, facilitating runtime performance tracking and resource usage monitoring. To use this feature, you need to enable `CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID` and `CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS` in menuconfig.
@@ -67,3 +69,43 @@ Provide common functions for GMF application unit tests
6769
- Call `esp_gmf_app_test_case_uses_tcpip()` in tests that require network functionality
6870
- Use test annotations like `[leaks]` or `[leaks=1024]` to control leak checking
6971
- The main function calls' esp_gmf_app_test_main() 'to create the unit test Task
72+
73+
### Other Board Support
74+
75+
Peripheral management currently uses `codec_board` as a reference implementation for fast verification. If you want to use supported peripherals on a custom board, follow these steps:
76+
77+
1. **Get `codec_board`** and put into project `components` folder
78+
79+
Can use either of following methods:
80+
81+
1.1 Build firstly to trigger auto download then copy it into project folder:
82+
```bash
83+
idf.py build
84+
mkdir -p components/codec_board
85+
cp -rf managed_components/tempotian__codec_board components/codec_board
86+
```
87+
88+
1.2 Download [codec_board](https://components.espressif.com/components/tempotian/codec_board/) from component registry and manual copy into project folder
89+
90+
2. **Add a new section** to `components/codec_board/board_cfg.txt` to describe your custom board:
91+
```
92+
Board: MY_BOARD
93+
i2c: {sda: 1, scl: 2}
94+
i2s: {mclk: 42, bclk: 40, ws: 41, dout: 39}
95+
out: {codec: ES8311, pa: 38, use_mclk: 0, pa_gain: 6}
96+
```
97+
98+
3. **Set the board type** in your application code before calling any peripheral APIs:
99+
```c
100+
#include "codec_board.h"
101+
void app_main(void)
102+
{
103+
set_codec_board_type("MY_BOARD");
104+
}
105+
```
106+
107+
4. **Rebuild to take effects**
108+
```bash
109+
idf.py fullclean
110+
idf.py -p /dev/XXXXX flash monitor
111+
```

packages/gmf_app_utils/README_CN.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ GMF 应用工具包(gmf_app_utils)是一个为方便 ESP GMF 开发应用程
3131
- SD 卡初始化和挂载
3232
- 连接管理
3333
- Wi-Fi 初始化连接
34+
- 通过 Menuconfig 选择支持的开发板
35+
- 其他开发板支持请参阅 [其他开发板支持](#其他开发板支持) 小节
3436

3537
### 系统工具(`esp_gmf_app_sys.h`
3638
提供系统资源监控功能的启动/停止,便于用户运行时性能跟踪以及资源使用情况监控,使用时需要在 menuconfig 中开启 `CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID``CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS`
@@ -67,3 +69,43 @@ GMF 应用工具包(gmf_app_utils)是一个为方便 ESP GMF 开发应用程
6769
- 使用`esp_gmf_app_test_case_uses_tcpip()`进行网络测试项资源预分配
6870
- 支持通过测试项描述如 `[leaks]``[leaks=1024]` 控制泄漏检查阈值
6971
- main 函数调用 `esp_gmf_app_test_main()` 创建单元测试线程
72+
73+
### 其他开发板支持
74+
75+
外设管理目前使用 `codec_board` 作为参考板卡实现,便于快速验证。若要在自定义开发板上使用支持的外设,请按照以下步骤操作:
76+
77+
1. **获取 `codec_board`** 并将其放入项目的 `components` 文件夹
78+
79+
可以使用以下任一方法:
80+
81+
1.1 首先构建代码以触发自动下载,然后复制到项目文件夹:
82+
```bash
83+
idf.py build
84+
mkdir -p components/codec_board
85+
cp -rf managed_components/tempotian__codec_board components/codec_board
86+
```
87+
88+
1.2 从组件注册表下载 [codec_board](https://components.espressif.com/components/tempotian/codec_board/) 并手动复制到项目文件夹
89+
90+
2. **`components/codec_board/board_cfg.txt` 中添加新的开发板配置节**,例如:
91+
```
92+
Board: MY_BOARD
93+
i2c: {sda: 1, scl: 2}
94+
i2s: {mclk: 42, bclk: 40, ws: 41, dout: 39}
95+
out: {codec: ES8311, pa: 38, use_mclk: 0, pa_gain: 6}
96+
```
97+
98+
3. **在调用任何外设 API 之前,在应用代码中设置板卡类型**
99+
```c
100+
#include "codec_board.h"
101+
void app_main(void)
102+
{
103+
set_codec_board_type("MY_BOARD");
104+
}
105+
```
106+
107+
4. **重新构建代码使修改生效**:
108+
```bash
109+
idf.py fullclean
110+
idf.py -p /dev/XXXXX flash monitor
111+
```

packages/gmf_app_utils/idf_component.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ tags:
1111

1212
dependencies:
1313
espressif/gmf_core:
14+
require: public
1415
version: "^0.7"
1516
tempotian/codec_board:
17+
require: public
1618
version: "^0.5.0"

packages/gmf_app_utils/src/esp_gmf_app_unit_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static size_t gmf_app_get_leak_level(esp_gmf_app_leak_type_t type_of_leak, esp_g
135135
#ifdef CONFIG_HEAP_TRACING
136136
static void gmf_app_setup_heap_record(void)
137137
{
138-
const size_t num_heap_records = 200;
138+
const size_t num_heap_records = CONFIG_UNITY_HEAP_TRACE_RECORDS;
139139
static heap_trace_record_t *record_buffer;
140140
if (!record_buffer) {
141141
record_buffer = heap_caps_malloc_prefer(sizeof(heap_trace_record_t) * num_heap_records, 2, MALLOC_CAP_SPIRAM, MALLOC_CAP_INTERNAL);

0 commit comments

Comments
 (0)