From patchwork Fri Sep 5 17:01:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 238 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091713; bh=h0tazrGizP5nRbtCF0HX0tCud7A9Bk0xe42G21nvxQQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ky3B9LdfTJlq/EvtegL1NEh63rEbm9L0x9KkLdrdiwf+2fptW9WsSpaOmapMlvPoy xdbuZ73bDOnx3qmYQ6oOr/+w0qHcO+5hTktw9rfHcCX200m94csLfkPU1gckWhtBJu qy2NJFfvSjzznfcZdVLEsSMd3B219EiBYnJ5x2td+liQkNC/TeYFb+Cnl+aMyFpwaQ xPFiouJ3lSA7boVaJ92hRZ5RVKgHEi9dTmZaljY39fMUXI9ebsjWv/AQj0EN/btbpr 5tQUowFWgsQGC+v/Ovm8Knv3+Z3pER8y9fCLnQa839oap43HIznBxbmcObxUf/N5/2 8OOfe0BqAzOMw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 594BA678E7 for ; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id FYkKHmlj-Ebd for ; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091713; bh=h0tazrGizP5nRbtCF0HX0tCud7A9Bk0xe42G21nvxQQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ky3B9LdfTJlq/EvtegL1NEh63rEbm9L0x9KkLdrdiwf+2fptW9WsSpaOmapMlvPoy xdbuZ73bDOnx3qmYQ6oOr/+w0qHcO+5hTktw9rfHcCX200m94csLfkPU1gckWhtBJu qy2NJFfvSjzznfcZdVLEsSMd3B219EiBYnJ5x2td+liQkNC/TeYFb+Cnl+aMyFpwaQ xPFiouJ3lSA7boVaJ92hRZ5RVKgHEi9dTmZaljY39fMUXI9ebsjWv/AQj0EN/btbpr 5tQUowFWgsQGC+v/Ovm8Knv3+Z3pER8y9fCLnQa839oap43HIznBxbmcObxUf/N5/2 8OOfe0BqAzOMw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4955767980 for ; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091711; bh=tshyhzeCZRaDyeo6heiIlpe3OG+6F0KyTXhvRt6Bcs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NA4uqNnOVDNnbQGRYN6rENADx2xrgY9zYBK4ZhefV5oa20cFJMRRXREugSgx28Q7g C9XdtS6/stv2dAHczDvTu8RkC0LF01Dl4j9TLQKeplZ9SJTaMS+wyxEAPE9CsoLEY0 ZVRLHHLHViH1CINVLXJlXkBV4vNi1q5ctYaSdsW/RKnMhLOqLmr4E5gl3jIUD7jM6r DQBF6QY7/uQ5ZnUt3j3QoepYYF/PNV6wHTD1rEwKB6mOtkDxK4mcybopuWI/aP0GX6 pZ5/Y2F1m049KxXVD+ThpOJ3s1+nrjrX9WKKUVNm2rEK9R5f3js3mRSlI04G+19GLN K3/Bhqbx0WFDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 55CCB678AA; Fri, 5 Sep 2025 11:01:51 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bRk1irR5XrC6; Fri, 5 Sep 2025 11:01:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091707; bh=yQQwsF9MvoEKkZ46B4bv6OE+MazBprRyDfqZXFRaHcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzaTs/VwWmvtuFihu9g7MxY4fPOyg5ZuRIHr1GzwMpPXAaMQSSea6UI0v58HIzJ4g vJAjk4LJnHqJryfGoTL+r0MAtf87jyGyJ7EAdYJeh+QyDz/0oWupsK77J6tMTB8QzS no5Itbe5RAIfNROh7Id1b3UNFYQq0dbT9jqnI35ypGywzyjcRmMHgph1WKCH/VfwDw WivHDtpqdH1PIw5e5Iwfe8UcGbVQJChTWRssEvhsdItzgOcmHaYVfcaWiAmekgNuB+ 2mG9+Cvcb0zfL6XoL0+gqRYhnIzYW4ioq7n1doU7vgmM5onBCrIHZvUM77L77ySPb+ gXOzkPiuSqz+w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0B804678E6; Fri, 5 Sep 2025 11:01:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:12 -0600 Message-ID: <20250905170132.182249-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TTFNONYQCBH57EMPJORKDZUROMSL7DZU X-Message-ID-Hash: TTFNONYQCBH57EMPJORKDZUROMSL7DZU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/15] sandbox: Add a function to read a line from a file List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide a version of fgets() which works on file descriptors. This can be used to read lines from a file, as will be needed for the ulib test-program. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 32 ++++++++++++++++++++++++++++++++ include/os.h | 14 ++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 1c4e23cb4eb..891dfd9c9b8 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -150,6 +150,38 @@ int os_unlink(const char *pathname) return unlink(pathname); } +char *os_fgets(char *str, int size, int fd) +{ + char *s = str; + int n = size - 1; + int i; + + if (n <= 0 || !str) + return NULL; + + for (i = 0; i < n; i++) { + ssize_t ret; + char c; + + ret = read(fd, &c, 1); + if (ret <= 0) { + /* EOF or error */ + if (!i) + return NULL; + break; + } + + *s++ = c; + + if (c == '\n') + break; + } + + *s = '\0'; + + return str; +} + void os_exit(int exit_code) { exit(exit_code); diff --git a/include/os.h b/include/os.h index 3393acb435a..e5c524c57a4 100644 --- a/include/os.h +++ b/include/os.h @@ -106,6 +106,20 @@ int os_isatty(int fd); */ int os_unlink(const char *pathname); +/** + * os_fgets() - read a string from a file stream + * + * Reads at most @size - 1 characters from the stream and stores them in str. + * Reading stops after an EOF or a newline. If a newline is read, it is + * stored in str. A terminating nul byte is appended. + * + * @str: Buffer to store the string + * @size: Maximum number of characters to read (including null terminator) + * @fd: File descriptor to read from + * Return: str on success, NULL on error, or EOF with no characters read + */ +char *os_fgets(char *str, int size, int fd); + /** os_persistent_fname() - Find the path to a test file * * @buf: Buffer to hold path From patchwork Fri Sep 5 17:01:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 239 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091713; bh=S5pPbpmyXLZ4XGUztKXaWr9pFYWL3cl3E1JbB/kdbYc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ifk247LwriDxDXle5f0SyuRNEogOb3irluvgGQ0msRNG0FOhzbCuaQhLseJXHmFy0 PEJoRNEpccpf2o53f7HcFfxRNUHywF9xgpVfe3yPg6OdvjpEdncyUEqV2KZ4byQXnq RcBhjFUfUPmBLCRNORwc9eb7WgpNRzrIgxwfk3vusHcY7T9SGp2WmFuJDlZcEcknY9 UWAk9ERtu6LNPvqt9zY8EF49gT38hPnF+Av0Jqjgd0FrMF72ISKHxHf1f1SVLzDren SczlJ6rgVcIlYfVRWqAooPP5opsQfULm+4cngVMG1VdGNkDlikkhVYMmrGSq3QT5+7 Bih7V4BYkbzIQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB621679AC for ; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id B5QlfBgKW3f7 for ; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091713; bh=S5pPbpmyXLZ4XGUztKXaWr9pFYWL3cl3E1JbB/kdbYc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ifk247LwriDxDXle5f0SyuRNEogOb3irluvgGQ0msRNG0FOhzbCuaQhLseJXHmFy0 PEJoRNEpccpf2o53f7HcFfxRNUHywF9xgpVfe3yPg6OdvjpEdncyUEqV2KZ4byQXnq RcBhjFUfUPmBLCRNORwc9eb7WgpNRzrIgxwfk3vusHcY7T9SGp2WmFuJDlZcEcknY9 UWAk9ERtu6LNPvqt9zY8EF49gT38hPnF+Av0Jqjgd0FrMF72ISKHxHf1f1SVLzDren SczlJ6rgVcIlYfVRWqAooPP5opsQfULm+4cngVMG1VdGNkDlikkhVYMmrGSq3QT5+7 Bih7V4BYkbzIQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D546267999 for ; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091712; bh=ncnger8RVkLO160ymoPt1wXPWcFgyCIL/UTRB0J0zKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vg5Xg756b1BYrlNLKxR+IRKfq9L9OMv6aGFXMPLm0RfU5ycoonrd+M9tqpl2Beqfz RZvHWscOEDF0OrST4+S0kwAks2f6hfTK531VpR1y6vaC1xb2fS1vlb/evSXD0RCLMN hGfOny68uNq6ssG9gX1UOGQxxcdWZECoDpH4UDqxY13zTge7q3VKx5An2p9vPEM2Lq QcViU/GCp+M9TbPoAzcuqLtACBLqYS30rTRDLzt5+qSsdPEY19qUWpA1KkayDWlKmd hmSMc0K5oRhb08Fgm0NJB906CSOLeOE3gB4LJHqOBqXsYVJYyJan8xBW/+/xFAFLe0 k39YPUdV0syRA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A6986799D; Fri, 5 Sep 2025 11:01:52 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Js32PanqxF-M; Fri, 5 Sep 2025 11:01:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091711; bh=yWBc/UdfJkHv8xxji0orNPN8xE12ZqFg1npCI/Z4oj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjmsFfjQhDhDvzM0k/WtcxfXrBKwkws1MqfM7c+eJFhRQ9grTeWkdyUAN1AskeuCM 99e+CM7DUFxOyeRMUSQqgkjDGtLLSGldIJ6tMUZdo4n429SZNA3x7zuFOMdzpNkfy9 kqfgIZUtAyj/Lt9KfBhguv7DugXNV/Ucp9L0/SbIUlTKX1vSY6y89s+X0X36C3Ser0 axKVpdp+SL92NPWQXFpbk+dJMrVnwRSVgP7WxhU/WXIJln+EdIC6q0RzUguwq2afc2 Ly4prIZ/D5oE4Oj+ZI9Yx7ZzhJ5c17eMtDkD0mid45Ln44FJlnc9apPaZsY745ADz5 jtm9WoWOOBfEQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 99844678E6; Fri, 5 Sep 2025 11:01:51 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:13 -0600 Message-ID: <20250905170132.182249-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Y4AVB6Q2IHIHO6RO4JHACS5RHFJAMSF7 X-Message-ID-Hash: Y4AVB6Q2IHIHO6RO4JHACS5RHFJAMSF7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/15] ulib: Disable environment setup List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The application may not wish to have an environment, so skip this init with the library. Signed-off-by: Simon Glass --- common/board_r.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index 1bb0eb37e9b..22506effae6 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -417,6 +417,9 @@ static int should_load_env(void) static int initr_env(void) { + if (gd_ulib()) + return 0; + /* initialize environment */ if (should_load_env()) env_relocate(); From patchwork Fri Sep 5 17:01:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 240 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091714; bh=J9ylY6Z6loaC7gelfUewSrXghkIIOrtNGs5QVR09Lpw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PHu9clutb9GY0Qo3qPKTY1TYZX6nkJLHxc9vxonhrBLVQFjAWQsG87D9JNbteJq6R 6QvaHYdyyVp/Pr1RNthl7dAF5N5o5zc4MgNYOSl1it/jymNFPpwK9+GDUNEvojzakQ UeuMovaZZHfg0XH/ZqdIYYiNrPgybNGBn9VLGU668eKHEr4sTqqiB+VN7W05bBoxAA KjZtzDt7tFmLVPBSxNTfbq/F1EjIe6N8B+PY3upnTTvyUdV/1Bh4jqojVTZDVNmC7Y 5+ja/GxxhRE3UpQBrE7kwxdKlwC5GiMVhHwZLMZMUmjIcTuNHo64u3uj4EupSdCosR ygsHSp+fnHPvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F23C2679AC for ; Fri, 5 Sep 2025 11:01:54 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Aug25m7kJyL0 for ; Fri, 5 Sep 2025 11:01:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091714; bh=J9ylY6Z6loaC7gelfUewSrXghkIIOrtNGs5QVR09Lpw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PHu9clutb9GY0Qo3qPKTY1TYZX6nkJLHxc9vxonhrBLVQFjAWQsG87D9JNbteJq6R 6QvaHYdyyVp/Pr1RNthl7dAF5N5o5zc4MgNYOSl1it/jymNFPpwK9+GDUNEvojzakQ UeuMovaZZHfg0XH/ZqdIYYiNrPgybNGBn9VLGU668eKHEr4sTqqiB+VN7W05bBoxAA KjZtzDt7tFmLVPBSxNTfbq/F1EjIe6N8B+PY3upnTTvyUdV/1Bh4jqojVTZDVNmC7Y 5+ja/GxxhRE3UpQBrE7kwxdKlwC5GiMVhHwZLMZMUmjIcTuNHo64u3uj4EupSdCosR ygsHSp+fnHPvQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC8BA679A6 for ; Fri, 5 Sep 2025 11:01:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091712; bh=wc94aHquXnXYsAhyYnaYd9cy/iK4z0/dxlEH79xu2UA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w35CWbUjI+c1orwdi1RZ6Fh4c+h9Pnhc/OsAh1sf22jRSv9aPbXEjVU5IYN+I7Xmc vqt6QFbA9KyBKS9jjGpBxKMIqcR6zv0vDTJxgWFrF84X8VH8bZieVX7H2pVLpUJiAO 0i+eLL7vI6NBqIe7N7kUTz7YhhY8paWDRGu3q83hSsE541YlNfapKHbOgZCh7uRrix o0lT5pNzz1UKpPzt6R2EA4XSEiOiVEQCHE+ZTg7dMA1/0ho8UVk2FRgCX/rylU/wOQ nnKkqUAKhUP64um40LOQKXhinCmkz6likBu0O1jo6IYZdQXrxP2KvulR6NaAIlPgGs 3/SYlB4JQjcTg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D35A0679A6; Fri, 5 Sep 2025 11:01:52 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id EvP0IvK207Rq; Fri, 5 Sep 2025 11:01:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091712; bh=4lFy2a+TLelLEh2/HicmBv3z1aL1LI/3AUk0jxl1g7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqWNfVMsB1C6PFHdSCe3Srb/DkDaV5r780q4v5I4ddJrBFR59Lneh4yy0LzxGRaV1 6c9ACyUU25Gmx9FWJEMFsyFAF43SRLxPzkXT39iRP/dgK2v+K1+4kuUXaXbiiX61f7 andzbAZCcqH2LR7i3EOsQJs5L6pGzAxHdRJGTatcisjQIIEn227PQZa4pF5vT66PDr /RYvxEZ3OP3I+pq2fbXLqn/tGiAQYvasMsBbczH8Z2RCVb04hUo9GKCXFIyEbfaS+e KizTuCqyMf5rxMgmX/PZJOwIFXxeyajVPN4ish3GOO3sJ3pOj4Iw7ZaHi0fP8YC2aZ gKoyb5laPmMiA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5FAD2678E6; Fri, 5 Sep 2025 11:01:52 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:14 -0600 Message-ID: <20250905170132.182249-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RYMTBBJAQIQVDNNZ5373SYF4E7BRPLJS X-Message-ID-Hash: RYMTBBJAQIQVDNNZ5373SYF4E7BRPLJS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/15] ulib: Disable console messages List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass By default U-Boot shows the console settings on startup, e.g.: In: serial,vidconsole Out: serial,vidconsole Err: serial,vidconsole These messages are useful for the user but not for an application using U-Boot as a library. Disable them. Signed-off-by: Simon Glass --- common/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/console.c b/common/console.c index 2073a9878a5..77f70588488 100644 --- a/common/console.c +++ b/common/console.c @@ -1301,7 +1301,7 @@ int console_init_r(void) done: - if (!IS_ENABLED(CONFIG_SYS_CONSOLE_INFO_QUIET)) + if (!IS_ENABLED(CONFIG_SYS_CONSOLE_INFO_QUIET) && !gd_ulib()) stdio_print_current_devices(); #ifdef CONFIG_VIDCONSOLE_AS_LCD From patchwork Fri Sep 5 17:01:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 241 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091720; bh=S+yTzEh0+2bX5MpOD4RDsoTsewLD6/opZg9nhHsfu8o=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=t3D7iaBAYSYiNT0mAWyrJ+tw61SkHtLgPx8Cu9uGsronvLcmTsw8UTBc1Na/xAG1P mOG6kfRKroJpHkW5zOjf9Jy5nN9jhHockKOwHoS4ESHbL8kBBk2MdxQw5pWhzLcD7t 5XuvDSOr/jyMHoOki2LSvxhvOLocTp1g18cu+8ZsF9tvYVfMnwndRQNJX9U2eCaaLN /9XfFIaHfmumpU7KJvwR+Xra4OHkF/bBRrnZ0/vBqiiPLByDzHahhF+ph+JCXf9TDe yGyOoFInJeXY2ft/OO9+pGE0RGwYjwxjNBZMFvDZRa1yaCI9UAtLVnnQKb0y0BfSEP CdmYl1ayq40ag== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 53FCA679A8 for ; Fri, 5 Sep 2025 11:02:00 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 8p-AAwjwyPjS for ; Fri, 5 Sep 2025 11:02:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091720; bh=S+yTzEh0+2bX5MpOD4RDsoTsewLD6/opZg9nhHsfu8o=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=t3D7iaBAYSYiNT0mAWyrJ+tw61SkHtLgPx8Cu9uGsronvLcmTsw8UTBc1Na/xAG1P mOG6kfRKroJpHkW5zOjf9Jy5nN9jhHockKOwHoS4ESHbL8kBBk2MdxQw5pWhzLcD7t 5XuvDSOr/jyMHoOki2LSvxhvOLocTp1g18cu+8ZsF9tvYVfMnwndRQNJX9U2eCaaLN /9XfFIaHfmumpU7KJvwR+Xra4OHkF/bBRrnZ0/vBqiiPLByDzHahhF+ph+JCXf9TDe yGyOoFInJeXY2ft/OO9+pGE0RGwYjwxjNBZMFvDZRa1yaCI9UAtLVnnQKb0y0BfSEP CdmYl1ayq40ag== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4487567999 for ; Fri, 5 Sep 2025 11:02:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091717; bh=kAevqqPtnlt4wpr7hdvFuuq+/Go3tm2R8M1jyaJzkus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r1P2ocmtuJV3JSTFDHevfFeNeyXnXleQHWPEN2gk9mw/mKkW5MKsN2SYqHnw2n/KO nunaUFJpkH6DfBcWTAmGm3aLJB7UMY6r/j2N/L5/9hkpP4C39b2ALqfqpJRYUjG2/k K02nR/hVxhFsges6mPnXdSnryYVvgTjo3JBe07yF9ZhXJkX+m+VCGjunQtoLWvOFoK isHPWbiZ8L3/eC782fWq4t3VLG+UGjLd6TdpaU1WB8Q294dTtR6DptKx7T1sYVCA8G Sjyapb+RFHshcCrv7bEgwWWz55XCEE273fvQXoBlozG62HED3O2eJ43L1lrAalBH1I tn1FuYrfAJsvA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6ACE8678AA; Fri, 5 Sep 2025 11:01:57 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 35gwio4KcUPu; Fri, 5 Sep 2025 11:01:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091713; bh=qvrf8tppqqjzycR1N2eYCQsAbB8trxlMqn8yk6K/tns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRU8yRWdbTHS43ksNzLbNIFtV84yNqDYyvUahovKEs8qB2CCiGx60fh8dfd6jMzAf JyU2pnWdlJyJB2PXkLnQ/Y9tdylIVIOX6o2rUqigVB5GYHaWHpTkJe8N7B5V6Q/mRi CxuY6XUxaD5kkkF9zkITqzWTZ8oBuRrn7x5MCtt+MUcAZ4aXbrk5T8K8WW4I4qUzpM YE8puCKfVKX8lvqd9QPFTertd1Gsu/NeXYIhSsLnSLyVl3AvR+I/NoSPYe8G7HLyq8 noKnz/tEQCn0SL5MTSDDmP+BXCCVZk1bE3eomUklLZWsvi4QcEyz0kMLhkFQQwEY32 zenKmtS/CFAjA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2510E678E6; Fri, 5 Sep 2025 11:01:53 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:15 -0600 Message-ID: <20250905170132.182249-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2AVEMLR5A5YQYPJL2YFCTOCQFWTUOOZL X-Message-ID-Hash: 2AVEMLR5A5YQYPJL2YFCTOCQFWTUOOZL X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/15] ulib: Disable network setup List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The application may not wish to use networking, so avoid setting it up and the associated console output. Signed-off-by: Simon Glass --- common/board_r.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index 22506effae6..a19c3138962 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -458,6 +458,9 @@ static int initr_malloc_bootparams(void) #if CONFIG_IS_ENABLED(NET) || CONFIG_IS_ENABLED(NET_LWIP) static int initr_net(void) { + if (gd_ulib()) + return 0; + puts("Net: "); eth_initialize(); #if defined(CONFIG_RESET_PHY_R) From patchwork Fri Sep 5 17:01:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 242 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091722; bh=gyFkL/fGaDzT6/Zbv7sV9TW9eZzzrk+b958C4fl2YN4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=L4jX/qwqLBJkegaVNCxv2TaNP56v84KSO9jjraVvU9nolYy064bC5VPyv1D9G1FRV tm0x3PCxYJjHWODcbj1zCvJtEoOCae+4Jr+YmTTtTw/hfH2xobxMO6krAqH4E+K2o5 +zbLzz6tGvg26q2jciC3fR1Je789PTSLMFPG3rSPTQ7REM/DyEtccn+bRJ1/u/2ln9 UzSMxVIVGw0U+udKK7n3+wuRTEwrP2wB3bqlxfXJZQPtRRYiYxC15Qsa8wsGzXBt/t fYXWXGYDfRswFbh5TSJ1+nXOqjX87SFwrBatmXwy+lyf3N6WO6fuqAeoaBEUC+FW61 TB/OVJqgpVTxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 937B3679AC for ; Fri, 5 Sep 2025 11:02:02 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GnXZvyIn6SWN for ; Fri, 5 Sep 2025 11:02:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091721; bh=gyFkL/fGaDzT6/Zbv7sV9TW9eZzzrk+b958C4fl2YN4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ax3ktGm2jRXiyjVJNr87vHOFMMAW1XLZkxraBowvYuDDnYWOS7fbmAms3RZ0VXQwl 7y+RIK8q0wIKUjIrGVIx0KddoUwa1FXWkm6DI3gfE6rjEOGcrVQ0Z41P5XrKt6AgNt gNTQOYW7FeRdyzf1KPn+mIQBYjxnUwd0IdfS8Rit1UCc7qAGq7orbg4tvmIMy1vQJZ RQx8ff3bhJlnwCmj/eZ4CBuPbT2xvODQ+eo0aoYtAPHUneXmj/FDHm0QIQCr2psjAR xZ67/CKTd0zgZx4iwQrHeMDkd6oHBvwlfX1+t0JNEcUN/LeDxJJK1zEKHQHxYK5SJI heIC60gMtmjFg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 932A1679A6 for ; Fri, 5 Sep 2025 11:02:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091719; bh=uKkVr6E8M6gZvX46nUlxAd/fd1CPAVodJgdPEZ6g+QA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gyIJ1I291LgZyG1clPubD8uttLO+VCwWuGFN07UIxXONx7/p4EoABQKizMvgxhK4b DlB9RG7CH4UhcRlIX+MayZhPolIa/5X22wsbZuk6H6UZ0qYPXAQ6fF0iiRvX+s6PPF VIRNokLQ8if64mJanPeejE9vFeeM+VGG83/JartoF2nhPk/Yxj5QXVHYM5SFbQQSfv VNKh4RK2IRx2V/GMoe7UfKM4Pc1+wSNvLT7PnmGJYUzabVUD/q4jiE84gbrY3xXRF0 jlcNO1lJW98/FpEtDRTIHTR1TMPUFfAR4P/KE9LDbVWSqfpI0V+CQtUQ6L6BtTLeFp 2jh3oNO5QzpHQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8279B678AA; Fri, 5 Sep 2025 11:01:59 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id U533n8twD9XP; Fri, 5 Sep 2025 11:01:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091717; bh=Nz1X26ZUyKoC+i7O0GK4kqtvIS7Sw3Un9I54bfPKMQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VO0s9LbQSWw8wv3GFGQJI4lm+sYyooMeLWgavQrNdepZibCAOWG973TFcHMd3j21x MPkWA0HnFijQBgUGDFa9B/NYDXK+luBGfUNCx/9FKoQZ7eYCVUq+P8lO/4uw45okNk RTfNNW16wSPHUlIbgqmAytBkMifUt7JnRbW6WRsL6KXLKZ2coBkC0BtNWn04zSWo8w 4zCZ/U7z6FzIJb4u3NEwDtyYu0XJI5F/kQizx8yELOycfmYHlYboGz7AIWjFUFtVAq GtVlIBiDeB6tahb0/RjdPxr2dG0NzHq4F+O+zMu9QyjcqFgriak4l/A5SFB5ZogLbw Q3vBEeyWIfuRg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B0313678E6; Fri, 5 Sep 2025 11:01:57 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:16 -0600 Message-ID: <20250905170132.182249-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KMYB7AU3GUIUVCR6S4YNSYJBHMZJ75TH X-Message-ID-Hash: KMYB7AU3GUIUVCR6S4YNSYJBHMZJ75TH X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/15] ulib: Disable the main loop List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The application wants control once the U-Boot library is ready, so skip the main loop and just return. Signed-off-by: Simon Glass --- common/board_r.c | 8 ++++++++ include/init.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index a19c3138962..d38c2304e87 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -539,6 +539,9 @@ static int dm_announce(void) static int run_main_loop(void) { + if (gd_ulib()) + return 0; + #ifdef CONFIG_SANDBOX sandbox_main_loop_init(); #endif @@ -768,6 +771,11 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) initcall_run_r(); +#ifdef CONFIG_ULIB + if (gd_ulib()) + return; +#endif + /* NOTREACHED - run_main_loop() does not return */ hang(); } diff --git a/include/init.h b/include/init.h index 2c37cef5fc0..e4b07ea48a0 100644 --- a/include/init.h +++ b/include/init.h @@ -277,8 +277,12 @@ struct global_data; void arch_setup_gd(struct global_data *gd_ptr); /* common/board_r.c */ +#ifdef CONFIG_ULIB +void board_init_r(struct global_data *id, ulong dest_addr); +#else void board_init_r(struct global_data *id, ulong dest_addr) __attribute__ ((noreturn)); +#endif int cpu_init_r(void); int mac_read_from_eeprom(void); From patchwork Fri Sep 5 17:01:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 243 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091727; bh=FscKGu6tjskmx+y38c7c5wqq6mzrOcufy/bwX1neOp0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=qID+WfWLgkz2Myzg+buE2qn+VnpigNkGJRsrYxOKH/9GN1Sh1KS3UhVlTTR+gwCIf UAMHTo+D93aFgqEU9uwfFESVdI0GXXEXp0M3PEQH/Xss4WvimAYDqQtvcz/7X3wpil X7pvfeXMA+qTSw1ujo6r3t4lIa6Q72+T1g0caSx2en9UB6nGWQgsdPFLbDgShclBTz dcr9wgPuPzpq8LdWm4GpwSlwNxDvd0qlcUNJoyoqXomGlOkZEEEC+n9uGDWN+OvMQT sqPtCunjFXNzsrN6xybsEaRe7q5JcW9uS5LtpI1pHS9CSGuUoYrJXVUPI8zHHdsz8W ksgQO+h/X1wiQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 06DE5678AA for ; Fri, 5 Sep 2025 11:02:07 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id E23gVoHcWizf for ; Fri, 5 Sep 2025 11:02:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091726; bh=FscKGu6tjskmx+y38c7c5wqq6mzrOcufy/bwX1neOp0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LIxtTE2W7yOhI3L7oeJ+BiU6xutCjc18ako2kjH9cdKTeDw2dJU1wZOrvljkePjEG I4lJEKotE/Ihi8NfmAmVtG2rfguWMsQvi0b8T52payrEPTg+3Em/1nFUIGL3iCgbCi OFviuic6+qlD8poDZlD7tYJyCd20kEQf0pnz0S8jt7ZwDzSm1txbKCBdMdRI6F86lm W03SrvGL/yTlak+fTWP5sVemhYrLH8qp5NLn9K8dsl0k2/nZNRSrhgyKIK+MJ0xyFg tUnLJPAlUoNa02bNaH8t16OZakPRxLB8Xd3yFMA+kJGGz6iBeEF6iAYHMTo5SReLA1 En6GJb6VYxeXg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA2B4678E6 for ; Fri, 5 Sep 2025 11:02:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091724; bh=sKhmdoLNzNRKEAKJgNUb/r6SOQXoiwjyUAB3xuniQ+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=boYty7qEGamu+xvV5GY74LnuqkCay4SwlsXMxfC6D15wQ3TYWyfajnEfkWW8IL+iX xpZaT/HdeBNygKB7qYK2s34P8/wpuQTL+WitN/VN6oeGQ0IlyVmbRN5LPT0w2OvPbC 5TkiqXlXFDnBZZL8/9yimGHL4O5GnjMp2tqcgTIE8lCBD869DzK5f055eeWknFPq7Y ioCNWSrGD7jbbX8zk5yKNVSFA0hxm2SsC4gb5iQg7xf5Yl0Bjsm3xyxPScJTyAZUxz 4/LQeSqUqhxvKetK2Tz6Otvbx/EdDtyiLRr50BIWf09sOMFt1YKWG0R1D8cg/YeGBy MjE4mHSrgPn3g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CCE61678AA; Fri, 5 Sep 2025 11:02:04 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Ltthy0jyitYk; Fri, 5 Sep 2025 11:02:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091720; bh=cxzOp2mIBr6y+KTbaOIBNfCb01fwCMnuQlrki6fCDas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bc4oP2aVar77ds0zLx4aEeGgvCxGAlLHj6rptsjGPpLXVfkQvp80dgLB10Sj7xSDt acxUd6x8SWbWFO/sY1dkULAUfcRAAq4BsOJLdHh7725I7PeJJeR2jwq5K/p2t5ToPr MsVgFnVCPWJPi6CgUaedB80WC7P5iQ8m+IRzAaAmiEtwtU4mU1rBw3f2tw9dyWTPlq /+NSgOvrsb0NmUYx7AgJcyK7K40nHW3sIayyIrNhBryyywsY2RQhoPTTdUUFNHO8Ow Y4EhHCvp+08crPn60XpwIW1Xh3YhOJaDH4b1XamVbR4dDx48TcRdpN+IXpImuuUQ50 Fbe2nigXzGUcw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C8599678E6; Fri, 5 Sep 2025 11:01:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:17 -0600 Message-ID: <20250905170132.182249-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2TI6ZAXJ7KPOGHMXWH3NJZSAMOTSEJI5 X-Message-ID-Hash: 2TI6ZAXJ7KPOGHMXWH3NJZSAMOTSEJI5 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/15] ulib: Move struct bd_info into its own header List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass This is currently in asm-generic/u-boot.h but it is no-longer the interface to U-Boot in any real sense. It also doesn't include assembler so having it in asm-generic seems wrong. Move it into its own header. Signed-off-by: Simon Glass --- include/asm-generic/u-boot.h | 52 +-------------------------- include/bd.h | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 51 deletions(-) create mode 100644 include/bd.h diff --git a/include/asm-generic/u-boot.h b/include/asm-generic/u-boot.h index 8c619c1b74a..1792165c6fa 100644 --- a/include/asm-generic/u-boot.h +++ b/include/asm-generic/u-boot.h @@ -15,56 +15,6 @@ #ifndef __ASM_GENERIC_U_BOOT_H__ #define __ASM_GENERIC_U_BOOT_H__ -/* - * Board information passed to Linux kernel from U-Boot - * - * include/asm-ppc/u-boot.h - */ - -#ifndef __ASSEMBLY__ - -#include -#include - -struct bd_info { - unsigned long bi_flashstart; /* start of FLASH memory */ - unsigned long bi_flashsize; /* size of FLASH memory */ - unsigned long bi_flashoffset; /* reserved area for startup monitor */ -#ifdef CONFIG_ARM - unsigned long bi_arm_freq; /* arm frequency */ - unsigned long bi_dsp_freq; /* dsp core frequency */ - unsigned long bi_ddr_freq; /* ddr frequency */ -#endif -#if defined(CONFIG_MPC8xx) || defined(CONFIG_E500) || defined(CONFIG_MPC86xx) - unsigned long bi_immr_base; /* base of IMMR register */ -#endif -#if defined(CONFIG_M68K) - unsigned long bi_mbar_base; /* base of internal registers */ -#endif -#if defined(CONFIG_MPC83xx) - unsigned long bi_immrbar; -#endif - unsigned long bi_bootflags; /* boot / reboot flag (Unused) */ - unsigned long bi_ip_addr; /* IP Address */ - unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ - unsigned long bi_intfreq; /* Internal Freq, in MHz */ - unsigned long bi_busfreq; /* Bus Freq, in MHz */ -#if defined(CONFIG_M68K) - unsigned long bi_pcifreq; /* PCI Bus Freq, in MHz */ -#endif -#if defined(CONFIG_EXTRA_CLOCK) - unsigned long bi_inpfreq; /* input Freq in MHz */ - unsigned long bi_vcofreq; /* vco Freq in MHz */ - unsigned long bi_flbfreq; /* Flexbus Freq in MHz */ -#endif - ulong bi_arch_number; /* unique id for this board */ - ulong bi_boot_params; /* where this board expects params */ - struct { /* RAM configuration */ - phys_addr_t start; - phys_size_t size; - } bi_dram[CONFIG_NR_DRAM_BANKS]; -}; - -#endif /* __ASSEMBLY__ */ +#include #endif /* __ASM_GENERIC_U_BOOT_H__ */ diff --git a/include/bd.h b/include/bd.h new file mode 100644 index 00000000000..5fb52e26c31 --- /dev/null +++ b/include/bd.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * + * (C) Copyright 2000 - 2002 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + ******************************************************************** + * NOTE: This header file defines an interface to U-Boot. Including + * this (unmodified) header file in another file is considered normal + * use of U-Boot, and does *not* fall under the heading of "derived + * work". + ******************************************************************** + */ + +#ifndef __ASM_GENERIC_BD_H__ +#define __ASM_GENERIC_BD_H__ + +/* + * Board information that used to be passed to Linux kernel from U-Boot + * + * include/asm-ppc/u-boot.h + */ + +#ifndef __ASSEMBLY__ + +#include +#include + +struct bd_info { + unsigned long bi_flashstart; /* start of FLASH memory */ + unsigned long bi_flashsize; /* size of FLASH memory */ + unsigned long bi_flashoffset; /* reserved area for startup monitor */ +#ifdef CONFIG_ARM + unsigned long bi_arm_freq; /* arm frequency */ + unsigned long bi_dsp_freq; /* dsp core frequency */ + unsigned long bi_ddr_freq; /* ddr frequency */ +#endif +#if defined(CONFIG_MPC8xx) || defined(CONFIG_E500) || defined(CONFIG_MPC86xx) + unsigned long bi_immr_base; /* base of IMMR register */ +#endif +#if defined(CONFIG_M68K) + unsigned long bi_mbar_base; /* base of internal registers */ +#endif +#if defined(CONFIG_MPC83xx) + unsigned long bi_immrbar; +#endif + unsigned long bi_bootflags; /* boot / reboot flag (Unused) */ + unsigned long bi_ip_addr; /* IP Address */ + unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ + unsigned long bi_intfreq; /* Internal Freq, in MHz */ + unsigned long bi_busfreq; /* Bus Freq, in MHz */ +#if defined(CONFIG_M68K) + unsigned long bi_pcifreq; /* PCI Bus Freq, in MHz */ +#endif +#if defined(CONFIG_EXTRA_CLOCK) + unsigned long bi_inpfreq; /* input Freq in MHz */ + unsigned long bi_vcofreq; /* vco Freq in MHz */ + unsigned long bi_flbfreq; /* Flexbus Freq in MHz */ +#endif + ulong bi_arch_number; /* unique id for this board */ + ulong bi_boot_params; /* where this board expects params */ + struct { /* RAM configuration */ + phys_addr_t start; + phys_size_t size; + } bi_dram[CONFIG_NR_DRAM_BANKS]; +}; + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_GENERIC_BD_H__ */ From patchwork Fri Sep 5 17:01:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 244 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091731; bh=Tn/F3KUgjrxuhaVfqfutd+8vtDjDHwv0Ad3avDSpY0U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XBqT3eCWKlWU2qDh4aABxcphll8k1kU+vesubeYj/Le/VGrLVQgi6d2Pe6sAZENGS FDbmgrOxqFLkRx5dvFxxukgWdUKv4S4LWQpmjkVie1mAIwZMpo7QcG2KGUPGrJhUK/ 7GhioamHlVcOrp7WFQqI79DxW403NVgLbCw4Rlds0rqGJSTCLTddjs96oJNpfBzTtR hg9q7MtmwUUwcgS5Cw6gGfq265z9c9f+2dT24ZWwlHapol1kOWT0NfL7VTarPDvqmf KPrBj+a6SwT12uZXrCSr9LVwHSbOATTdbA8635NV+vYmhNavlJ8YANuUUVDydzv+UI O0OdbkVNAQYpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4F111678E7 for ; Fri, 5 Sep 2025 11:02:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Kymzh2tIJzCD for ; Fri, 5 Sep 2025 11:02:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091731; bh=Tn/F3KUgjrxuhaVfqfutd+8vtDjDHwv0Ad3avDSpY0U=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XBqT3eCWKlWU2qDh4aABxcphll8k1kU+vesubeYj/Le/VGrLVQgi6d2Pe6sAZENGS FDbmgrOxqFLkRx5dvFxxukgWdUKv4S4LWQpmjkVie1mAIwZMpo7QcG2KGUPGrJhUK/ 7GhioamHlVcOrp7WFQqI79DxW403NVgLbCw4Rlds0rqGJSTCLTddjs96oJNpfBzTtR hg9q7MtmwUUwcgS5Cw6gGfq265z9c9f+2dT24ZWwlHapol1kOWT0NfL7VTarPDvqmf KPrBj+a6SwT12uZXrCSr9LVwHSbOATTdbA8635NV+vYmhNavlJ8YANuUUVDydzv+UI O0OdbkVNAQYpw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F5186790F for ; Fri, 5 Sep 2025 11:02:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091729; bh=ftW7rUFjrwYTxWXyUDmqEZSYUuDK+DBWXAkleG6K8K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z69aVHODef3pBrkS9glodAyQpud6gCBWxESfDVs8qhAvU+6gHCTjyOono4oOXfaTT Y2/AL8ond3TqtrOPBl8EW35QbA+d9f7J0ef9srqeoOCvB9OJazqjnugt3uF8wL9lDt VQC9u/aPE6ixZdJPJ4+XejqQKcEr/ChbxHGqQb2dNqTKlzeFCiCGzG7hUV89JHQYTm hK3FooLvP3veVAxG4l3cxAPMGIf/hncIB4fgACafav1+vud+NOROEIZr7aOHhWOdyA y4FZN6L+POHPMOAGShYDm+mVssbgED1J/+s+tDxZIW0WNoii8ktB4Cn++wZ4s7yOSq c1F6x9xBbMjpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46222678E7; Fri, 5 Sep 2025 11:02:09 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id VxMu4p-nTxkT; Fri, 5 Sep 2025 11:02:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091724; bh=80aXgAYDyYYdY0+JEtJdBfHiWI+AHTCmvQzCXHoLkOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLQ/uYoEaNI7bihTS0qswdpP0+JsQbh4n5YpIRM7z+elj1b/Y6jPHcr5xPm/jE3C0 6KICYhLEFXeGDVHUYIVBg03J7C1gXh7WHIeNlhNgVsRGq+V6qFI5m54orgnHlx31xg 41MTd13BueNPzO+y5JP3YQ90PHAVNVT8R6ZakT/fivSdJRHOldt0s4AZpSTuReYqAx j4d8P0ByfTx3v0Q4/HJ6AqXo+z9ZzewC2chbzwa51tjhWeg3rE5E2SgYvIjRFwfK1J f5Tpf/1T7tuvcEUsmrNxDbwBOC2ci5QxJ5HGRcDSnncrLGNPlug7o67MiJUItZyfbH JSCdaCr4wq6zg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6E39E6790F; Fri, 5 Sep 2025 11:02:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:18 -0600 Message-ID: <20250905170132.182249-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QQN6VBL7Q535NLX3TQXS6NY5WIT6XI3G X-Message-ID-Hash: QQN6VBL7Q535NLX3TQXS6NY5WIT6XI3G X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/15] ulib: sandbox: Move the linker-script name into config.mk List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Each architecture will have its own version of the linker script, so use a Makefile variable for it. Signed-off-by: Simon Glass --- Makefile | 5 +++-- arch/sandbox/config.mk | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7011535bb2f..1a378ebbee3 100644 --- a/Makefile +++ b/Makefile @@ -1856,7 +1856,7 @@ endif # Build U-Boot as a shared library quiet_cmd_libu-boot.so = LD $@ cmd_libu-boot.so = $(CC) -shared -o $@ -Wl,--build-id=none \ - -Wl,-T,$(srctree)/arch/sandbox/cpu/u-boot-lib.lds \ + -Wl,-T,$(LIB_LDS) \ $(u-boot-init) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(SANITIZERS) $(LTO_FINAL_LDFLAGS) \ -Wl,--whole-archive \ @@ -1865,7 +1865,8 @@ quiet_cmd_libu-boot.so = LD $@ -Wl,--no-whole-archive \ $(PLATFORM_LIBS) -Wl,-Map -Wl,libu-boot.map -libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) FORCE +libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) \ + $(LIB_LDS) FORCE $(call if_changed,libu-boot.so) # Build ulib_test that links with shared library diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 405843800e9..566f5b417ae 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -69,3 +69,6 @@ EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds endif EFI_CRT0 := crt0_sandbox_efi.o EFI_RELOC := reloc_sandbox_efi.o + +# U-Boot Library +LIB_LDS := $(srctree)/arch/sandbox/cpu/u-boot-lib.lds From patchwork Fri Sep 5 17:01:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 245 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091736; bh=IqDDdO7OegmYJ9XapAZsNj0Xdk36hGmzuj5quXR5g54=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eQFIyPR0uLguQtD7WL9XrgjgP/acfvbZcQ9b7xvXHQmQAkW2xBIB565Ng20IqlZvc BJxD0L4Ox0zITi88oCXO0gvx/8KS7bR9LgczcSyimmI+mcOoGg2GvyURkx5aFFjUhW yppVfTYpJJTEdZIDUgW6tLlM72VyPYrWAFqgE7mgE6Iyoci51h3Rh3FS8Wm/evSwfC Fn8qlmIIKe3+uTFXdqTKHxInfDTVZHXl8qJIw6HCCdRRW5moRwiF7UoO4yYOGV7r7S feJXfzuJy02zsztaXSV742g/q7BohiTp67XO0+0o6PBomUQLi4prQBjbC2q1SevSxa 6ZsCM6RbXIwtw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A071F6799D for ; Fri, 5 Sep 2025 11:02:16 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VzOLYf07JFEK for ; Fri, 5 Sep 2025 11:02:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091736; bh=IqDDdO7OegmYJ9XapAZsNj0Xdk36hGmzuj5quXR5g54=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eQFIyPR0uLguQtD7WL9XrgjgP/acfvbZcQ9b7xvXHQmQAkW2xBIB565Ng20IqlZvc BJxD0L4Ox0zITi88oCXO0gvx/8KS7bR9LgczcSyimmI+mcOoGg2GvyURkx5aFFjUhW yppVfTYpJJTEdZIDUgW6tLlM72VyPYrWAFqgE7mgE6Iyoci51h3Rh3FS8Wm/evSwfC Fn8qlmIIKe3+uTFXdqTKHxInfDTVZHXl8qJIw6HCCdRRW5moRwiF7UoO4yYOGV7r7S feJXfzuJy02zsztaXSV742g/q7BohiTp67XO0+0o6PBomUQLi4prQBjbC2q1SevSxa 6ZsCM6RbXIwtw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FE17678E6 for ; Fri, 5 Sep 2025 11:02:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091733; bh=gJHq+1uMrKQtFSeMUFKDIAp34DppQ+IUjx3cI5zbKpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYaFJPBMG57P1ttaQA1XOOmpAtWCqeeF+IcRE9qHHFU1spmJiiHeA806v5GKitM9y AlNQNue9A0sTYbGdORIJGE3shmK+poiZ40Z7EOmGayJNWnJZGQzvUj0Mx8dXuAs+wS NYEw1QyMjSFihPsMheesaeA5lAXOTFlq2AF4MKQbZYj4FzZyAp+KIk3pfmnB21zH5u BLCMP10je7CIjVOFiAoR6P1iW80xAz5kky1lHCugYiULTk6AbKFTa0+r6ECeJGicxR DPEgKS0FpL/NzIf4FSljBGtq+EnhRbi99Zzm9Tewv0Kf1RNKK3GyaAXqgIQpb3Xbm7 pfdDhKmHeo7jA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 92BC7678AA; Fri, 5 Sep 2025 11:02:13 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id R0DMm99EDtEP; Fri, 5 Sep 2025 11:02:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091729; bh=OVxyuJNZuO2SivfnMB5T8VA7Lexz25rPZ2xPrH0NNr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cEtOVnhnxisC1+JlL00a6l5Wehqu4o0rV9X6GODEFWx6paePnCDDVv4UzBXO+IXtY wAv2AoWdwBRcgqaoB/Ow4s3MGa8ZftWsr6Cej2aM6RyjXx7EGxQ9lnPCxFeu7QA+ak 0Wn8De6iJ/fBsqMT8BmboifO2p37A7MomaNbnx04CYgrkRdUv7fkS+CVj2aG/MvqAH GLKiR1KIfKFrO8BTPG4A1H4ep81IQUn1wbS2gXfb0MjcCoL4pX+7wKZqsO3gI70hxy gi/gTG/aGgFCMXmacuw/P92fXrV7YukNiPI9nc35fkD0aCuXq00HNTo5hxCqGk6Bt+ BpTm5ecZMMEmA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 259AD678E6; Fri, 5 Sep 2025 11:02:09 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:19 -0600 Message-ID: <20250905170132.182249-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Y24DTZULLPEJSAUR5YVRC3XYHHOMRKGW X-Message-ID-Hash: Y24DTZULLPEJSAUR5YVRC3XYHHOMRKGW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/15] ulib: Add static-library build support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Sometimes it is more convenient to link an application directly with a static library. Add build rules to create libu-boot.a as a static library alongside the existing shared library (libu-boot.so). The static library is a fat archive containing all U-Boot object files except for arch/sandbox/cpu/main.o since it contains main(). A temporary thin archive is used to collect all the objects. Co-developed-by: Claude Signed-off-by: Simon Glass --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Makefile b/Makefile index 1a378ebbee3..bf571de9f06 100644 --- a/Makefile +++ b/Makefile @@ -1046,6 +1046,7 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ ifdef CONFIG_CMDLINE ifneq ($(cc-name),clang) INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test +INPUTS-$(CONFIG_ULIB) += libu-boot.a endif endif @@ -1869,6 +1870,20 @@ libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) \ $(LIB_LDS) FORCE $(call if_changed,libu-boot.so) +# Build U-Boot as a static library +# Create a fat archive with all object files (except arch/sandbox/cpu/main.o) +# Avoid partial linking so as to preserve the linker-list sections +quiet_cmd_libu-boot.a = AR $@ + cmd_libu-boot.a = rm -f $@ $@.tmp $@.objlist; \ + $(AR) rcT $@.tmp $(u-boot-init) $(u-boot-main) \ + $(u-boot-keep-syms-lto); \ + $(AR) t $@.tmp | grep -v "arch/sandbox/cpu/main\.o$$" > $@.objlist; \ + cat $@.objlist | xargs $(AR) rcs $@; \ + rm -f $@.tmp $@.objlist + +libu-boot.a: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) FORCE + $(call if_changed,libu-boot.a) + # Build ulib_test that links with shared library quiet_cmd_ulib_test = HOSTCC $@ cmd_ulib_test = $(HOSTCC) $(HOSTCFLAGS) \ From patchwork Fri Sep 5 17:01:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 246 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091742; bh=5qHNwVxCCuFIppmFmO1nLzdu3yn6STf4lb9Qi1zLsGY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sfGoVyVfIjy5HoCSABVjtNIhUAMjHHZOWzSjLLuMpJDlxdgq1FQo04wn5egbk2qKq afiscNmWjLgO03lFKSrfs3GYeJCziMfjZ+uEl7bPB4qgh2f7zSeBWXFg4y3X7jBkE6 LCXpRNxM3PjE9RLwQTPu8lBpFe8BpkiLg8gAccmaSY5yDX95bqzJzLpYRSlxTLzCLl P9hfaExfzAIuWQjwbjbFxNNuSpqX+vs8ja2gXmlUB+jKBvP/vMgs3bVlhqGMOzokQ6 AYP7eUsuxkz+6Fe0/inEOOg8YiBVLPnJ2FlxBplmkyKWe55v0z8LPPgsMjb+HErK3E KfUIHiSXk/jzw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F3B5F679A8 for ; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rPhjI7gSstq7 for ; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091742; bh=5qHNwVxCCuFIppmFmO1nLzdu3yn6STf4lb9Qi1zLsGY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sfGoVyVfIjy5HoCSABVjtNIhUAMjHHZOWzSjLLuMpJDlxdgq1FQo04wn5egbk2qKq afiscNmWjLgO03lFKSrfs3GYeJCziMfjZ+uEl7bPB4qgh2f7zSeBWXFg4y3X7jBkE6 LCXpRNxM3PjE9RLwQTPu8lBpFe8BpkiLg8gAccmaSY5yDX95bqzJzLpYRSlxTLzCLl P9hfaExfzAIuWQjwbjbFxNNuSpqX+vs8ja2gXmlUB+jKBvP/vMgs3bVlhqGMOzokQ6 AYP7eUsuxkz+6Fe0/inEOOg8YiBVLPnJ2FlxBplmkyKWe55v0z8LPPgsMjb+HErK3E KfUIHiSXk/jzw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E43CE67980 for ; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091738; bh=/LupZRUhu+4Wtl6WxVDatGoaZmbNiv6t8SRb78XR6YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BwmudXfI8BPvnVyBiHn/httmrvou8ymRcCDvyx4OGO4y7Tps6x7LKt5ibeCD1SMGu y+De6ghL0M69sM79Ex+VKa1ICmz4Gt/L89c7xFV4/qtd7AE3RRDOOUwn13YMK5oRSr lrQZMXDKqL4rckrDU3u53l4YqBLnhP1/2QjQU1093J1lHW1tu/MuvfjcMl6WuFgue3 xbh/1UuRxn0lLPUI4fK+0m9Ke5uwT5QfDDQZIWjS8Wm04Ck7xy2cgV91iAxSOHpFwG qLuFrjhpRIKrAoG6G02Bkl7Qo2a496U7pJfhNvw2H6R81K7UNnpHiGDptYFgFOWIjd HKV6Nt7eHcuKA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E089F6790F; Fri, 5 Sep 2025 11:02:18 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 9FmAU6hj64_E; Fri, 5 Sep 2025 11:02:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091733; bh=4AJpxLAsMxueEq/tVtvsGUEj9uT1ulLtt+q3YMvvVAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iO7XiK6nksXeJS26mFjWQcBgEMS3G23y6o70ZrffJmbLmi34Zc5aQ+2hym0vPbmYm hq6nYtTycOXCZihmKwvaO6PXQ1RN7zOmtTMO+1IgJZRejuRDHu3ajLSrZx48VFqkCd bzlnNS11oJEkfoCpyCeqyVJe8UzbMfyiESHLAqMX3vDcTJKkV/I5vJjaoqlBQwPqu9 MdPgn6iNLETARxc6CZflBMkDu+YKJW6x9LfPdx4Twa3AClplazbyMW1U9svId1srra zkfhF/7nFyJsiubLUXufY7SKYWREjTdjj43gwu3S1fXqLaaFzW8Rhj0byygKKzzDnb GCDQxtgVOjTKg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9300167980; Fri, 5 Sep 2025 11:02:13 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:20 -0600 Message-ID: <20250905170132.182249-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: USKT7N4IXIATIBYVBJXJDHBI3IF7M2BZ X-Message-ID-Hash: USKT7N4IXIATIBYVBJXJDHBI3IF7M2BZ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/15] ulib: Provide an init function for sandbox List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide a simple function to set up the library, to avoid having to worry about the details. This requires the caller to know about global_data Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 30 +++++++++++++++++++---- arch/sandbox/include/asm/u-boot-sandbox.h | 9 +++++++ test/ulib/ulib_test.c | 12 +++------ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 59682b039e5..556d1985ccc 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -693,13 +693,14 @@ int sandbox_init(int argc, char *argv[], struct global_data *data) return 0; } -int sandbox_main(int argc, char *argv[]) +static int sandbox_flow(int argc, char *argv[], struct global_data *data, + uint flags) { - gd_t data; int ret; - memset(&data, '\0', sizeof(data)); - ret = sandbox_init(argc, argv, &data); + memset(data, '\0', sizeof(struct global_data)); + data->flags = flags; + ret = sandbox_init(argc, argv, data); if (ret) goto err; @@ -708,10 +709,29 @@ int sandbox_main(int argc, char *argv[]) board_init_r(gd->new_gd, 0); - /* NOTREACHED - board_init_r() does not return */ return 0; err: printf("Error %d\n", ret); return 1; } + +int sandbox_main(int argc, char *argv[]) +{ + gd_t data; + + sandbox_flow(argc, argv, &data, 0); + + /* NOTREACHED - board_init_r() does not return */ + return 1; +} + +int ulib_init_with_data(char *progname, struct global_data *data) +{ + char *argv[] = {progname, NULL}; + int ret; + + ret = sandbox_flow(1, argv, data, GD_FLG_ULIB); + + return ret; +} diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 941f35f9e69..859c2f08b4c 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -75,4 +75,13 @@ int sandbox_init(int argc, char *argv[], struct global_data *data); */ int sandbox_main(int argc, char *argv[]); +/** + * ulib_init_with_data() - set up the U-Boot library + * + * @progname: Program name to use, typically argv[0] + * @data: Global data (must remain valid until the program exits) + * Return: 0 if OK, -ve error code on error + */ +int ulib_init_with_data(char *progname, struct global_data *data); + #endif /* _U_BOOT_SANDBOX_H_ */ diff --git a/test/ulib/ulib_test.c b/test/ulib/ulib_test.c index 621bcd49be9..e1e863712a8 100644 --- a/test/ulib/ulib_test.c +++ b/test/ulib/ulib_test.c @@ -23,15 +23,9 @@ int main(int argc, char *argv[]) printf("Calling U-Boot initialization via shared library...\n"); - /* init global data */ - memset(&data, '\0', sizeof(data)); - data.flags = GD_FLG_ULIB; - - ret = sandbox_init(argc, argv, &data); - - /* Do pre- and post-relocation init */ - board_init_f(gd->flags); - board_init_r(data.new_gd, 0); + ret = ulib_init_with_data(argv[0], &data); + if (ret) + return 1; return ret; } From patchwork Fri Sep 5 17:01:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 247 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091745; bh=rk1L11TJsKAzAS1Mug4LKYUIv0LzVLdWxwc+TJFCXAM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=On04XcFjr3p0TpKGuC129BeUiNwiiRybKoPq+yZ0kR+DusMLAFDNIrPf2nxpG71Rz TIGvxMzpBXXzUO9HF8o+V3GR91YGdhFjuqAQdhk/234eOimzFiymHB8s+wCYyvaKVa q6xC8nc+VbCFhNwBMY9gRk9qggWN0p37SNTXyFp/Qtz1PQq93E7NgBq6JDBPxU64oD FtzFfu5k8yGzcfAInlVQBcan2OfdljALzWAThk97fdpGqC4HaVYJsiYiPayCZbIhcB nCemTp7kH6wN9uQtjKp3Hpp+IKgU/V6vw3h7Jw2+2c3myJ89wuFEBy9pkV97B/pW+C lzpzmk0ojOv8g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 43DE16794B for ; Fri, 5 Sep 2025 11:02:25 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rE3mwYhiMwh7 for ; Fri, 5 Sep 2025 11:02:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091744; bh=rk1L11TJsKAzAS1Mug4LKYUIv0LzVLdWxwc+TJFCXAM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WzwNsuUPrQm/uN3bhUIw4Rc/7Dh+IJwjkEBoURv5pZ5MbyDs8dAX91rLm8+261amf ywYFPv7ZUlsL9NZ0kTYQqkmIq4jTwYzC06PHJnBuEeIxjYemmIJggVWUsg9DYLm2nP ggrKc+/KS6Eu53230Ea2tNs7VtQnCAzKgvA0C70bLe4BFB+dTslW9z3b/rAN30+T4k VJjnXcmwZMGtiVz4T8LPFkGJTtej6WnFHscESIMG7FwPSLSbH2j4h2okq8Z+iRXiqQ NFwBcRkRTf4Ig/DaqYwbLPShXJiIfwEUVNC+GMPhnJLL+ywubml5m1YVJfpxRGc2vr 1odw3aJ4SEqcg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF2A067980 for ; Fri, 5 Sep 2025 11:02:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091742; bh=wrNv2N2Tt9SCggUhsYVUlgvbOLf0ZZXYeLwmshiMRYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTAttEiE61GWVHB0h2J1glO9VRwgtG7pxz4hx81lu4hLC3ewYcObRWqR6J/rr4izN Rp8CUUPdzp+cdf803CicgnXJZ5AWr+kgnT7wSKkEfOgX6MRyW9veEoO+/K3jmTuxwG y8uqP6vtqDRZuPgw+xypiEEyC650fiaGnvbrjB89aSi+B4VQWN6rB1QHzaMlVNq23l w2OI0j0gLXM8vyh6geQH1UxZZAMxggbTzxxQbgcwBf7a6wnf1pARBzMMXd4cOmqNiL H3cQZ6rZCCJAUJj3EBhvCtkGlT35W27R9BWIdHqvFhlGd3l9oyHMZM4tFkvSzJVHkj 0+QYUlm3JFCSg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 68CBF678E6; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id YjgY7BI9eIUJ; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091738; bh=+HDFxi5JId6MPdkyVjPlBw6DJ/oZusdpaxHzNcoxx2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ndEHLL8yqORwo75Mrk2sfG39AIjaMwK7DVint4UE/bIrQgpES0ZZ8q5dFMPhTw5U7 Ww7YbjMS5n/fNMSd5wCa/Fq9596zIngekwNYozSeJeCzlOlmWHiTovTVaK2gruyi5y eBya8aVC1wXKrbpOMIDm0i6SZLhgTBWKRCX2Onxjc5iHd1FnpGWQtBndzOoMN6cydR wYljovJ3C0zPiD73PQHc6ev1td78xl1zUTjRO9tlk6YksebPtQ4jj8if+g7AxmT/hE ilTGG+GMTCQCr0TivowrlJHnYfBh52/6ozm/1m59nDk0+vJCKCDDleRDhJCnUPoJ9M /ukJi3YpDejKg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 29458678AA; Fri, 5 Sep 2025 11:02:18 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:21 -0600 Message-ID: <20250905170132.182249-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YMDD7MLVWATEAJYBKEKJUKYVC2FONFE2 X-Message-ID-Hash: YMDD7MLVWATEAJYBKEKJUKYVC2FONFE2 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/15] ulib: Provide a generic init function List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide an arch-neutral init function that can be used by including a single header file. This declares a static global_data which is used for the initial startup process. Once board_init_r() is called, the global_data is moved into a new place and the static version is not needed. Signed-off-by: Simon Glass --- include/u-boot-lib.h | 34 ++++++++++++++++++++++++++++++++++ lib/Makefile | 2 ++ lib/ulib.c | 36 ++++++++++++++++++++++++++++++++++++ test/ulib/ulib_test.c | 8 ++------ 4 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 include/u-boot-lib.h create mode 100644 lib/ulib.c diff --git a/include/u-boot-lib.h b/include/u-boot-lib.h new file mode 100644 index 00000000000..7157ef6ba60 --- /dev/null +++ b/include/u-boot-lib.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * U-Boot library interface + * + * This provides basic access to setup of the U-Boot library. + * + * Library functions must be individually accessed via their respective headers. + * + * Copyright 2025 Canonical + * Written by Simon Glass + */ + +#ifndef __U_BOOT_LIB_H +#define __U_BOOT_LIB_H + +struct global_data; + +/** + * ulib_init() - set up the U-Boot library + * + * @progname: Program name to use (must be a writeable string, typically argv[0]) + * @data: Global data (must remain valid until the program exits) + * Return: 0 if OK, -ve error code on error + */ +int ulib_init(char *progname); + +/** + * ulib_uninit() shut down the U-Boot librrary + * + * Call this when your program has finished using the library, before it exits + */ +void ulib_uninit(void); + +#endif diff --git a/lib/Makefile b/lib/Makefile index 1db1e3c9000..eb6da6d63c9 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -166,6 +166,8 @@ obj-$(CONFIG_LIB_ELF) += elf.o obj-$(CONFIG_$(PHASE_)SEMIHOSTING) += semihosting.o +obj-$(CONFIG_ULIB) += ulib.o + # # Build a fast OID lookup registry from include/linux/oid_registry.h # diff --git a/lib/ulib.c b/lib/ulib.c new file mode 100644 index 00000000000..03acbe93fd1 --- /dev/null +++ b/lib/ulib.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Simplified U-Boot library interface implementation + * + * Copyright 2025 Canonical + * Written by Simon Glass + */ + +#include +#include +#include +#include + +/* Static storage for global data when using simplified API */ +static struct global_data static_gd; + +int ulib_init(char *progname) +{ + int ret; + + /* Initialize the U-Boot library with our static global data */ + ret = ulib_init_with_data(progname, &static_gd); + if (ret) + return ret; + + return 0; +} + +void ulib_uninit(void) +{ +} + +const char *ulib_get_version(void) +{ + return PLAIN_VERSION; +} diff --git a/test/ulib/ulib_test.c b/test/ulib/ulib_test.c index e1e863712a8..a68290ff484 100644 --- a/test/ulib/ulib_test.c +++ b/test/ulib/ulib_test.c @@ -11,19 +11,15 @@ /* Use system headers, not U-Boot headers */ #include #include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; +#include int main(int argc, char *argv[]) { - struct global_data data; int ret; printf("Calling U-Boot initialization via shared library...\n"); - ret = ulib_init_with_data(argv[0], &data); + ret = ulib_init(argv[0]); if (ret) return 1; From patchwork Fri Sep 5 17:01:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 248 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091749; bh=fOdIKTxBDi8c7gAfdXamLrLmdZah5dgdyfOMiV40CJA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=V17cPGyAoNJcAsLg8+tG5sjnG8g2h/lhbKTKOfGByrv37eaPYhBQjLepnfQVZWbFv 5EzMLq5vvQYqyaaYIuZyPEyww3kgJAb8+iqRgykixQIKXWWkY6D0v4KKoPw0W3/vEZ 6HAnnpniR6J1WZdHhzRQ2D7wnOLYmrITfdeFJkbwHNexY/vd2oNF6BofmtEuIrwJd0 /rlT7co64vM5dBcnozhoNrXuRvfg50DLRjwSn20EGwHDllyxtsAMSZu0OaHwQDHktu 0iFBAwXXi2p/OgLJeg7NClU9iRH8mOeuYlO7Rmfr1VsVg3ucM8qPhEO4Ckza/fLsij pRUzI1mZGjpnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 567B3679A6 for ; Fri, 5 Sep 2025 11:02:29 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3jgjp5osY49D for ; Fri, 5 Sep 2025 11:02:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091749; bh=fOdIKTxBDi8c7gAfdXamLrLmdZah5dgdyfOMiV40CJA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=V17cPGyAoNJcAsLg8+tG5sjnG8g2h/lhbKTKOfGByrv37eaPYhBQjLepnfQVZWbFv 5EzMLq5vvQYqyaaYIuZyPEyww3kgJAb8+iqRgykixQIKXWWkY6D0v4KKoPw0W3/vEZ 6HAnnpniR6J1WZdHhzRQ2D7wnOLYmrITfdeFJkbwHNexY/vd2oNF6BofmtEuIrwJd0 /rlT7co64vM5dBcnozhoNrXuRvfg50DLRjwSn20EGwHDllyxtsAMSZu0OaHwQDHktu 0iFBAwXXi2p/OgLJeg7NClU9iRH8mOeuYlO7Rmfr1VsVg3ucM8qPhEO4Ckza/fLsij pRUzI1mZGjpnA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 44CB2678E7 for ; Fri, 5 Sep 2025 11:02:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091747; bh=1gQ4qo2f6hDrhfTW60NPc1llH08tikfY+rhWRUZXDwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/sx6SGkkP3uMpr1F1y3MnJG7tt4qRK0EUbqF1yeCVKBs6ahf3HuC7FYWrk7/4u9s MG7JjfQMTqITmArgy6NDmrHL/Who/F5zQ61MU5DP6s2HTQcFSRRFC5Rt9KlsRFM8wY wDApy7RybHwEBGFhe7PWtuJZluXlHY8TEbd3jDB+YIS0vFpz15tzF8oH/zH+WWWcqm kqSxTh27v7YaSVaNK/2zoqkn9BZcvqr+KDITb8JqVHusIMBpqF02T1XxYoZd4SJo8V qCgxb0QmfToRIMUAYL4Pl9CwGcw+d7fiAYwaBqmEVrJm8VOnn09qtpfZCAV8Or3mwg 4JrVX2nT9AZSA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E2386799D; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id dVxT2Rf-BGj0; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091743; bh=Py/GHoS/0OcSM4lu1SfzgVZAPtKckU4lBXmtw4+AcnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEnyey9xgXzixEWuTCRtisPDchImZuDwS4RYM966jOg47lgV0xNLO0ayK6X3ZwPmH G+FUFhulqMlByuK+gbNpVY7M4ElqukVU3Qs/mqraUl1nQce8A1HGoBr8CORm+38ld/ yXVmaNIFqBY/up0BJ8yotXRrr3KCoSeukDaMrqQLL0U1uhZX4Y3JKE/KJEq0yNdpo+ PZrI59uWOEljhgoPr4D45zsTslSAFT6L4ly2Sauzsyt2yYYIRmRq78LY5wrZZhEYxc oqbH6sxMuaSJ+OJ0ErnfIVd7sACI7IbXXMKPWxnsumWusKfOTe9Eg/mS8HHE53uyBM pjJaw4FH+vr/g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BCD11678AA; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:22 -0600 Message-ID: <20250905170132.182249-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ESMNMBO2QUBDH3E3Y6WXTLQDK467I34Y X-Message-ID-Hash: ESMNMBO2QUBDH3E3Y6WXTLQDK467I34Y X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/15] ulib: Provide a test program for the static library List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Create a static version of the library test. This requires a linker script, since the linker lists much be correctly placed within the final executable. Provide a linker script for the sandbox version. Signed-off-by: Simon Glass --- Makefile | 18 +++++++++++++++++- arch/sandbox/config.mk | 1 + arch/sandbox/cpu/ulib-test-static.lds | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 arch/sandbox/cpu/ulib-test-static.lds diff --git a/Makefile b/Makefile index bf571de9f06..3ece9a02b6c 100644 --- a/Makefile +++ b/Makefile @@ -1046,7 +1046,7 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ ifdef CONFIG_CMDLINE ifneq ($(cc-name),clang) INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test -INPUTS-$(CONFIG_ULIB) += libu-boot.a +INPUTS-$(CONFIG_ULIB) += libu-boot.a test/ulib/ulib_test_static endif endif @@ -1893,6 +1893,22 @@ quiet_cmd_ulib_test = HOSTCC $@ test/ulib/ulib_test: test/ulib/ulib_test.o libu-boot.so FORCE $(call if_changed,ulib_test) +# Build ulib_test_static to test linking with the static library +# main.o is excluded from the static library since the main program is provided +# by the user +# Use --whole-archive to include all linker lists +# Use a linker script to ensure proper alignment of linker-lists +quiet_cmd_ulib_test_static = HOSTCC $@ + cmd_ulib_test_static = $(HOSTCC) $(HOSTCFLAGS) \ + -I$(srctree)/arch/sandbox/include -o $@ $< \ + -Wl,-T,$(LIB_STATIC_LDS) \ + -Wl,--whole-archive $(obj)/libu-boot.a -Wl,--no-whole-archive \ + -lpthread -ldl -lSDL2 -lrt -Wl,-z,noexecstack + +test/ulib/ulib_test_static: test/ulib/ulib_test.o libu-boot.a \ + $(LIB_STATIC_LDS) FORCE + $(call if_changed,ulib_test_static) + quiet_cmd_sym ?= SYM $@ cmd_sym ?= $(OBJDUMP) -t $< > $@ u-boot.sym: u-boot FORCE diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 566f5b417ae..f80e2ef369f 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -72,3 +72,4 @@ EFI_RELOC := reloc_sandbox_efi.o # U-Boot Library LIB_LDS := $(srctree)/arch/sandbox/cpu/u-boot-lib.lds +LIB_STATIC_LDS := $(srctree)/arch/sandbox/cpu/ulib-test-static.lds diff --git a/arch/sandbox/cpu/ulib-test-static.lds b/arch/sandbox/cpu/ulib-test-static.lds new file mode 100644 index 00000000000..c400fba4f2b --- /dev/null +++ b/arch/sandbox/cpu/ulib-test-static.lds @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Linker script for ulib_test_static binary + * + * This ensures proper alignment for linker-lists when linking with libu-boot.a + */ + +SECTIONS +{ + /* Ensure proper alignment for linker lists */ + . = ALIGN(32); + __u_boot_list : { + __u_boot_list_start = .; + KEEP(*(SORT(__u_boot_list*))); + __u_boot_list_end = .; + } +} + +INSERT AFTER .rodata; From patchwork Fri Sep 5 17:01:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 249 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091751; bh=K+06CYKqCX4/eqBPPsm9MZuJ23k/RMD+WOxbpGjO36I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=j9mzXc6aWEILFRhKnyWmMEeeS/E/nHOzXIFE5E+GDnXBneaQsZJznt9MtDQH/x3c0 F9xQ1NgLiVk/zHMbkvuIQ/Ctxt75wpKYaO3JZsajS8gxMAk2UQLDnuDG+bGmhivyf7 3WdqPs8EwZNAm2gFQ0yKSpaBzrJhNayLkdMUb5zApeIA9NM50EvG2fv3XUW0PJbOqd Ynik5tVo6L/Mp/8VpYDnDoygtk+QchiDlBdeYLLAgZbnGhmdebI6cU1yR03x7ErqeX cjjuo1ZM8Nt2S2EIfIkEuJwJY05KnF6UKOqILOpiNt7fsIvCaLupjvEtquaiAfQLY8 KoVQ4zHrvVl8A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9B4E9679A6 for ; Fri, 5 Sep 2025 11:02:31 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OvEkmgRapqmS for ; Fri, 5 Sep 2025 11:02:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091749; bh=K+06CYKqCX4/eqBPPsm9MZuJ23k/RMD+WOxbpGjO36I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Q2r6hbpHL0Eb9KGEsysgFyylrRbKEYevONEP7q1/H8M789Q5LKE3ZenX4Qqtum+PA 7VBgP2Dq0VmWf9TbpJUD5tX3kkdbhrZy2EQqu81joEhZvHgB6OkyR6xPTp5XGIicIO 0DlGHLOYMGJeRelfCG+M0P/f8/dITGqdGUPvjacq0VrSogQmeB0nabsZ29fWRwD+lf 50hqZK5T/Q3e//aoALdZTMx2U2RYgiDeSonbVWNOks/rihbDENZhVH9a0qUDJaReHe +aHBWjOnaqZak0NXFqwSZBbhrBOpAQsMKe0Qho0+PaX2YVvrJuq9GKL7Uf6VYW18BW 1JYEXC6c6dZ3Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 97EC6679B5 for ; Fri, 5 Sep 2025 11:02:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091747; bh=nDxDn9Sy+unaZYk5CpcTkVP8EG2/0Cqan65aDG2MkQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWENtA9QvJ83606y4iwfeDfBJy5yW8UOG/It1byc2efp94hWDiafDtEoZtXnSIUGj DSfQAV3yL51ZKrnROgbTuhKvwb0nDabVT4dRB5GHzuW+/rcnWLfa8YTz6pxZfzSV1L VBH3VxT/EqkI4mBIzpKkxGD3Qn+CdzF9dXO2xyDKL4zgED2UWi+7+Anr9S7euXvJNq +WybwdHMAXeoi17l/R6+7vwhz0Vq4V642+CwNIQFPrPiyp6q6fDSn/c2vXhXLgkHJ9 RCMg70v14HWoNy7RpBWGxLiA3IXTY4NakDWCNyG38FOExcopALxYABeI91LsoGB3se IpmkVj0fYmz1Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B1A07678AA; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id TdDHMi-7JVU8; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091747; bh=N0LNWg6Kq4mQIzAa2GmFQTWmwa8Z3tzf7e4mAWqdWmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rkArvBGtPR93KemszESCZxhaR2hFeoSr2ZG1lR55G1r38LTOHM2s//7QDmZgzgRAO cExRsC0VDF5gKakUSljD20YXB7tzgM9T8HnRRcTbU+QHbQANgG6xMQbLf7WJ4RTctW 2QvCMBACGLbtLVwvzGKcxI10b5Y1TZjtyGc1T/e1h9aSayAZJothn4EYMDIjciSKrF pnF8lHnB5cjoiQ5WQFN8b1FE/VIY3BQSx+OvecoZVkIEC/orNe5ztpNo+3H5xX0Qea /NaFfCEthPgvN+65JVr0Do1mjQWE7G/IATYdzzLbVqAQp/95u8XmZ4BS+faHdBlqTV inKSADRf1vT2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 401F0678E6; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:23 -0600 Message-ID: <20250905170132.182249-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KOTMHL36GMTI2REGGAYERACSV6MH2P2M X-Message-ID-Hash: KOTMHL36GMTI2REGGAYERACSV6MH2P2M X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/15] ulib: Drop unnecessary pieces in test/ulib/Makefile List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass We now have rules in the main Makefile to ensure that the library is built before the ulib test-binaries. Drop the unnecessary dependency. Also the link is done entirely in the main Makefile, so drop the flags as well. Signed-off-by: Simon Glass --- test/ulib/Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/ulib/Makefile b/test/ulib/Makefile index ae58e01fccd..b6c3df38c9b 100644 --- a/test/ulib/Makefile +++ b/test/ulib/Makefile @@ -3,10 +3,3 @@ # Copyright 2025 Simon Glass obj-y += ulib_test.o - -# Link with the shared library -HOSTCFLAGS_ulib_test.o += -I$(srctree)/arch/sandbox/include -HOSTLDLIBS_ulib_test += -L$(obj)/../.. -lu-boot -Wl,-rpath,$(obj)/../.. - -# Ensure shared library is built first -$(obj)/ulib_test: $(obj)/../../libu-boot.so From patchwork Fri Sep 5 17:01:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 250 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091754; bh=wueSKN2OPP0c/uyXOuyMBqyyiwWVU3DA43D79vGNyw8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=mqkYmAo3JrueXRakwFMOQawn3yPmolrbNikzKDvogWaxgeLSHDMDEL7rP31OJjxAv MAJ0ZoDSVxvZLuSGA6amaa8HolulxhvH4qFXpbEYlKOkCzUjfZPCwXwiooJkoYQ7b7 a8CH70La+Wy5re0sqFdfr+42DAhPMQUSlgg76fVJl/ygS62lennmZYCEHFgtJ7qcZh ZSbblDYix1o1Ctfl0v82yytzrizuaMvbt1OBlhZvnvCGcYjKP5PN+PEY629K075Ea0 +9bOswsglfeieqGmy1UyAq4cIiyfxwUd9NSFcpUtJ4NzU81DTAjoq8A6QCHE2cJRZf wcUP0atOsvOow== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EECA4679A8 for ; Fri, 5 Sep 2025 11:02:34 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PVhvnsWOs8mB for ; Fri, 5 Sep 2025 11:02:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091754; bh=wueSKN2OPP0c/uyXOuyMBqyyiwWVU3DA43D79vGNyw8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=mqkYmAo3JrueXRakwFMOQawn3yPmolrbNikzKDvogWaxgeLSHDMDEL7rP31OJjxAv MAJ0ZoDSVxvZLuSGA6amaa8HolulxhvH4qFXpbEYlKOkCzUjfZPCwXwiooJkoYQ7b7 a8CH70La+Wy5re0sqFdfr+42DAhPMQUSlgg76fVJl/ygS62lennmZYCEHFgtJ7qcZh ZSbblDYix1o1Ctfl0v82yytzrizuaMvbt1OBlhZvnvCGcYjKP5PN+PEY629K075Ea0 +9bOswsglfeieqGmy1UyAq4cIiyfxwUd9NSFcpUtJ4NzU81DTAjoq8A6QCHE2cJRZf wcUP0atOsvOow== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DEB956799D for ; Fri, 5 Sep 2025 11:02:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091753; bh=ktHPRhoDvo6c42wdaRnIGNKcUUPB2+DplJqCx3SY4/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHw2sOPRvqomSPTGGdjRMht6z2bXk5hagEzAxPITT42yYIMUrtW9wi3aY3p2oUF6u R6n0FAGJjyttzDr7Pe+J2/RA5Hc7lTG+cj78vFMlUi1uLgvlWY1CMyohZZVFfHPPyW J5s9n77MWNy00OAPhchmHdDPLMmCxbILrf5gPYq13ndARrZD/5/CK5YfnseTe7ZCbo emp7cmYaIz7Pxd+gtgAUgo9IEaEelx2RyFjKNa1t/nF93Ck/BziU7ZyBJ6zI1Lunjm xwmIz176cZUIkRUrgaTttMHk5NXic7VQYWwxSJudwdTtH+OwhKzD1k7hDDt3UK9kXa x88cajfxDrmMQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D1B1E6799D; Fri, 5 Sep 2025 11:02:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Mpk2uoyxqfq2; Fri, 5 Sep 2025 11:02:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091748; bh=Pp6XC6z6cSfwVPXLUvGGdUPTg2kqppvnPUdp/X225Lo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a97DkL0tkWrYgYH+/Cqf+zrUl4tzbHi0ZHaxsUkvZg3TfLkZ3c2+/5DKiymvR+Cx2 fLoZhfxv3HvEXzjMALQ5T1UciHnl3qL2WeNegbMKtK51k2Eu7ITqrqyrtUFza9m3hb YMfDpL+KU6J9JHAuW8IHtCZSS0Zjm2Mju1mob+8rbrvXK7a7hl03If59LAOqEBxQPn jWm6q7ZKGVDK2762XmGntEA7S0klD4Q4xQSirDg05xqHLnnSa4kxoQ2wBXyTugSVcz SIgRna0Lkd3BLxzkTBNH1K84ulfMal3TxGy0CrLX3OJpIQbryG0IbgSSmK6QNsiK2f 57Q0ivjTBjEgQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 00257678E6; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:24 -0600 Message-ID: <20250905170132.182249-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VTUUW7F5NXZFK7QPPHYFOW5GNY3DTZ7S X-Message-ID-Hash: VTUUW7F5NXZFK7QPPHYFOW5GNY3DTZ7S X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/15] ulib: Provide a bit more info in the library-test program List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass When the test is run, indicate which library the test was linked against, static or dynamic. Drop the printf() at the start of main(). Since all printf() calls go to U-Boot, this message is not shown anyway, since the global-data pointer gd is NULL at this point and console_puts() just returns immediately. Signed-off-by: Simon Glass --- test/ulib/ulib_test.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/test/ulib/ulib_test.c b/test/ulib/ulib_test.c index a68290ff484..51b1c62e6b2 100644 --- a/test/ulib/ulib_test.c +++ b/test/ulib/ulib_test.c @@ -2,7 +2,7 @@ /* * Test application for U-Boot shared library * - * This demonstrates linking against libu-boot.so + * This demonstrates linking against libu-boot.so and libu-boot.a * * Copyright 2025 Canonical * Written by Simon Glass @@ -11,17 +11,50 @@ /* Use system headers, not U-Boot headers */ #include #include + +#include #include +/* Runtime detection of link type using /proc/self/maps */ +static const char *detect_link_type(void) +{ + char line[512]; + int fd; + int found_libuboot = 0; + + /* Open /proc/self/maps to check loaded libraries */ + fd = os_open("/proc/self/maps", 0); + if (fd < 0) + return "unable to detect linkage"; + + /* Read line by line to avoid boundary issues */ + while (os_fgets(line, sizeof(line), fd)) { + if (strstr(line, "libu-boot.so")) { + found_libuboot = 1; + break; + } + } + + os_close(fd); + + /* Return appropriate message based on what we found */ + if (found_libuboot) + return "dynamically linked (uses libu-boot.so)"; + else + return "statically linked (uses libu-boot.a)"; +} + int main(int argc, char *argv[]) { int ret; - printf("Calling U-Boot initialization via shared library...\n"); - ret = ulib_init(argv[0]); if (ret) return 1; + printf("Hello, world\n"); + printf("\n- U-Boot\n"); + printf("\nPS: This program is %s\n", detect_link_type()); + return ret; } From patchwork Fri Sep 5 17:01:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 251 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091757; bh=p+Nm7qs2Je5mUBQP3MlroTwjooD3gwNlJAUTjDS6Wsc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=krN0RolzxR6dmgsmb8V+iYqIOR0kcq8zPVEpM5DXZpnTCf/IIFDEFx7G6JKaaTqXQ qhoEbZzSIoeEX4G2QQtmtGBCyV8m84R8LYeH0DxPtravtFU8BQoPauwyH60uEXOGb1 fk0qoEKB8BEqyATkQJ4fu0fd/CPgVPD/4oIo53pPGu+ZFYQslc3NfhQRVslFGFNOS7 e+AxuWKVeefcebFFdMvN3hYUfWtNg9Zt7Utkp7n3pPK1t/omSzpKxJKOxaqbzh4A/g gZliRnDyiivM+tX8Zz6v+X2pKQWyHK9vwgNOsYeOkwXcqMGJvV9C3BMzQseMDMfzKt Pc8aduhp+3nuQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B899679BC for ; Fri, 5 Sep 2025 11:02:37 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id EMhzWUf3cAQ9 for ; Fri, 5 Sep 2025 11:02:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091756; bh=p+Nm7qs2Je5mUBQP3MlroTwjooD3gwNlJAUTjDS6Wsc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=atJMsuUQO15Milk2ZTwmXIMtkAH0X7u0YngKDXr/fK2Nc5+YuXz55w+seRNUFAgDG IeajYQe5fTlVkjXz73OA4QnsGhtVEIvLhWQK0q6YNxwxUvglJXckj3b79NTMie4DuD 8D7CLAipgqN+T1mleh4BFCvqqf0T+pKfsRkA5GqsqOf57Rb+qPVALpxQknLbBKNwf1 NtTRN4BRvhxIC3GR3Na6LXF1yWZ7cTazXmgx2jt3MXhThPnz70ODZ40yojXFRUiWqB 0VccPuRiXhYV/TvcDbxWFwEZE8cW23G7/4uGzaofGhmoNxymiLuEQQIrUhxyfsydv1 /S1yo579b54HQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 38EFB679B5 for ; Fri, 5 Sep 2025 11:02:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091754; bh=aBvewCgAcDn00tkQ+AyXAG+5luaGL4ksNXvmxMWUQTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hvyGeZSfZsH/HtcivDxtkHgcZOwFdVTpujL430uHNgB9DaDxvgvTUDmP/R/g+8LlA 1zPdKmpTFWrs25OFW1QKRvTfijnxlXFazjZvm+9PqWG3kM7eKmT4+MDhESFIC6lN4W no0OozNeTtPIE17bcoWg8FnCTpr06KiX+GiAvVgTH5e0XG+yT8dYtrcifnKdZCbOWg Z133RBjSoh4fS2zQz9m3DBWHiqugSdNCsI8fiUxJrVjrk2L099EHelR+zMTkFf68Pv lOHqkv9O75UfxYPfhvQ06C2fXbO47d5Yk9C2cw/kuM0zKt/vuYaiFYSuSxt/jciXkJ ni0z7ilYS7L6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5357E678AA; Fri, 5 Sep 2025 11:02:34 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id mqN07-zSLz0N; Fri, 5 Sep 2025 11:02:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091752; bh=vvY36BWcOJSul2GzG68GpUWwkVPlKhROpLIO7G6tfBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3yTbeof2yD8YtUzbJMTu7QnR+Agh9s8cNyDgpCiv5rZhpTTvNnlqCd2fSEcLtJ9C uveJsjjJkyHcRUN8GXz2XO5T1IyjSetybYXSaZrXLoc+h/HuL395QoHmFktxzmNI0d Kre6lRVPsiBjMhSi63LP95wBuZXDzxL9z+3cr3auKqnNrB5flab85laHORpGp8bsdx j6v0GKCwLLWq3dElzwb1v4K5FUauOabIIwUGKFKnjLFRDoTBPGQvURMOIgd0Umk6he pfTn0G74C04poWkagCm/hDib5+qCSQpeRoe3j+h0J4oWOkeRTf2va2wfFf1IUoDCph ce66ylF/1P52A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5CEBB679A6; Fri, 5 Sep 2025 11:02:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:25 -0600 Message-ID: <20250905170132.182249-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 73N4RTJ4SAKNDJACV67NF3CV3Y4NEVCS X-Message-ID-Hash: 73N4RTJ4SAKNDJACV67NF3CV3Y4NEVCS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/15] ulib: Allow building of the libraries to be disabled List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide a NO_LIB option which disables building the libraries. This saves a little time. Signed-off-by: Simon Glass --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 3ece9a02b6c..2c4685d161c 100644 --- a/Makefile +++ b/Makefile @@ -1045,10 +1045,12 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ ifdef CONFIG_CMDLINE ifneq ($(cc-name),clang) +ifeq ($(NO_LIBS),) INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test INPUTS-$(CONFIG_ULIB) += libu-boot.a test/ulib/ulib_test_static endif endif +endif LDFLAGS_u-boot += $(LDFLAGS_FINAL) From patchwork Fri Sep 5 17:01:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 252 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091761; bh=ToWnLBoIqgILOcO20BGmgA9FTGJrRil0znAYoMLmdEs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=W9QMEHlGiDdJvj7tSs/2wS7+AQrMPbP3TmowJ1pGT/xAQvY6B1T44I3/iqYQl740z Rbb478ojsZbw5FFQXH7Zo6j0CB9PE4xuKbHtfoFOXNGiMu6rSsD2LMzaPr2Bc2xncE gX2tUdpvrCfudUdDs5lMl5jMqyNvH4TOCjL2+/tY1P2i6sxAiUrl3KxY7DsBaAHKN6 D0yyeM9MjZgMrErtPrNqIiM96dYROwXrlNurt2T8nIZwp11ky4NMAzdj7PVyyuUxtp 9shRrtjN5FjhgvQX0fg7sde+dx65myEpSsZEI9hL8263UmUJKO81TTq1m6Ni3szEyv U9vxFPcVVjp3Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A481D679B5 for ; Fri, 5 Sep 2025 11:02:41 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Rj2kn3reY3Gz for ; Fri, 5 Sep 2025 11:02:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091761; bh=ToWnLBoIqgILOcO20BGmgA9FTGJrRil0znAYoMLmdEs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=W9QMEHlGiDdJvj7tSs/2wS7+AQrMPbP3TmowJ1pGT/xAQvY6B1T44I3/iqYQl740z Rbb478ojsZbw5FFQXH7Zo6j0CB9PE4xuKbHtfoFOXNGiMu6rSsD2LMzaPr2Bc2xncE gX2tUdpvrCfudUdDs5lMl5jMqyNvH4TOCjL2+/tY1P2i6sxAiUrl3KxY7DsBaAHKN6 D0yyeM9MjZgMrErtPrNqIiM96dYROwXrlNurt2T8nIZwp11ky4NMAzdj7PVyyuUxtp 9shRrtjN5FjhgvQX0fg7sde+dx65myEpSsZEI9hL8263UmUJKO81TTq1m6Ni3szEyv U9vxFPcVVjp3Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 941406797B for ; Fri, 5 Sep 2025 11:02:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091759; bh=oxRDFT5frm5C2RgGiHxAlj/LNja53r2dQ+2sN4siYNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=huG+6D02rNt4oK/leU0/3lN6J2iBl2QD76Y+6S/8NAaVikMXNNvqJ+/4IGXhGgw4v UpZLTbxbgaLBPEnewQabzHhcWEWQ7q7HmMVK2v5IVc2ZqRfFnZfU1dMXCAiCcsu0La EIVGlnvuqxb7g2bFkl0Cb0h2QxgINYJGLMWFpxkEe+5OJ7qdTQ027esRSKOz+CMo1s 6golKUxnzP0N0SdF8lA0k+3y9Opm8X3DTd1pcoZZ/6zqRnKiMIQpJrbxqhFwiwFBZF 77a1c6FsHEZgINFdDFSnfPVsSLybFxJeNzp3jUe6eU2i0b8sUREvsMdBPS0lylBkrt HuIwEiE96i/qg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70F346790F; Fri, 5 Sep 2025 11:02:39 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 9O-8vnOPwh4E; Fri, 5 Sep 2025 11:02:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091755; bh=U04c4PibtLYEaEVcLyyYSeL80n3hOiIR59DG2mM+z1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vW3ANd7PMYK5OiAZxeC9L8ZB/z5s0YXWhFddoU6NTAksgk4qPjj5Z6WewWSwq0A67 PkDWAlcvdB2UBPqisbovjQI+39zeQdtk9I5fLrpiUvH2Jd/u7zw9kEUfVn2lutAqm4 /+0ECDepH/FKie2ntG0ryIJuEv5C0onqYIbl+nGI/jKPsblDwICq3i4fyT3rhSxnXo yN8k07UANSy3516vj4zP+NV1DGow3vOAkd93xRUgtWnDrxGPVEf/s7oveQhUJQ9r2D CzlFUFeKLGcjmDp969FObO05S+SxEOJOcPD+3+b+zgmt9lftkYsWur7r+qwX1UEVS6 clGP9CwEdso/w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DB2A2678E7; Fri, 5 Sep 2025 11:02:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:26 -0600 Message-ID: <20250905170132.182249-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FB4BTL6BXQDV53YECH5BVKHHNS6KFJY4 X-Message-ID-Hash: FB4BTL6BXQDV53YECH5BVKHHNS6KFJY4 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/15] doc: Add ulib documentation for shared and static libraries List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add documentation for the U-Boot Library (ulib) feature, explaining how to build and use both shared (.so) and static (.a) libraries. Co-developed-by: Claude Signed-off-by: Simon Glass --- doc/develop/index.rst | 1 + doc/develop/ulib.rst | 253 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 doc/develop/ulib.rst diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 592736331f2..12a71b5b23a 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -56,6 +56,7 @@ Implementation falcon std_passage uefi/index + ulib vbe version diff --git a/doc/develop/ulib.rst b/doc/develop/ulib.rst new file mode 100644 index 00000000000..559f170ce42 --- /dev/null +++ b/doc/develop/ulib.rst @@ -0,0 +1,253 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +U-Boot Library (ulib) +===================== + +The U-Boot Library (ulib) allows U-Boot to be built as a shared or static +library that can be used by external programs. This enables reuse of U-Boot +functionality in test programs and other applications without needing to +build that functionality directly into U-Boot image. + +Please read `License Implications`_ below. + +Building the Libraries +---------------------- + +For now the library is only available for :doc:`/arch/sandbox/sandbox`, i.e. for +running natively on a host machine. Further work will extend that to other +architectures supported by U-Boot. + +To build U-Boot as a library (libu-boot.so):: + + make sandbox_defconfig + make [-s] -j$(nproc) + +Use ``-s`` if you just want to see warnings / errors. This produces two files: + +``libu-boot.so`` + This is the shared library, sometimes called a dynamically linked library. + Programs which need it can be dynamically linked with this library at + runtime. This provides: + + - Smaller executable size for linked programs + - Runtime dependency on the .so file + - Must set LD_LIBRARY_PATH or use rpath for runtime linking + - Suitable for development and testing + +``libu-boot.a`` + This is a static library, meaning that it is directly linked with your + program and the resulting executable includes the U-Boot code. This + provides: + + - Larger executable size (includes all code) + - No runtime dependencies + - Self-contained executables + - Suitable for distribution and embedded systems + +To disable creation of the library (e.g. to speed up the build), provide +NO_LIBS=1 in the environment:: + + NO_LIBS=1 make -j$(nproc) + +Simple test programs are provided for each library. + +For dynamic linking:: + + $ LD_LIBRARY_PATH=. ./test/ulib/ulib_test + Hello, world + + - U-Boot + + PS: This program is dynamically linked (uses libu-boot.so) + +For static linking:: + + $ ./test/ulib/ulib_test_static + Hello, world + + - U-Boot + + PS: This program is statically linked (uses libu-boot.a) + + +Architecture Notes +------------------ + +Both libraries exclude ``arch/sandbox/cpu/main.o`` which contains the +``main()`` function. This allows the linking program to provide its own +main entry point while still using U-Boot functionality. + +The libraries preserve U-Boot's linker lists, which are essential for +driver registration and other U-Boot subsystems. + +Building outside the U-Boot tree +-------------------------------- + +This is possible, but as soon as you want to call a function that is not in +u-boot-lib.h you will have problems, as described in the following sections. + +This will be addressed with future work. + +Including U-Boot header files from outside +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +U-Boot has many header files, some of which are arch-specific. These are +typically including via:: + + #include + +and are located in the ```arch//include/asm/...`` directory within the +U-Boot source tree. You will need to ensure that this directory is present in +the include path. + + +Kconfig options +~~~~~~~~~~~~~~~ + +There is currently no mechanism to make use of the Kconfig options used to +build the U-Boot library. It is possible to add `-include kconfig.h` to your +build, but for this to work more generally, the header file containing the +CONFIG settings would need to be exported from the build and packaged with the +library. + + +Test Programs +------------- + +U-Boot includes test programs that demonstrate library usage: + +* ``test/ulib/ulib_test`` - Uses the shared library +* ``test/ulib/ulib_test_static`` - Uses the static library + +These are built by default with the sandbox build. + +Run the shared library version:: + + ./test/ulib/ulib_test + +Run the static library version:: + + ./test/ulib/ulib_test_static + +Linking and the Linker Script +----------------------------- + +For the static library, a custom linker script is needed to ensure proper +section alignment, particularly for U-Boot linker lists. See +``arch/sandbox/cpu/ulib-test-static.lds`` for an example. + +The linker script ensures: + +* Proper alignment of the ``__u_boot_list`` section (32-byte alignment) +* Correct ordering of sandbox-specific sections +* Preservation of linker list entries with ``KEEP()`` directives + +For this to work, the library must be linked using a 'whole archive' approach, +for example:: + + -Wl,--whole-archive $(obj)/libu-boot.a -Wl,--no-whole-archive + +Failure to do either of these will result in strange errors, such as running +out of memory or simple crashes during library init. + +Dependencies +------------ + +When linking with the U-Boot library for sanbod, you may need these system +libraries: + +* ``pthread`` - POSIX threads +* ``dl`` - Dynamic linking support +* ``SDL2`` - For sandbox display emulation (optional) +* ``rt`` - Real-time extensions + +Troubleshooting +--------------- + +Missing Symbols +~~~~~~~~~~~~~~~ + +If you encounter undefined symbol errors when linking: + +1. For static library, ensure you're using ``--whole-archive`` +2. Check that required system libraries are linked +3. Some symbols may need to be defined with ``--defsym``: + + - ``__stack_chk_guard`` - Stack protection guard + - ``sandbox_sdl_sync`` - SDL synchronization (can be set to 0 if unused) + +Linker List Issues +~~~~~~~~~~~~~~~~~~ + +If U-Boot subsystems don't initialize properly: + +1. Check linker list alignment with:: + + scripts/check_linker_lists.py /path/to/executable + +2. For static linking, use ``--whole-archive`` to include all sections +3. Use a custom linker script for proper section organization + +Runtime Errors +~~~~~~~~~~~~~~ + +For shared library programs: + +1. Ensure ``LD_LIBRARY_PATH`` includes the directory with ``libu-boot.so`` +2. Or use ``-Wl,-rpath`` when linking to embed the library path +3. Check library dependencies with ``ldd myapp`` + + +License Implications +-------------------- + +U-Boot is licensed under GPL-2.0+ (GNU General Public License version 2 or later). +This has important implications when linking against the U-Boot library: + +* **Static Linking (libu-boot.a)**: + + - Your program becomes a derivative work of U-Boot + - The entire combined work must be distributed under GPL-2.0+ terms + - You must provide source code for your entire application + - All code linked with the static library must be GPL-compatible + +* **Dynamic Linking (libu-boot.so)**: + + - The GPL interpretation for dynamic linking is legally complex + - Conservative interpretation: still creates a derivative work requiring GPL + - Some jurisdictions may treat dynamic linking differently + - Consult legal counsel for commercial applications + +* **Compliance Requirements**: + + - Provide a GPL-2.0+ license notice + - Make source code available (including your modifications) + - Include copyright notices from U-Boot + - Provide build instructions to reproduce the binary + +* **Alternative Approaches**: + + - Consider using U-Boot functionality via separate processes (IPC) + - Implement a clean-room alternative for needed functionality + - Request dual-licensing from all U-Boot contributors (impractical) + +**Note**: This is not legal advice. Always consult with legal professionals +when using GPL-licensed code in your products, especially for commercial use. + +Limitations +----------- + +* Currently only supported for sandbox architecture +* Network-subsystem init is disabled in library mode +* Main-loop functionality is disabled to prevent interference with the host + program +* EFI runtime-services and relocation are disabled + +Future Work +----------- + +* Support for other architectures beyond sandbox +* Selective inclusion of U-Boot subsystems +* API versioning and stability guarantees +* pkg-config support for easier integration +* Support for calling functions in any U-Boot header