From ac9b574b278ff0ac4abc74a4bf7fa3848175fa9a Mon Sep 17 00:00:00 2001 From: Igor Belwon Date: Sat, 23 Aug 2025 18:39:52 +0200 Subject: [PATCH 1/4] project: Add new compression options Add support for compressing the uniLoader image with lz4, and while we're at it add two new Kconfig variables for setting compression tools used in the build. --- Kconfig | 13 +++++++++++++ Makefile | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/Kconfig b/Kconfig index a9331c4..ccb9bc9 100644 --- a/Kconfig +++ b/Kconfig @@ -19,6 +19,19 @@ menu "Building options" int "Verbosity of logs" default 7 + config COMPRESS_GZIP + bool "Compress the uniLoader image with gzip" + default y + help + Select this if you want to use gzip to compress the final uniLoader image. + + config COMPRESS_LZ4 + bool "Compress the uniLoader image with lz4" + default n + help + Select this if you want to use lz4 to compress the final uniLoader image. + This is required on some new MediaTek devices. + config EMBED_LINUX bool "Embed linux kernel and device tree" default y diff --git a/Makefile b/Makefile index 91c6cdf..d898cc4 100644 --- a/Makefile +++ b/Makefile @@ -399,10 +399,18 @@ quiet_cmd_uniloader_objcopy = OBJCOPY $@ quiet_cmd_gzip_uniloader = GZIP $@.gz cmd_gzip_uniloader = gzip -c uniLoader > uniLoader.gz +quiet_cmd_lz4_uniloader = LZ4 $@.lz4 + cmd_lz4_uniloader = lz4 uniLoader -l -f -q + uniLoader: $(uniloader-all) arch/$(ARCH)/linker.lds FORCE $(call if_changed,uniloader_link) $(call if_changed,uniloader_objcopy) +ifdef CONFIG_COMPRESS_GZIP $(call if_changed,gzip_uniloader) +endif +ifdef CONFIG_COMPRESS_LZ4 + $(call if_changed,lz4_uniloader) +endif # The actual objects are generated when descending, # make sure no implicit rule kicks in From f6f2c5e030d89f8cab63b7e362a5967fafcf7bc3 Mon Sep 17 00:00:00 2001 From: Igor Belwon Date: Sat, 23 Aug 2025 18:40:17 +0200 Subject: [PATCH 2/4] gitignore: Ignore lz4-built uniLoader --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e9971f0..dbf187e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ uniLoader *.o *.gz +*.lz4 main/*.o arch/*/linker.lds board/*/*.o* From 191b8d60a848a621ef6169c38c050b7eaccc8e0b Mon Sep 17 00:00:00 2001 From: Igor Belwon Date: Sat, 23 Aug 2025 19:23:06 +0200 Subject: [PATCH 3/4] soc: Define MediaTek MT6878 SoC Signed-off-by: Igor Belwon --- soc/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/soc/Kconfig b/soc/Kconfig index 87d71a0..26579ef 100644 --- a/soc/Kconfig +++ b/soc/Kconfig @@ -123,6 +123,13 @@ config QUALCOMM help Say Y if your device uses Mediatek MT6877 SoC + config MT6878 + bool "Support for Mediatek MT6878" + default n + select MEDIATEK + help + Say Y if your device uses Mediatek MT6878 SoC + config QC32_8916 bool "Support for QUALCOMM MSM8916" default n From 4d9be0bc55695cd06f8d6150d2c2fc0fa19e5fd0 Mon Sep 17 00:00:00 2001 From: Igor Belwon Date: Sat, 23 Aug 2025 19:23:23 +0200 Subject: [PATCH 4/4] board: Add support for the CMF Phone (1) This device has a broken framebuffer. As such, logs are passed via UART. Signed-off-by: Igor Belwon --- board/Kconfig | 19 +++++++++ board/Makefile | 1 + board/nothing/board-tetris.c | 80 ++++++++++++++++++++++++++++++++++++ configs/tetris_defconfig | 11 +++++ 4 files changed, 111 insertions(+) create mode 100644 board/nothing/board-tetris.c create mode 100644 configs/tetris_defconfig diff --git a/board/Kconfig b/board/Kconfig index 8c5a31c..fdb958f 100644 --- a/board/Kconfig +++ b/board/Kconfig @@ -21,6 +21,23 @@ menu "Device Support" help Say Y if you want to include support for Pixel 2 XL + config NOTHING_TETRIS + bool "Support for CMF Phone 1" + default n + depends on MT6878 + help + Say Y if you want to include support for CMF Phone 1 + + config NOTHING_TETRIS_DISABLE_WDT + bool "Disable the watchdog timer on startup" + default y + depends on NOTHING_TETRIS + help + Say Y if you want to disable the watchdog timer on startup + on this board. While this is obviously useful for end-users, + developers may want to leave this on to avoid holding down + the power button every time. + config QEMU_BOARD_VIRT bool "Support for QEMU virt platform (aarch64)" default n @@ -157,6 +174,7 @@ menu "Device Specific Addresses" config PAYLOAD_ENTRY hex "Payload Entry Address" + default 0x50000000 if NOTHING_TETRIS default 0x050000000 if SAMSUNG_J4LTE default 0x090000000 if SAMSUNG_J5LTE default 0x090000000 if SAMSUNG_GTA4XL @@ -164,6 +182,7 @@ menu "Device Specific Addresses" config RAMDISK_ENTRY hex "Ramdisk Entry Address" + default 0x40000000 if NOTHING_TETRIS default 0x084000000 if SAMSUNG_GTA4XL default 0x51100000 if VOLLA_ALGIZ diff --git a/board/Makefile b/board/Makefile index 403eed0..3a3284c 100644 --- a/board/Makefile +++ b/board/Makefile @@ -1,6 +1,7 @@ lib-$(CONFIG_APPLE_N61AP) += apple/board-n61ap.o lib-$(CONFIG_AMAZON_PW3) += amazon/board-pw3.o lib-$(CONFIG_GOOGLE_TAIMEN) += google/board-taimen.o +lib-$(CONFIG_NOTHING_TETRIS) += nothing/board-tetris.o lib-$(CONFIG_QEMU_BOARD_VIRT) += qemu/board-virt.o lib-$(CONFIG_SAMSUNG_A105F) += samsung/board-a105f.o lib-$(CONFIG_SAMSUNG_A127F) += samsung/board-a127f.o diff --git a/board/nothing/board-tetris.c b/board/nothing/board-tetris.c new file mode 100644 index 0000000..18fab58 --- /dev/null +++ b/board/nothing/board-tetris.c @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2025, Igor Belwon + */ +#include +#include +#include + +#define UART_BASE 0x11001000 + +#define UART_LSR_BASE 0x14 +#define UART_LSR_DR 0x01 /* Data ready */ +#define UART_LSR_THRE 0x20 /* TX holding register empty */ + +#define WDT_BASE 0x1c00a000 +#define WDT_MODE_KEY 0x22000000 +#define WDT_MODE_EN (1 << 0) + +void uart_putc(char ch) +{ + /* wait until TX is ready */ + while (!(readl((void *)(UART_BASE + UART_LSR_BASE)) & UART_LSR_THRE)) + ; + + writel(ch, (void *)UART_BASE); // thr is at offset 0x0, which is just uart_base +} + +void uart_puts(const char *s) +{ + while (*s != '\0') { + uart_putc(*s); + s++; + } +} + +void tetris_disable_wdt(void) +{ + uint32_t reg; + + reg = readl((void*)WDT_BASE); + if (reg & WDT_MODE_EN) + { + reg &= ~WDT_MODE_EN; + reg |= WDT_MODE_KEY; + writel(reg, (void*)WDT_BASE); + printk(KERN_INFO, "%s: disabled watchdog timer.\n", __func__); + } + else + printk(KERN_ERR, "%s: watchdog is already disabled.\n", __func__); + + return; +} + +int tetris_init(void) +{ + return 0; +} + +int tetris_drv(void) +{ + return 0; +} + +int tetris_late_init(void) +{ +#ifdef CONFIG_NOTHING_TETRIS_DISABLE_WDT + tetris_disable_wdt(); +#endif + return 0; +} + +struct board_data board_ops = { + .name = "cmf-phone-1", + .ops = { + .early_init = tetris_init, + .drivers_init = tetris_drv, + .late_init = tetris_late_init, + }, + .quirks = 0 +}; diff --git a/configs/tetris_defconfig b/configs/tetris_defconfig new file mode 100644 index 0000000..a62e11f --- /dev/null +++ b/configs/tetris_defconfig @@ -0,0 +1,11 @@ +CONFIG_POSITION_INDEPENDENT=y +# CONFIG_COMPRESS_GZIP is not set +CONFIG_COMPRESS_LZ4=y +# CONFIG_SIMPLE_FB is not set +CONFIG_UART_DEBUG=y +CONFIG_MT6878=y +CONFIG_NOTHING_TETRIS=y +CONFIG_NOTHING_TETRIS_DISABLE_WDT=y +CONFIG_TEXT_BASE=0x40000000 +CONFIG_PAYLOAD_ENTRY=0x60000000 +CONFIG_RAMDISK_ENTRY=0x51100000