2024/3/26

lvgl label, font

找 font 的 code:
/home/charles-chang/lv_sim_vscode_sdl/lvgl/src/font/lv_font_fmt_txt.c

static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
好像是..
/home/charles-chang/lv_sim_vscode_sdl/lvgl/src/font/lv_font_fmt_txt.c

const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unicode_letter)
設定歸設定,之後的,可以在 draw_ 設定斷點,看到 call 的時機 (後來的 timer callback, update_layout(cb))

2024/3/25

android studio for platform

就是能 support AOSP source code 的 Android Studio。
好像是 Android Studio + plugin,有這個 plugin 後,在 Android Studio 的 Welcom Page,除了一般的New Project 和 Open 之外,
還會多一個 "Import Asfp Project"

選 Import Asfp Project 就是 Import Aosp 裡面的 project (code)
所以要設定 AOSP source code 位置。還有build 時,lunch 的 target 是 ? (例如 pixel4 就是 aosp_flame-userdebug)
後面才是挑選aosp 中,要 import 的 module (folder)

2024/3/12

wayland. weston hello-world

wayland 是新的 X protocol (?)。
wayland 也是一樣,一個 server 負責顯示,一堆 client 藉由 wayland protocol 要求 server 畫圖。
wayland server 的實做就是 weston。

weston 也可以 run 在 X上(變成 interpreter ?),所以在 ubuntu 上,使用 X 的系統,也可以 run wayland client.
開啟console 啟動 weston 就可以。
~$ weston
Date: 2024-03-12 CST
[15:11:15.003] weston 9.0.0
               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 9.0.0
[15:11:15.003] Command line: weston
[15:11:15.003] OS: Linux, 6.5.0-25-generic, #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2, x86_64
[15:11:15.003] Starting with no config file.
[15:11:15.003] Output repaint window is 7 ms maximum.
[15:11:15.003] Loading module '/usr/lib/x86_64-linux-gnu/libweston-9/x11-backend.so'
[15:11:15.009] Loading module '/usr/lib/x86_64-linux-gnu/libweston-9/gl-renderer.so'
[15:11:15.019] EGL client extensions: EGL_EXT_platform_base EGL_EXT_device_base
               EGL_EXT_device_enumeration EGL_EXT_device_query
               EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions
               EGL_KHR_debug EGL_KHR_platform_x11 EGL_EXT_platform_x11
               EGL_EXT_platform_device EGL_KHR_platform_wayland
               EGL_EXT_platform_wayland EGL_EXT_platform_xcb
               EGL_MESA_platform_gbm EGL_KHR_platform_gbm
               EGL_MESA_platform_surfaceless
[15:11:15.026] EGL version: 1.5
[15:11:15.026] EGL vendor: NVIDIA
[15:11:15.026] EGL client APIs: OpenGL_ES OpenGL
...
然後看到一個小window 跑起來,裡面有小游標。

然後clone 這個 client example: hello-wayland make 就可以。
然後 run ./hello-wayland
就可以看到一個圖片show 在剛剛的 weston windows 上。



另外一個簡單測試 wayland server connection 的 client code:
#include <stdio.h>
#include <wayland-client.h>

int
main(int argc, char *argv[])
{
    struct wl_display *display = wl_display_connect(NULL);
    if (!display) {
        fprintf(stderr, "Failed to connect to Wayland display.\n");
        return 1;
    }
    fprintf(stderr, "Connection established!\n");

    wl_display_disconnect(display);
    return 0;
}
compile 的時候要 link wayland-client.so
gcc -o waylandclient waylandclient.c -lwayland-client
另外一個簡單的,紙提供 wayland sock connect 的 server (chatgpt 寫的):
#include <stdio.h>
#include <wayland-server.h>

int
main(int argc, char *argv[])
{
    struct wl_display *display = wl_display_create();
    if (!display) {
        fprintf(stderr, "Unable to create Wayland display.\n");
        return 1;
    }

    const char *socket = wl_display_add_socket_auto(display);
    if (!socket) {
        fprintf(stderr, "Unable to add socket to Wayland display.\n");
        return 1;
    }

    fprintf(stderr, "Running Wayland display on %s\n", socket);
    wl_display_run(display);

    wl_display_destroy(display);
    return 0;
}
一樣,compile 的時候要link wayland-server (-lwayland-server)

2024/3/4

build aosp android 12 for pixel4

repo version 顯示 repo launcher version 要是 2.15 以上。
"codenanme-tages-and-buildnumber" 去看,pixel4最後一個版本tag name 是 android-12.1.0_r11

所以
repo init -u https://android.googlesource.com/platform/manifest -b android-12.1.0_r11
repo sync -c -j8
官方說 "-c" 就可以只fetch current version (所以 repo init 不用加 --depth=1 ?)

download 玩aosp 後,要 download hardware 相關的 none-open binary.
要依照build id 來download,剛剛的android-12.1.0_r11 的 build id 是 SQ3A.220705.003.A1
有 google 跟 qualcomm 兩個 tgz 檔。

說明解開後是自解壓縮script,說在 aosp 的 root folder 執行,accept license後,就會放在正確位置 (vendor)。

開始build:
source build/envsetup.sh
接下來的lunch 要選pixel4,依照說明去 flash device 查,是 flame,所以:
lunch aosp_flame-userdebug
然後就可以用 "m" 來build,不用加任何option,他會看cpu核心數開啟對應process。
-- 用 i9 13 代,限制溫度70,64G ram, 普通hd, 需要90分鐘。



build kernel
現在AOSP 的kernel是 prebuilt kernel,所以要build 的話,要另外clone 下來。
kernel build法以 Android 12 為分界。
12 (含)以前,用build.sh
另外,pixel6以上,android 13(含)以上,支援 GKI (generalize kernel image),所以可以只update kernel vender part,所以只build 出 kernel 就可以。
古老的還是要build 好 kernel 後,到 aosp 再build 一次,把 kernel 包進去。

現在做 pixel4, android12 的作法:build.sh

用 repo clone source,先到kernel branch 去看android12 for pixel 4 的 branch name 是什嗎。
猜大概是 common-android12-5.10 吧?
repo init -u https://android.googlesource.com/kernel/manifest -b common-android12-5.10
repo sync -j8

燒錄

要先 unlock bootloader
pixel 4 要先到 Setting 中的 developement option 去開啟 allow unlock bootloader,
然後關機,按著volume down + power 開機進入bootloader mode.
用 fastboot flashing unlock 來unlock
其實在pixel 4 的 bootloader 畫面也有 unlock 選項,選後按下 power,他會自己 reboot,之後就是 unlock mode 了。

開始燒錄。
一樣在 bootloader mode,所以先進入 bootlaoder:
adb reboot bootloader
fastboot 要看環境變數 ANDROID_PRODUCT_OUT 來找 img 檔。
所以要先設定這個變數到剛剛 build 好的 aosp src /out/target/product/flame
之後就可以下
$ fastboot flashall -w
--------------------------------------------
Bootloader Version...: c2f2-0.4-7617419
Baseband Version.....: g8150-00111-210817-B-7650554
Serial Number........: 99211FFAXXXXXX
--------------------------------------------
Checking 'product'                                 OKAY [  0.070s]
Setting current slot to 'b'                        OKAY [  0.157s]
Sending 'boot_b' (65536 KB)                        OKAY [  1.850s]
Writing 'boot_b'                                   OKAY [  0.299s]
Sending 'dtbo_b' (8192 KB)                         OKAY [  0.340s]
Writing 'dtbo_b'                                   OKAY [  0.094s]
Sending 'vbmeta_b' (4 KB)                          OKAY [  0.140s]
Writing 'vbmeta_b'                                 OKAY [  0.078s]
Sending 'vbmeta_system_b' (4 KB)                   OKAY [  0.140s]
Writing 'vbmeta_system_b'                          OKAY [  0.078s]
Rebooting into fastboot                            OKAY [  0.070s]
< waiting for any device >
Sending 'super' (4 KB)                             OKAY [  0.018s]
Updating super partition                           OKAY [  0.025s]
Resizing 'product_b'                               OKAY [  0.003s]
Resizing 'system_b'                                OKAY [  0.003s]
Resizing 'system_ext_b'                            OKAY [  0.003s]
Resizing 'system_a'                                OKAY [  0.005s]
Resizing 'vendor_b'                                OKAY [  0.005s]
Resizing 'vendor_a'                                OKAY [  0.003s]
Resizing 'product_b'                               OKAY [  0.003s]
Sending sparse 'product_b' 1/2 (262140 KB)         OKAY [  6.835s]
Writing 'product_b'                                OKAY [  1.816s]
Sending sparse 'product_b' 2/2 (10064 KB)          OKAY [  0.274s]
Writing 'product_b'                                OKAY [  0.089s]
Resizing 'system_b'                                OKAY [  0.004s]
Sending sparse 'system_b' 1/4 (262140 KB)          OKAY [  7.071s]
Writing 'system_b'                                 OKAY [  1.884s]
Sending sparse 'system_b' 2/4 (262140 KB)          OKAY [  7.484s]
Writing 'system_b'                                 OKAY [  0.896s]
Sending sparse 'system_b' 3/4 (262140 KB)          OKAY [  6.993s]
Writing 'system_b'                                 OKAY [  0.873s]
Sending sparse 'system_b' 4/4 (34396 KB)           OKAY [  0.924s]
Writing 'system_b'                                 OKAY [  0.176s]
Resizing 'system_ext_b'                            OKAY [  0.004s]
Sending 'system_ext_b' (136184 KB)                 OKAY [  3.665s]
Writing 'system_ext_b'                             OKAY [  1.531s]
Resizing 'system_a'                                OKAY [  0.003s]
Sending 'system_a' (23492 KB)                      OKAY [  0.728s]
Writing 'system_a'                                 OKAY [  0.151s]
Resizing 'vendor_b'                                OKAY [  0.004s]
Sending sparse 'vendor_b' 1/4 (262140 KB)          OKAY [  7.022s]
Writing 'vendor_b'                                 OKAY [  1.893s]
Sending sparse 'vendor_b' 2/4 (262140 KB)          OKAY [  6.996s]
Writing 'vendor_b'                                 OKAY [  0.898s]
Sending sparse 'vendor_b' 3/4 (262140 KB)          OKAY [  7.075s]
Writing 'vendor_b'                                 OKAY [  0.902s]
Sending sparse 'vendor_b' 4/4 (42360 KB)           OKAY [  1.120s]
Writing 'vendor_b'                                 OKAY [  0.212s]
Erasing 'userdata'                                 OKAY [ 12.301s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata'                                 OKAY [  0.008s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting                                          OKAY [  0.000s]
Finished. Total time: 105.627s
可以看到燒錄過程中,燒完 dtb 和 system 後會自己 reboot,不要動他。
reboot 完會自己繼續download,最後 reboot,進入android.


memo 一下 pixel4 的最後版本 android-13.0.0_r31
一樣,下載 propriety binary 後 build OK, 但是燒錄後無法開機,停在 google logo 畫面。

另外,build 好的 aosp folder copy 到另一台機器上 會 build fail。
因為 out/host/linux-x86/b8in 下,有一些 python script 是絕對路徑的 link。



結果要燒回 factory ota image 時,用 adb sideload 出現 signiture verified error。
最後用 android flash tool 網頁版,才燒錄成功。