Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly
#1
We have created an LVGL App that runs in a Web Browser and on PinePhone…

1. We compiled LVGL Library from C to WebAssembly with Zig Compiler

2. We wrote our LVGL App in the Zig Programming Language (instead of C)

3. Exact same code runs in a Web Browser and on PinePhone (with Apache NuttX RTOS)

4. Which is super helpful for prototyping LVGL Apps

Check out the details in this article:

“NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly”

How it looks on PinePhone:

[Image: lvgl4-title.jpg]

And how we tested in a Web Browser with WebAssembly:

[Image: lvgl3-wasm6.png]
  Reply
#2
Awesome work!! and just to say I just this minute got it all working Smile There were quite a few tweeks required, and somewhere I have tracked most of them. But I made the mistake of trying to place the phone-app folder within the nuttx/apps/.../demo tree. So although I got the WASM part running after a few hours, the pinephone-app part took a bit longer to figure out hosting it outside the nuttx directories and adjusting lots of paths and the ../../includes. Then the final build trick of delete the .o, build the nuttx, build the phone app, then build the nuttx again, and finally deploy. So you did some amazing work, thank you, and well done figuring all that out! I'll try and post back the rest of my tweeks, it is a bit of a mess after all that, but I already delayed my weekend start to crack the last issue (adding a couple dummy exports for __stack_chk_fail and __stack_chk_guard). But now I can look forward to further exploring lvgl with nuttx. SVG icons and WiFi connectivity are probably top of my list Smile Cheers, Peter
  Reply
#3
(06-16-2023, 05:29 AM)WhiteHexagon Wrote: Awesome work!! and just to say I just this minute got it all working Smile  

That's fantastic Peter! Sorry about the messy Build Script. Please check out my latest article, hopefully the LVGL + NuttX + WebAssembly setup looks a little tidier:

NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly

BTW I might be moving on to NuttX on RISC-V Star64 and PineTab-V. I'll explain why in the next article :-)
  Reply
#4
That is what I got working, feature-phone app via wasm and device Smile

Sure, I understand, the RISC-V stuff is the future Smile  Maybe I manage to get a PineTabV in the next batch, although no blog news in over two months, so I wasnt sure they had even shipped it yet (and store still shows 'late May'). 

Anyway I have plenty to explore now you got the pinephone working.  Amazing that you got it booting into a interactive UI in under a second! again, good work Smile

[edit]

here are a few of the tweeks I needed to get it to build:

1) there was an unused variable:  static x    x++
2) build: I needed to link in libc via    -lc \
3) custom panic handlers required a third parameter adding:  , ret_addr: ?usize
4) in memset I had to change d.* = c2;  to: d[0] = c2;  (maybe in two places)
5) changed lines like this:
Code:
    @cInclude("../../../../../../nuttx/include/limits.h");
    @cInclude("../../../../../../nuttx/config.h");

to:

Code:
    @cInclude("nuttx/include/limits.h");
    @cInclude("nuttx/config.h");

6) feature-phone needed these:

Code:
pub export fn __stack_chk_fail() void {}
pub export fn __stack_chk_guard() void {}


Possibly I have a slightly different Zig version? mine reports 0.10.1

Sorry my notes are not clear, I didnt use git and vscode seems to ignore some subfolders still when I look for changes.

Updated build.sh

Code:
#!/usr/bin/env bash
#  Build LVGL App (in Zig) and LVGL Library (in C) for PinePhone and WebAssembly

set -e  #  Exit when any command fails
set -x  #  Echo commands

export PRJ_HOME=/home/peter/prj/zig/examples/lvgl/pinephone-lvgl-zig
export OBJ_HOME=/home/peter/software/nuttx/apps/graphics/lvgl/lvgl/demos/widgets
export NUTTX_HOME=/home/peter/software/nuttx
export APPS_HOME=$NUTTX_HOME/apps
export LVGL_HOME=$NUTTX_HOME/apps/graphics/lvgl
export LVGL_SRC=$LVGL_HOME/lvgl/src


## Build the LVGL App (in Zig) and LVGL Library (in C) for PinePhone and WebAssembly
function build_zig {

  ## Check that NuttX Build has completed and `lv_demo_widgets.*.o` exists
  if [ ! -f $OBJ_HOME/lv_demo_widgets.*.o ]
  then
    echo "*** Error: Build NuttX first before building Zig app"
    exit 1
  fi

  ## Compile our LVGL Display Driver from C to WebAssembly with Zig Compiler
  compile_lvgl $PRJ_HOME/display.c $PRJ_HOME/display.o

  ## Compile LVGL Library from C to WebAssembly with Zig Compiler
  compile_lvgl $LVGL_SRC/font/lv_font_montserrat_14.c $PRJ_HOME/lv_font_montserrat_14.o
  compile_lvgl $LVGL_SRC/font/lv_font_montserrat_20.c $PRJ_HOME/lv_font_montserrat_20.o
  compile_lvgl $LVGL_SRC/widgets/lv_label.c $PRJ_HOME/lv_label.o
  compile_lvgl $LVGL_SRC/core/lv_obj.c $PRJ_HOME/lv_obj.o
  compile_lvgl $LVGL_SRC/misc/lv_mem.c $PRJ_HOME/lv_mem.o
  compile_lvgl $LVGL_SRC/core/lv_event.c $PRJ_HOME/lv_event.o
  compile_lvgl $LVGL_SRC/core/lv_obj_style.c $PRJ_HOME/lv_obj_style.o
  compile_lvgl $LVGL_SRC/core/lv_obj_pos.c $PRJ_HOME/lv_obj_pos.o
  compile_lvgl $LVGL_SRC/misc/lv_txt.c $PRJ_HOME/lv_txt.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_label.c $PRJ_HOME/lv_draw_label.o
  compile_lvgl $LVGL_SRC/core/lv_obj_draw.c $PRJ_HOME/lv_obj_draw.o
  compile_lvgl $LVGL_SRC/misc/lv_area.c $PRJ_HOME/lv_area.o
  compile_lvgl $LVGL_SRC/core/lv_obj_scroll.c $PRJ_HOME/lv_obj_scroll.o
  compile_lvgl $LVGL_SRC/font/lv_font.c $PRJ_HOME/lv_font.o
  compile_lvgl $LVGL_SRC/core/lv_obj_class.c $PRJ_HOME/lv_obj_class.o
  compile_lvgl $LVGL_SRC/core/lv_obj_tree.c $PRJ_HOME/lv_obj_tree.o
  compile_lvgl $LVGL_SRC/hal/lv_hal_disp.c $PRJ_HOME/lv_hal_disp.o
  compile_lvgl $LVGL_SRC/misc/lv_anim.c $PRJ_HOME/lv_anim.o
  compile_lvgl $LVGL_SRC/misc/lv_tlsf.c $PRJ_HOME/lv_tlsf.o
  compile_lvgl $LVGL_SRC/core/lv_group.c $PRJ_HOME/lv_group.o
  compile_lvgl $LVGL_SRC/core/lv_indev.c $PRJ_HOME/lv_indev.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_rect.c $PRJ_HOME/lv_draw_rect.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_mask.c $PRJ_HOME/lv_draw_mask.o
  compile_lvgl $LVGL_SRC/misc/lv_style.c $PRJ_HOME/lv_style.o
  compile_lvgl $LVGL_SRC/misc/lv_ll.c $PRJ_HOME/lv_ll.o
  compile_lvgl $LVGL_SRC/core/lv_obj_style_gen.c $PRJ_HOME/lv_obj_style_gen.o
  compile_lvgl $LVGL_SRC/misc/lv_timer.c $PRJ_HOME/lv_timer.o
  compile_lvgl $LVGL_SRC/core/lv_disp.c $PRJ_HOME/lv_disp.o
  compile_lvgl $LVGL_SRC/core/lv_refr.c $PRJ_HOME/lv_refr.o
  compile_lvgl $LVGL_SRC/misc/lv_color.c $PRJ_HOME/lv_color.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_line.c $PRJ_HOME/lv_draw_line.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_img.c $PRJ_HOME/lv_draw_img.o
  compile_lvgl $LVGL_SRC/misc/lv_math.c $PRJ_HOME/lv_math.o
  compile_lvgl $LVGL_SRC/hal/lv_hal_indev.c $PRJ_HOME/lv_hal_indev.o
  compile_lvgl $LVGL_SRC/core/lv_theme.c $PRJ_HOME/lv_theme.o
  compile_lvgl $LVGL_SRC/hal/lv_hal_tick.c $PRJ_HOME/lv_hal_tick.o
  compile_lvgl $LVGL_SRC/misc/lv_log.c $PRJ_HOME/lv_log.o
  compile_lvgl $LVGL_SRC/misc/lv_printf.c $PRJ_HOME/lv_printf.o
  compile_lvgl $LVGL_SRC/misc/lv_fs.c $PRJ_HOME/lv_fs.o
  compile_lvgl $LVGL_SRC/draw/lv_draw.c $PRJ_HOME/lv_draw.o
  compile_lvgl $LVGL_SRC/draw/lv_img_decoder.c $PRJ_HOME/lv_img_decoder.o
  compile_lvgl $LVGL_SRC/extra/lv_extra.c $PRJ_HOME/lv_extra.o
  compile_lvgl $LVGL_SRC/extra/layouts/flex/lv_flex.c $PRJ_HOME/lv_flex.o
  compile_lvgl $LVGL_SRC/extra/layouts/grid/lv_grid.c $PRJ_HOME/lv_grid.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw.c $PRJ_HOME/lv_draw_sw.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_rect.c $PRJ_HOME/lv_draw_sw_rect.o
  compile_lvgl $LVGL_SRC/draw/lv_img_cache.c $PRJ_HOME/lv_img_cache.o
  compile_lvgl $LVGL_SRC/draw/lv_img_buf.c $PRJ_HOME/lv_img_buf.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_arc.c $PRJ_HOME/lv_draw_sw_arc.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_letter.c $PRJ_HOME/lv_draw_sw_letter.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_blend.c $PRJ_HOME/lv_draw_sw_blend.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_layer.c $PRJ_HOME/lv_draw_sw_layer.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_transform.c $PRJ_HOME/lv_draw_sw_transform.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_polygon.c $PRJ_HOME/lv_draw_sw_polygon.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_line.c $PRJ_HOME/lv_draw_sw_line.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_img.c $PRJ_HOME/lv_draw_sw_img.o
  compile_lvgl $LVGL_SRC/draw/sw/lv_draw_sw_gradient.c $PRJ_HOME/lv_draw_sw_gradient.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_transform.c $PRJ_HOME/lv_draw_transform.o
  compile_lvgl $LVGL_SRC/extra/themes/default/lv_theme_default.c $PRJ_HOME/lv_theme_default.o
  compile_lvgl $LVGL_SRC/font/lv_font_fmt_txt.c $PRJ_HOME/lv_font_fmt_txt.o
  compile_lvgl $LVGL_SRC/draw/lv_draw_layer.c $PRJ_HOME/lv_draw_layer.o
  compile_lvgl $LVGL_SRC/misc/lv_style_gen.c $PRJ_HOME/lv_style_gen.o
  compile_lvgl $LVGL_SRC/misc/lv_gc.c $PRJ_HOME/lv_gc.o
  compile_lvgl $LVGL_SRC/misc/lv_utils.c $PRJ_HOME/lv_utils.o
  compile_lvgl $LVGL_SRC/widgets/lv_btn.c $PRJ_HOME/lv_btn.o
  compile_lvgl $LVGL_SRC/core/lv_indev_scroll.c $PRJ_HOME/lv_indev_scroll.o

  ## Compile the Zig LVGL App for WebAssembly
    zig build-lib \
    --verbose-cimport \
    -target wasm32-freestanding \
    -dynamic \
    -rdynamic \
    -lc \
    -DFAR= \
    -DLV_MEM_CUSTOM=1 \
    -DLV_FONT_MONTSERRAT_14=1 \
    -DLV_FONT_MONTSERRAT_20=1 \
    -DLV_FONT_DEFAULT_MONTSERRAT_20=1 \
    -DLV_USE_FONT_PLACEHOLDER=1 \
    -DLV_USE_LOG=1 \
    -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE \
    -DLV_LOG_TRACE_OBJ_CREATE=1 \
    "-DLV_ASSERT_HANDLER={void lv_assert_handler(void); lv_assert_handler();}" \
    -I . \
    \
    -isystem "$NUTTX_HOME/nuttx/include" \
    -I "$NUTTX_HOME" \
    -I "$APPS_HOME/include" \
    -I "$LVGL_HOME" \
    -I "$LVGL_SRC/core" \
    -I "$LVGL_SRC/draw" \
    -I "$LVGL_SRC/draw/arm2d" \
    -I "$LVGL_SRC/draw/nxp" \
    -I "$LVGL_SRC/draw/nxp/pxp" \
    -I "$LVGL_SRC/draw/nxp/vglite" \
    -I "$LVGL_SRC/draw/sdl" \
    -I "$LVGL_SRC/draw/stm32_dma2d" \
    -I "$LVGL_SRC/draw/sw" \
    -I "$LVGL_SRC/draw/swm341_dma2d" \
    -I "$LVGL_SRC/font" \
    -I "$LVGL_SRC/hal" \
    -I "$LVGL_SRC/misc" \
    -I "$LVGL_SRC/widgets" \
    \
    lvglwasm.zig \
    display.o \
    lv_font_montserrat_14.o \
    lv_font_montserrat_20.o \
    lv_label.o \
    lv_mem.o \
    lv_obj.o \
    lv_event.o \
    lv_obj_style.o \
    lv_obj_pos.o \
    lv_txt.o \
    lv_draw_label.o \
    lv_obj_draw.o \
    lv_area.o \
    lv_obj_scroll.o \
    lv_font.o \
    lv_obj_class.o \
    lv_obj_tree.o \
    lv_hal_disp.o \
    lv_anim.o \
    lv_tlsf.o \
    lv_group.o \
    lv_indev.o \
    lv_draw_rect.o \
    lv_draw_mask.o \
    lv_style.o \
    lv_ll.o \
    lv_obj_style_gen.o \
    lv_timer.o \
    lv_disp.o \
    lv_refr.o \
    lv_color.o \
    lv_draw_line.o \
    lv_draw_img.o \
    lv_math.o \
    lv_hal_indev.o \
    lv_theme.o \
    lv_hal_tick.o \
    lv_log.o \
    lv_printf.o \
    lv_fs.o \
    lv_draw.o \
    lv_img_decoder.o \
    lv_extra.o \
    lv_flex.o \
    lv_grid.o \
    lv_draw_sw.o \
    lv_draw_sw_rect.o \
    lv_img_cache.o \
    lv_img_buf.o \
    lv_draw_sw_arc.o \
    lv_draw_sw_letter.o \
    lv_draw_sw_blend.o \
    lv_draw_sw_layer.o \
    lv_draw_sw_transform.o \
    lv_draw_sw_polygon.o \
    lv_draw_sw_line.o \
    lv_draw_sw_img.o \
    lv_draw_sw_gradient.o \
    lv_draw_transform.o \
    lv_theme_default.o \
    lv_font_fmt_txt.o \
    lv_draw_layer.o \
    lv_style_gen.o \
    lv_gc.o \
    lv_utils.o \
    lv_btn.o \
    lv_indev_scroll.o \

  ## Compile the Zig LVGL App for PinePhone
  ## (armv8-a with cortex-a53)
  zig build-obj \
    -lc \
    --verbose-cimport \
    -target aarch64-freestanding-none \
    -mcpu cortex_a53 \
    \
    -isystem "$NUTTX_HOME/nuttx/include" \
    -I . \
    -I "$NUTTX_HOME" \
    -I "$APPS_HOME/include" \
    -I "$LVGL_HOME" \
    -I "$LVGL_SRC/core" \
    -I "$LVGL_SRC/draw" \
    -I "$LVGL_SRC/draw/arm2d" \
    -I "$LVGL_SRC/draw/nxp" \
    -I "$LVGL_SRC/draw/nxp/pxp" \
    -I "$LVGL_SRC/draw/nxp/vglite" \
    -I "$LVGL_SRC/draw/sdl" \
    -I "$LVGL_SRC/draw/stm32_dma2d" \
    -I "$LVGL_SRC/draw/sw" \
    -I "$LVGL_SRC/draw/swm341_dma2d" \
    -I "$LVGL_SRC/font" \
    -I "$LVGL_SRC/hal" \
    -I "$LVGL_SRC/misc" \
    -I "$LVGL_SRC/widgets" \
    lvgltest.zig

  ## Copy the compiled Zig LVGL App to NuttX and overwrite `lv_demo_widgets.*.o`
  cp lvgltest.o $OBJ_HOME/lv_demo_widgets.*.o
}

## Compile LVGL Library from C to WebAssembly with Zig Compiler
function compile_lvgl {
  local source_file=$1  ## Input Source File (LVGL in C)
  local object_file=$2  ## Output Object File (WebAssembly)

  zig cc \
    -target wasm32-freestanding \
    -dynamic \
    -rdynamic \
    -lc \
    -DFAR= \
    -DLV_MEM_CUSTOM=1 \
    -DLV_FONT_MONTSERRAT_14=1 \
    -DLV_FONT_MONTSERRAT_20=1 \
    -DLV_FONT_DEFAULT_MONTSERRAT_20=1 \
    -DLV_USE_FONT_PLACEHOLDER=1 \
    -DLV_USE_LOG=1 \
    -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE \
    -DLV_LOG_TRACE_OBJ_CREATE=1 \
    "-DLV_ASSERT_HANDLER={void lv_assert_handler(void); lv_assert_handler();}" \
    \
    -c \
    -fno-common \
    -Wall \
    -Wstrict-prototypes \
    -Wshadow \
    -Wundef \
    -Werror \
    -Os \
    -fno-strict-aliasing \
    -fomit-frame-pointer \
    -ffunction-sections \
    -fdata-sections \
    -g \
    -isystem $NUTTX_HOME/nuttx/include \
    -D__NuttX__  \
    -pipe \
    -I $LVGL_HOME \
    -I "$APPS_HOME/include" \
    -Wno-format \
    -Wno-format-security \
    -Wno-unused-variable \
    "-I./lvgl/src/core" \
    "-I./lvgl/src/draw" \
    "-I./lvgl/src/draw/arm2d" \
    "-I./lvgl/src/draw/nxp" \
    "-I./lvgl/src/draw/nxp/pxp" \
    "-I./lvgl/src/draw/nxp/vglite" \
    "-I./lvgl/src/draw/sdl" \
    "-I./lvgl/src/draw/stm32_dma2d" \
    "-I./lvgl/src/draw/sw" \
    "-I./lvgl/src/draw/swm341_dma2d" \
    "-I./lvgl/src/font" \
    "-I./lvgl/src/hal" \
    "-I./lvgl/src/misc" \
    "-I./lvgl/src/widgets" \
    $source_file \
    -o $object_file
}

## Build the Feature Phone Zig LVGL App for WebAssembly
function build_feature_phone_wasm {
  zig build-lib \
    -lc \
    --verbose-cimport \
    -target wasm32-freestanding \
    -dynamic \
    -rdynamic \
    -DFAR= \
    -DLV_MEM_CUSTOM=1 \
    -DLV_FONT_MONTSERRAT_14=1 \
    -DLV_FONT_MONTSERRAT_20=1 \
    -DLV_FONT_DEFAULT_MONTSERRAT_20=1 \
    -DLV_USE_FONT_PLACEHOLDER=1 \
    -DLV_USE_LOG=1 \
    -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE \
    -DLV_LOG_TRACE_OBJ_CREATE=1 \
    "-DLV_ASSERT_HANDLER={void lv_assert_handler(void); lv_assert_handler();}" \
    -I . \
    \
    -isystem "$NUTTX_HOME/nuttx/include" \
    -I "$NUTTX_HOME" \
    -I "$APPS_HOME/include" \
    -I "$LVGL_HOME" \
    -I "$LVGL_SRC/core" \
    -I "$LVGL_SRC/draw" \
    -I "$LVGL_SRC/draw/arm2d" \
    -I "$LVGL_SRC/draw/nxp" \
    -I "$LVGL_SRC/draw/nxp/pxp" \
    -I "$LVGL_SRC/draw/nxp/vglite" \
    -I "$LVGL_SRC/draw/sdl" \
    -I "$LVGL_SRC/draw/stm32_dma2d" \
    -I "$LVGL_SRC/draw/sw" \
    -I "$LVGL_SRC/draw/swm341_dma2d" \
    -I "$LVGL_SRC/font" \
    -I "$LVGL_SRC/hal" \
    -I "$LVGL_SRC/misc" \
    -I "$LVGL_SRC/widgets" \
    \
    feature-phone.zig \
    display.o \
    lv_font_montserrat_14.o \
    lv_font_montserrat_20.o \
    lv_label.o \
    lv_mem.o \
    lv_obj.o \
    lv_event.o \
    lv_obj_style.o \
    lv_obj_pos.o \
    lv_txt.o \
    lv_draw_label.o \
    lv_obj_draw.o \
    lv_area.o \
    lv_obj_scroll.o \
    lv_font.o \
    lv_obj_class.o \
    lv_obj_tree.o \
    lv_hal_disp.o \
    lv_anim.o \
    lv_tlsf.o \
    lv_group.o \
    lv_indev.o \
    lv_draw_rect.o \
    lv_draw_mask.o \
    lv_style.o \
    lv_ll.o \
    lv_obj_style_gen.o \
    lv_timer.o \
    lv_disp.o \
    lv_refr.o \
    lv_color.o \
    lv_draw_line.o \
    lv_draw_img.o \
    lv_math.o \
    lv_hal_indev.o \
    lv_theme.o \
    lv_hal_tick.o \
    lv_log.o \
    lv_printf.o \
    lv_fs.o \
    lv_draw.o \
    lv_img_decoder.o \
    lv_extra.o \
    lv_flex.o \
    lv_grid.o \
    lv_draw_sw.o \
    lv_draw_sw_rect.o \
    lv_img_cache.o \
    lv_img_buf.o \
    lv_draw_sw_arc.o \
    lv_draw_sw_letter.o \
    lv_draw_sw_blend.o \
    lv_draw_sw_layer.o \
    lv_draw_sw_transform.o \
    lv_draw_sw_polygon.o \
    lv_draw_sw_line.o \
    lv_draw_sw_img.o \
    lv_draw_sw_gradient.o \
    lv_draw_transform.o \
    lv_theme_default.o \
    lv_font_fmt_txt.o \
    lv_draw_layer.o \
    lv_style_gen.o \
    lv_gc.o \
    lv_utils.o \
    lv_btn.o \
    lv_indev_scroll.o \

}

## Compile the Feature Phone Zig LVGL App for Apache NuttX RTOS
function build_feature_phone_nuttx {
  ## Compile the Zig LVGL App for PinePhone
  ## (armv8-a with cortex-a53)
  zig build-obj \
    -lc \
    --verbose-cimport \
    -target aarch64-freestanding-none \
    -mcpu cortex_a53 \
    \
    -isystem "$NUTTX_HOME/nuttx/include" \
    -I . \
    -I "$NUTTX_HOME" \
    -I "$APPS_HOME/include" \
    -I "$LVGL_HOME" \
    -I "$LVGL_SRC/core" \
    -I "$LVGL_SRC/draw" \
    -I "$LVGL_SRC/draw/arm2d" \
    -I "$LVGL_SRC/draw/nxp" \
    -I "$LVGL_SRC/draw/nxp/pxp" \
    -I "$LVGL_SRC/draw/nxp/vglite" \
    -I "$LVGL_SRC/draw/sdl" \
    -I "$LVGL_SRC/draw/stm32_dma2d" \
    -I "$LVGL_SRC/draw/sw" \
    -I "$LVGL_SRC/draw/swm341_dma2d" \
    -I "$LVGL_SRC/font" \
    -I "$LVGL_SRC/hal" \
    -I "$LVGL_SRC/misc" \
    -I "$LVGL_SRC/widgets" \
    feature-phone.zig

  ## Copy the compiled Zig LVGL App to NuttX and overwrite `lv_demo_widgets.*.o`
  cp feature-phone.o $OBJ_HOME/lv_demo_widgets.*.o
}

## Build the LVGL App (in Zig) and LVGL Library (in C) for PinePhone and WebAssembly
build_zig

## Compile the Feature Phone Zig LVGL App for WebAssembly
build_feature_phone_wasm

## Compile the Feature Phone Zig LVGL App for Apache NuttX RTOS
build_feature_phone_nuttx
  Reply
#5
(06-17-2023, 02:10 AM)WhiteHexagon Wrote: That is what I got working, feature-phone app via wasm and device Smile

Thanks, this is really helpful! I'll link to this in my article.

Yep I'm using an older version of Zig: 0.10.0, because newer versions of Zig won't support my 10-year-old MacBook Pro that's stuck on macOS 10.15.

I might need to run an Alpine Linux Container on macOS to work around this. But this slows down my machine though, sigh.
  Reply
#6
Same issue with my MBP on 10.12, although not sure I would like to update to latest macos at this point Wink So my test above was on an even older MBP that I installed Manjaro on (that might be another difference for the tweeks I found). Actually it is working really good, I just have to learn more about linux since macos has made life too easy Smile I did ask the Zig team why they dont support older macos, when they support much older windows and linux versions, but I think the problem is that Apple like to force latest tools upon their developers. At least that was the case when I was doing iOS development. A trick they use to generate iWaste Wink

So what other features are you working on for Nuttx and PinePhone? or will you switch fully to RISC-V now?
  Reply
#7
(06-19-2023, 03:46 AM)WhiteHexagon Wrote: So what other features are you working on for Nuttx and PinePhone? or will you switch fully to RISC-V now?

I wish I could finish up the Feature Phone UI with Incoming Calls, SMS and PCM Audio. But I might have to switch to RISC-V now and make up for lost time. Here's a sneak preview of my new article :-)

https://lupyuen.codeberg.page/articles/pinephone2.html
  Reply
#8
(06-19-2023, 08:13 PM)lupyuen Wrote: I wish I could finish up the Feature Phone UI with Incoming Calls, SMS and PCM Audio.

I understand, there is still a lot of work to do, but you made an amazing start! 

I might have a look at the PCM stuff, since I previously developed some Apps for streaming WiFi cameras with video/audio ( a couple different audio codecs but PCM was the simplest).  I saw on your block diagram (from the LCD article) the audio pins on the A64.  But how would I find more information on how the microphone is connected, and how those pins relate to the modem chip you described in another article with the PCM configuration information?   Or maybe I should start with something more simple like switching a led on/off Wink  But it seems like you have an amazing inside view into how everything is connected.  I downloaded the A64 user manual, but I dont think that has enough info, and the AT modem document, also only tells a part of the story.

Regarding the feature-phone demo, I noticed that the old blue/green/red test pattern flashes briefly on the PP before the keypad displays.  I seem to recall this was one of your display driver experiments Smile but I cannot find the code that is drawing that pattern...  can you give me a pointer please?
  Reply
#9
OK, I found the 'pinephone_display_test_pattern' code Smile but are the  fixes below still needed, I thought I read somewhere that you had found a better solution to that?


Code:
      ARM64_DMB();
      ARM64_DSB();
      ARM64_ISB();
  Reply
#10
(06-20-2023, 07:24 AM)WhiteHexagon Wrote: But how would I find more information on how the microphone is connected, and how those pins relate to the modem chip you described in another article with the PCM configuration information?

Yep it looks complex, let's walk through the connections:
  1. The LTE Modem is connected to A64 Port PCM0 for PCM Audio
  2. A64 Port PCM0 is documented in the A64 User Manual, "I2C/PCM", Page 621
  3. So we need to route the PCM Audio from PCM0 to PinePhone's Microphone / Speaker

According to the PinePhone Schematic:
  1. The Audio Connections are HPOUT, MIC1 (MICIN1), MIC2 (MICIN2), EAROUT, LINEOUT
  2. HPOUT and MIC2 (MICIN2) are connected to Headphone Jack
  3. MIC1 (MICIN1) is connected to the Digital Video Connector (?)
  4. EAROUT is connected to the Earpiece Speaker
  5. LINEOUT is connected to the Loudspeaker

A64 Ports HPOUT, MICIN1, MICIN2, EAROUT, LINEOUT are documented in the A64 User Manual, "Audio Codec", Page 278

I hope this will get you started :-)

To fix the DMB issue, we need to flush the CPU Cache.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How-To: Remote Control Your Phone from Desktop via VNC biketool 2 481 10-12-2024, 11:47 AM
Last Post: biketool
  Office applications for the Pinephone Peter Gamma 2 553 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 35,479 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 1,021 07-04-2024, 07:34 AM
Last Post: Kevin Kofler
  Which word processor to choose for the Pinephone? Peter Gamma 16 5,514 06-22-2024, 07:28 AM
Last Post: Peter Gamma
  Samba share on the Pinephone? Peter Gamma 0 656 06-16-2024, 10:26 PM
Last Post: Peter Gamma
  Possible Free Backup Carrier for PinePhone PineFone 0 466 06-13-2024, 03:45 PM
Last Post: PineFone
  Using Signal on PinePhone in mid-2023? dante404 47 22,397 05-03-2024, 02:19 AM
Last Post: dragonhospital
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 38 32,905 04-23-2024, 10:29 AM
Last Post: donchurch
Wink PINEPHONE not booting Touchwood 2 1,232 02-23-2024, 07:27 AM
Last Post: Touchwood

Forum Jump:


Users browsing this thread: 2 Guest(s)