Skip to content

Commit 5c3fce3

Browse files
committed
Add Zephyr support for Renesas EK-RZ/A3M board
- Add RZ/A3M board configuration in CMakeLists.txt for both demos - Add software rotation support for portrait displays (720x1280) - Add touch input support with GT911 controller - Update west.yaml to use Renesas Zephyr fork (wip_rz branch) - Add board-specific config and overlay files
1 parent 98cc38d commit 5c3fce3

8 files changed

Lines changed: 150 additions & 19 deletions

File tree

demos/home-automation/zephyr/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ if(BOARD STREQUAL "native_sim/native/64")
1414
elseif(BOARD STREQUAL "mimxrt1170_evk@B/mimxrt1176/cm7")
1515
set(Rust_CARGO_TARGET "thumbv7em-none-eabihf")
1616
set(BOARD_CONF_NAME "mimxrt1170_evk_mimxrt1176_cm7")
17+
elseif(BOARD STREQUAL "rza3m_ek")
18+
set(Rust_CARGO_TARGET "aarch64-unknown-none")
19+
set(SLINT_LIBRARY_CARGO_FLAGS "-Zbuild-std=core,alloc")
20+
set(BOARD_CONF_NAME "rza3m_ek")
1721
else()
1822
# See rustc --print target-list for available targets. Match that up with you supported board
1923
# https://docs.zephyrproject.org/latest/boards

demos/home-automation/zephyr/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ The `-p always` option of the build command forces a pristine build. The Zephyr
8383

8484
## Build and Run the Example on a Device
8585

86+
### NXP MIMXRT1170-EVKB
87+
8688
This sample has been tested on the [NXP MIMXRT1170-EVKB](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html) with a [RK055HDMIPI4MA0 MIPI display](https://docs.zephyrproject.org/latest/boards/shields/rk055hdmipi4ma0/doc/index.html). The board/debug probe may require configuring as described [here](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html#configuring-a-debug-probe).
8789

8890
```bash
@@ -92,3 +94,30 @@ west build -b mimxrt1170_evk@B/mimxrt1176/cm7 -p always slint/demos/home-automat
9294
# Flash
9395
west flash
9496
```
97+
98+
### Renesas EK-RZ/A3M
99+
100+
This sample can run on the [Renesas EK-RZ/A3M](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus/ek-rza3m-evaluation-kit-rza3m-mpu) evaluation kit with its 5-inch 720x1280 MIPI display.
101+
102+
**Note:** The EK-RZ/A3M requires using Renesas's Zephyr fork. Replace step 4 of the prerequisites with:
103+
104+
```bash
105+
# If Slint source is already checked out (use west-rza3m.yaml instead of west.yaml):
106+
cd ..
107+
west init -l --mf demos/zephyr-common/west-rza3m.yaml ./slint
108+
109+
# If you do not have Slint source yet:
110+
west init -m https://github.com/slint-ui/slint --mr zephyr --mf demos/zephyr-common/west-rza3m.yaml slint-zephyr
111+
cd slint-zephyr
112+
113+
# Checkout the repositories:
114+
west update
115+
```
116+
117+
```bash
118+
# Build
119+
west build -b rza3m_ek -p always slint/demos/home-automation/zephyr -- -DSHIELD=rtkapplcdms02001be -DCMAKE_BUILD_TYPE=Release
120+
121+
# Flash (using J-Link)
122+
west flash
123+
```

demos/printerdemo/zephyr/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ if(BOARD STREQUAL "native_sim/native/64")
1414
elseif(BOARD STREQUAL "mimxrt1170_evk@B/mimxrt1176/cm7")
1515
set(Rust_CARGO_TARGET "thumbv7em-none-eabi")
1616
set(BOARD_CONF_NAME "mimxrt1170_evk_mimxrt1176_cm7")
17+
elseif(BOARD STREQUAL "rza3m_ek")
18+
set(Rust_CARGO_TARGET "aarch64-unknown-none")
19+
set(SLINT_LIBRARY_CARGO_FLAGS "-Zbuild-std=core,alloc")
20+
set(BOARD_CONF_NAME "rza3m_ek")
1721
else()
1822
# See rustc --print target-list for available targets. Match that up with you supported board
1923
# https://docs.zephyrproject.org/latest/boards
@@ -33,10 +37,10 @@ endif()
3337
find_package(Zephyr)
3438
project(slint_zephyr_printer_demo_mcu LANGUAGES CXX)
3539

36-
set(SLINT_FEATURE_FREESTANDING ON)
37-
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
38-
set(DEFAULT_SLINT_EMBED_RESOURCES "embed-for-software-renderer" CACHE STRING "")
39-
# set(CMAKE_BUILD_TYPE Release)
40+
set(SLINT_FEATURE_FREESTANDING ON CACHE BOOL "" FORCE)
41+
set(SLINT_FEATURE_RENDERER_SOFTWARE ON CACHE BOOL "" FORCE)
42+
set(SLINT_FEATURE_SDF_FONTS ON CACHE BOOL "" FORCE)
43+
set(DEFAULT_SLINT_EMBED_RESOURCES "embed-for-software-renderer-with-sdf" CACHE STRING "")
4044
set(BUILD_SHARED_LIBS OFF)
4145

4246
# Work around gcc_s linker issue?

demos/printerdemo/zephyr/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ The `-p always` option of the build command forces a pristine build. The Zephyr
8383

8484
## Build and Run the Example on a Device
8585

86+
### NXP MIMXRT1170-EVKB
87+
8688
This sample has been tested on the [NXP MIMXRT1170-EVKB](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html) with a [RK055HDMIPI4MA0 MIPI display](https://docs.zephyrproject.org/latest/boards/shields/rk055hdmipi4ma0/doc/index.html). The board/debug probe may require configuring as described [here](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html#configuring-a-debug-probe).
8789

8890
```bash
@@ -92,3 +94,30 @@ west build -b mimxrt1170_evk@B/mimxrt1176/cm7 -p always slint/demos/printerdemo/
9294
# Flash
9395
west flash
9496
```
97+
98+
### Renesas EK-RZ/A3M
99+
100+
This sample can run on the [Renesas EK-RZ/A3M](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus/ek-rza3m-evaluation-kit-rza3m-mpu) evaluation kit with its 5-inch 720x1280 MIPI display.
101+
102+
**Note:** The EK-RZ/A3M requires using Renesas's Zephyr fork. Replace step 4 of the prerequisites with:
103+
104+
```bash
105+
# If Slint source is already checked out (use west-rza3m.yaml instead of west.yaml):
106+
cd ..
107+
west init -l --mf demos/zephyr-common/west-rza3m.yaml ./slint
108+
109+
# If you do not have Slint source yet:
110+
west init -m https://github.com/slint-ui/slint --mr zephyr --mf demos/zephyr-common/west-rza3m.yaml slint-zephyr
111+
cd slint-zephyr
112+
113+
# Checkout the repositories:
114+
west update
115+
```
116+
117+
```bash
118+
# Build
119+
west build -b rza3m_ek -p always slint/demos/printerdemo/zephyr -- -DSHIELD=rtkapplcdms02001be -DCMAKE_BUILD_TYPE=Release
120+
121+
# Flash (using J-Link)
122+
west flash
123+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright © SixtyFPS GmbH <info@slint.dev>
2+
# SPDX-License-Identifier: MIT
3+
4+
CONFIG_MAIN_STACK_SIZE=65536
5+
CONFIG_HEAP_MEM_POOL_SIZE=16777216
6+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8388608
7+
8+
CONFIG_DISPLAY=y
9+
CONFIG_MIPI_DSI=y
10+
CONFIG_GPIO=y
11+
12+
CONFIG_INPUT=y
13+
CONFIG_INPUT_GT911=y
14+
CONFIG_INPUT_QUEUE_MAX_MSGS=64
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright © SixtyFPS GmbH <info@slint.dev>
2+
// SPDX-License-Identifier: MIT
3+
4+
/ {
5+
chosen {
6+
zephyr,touch = &gt911_rtkapplcdms02001be;
7+
};
8+
};

demos/zephyr-common/slint-zephyr.cpp

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct RotationInfo
6767
using RenderingRotation = slint::platform::SoftwareRenderer::RenderingRotation;
6868
RenderingRotation rotation = RenderingRotation::NoRotation;
6969
slint::PhysicalSize size;
70+
bool software_rotation = false;
7071

7172
bool is_transpose() const
7273
{
@@ -75,12 +76,22 @@ struct RotationInfo
7576

7677
bool mirror_width() const
7778
{
78-
return rotation == RenderingRotation::Rotate180 || rotation == RenderingRotation::Rotate270;
79+
if (software_rotation) {
80+
return rotation == RenderingRotation::Rotate180
81+
|| rotation == RenderingRotation::Rotate90;
82+
}
83+
return rotation == RenderingRotation::Rotate180
84+
|| rotation == RenderingRotation::Rotate270;
7985
}
8086

8187
bool mirror_height() const
8288
{
83-
return rotation == RenderingRotation::Rotate90 || rotation == RenderingRotation::Rotate180;
89+
if (software_rotation) {
90+
return rotation == RenderingRotation::Rotate270
91+
|| rotation == RenderingRotation::Rotate180;
92+
}
93+
return rotation == RenderingRotation::Rotate90
94+
|| rotation == RenderingRotation::Rotate180;
8495
}
8596
};
8697

@@ -150,7 +161,8 @@ class ZephyrWindowAdapter : public slint::platform::WindowAdapter
150161

151162
const struct device *m_display;
152163
const RotationInfo m_rotationInfo;
153-
const slint::PhysicalSize m_size;
164+
const slint::PhysicalSize m_physicalSize;
165+
const slint::PhysicalSize m_logicalSize;
154166

155167
bool m_needs_redraw = true;
156168
std::vector<slint::platform::Rgb565Pixel> m_buffer;
@@ -228,6 +240,10 @@ std::unique_ptr<ZephyrWindowAdapter> ZephyrWindowAdapter::init_from(const device
228240
info.rotation = slint::platform::SoftwareRenderer::RenderingRotation::Rotate180;
229241
else if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_ROTATE_270))
230242
info.rotation = slint::platform::SoftwareRenderer::RenderingRotation::Rotate90;
243+
#ifdef CONFIG_BOARD_RZA3M_EK
244+
info.rotation = slint::platform::SoftwareRenderer::RenderingRotation::Rotate90;
245+
info.software_rotation = true;
246+
#endif
231247

232248
const auto rotatedSize = transformed(info.size, info);
233249
LOG_INF("Rotated screen size: %u x %u", rotatedSize.width, rotatedSize.height);
@@ -239,14 +255,19 @@ ZephyrWindowAdapter::ZephyrWindowAdapter(const device *display, RepaintBufferTyp
239255
: m_renderer(buffer_type),
240256
m_display(display),
241257
m_rotationInfo(info),
242-
m_size(transformed(m_rotationInfo.size, m_rotationInfo))
258+
m_physicalSize(info.size),
259+
m_logicalSize(transformed(info.size, info))
243260
{
244-
m_buffer.resize(m_size.width * m_size.height);
261+
m_buffer.resize(m_physicalSize.width * m_physicalSize.height);
245262

246263
m_buffer_descriptor.buf_size = sizeof(m_buffer[0]) * m_buffer.size();
247-
m_buffer_descriptor.width = m_size.width;
248-
m_buffer_descriptor.height = m_size.height;
249-
m_buffer_descriptor.pitch = m_size.width;
264+
m_buffer_descriptor.width = m_physicalSize.width;
265+
m_buffer_descriptor.height = m_physicalSize.height;
266+
m_buffer_descriptor.pitch = m_physicalSize.width;
267+
268+
if (m_rotationInfo.software_rotation) {
269+
m_renderer.set_rendering_rotation(m_rotationInfo.rotation);
270+
}
250271
}
251272

252273
void ZephyrWindowAdapter::request_redraw()
@@ -256,7 +277,7 @@ void ZephyrWindowAdapter::request_redraw()
256277

257278
slint::PhysicalSize ZephyrWindowAdapter::size()
258279
{
259-
return m_size;
280+
return m_logicalSize;
260281
}
261282

262283
slint::platform::AbstractRenderer &ZephyrWindowAdapter::renderer()
@@ -270,16 +291,16 @@ void ZephyrWindowAdapter::maybe_redraw()
270291
return;
271292

272293
auto start = k_uptime_get();
273-
auto region = m_renderer.render(m_buffer, m_size.width);
294+
auto region = m_renderer.render(m_buffer, m_physicalSize.width);
274295
const auto slintRenderDelta = k_uptime_delta(&start);
275296
LOG_DBG("Rendering %d dirty regions:", std::ranges::size(region.rectangles()));
276297
for (auto [o, s] : region.rectangles()) {
277-
#ifndef CONFIG_SHIELD_RK055HDMIPI4MA0
298+
#if !defined(CONFIG_SHIELD_RK055HDMIPI4MA0) && !defined(CONFIG_BOARD_RZA3M_EK)
278299
// Convert to big endian pixel data for Zephyr, unless we are using the RK055HDMIPI4MA0
279-
// shield. See is_supported_pixel_format above.
300+
// shield or rza3m_ek board. See is_supported_pixel_format above.
280301
for (int y = o.y; y < o.y + s.height; y++) {
281302
for (int x = o.x; x < o.x + s.width; x++) {
282-
auto px = reinterpret_cast<uint16_t *>(&m_buffer[y * m_size.width + x]);
303+
auto px = reinterpret_cast<uint16_t *>(&m_buffer[y * m_physicalSize.width + x]);
283304
*px = (*px << 8) | (*px >> 8);
284305
}
285306
}
@@ -292,7 +313,7 @@ void ZephyrWindowAdapter::maybe_redraw()
292313
m_buffer_descriptor.height = s.height;
293314

294315
if (const auto ret = display_write(m_display, o.x, o.y, &m_buffer_descriptor,
295-
m_buffer.data() + ((o.y * m_size.width) + o.x))
316+
m_buffer.data() + ((o.y * m_physicalSize.width) + o.x))
296317
!= 0) {
297318
LOG_WRN("display_write returned non-zero: %d", ret);
298319
}
@@ -391,7 +412,10 @@ void ZephyrPlatform::run_event_loop()
391412
}
392413

393414
if (auto next_timer_update = slint::platform::duration_until_next_timer_update()) {
394-
const auto wait_time_ms = next_timer_update.value().count();
415+
auto wait_time_ms = next_timer_update.value().count();
416+
#ifdef CONFIG_BOARD_RZA3M_EK
417+
wait_time_ms = std::min(wait_time_ms, static_cast<decltype(wait_time_ms)>(10000));
418+
#endif
395419
LOG_DBG("Sleeping for %llims", wait_time_ms);
396420
k_sem_take(&SLINT_SEM, K_MSEC(wait_time_ms));
397421
} else {
@@ -483,7 +507,9 @@ void zephyr_process_input_event(struct input_event *event, void *user_data)
483507
}
484508
}
485509

510+
#if DT_HAS_CHOSEN(zephyr_touch)
486511
INPUT_CALLBACK_DEFINE(DEVICE_DT_GET(DT_CHOSEN(zephyr_touch)), zephyr_process_input_event, NULL);
512+
#endif
487513

488514
void slint_zephyr_init(const struct device *display)
489515
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright © SixtyFPS GmbH <info@slint.dev>
2+
# SPDX-License-Identifier: MIT
3+
4+
# West manifest for Renesas EK-RZ/A3M board.
5+
# The RZ/A3M requires Renesas's Zephyr fork (wip_rz branch) for board and display support.
6+
# Use this manifest instead of west.yaml when building for rza3m_ek.
7+
8+
---
9+
manifest:
10+
remotes:
11+
- name: renesas
12+
url-base: https://github.com/renesas
13+
projects:
14+
- name: zephyr
15+
remote: renesas
16+
revision: wip_rz
17+
import: true

0 commit comments

Comments
 (0)