JieLi Bluetooth Smart Speakers Developing: Getting Started with AC696N Speaker SoCs(1)

Debugging is a crucial part of embedded development. For AC696N series SoCs, the SDK provides a flexible and layered print output control system. This guide will walk you through the key configuration options for managing debug prints.


1. Print Control

a. Global Print Switch

The master switch for all debug output is located in app_config.h .

// app_config.h
#ifndef CONFIG_DEBUG_ENABLE
// Control global debug output here
#endif

b. Library Debug Output (LIB_DEBUG)

Library-specific debug prints can be controlled separately in app_config.h .

// app_config.h
#ifdef CONFIG_RELEASE_ENABLE
#define LIB_DEBUG 1
#else
#define LIB_DEBUG 1
#endif

c. Logging System & Level Control

The logging module ( log.h ) supports multiple severity levels.

Level Definitions (0–6):

// log.h
#define __LOG_VERB 0 // Verbose
#define __LOG_DEBUG 1 // Debug
#define __LOG_INFO 2 // Info
#define __LOG_WARN 3 // Warning
#define __LOG_ERROR 4 // Error
#define __LOG_CHAR 5 // Character output

Level Filter:

Set  __LOG_LEVEL  to control which messages are printed. Only logs with a level greater than or equal to this threshold will appear.

#ifdef CONFIG_RELEASE_ENABLE
#undef __LOG_LEVEL
#define __LOG_LEVEL 0 // Valid range: 0–6. Example: 0 enables all levels.
#endif

Logging APIs (usage identical to printf ):

log_v("verbose message");   // Level 0
log_d("debug message"); // Level 1
log_i("info message"); // Level 2
log_w("warning message"); // Level 3
log_e("error message"); // Level 4
log_c("character output"); // Level 5

Module-Specific Log Level Control:

Each module can define its own log level threshold for finer granularity.

文章内容
文章内容

d. Colored Output

The following macros provide colored (and blinking) log output. Note: The global log level must be set to 0 for these to work.

// log.h
// Standard colored output (red, green, yellow)
#define r_printf(x, ...) log_i("\e[31m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define g_printf(x, ...) log_i("\e[32m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define y_printf(x, ...) log_i("\e[33m\e[1m" x "\e[0m", ## __VA_ARGS__)
// Blinking colored output (red, green, yellow)
#define r_f_printf(x, ...) log_i("\e[31m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define g_f_printf(x, ...) log_i("\e[32m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define y_f_printf(x, ...) log_i("\e[33m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__)

e. Power-On Time Stamp

Enable or disable time-stamped print messages during boot in lib_system_config.c .

// lib_system_config.c
/// Enable/disable time-stamp in print messages
const int config_printf_time = 1; // 1 = enable, 0 = disable

f. Assertion System

The assertion (assert) mechanism helps catch runtime errors. Configure it in lib_system_config.c .

// lib_system_config.c
/// Enable/disable assert print output on exception
#ifdef CONFIG_RELEASE_ENABLE
 const int config_asser = 1;
#else
 const int config_asser = 1;
#endif

Using Assertions:

  1. Diagnosing Crashes: When an assert triggers, refer to the serial debug output for clues about the cause.
  2. Locating the Fault:

  • The assert message often includes an address.
  • Cross-reference this address with the sdk.lst file to map it to a specific function or API.

Generating sdk.lst :

文章内容

Add the following command to your download.c (or build script) to generate the symbol list:

%OBJDUMP% -D -address-mask=0x1ffffff -print-dbg %ELFFILE% > sdk.lst

Summary

Properly configuring the print and debug system is the first step in AC696N development. By adjusting the global switch, log levels, colored output, timestamps, and assertions, developers can efficiently trace code execution and diagnose issues. The layered design ensures you can control verbosity from coarse (global) to fine (module-level), balancing debug needs with final release performance.

评论

此博客中的热门博文

KT148A Voice Chip at Baidu Baike

KT148A Voice Chip: A Powerful Tool to Enhance the User Experience of Smart Soymilk Makers