Skip to content

Commit b0c42d0

Browse files
committed
platform: add ATK-ESP32S3-LVGL support & fix build issues
Signed-off-by: Tang Sun <714858993@qq.com>
1 parent 57e536e commit b0c42d0

41 files changed

Lines changed: 139815 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,101 @@ _s3-build:
371371
-DRTCLAW_BOARD=$(S3_BOARD) build
372372
@echo "Output: $(BUILD_DIR)/esp32s3-$(S3_BOARD)/"
373373

374+
# --- ATK-ESP32-S3 unified targets ---
375+
# Prerequisite: source $$HOME/esp/esp-idf/export.sh
376+
#
377+
# All boards share platform/atk-esp32s3/ as the single ESP-IDF project.
378+
# Board-specific config lives in platform/atk-esp32s3/boards/<board>/.
379+
#
380+
# Boards:
381+
# qemu QEMU virtual devkit (4MB, OpenCores Ethernet)
382+
# default Real hardware (16MB, WiFi + PSRAM)
383+
#
384+
ATK_ESP_S3_DIR := platform/atk-esp32s3-lvgl
385+
386+
# Default aliases
387+
.PHONY: build-atk-esp32s3
388+
build-atk-esp32s3: build-atk-esp32s3-default
389+
390+
# ---- All boards: build ----
391+
.PHONY: build-atk-esp32s3-default
392+
build-atk-esp32s3-default: ATK_S3_BOARD = default
393+
build-atk-esp32s3-default: _atk_s3-build
394+
395+
# Backwards-compatible alias
396+
.PHONY: atk-esp32s3
397+
atk-esp32s3: build-atk-esp32s3-default
398+
399+
# ---- Hardware: flash + monitor ----
400+
# .PHONY: flash-atk-esp32s3
401+
# flash-atk-esp32s3: build-atk-esp32s3-default
402+
# cd $(ATK_ESP_S3_DIR) && idf.py -B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf flash
403+
404+
# .PHONY: monitor-atk-esp32s3
405+
# monitor-atk-esp32s3:
406+
# cd $(ATK_ESP_S3_DIR) && idf.py -B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf monitor
407+
408+
.PHONY: flash-atk-esp32s3
409+
flash-atk-esp32s3: ATK_S3_BOARD = default
410+
flash-atk-esp32s3: build-atk-esp32s3-default
411+
cd $(ATK_ESP_S3_DIR) && idf.py -B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf flash
412+
413+
.PHONY: monitor-atk-esp32s3
414+
monitor-atk-esp32s3: ATK_S3_BOARD = default
415+
monitor-atk-esp32s3:
416+
cd $(ATK_ESP_S3_DIR) && idf.py -B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf monitor
417+
# ---- Internal: shared build logic for all ATK-ESP32-S3 boards ----
418+
.PHONY: _atk_s3-build
419+
_atk_s3-build:
420+
@if [ ! -f $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf/build.ninja ]; then \
421+
cd $(ATK_ESP_S3_DIR) && idf.py \
422+
-B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf \
423+
-DRTCLAW_BOARD=$(ATK_S3_BOARD) set-target esp32s3; \
424+
fi
425+
@CCJSON=$(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf/compile_commands.json; \
426+
DEFAULTS=$(ATK_ESP_S3_DIR)/boards/$(ATK_S3_BOARD)/sdkconfig.defaults; \
427+
KCONFIG=$(ATK_ESP_S3_DIR)/components/rt_claw/Kconfig; \
428+
SDKCONFIG=$(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf/sdkconfig; \
429+
if [ ! -f "$$CCJSON" ] || [ "$$DEFAULTS" -nt "$$CCJSON" ] \
430+
|| [ "$$KCONFIG" -nt "$$CCJSON" ] \
431+
|| { [ -f "$$SDKCONFIG" ] && [ "$$SDKCONFIG" -nt "$$CCJSON" ]; }; then \
432+
cd $(ATK_ESP_S3_DIR) && idf.py \
433+
-B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf \
434+
-DRTCLAW_BOARD=$(ATK_S3_BOARD) reconfigure; \
435+
fi
436+
437+
python3 scripts/gen_atk_esp32s3_cross.py $(ATK_S3_BOARD)
438+
439+
@mkdir -p $(BUILD_DIR)
440+
@rm -rf $(BUILD_DIR)/esp32s3-$(ATK_S3_BOARD)
441+
@ln -sfn atk-esp32s3-$(ATK_S3_BOARD) $(BUILD_DIR)/esp32s3-$(ATK_S3_BOARD)
442+
443+
@NINJA=$(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/meson/build.ninja; \
444+
CROSS=$(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/cross.ini; \
445+
if [ ! -f "$$NINJA" ]; then \
446+
meson setup $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/meson \
447+
--cross-file "$$CROSS"; \
448+
elif [ "$$CROSS" -nt "$$NINJA" ]; then \
449+
meson setup $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/meson \
450+
--reconfigure --cross-file "$$CROSS"; \
451+
fi
452+
453+
meson compile -C $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/meson
454+
455+
cd $(ATK_ESP_S3_DIR) && idf.py \
456+
-B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf \
457+
-DRTCLAW_BOARD=$(ATK_S3_BOARD) reconfigure && \
458+
idf.py \
459+
-B $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/idf \
460+
-DRTCLAW_BOARD=$(ATK_S3_BOARD) build
461+
@echo "Output: $(BUILD_DIR)/atk-esp32s3-$(ATK_S3_BOARD)/"
462+
# use
463+
# make build-atk-esp32s3
464+
# make flash-atk-esp32s3
465+
# make monitor-atk-esp32s3
466+
467+
468+
374469
# --- Linux native ---
375470
MESON_BUILDDIR_LINUX := $(BUILD_DIR)/linux
376471

claw/services/tools/audio.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,27 @@
1212

1313
#ifdef CONFIG_RTCLAW_AUDIO_ENABLE
1414

15+
#ifdef CONFIG_RTCLAW_ES8388
16+
#include "drivers/audio/espressif/es8388_audio.h"
17+
#else
1518
#include "drivers/audio/espressif/es8311_audio.h"
19+
#endif
20+
21+
22+
typedef void (*audio_beep_t)(int freq, int duration, int volume);
23+
typedef void (*audio_set_volume_t)(int vol);
24+
typedef int (*audio_play_sound_t)(const char *name);
25+
26+
27+
#ifdef CONFIG_RTCLAW_ES8388
28+
static audio_beep_t board_audio_beep = es8388_audio_beep;
29+
static audio_set_volume_t board_audio_set_volume = es8388_audio_set_volume;
30+
static audio_play_sound_t board_audio_play_sound = es8388_audio_play_sound;
31+
#else
32+
static audio_beep_t board_audio_beep = es8311_audio_beep;
33+
static audio_set_volume_t board_audio_set_volume = es8311_audio_set_volume;
34+
static audio_play_sound_t board_audio_play_sound = es8311_audio_play_sound;
35+
#endif
1636

1737
static claw_err_t tool_audio_beep(struct claw_tool *tool,
1838
const cJSON *params, cJSON *result)
@@ -47,7 +67,8 @@ static claw_err_t tool_audio_beep(struct claw_tool *tool,
4767
return CLAW_ERROR;
4868
}
4969

50-
es8311_audio_beep(freq, duration, volume);
70+
/* es8311_audio_beep(freq, duration, volume); */
71+
board_audio_beep(freq, duration, volume);
5172

5273
cJSON_AddStringToObject(result, "status", "ok");
5374
char msg[64];
@@ -74,7 +95,8 @@ static claw_err_t tool_audio_volume(struct claw_tool *tool,
7495
return CLAW_ERROR;
7596
}
7697

77-
es8311_audio_set_volume(vol);
98+
/* es8311_audio_set_volume(vol); */
99+
board_audio_set_volume(vol);
78100
cJSON_AddStringToObject(result, "status", "ok");
79101
char msg[32];
80102
snprintf(msg, sizeof(msg), "volume set to %d", vol);
@@ -92,7 +114,8 @@ static claw_err_t tool_audio_play_sound(struct claw_tool *tool,
92114
return CLAW_ERROR;
93115
}
94116

95-
if (es8311_audio_play_sound(name_j->valuestring) != 0) {
117+
/* if (es8311_audio_play_sound(name_j->valuestring) != 0) { */
118+
if (board_audio_play_sound(name_j->valuestring) != 0) {
96119
cJSON_AddStringToObject(result, "error",
97120
"unknown sound name");
98121
return CLAW_ERROR;

claw/services/tools/lcd.c

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -582,25 +582,34 @@ int claw_lcd_available(void)
582582
#define BAR_X 4
583583
#define BAR_W (LCD_WIDTH - 8)
584584

585-
void claw_lcd_status(const char *msg)
586-
{
587-
if (!msg) {
585+
#ifdef CONFIG_RTCLAW_USE_LVGL
586+
#include "platform/atk-esp32s3-lvgl/main/ui_control.h"
587+
void claw_lcd_status(const char *msg)
588+
{
589+
ui_set_status_text(msg);
588590
return;
589591
}
592+
#else
593+
void claw_lcd_status(const char *msg)
594+
{
595+
if (!msg) {
596+
return;
597+
}
590598

591-
/* Skip slow MMIO framebuffer writes until user explicitly uses LCD */
592-
if (!s_fb || !s_lcd_active) {
593-
return;
594-
}
599+
/* Skip slow MMIO framebuffer writes until user explicitly uses LCD */
600+
if (!s_fb || !s_lcd_active) {
601+
return;
602+
}
595603

596-
/* Clear status strip */
597-
lcd_draw_rect(0, STATUS_Y, LCD_WIDTH, STATUS_H,
598-
rgb888_to_565(0, 0, 40), 1);
604+
/* Clear status strip */
605+
lcd_draw_rect(0, STATUS_Y, LCD_WIDTH, STATUS_H,
606+
rgb888_to_565(0, 0, 40), 1);
599607

600-
lcd_draw_text(BAR_X, STATUS_Y + 2, msg,
601-
rgb888_to_565(0, 220, 255),
602-
rgb888_to_565(0, 0, 40), 1);
603-
}
608+
lcd_draw_text(BAR_X, STATUS_Y + 2, msg,
609+
rgb888_to_565(0, 220, 255),
610+
rgb888_to_565(0, 0, 40), 1);
611+
}
612+
#endif
604613

605614
void claw_lcd_progress(int percent)
606615
{
@@ -642,10 +651,19 @@ int __attribute__((weak)) claw_lcd_available(void)
642651
return 0;
643652
}
644653

654+
#ifdef CONFIG_RTCLAW_USE_LVGL
655+
#include "platform/atk-esp32s3-lvgl/main/ui_control.h"
656+
void claw_lcd_status(const char *msg)
657+
{
658+
ui_set_status_text(msg);
659+
return;
660+
}
661+
#else
645662
void __attribute__((weak)) claw_lcd_status(const char *msg)
646663
{
647664
(void)msg;
648665
}
666+
#endif
649667

650668
void __attribute__((weak)) claw_lcd_progress(int percent)
651669
{

0 commit comments

Comments
 (0)