From patchwork Thu Sep 4 13:04:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 215 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=1756991121; bh=eL1FkqndabxutLqCyaYy6xSiYLBoculVNHJ02KLfyJc=; 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=ZSBIDb1yTi6P0PHfD2VXYN1wVyxpeYzksvBqgCmtCTWmQpSQMqAY5UsY1pVkLJIlE GdngnCSBl/8bjhtI5BrKzscxYik4QvURt3SWsOBykQt69xLJVJMkVTC0lHXQ0dEGZ0 TyZ3zq3ze7lmoKI0pXVtlmyncL/vy3y3G9avUBFYTZsOzHf9PFIw5BCIqIm7xR72l3 U/FcKFevTbRoeKH/oxpZvnEMCiGG3mfQzcitSC9Hmd6RgTejNiSH3KKltIo3TpNKKx W7FKlTdpIkH6PUXvh3dauab+vMEFOo6ZnRhVy9onMxCymJCKWIhldYPRhweL00U6qB Rw1rNIh6cBLFQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 76DC86795D for ; Thu, 4 Sep 2025 07:05:21 -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 VzkD-oT90VKC for ; Thu, 4 Sep 2025 07:05:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991121; bh=eL1FkqndabxutLqCyaYy6xSiYLBoculVNHJ02KLfyJc=; 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=ZSBIDb1yTi6P0PHfD2VXYN1wVyxpeYzksvBqgCmtCTWmQpSQMqAY5UsY1pVkLJIlE GdngnCSBl/8bjhtI5BrKzscxYik4QvURt3SWsOBykQt69xLJVJMkVTC0lHXQ0dEGZ0 TyZ3zq3ze7lmoKI0pXVtlmyncL/vy3y3G9avUBFYTZsOzHf9PFIw5BCIqIm7xR72l3 U/FcKFevTbRoeKH/oxpZvnEMCiGG3mfQzcitSC9Hmd6RgTejNiSH3KKltIo3TpNKKx W7FKlTdpIkH6PUXvh3dauab+vMEFOo6ZnRhVy9onMxCymJCKWIhldYPRhweL00U6qB Rw1rNIh6cBLFQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 655046794A for ; Thu, 4 Sep 2025 07:05:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991120; bh=/zBXMvCwFNCErD/XcrCNIhLs9lb/k8wGSj0DAltCHmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O5Swg7QcH13fqlHV8Fd6qM7duLxp+GrwEZxwZspoq7NAdip5lXSIdfMAIxhHUr6sp +8qxVsHv+v78vz2Y3Z64tSipcSZbmv9IBoRfsHIWe3KIGK7WWWN8dN9Gd5Baneq4QZ Qrs1AyKy38/mwnEaO6j52cJFrrEp0HgSfWIEIL8etxz1Br98Xde3w/wxDjjI/Vuy7z eE/JGU6Sn+rg+d5BlRONQpgUHeMJYtUB+vWYx9NHVcp667denZQhVYojh54udW/qJE F5KwaWv4O0oZYgC7n+lC/XK6I25mCxQV+rSO5z0xnp7EOCruR9PsiKU3e0Df9SLluZ JddT5R0Bxt3nA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D29367886; Thu, 4 Sep 2025 07:05:20 -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 x9bWPp-jUQrL; Thu, 4 Sep 2025 07:05:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991115; bh=Bz1I4fY9QjhDZVmm6qRYP7+u6EZR5SoHuVkeLrE58OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KU7Sd0L8wmKmVhJPin+vwCnhEJTRFPgakypDYBZdIw7I0SE3qFqQr7V1raQCCS5h0 VE5aPO+RbpDEzCtH7cF17ry8k5Kag9WQFPoGPHRVTXBjfDJq+mcor7wlDXNjQUAoKl HUJx4qiWD4MJG/A9IerSS+hbEO6WNljn3bKPCIZc2qenmMkE8+tghGwoFO3EXnzfL9 RW48DDGMeSGM6hyupVmMGgE018ce1BfQYCyFtuHgPmpGF4PCe+QBtWA8U7BSsqmjha B1SKpxSOPYxmbKYXBGk0jaa8kIeNTuHHWFcpgW8XQgyWdK/RPIq+gK/kPjXEAoO2pj hdQPyDZOoe5Rw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8DA74678AB; Thu, 4 Sep 2025 07:05:15 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:34 -0600 Message-ID: <20250904130459.848794-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JWIF2L53NYH4CFZ3YR6J22POK2FNSJQ6 X-Message-ID-Hash: JWIF2L53NYH4CFZ3YR6J22POK2FNSJQ6 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: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/18] doc: Add fuzzing build documentation 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 some docs for using fuzzing with U-Boot, including building, running tests, and adding new tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- doc/build/fuzz.rst | 219 ++++++++++++++++++++++++++++++++++++++++++++ doc/build/index.rst | 1 + 2 files changed, 220 insertions(+) create mode 100644 doc/build/fuzz.rst diff --git a/doc/build/fuzz.rst b/doc/build/fuzz.rst new file mode 100644 index 00000000000..4c05df4dc21 --- /dev/null +++ b/doc/build/fuzz.rst @@ -0,0 +1,219 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Building U-Boot with Fuzzing Support +===================================== + +U-Boot supports fuzzing through libFuzzer when built for the sandbox +architecture. Fuzzing helps identify security vulnerabilities and crashes by +testing with randomly generated inputs. + +Prerequisites +------------- + +The following tools are required: + +* Clang compiler with fuzzing support +* libstdc++ development libraries + +On Ubuntu/Debian systems, install the required packages:: + + sudo apt install clang libstdc++-dev + +Building with Fuzzing +--------------------- + +The recommended approach is to use buildman, which handles the configuration +automatically: + +1. Build with buildman (recommended):: + + buildman --bo sandbox -a FUZZ=y -O clang -L -o /tmp/fuzz -w + +The buildman options: + +* ``--booard sandbox`` - Build for sandbox board only +* ``-a FUZZ=y`` - Enable fuzzing support via CONFIG_FUZZ=y +* ``-O clang`` - Use Clang compiler (required for fuzzing) +* ``-L`` - Disable LTO to avoid sanitizer coverage linker issues +* ``-o /tmp/fuzz`` - Output directory +* ``-w`` - Use the output directory as the work directory + +Alternative: Manual build +~~~~~~~~~~~~~~~~~~~~~~~~~ + +To build manually with make: + +1. Configure the build with fuzzing enabled:: + + make HOSTCC=clang CC=clang O=/tmp/fuzz LTO_ENABLE= sandbox_defconfig + scripts/config --file /tmp/fuzz/.config --enable FUZZ + +2. Build the fuzzing-enabled binary:: + + make HOSTCC=clang CC=clang O=/tmp/fuzz LTO_ENABLE= -j$(nproc) + +Build Output +------------ + +The fuzzing build produces: + +* ``u-boot`` - Main fuzzing binary with AddressSanitizer and fuzzer + instrumentation +* Significantly larger binary size due to instrumentation (typically 40-50MB) +* Debug symbols included for better crash analysis + +Fuzzing Architecture +-------------------- + +The U-Boot fuzzing implementation consists of: + +* **Fuzzing Engine**: Sandbox-specific driver that interfaces with libFuzzer +* **Threading Model**: Separate threads for fuzzing harness and U-Boot + execution +* **Input Handling**: ``LLVMFuzzerTestOneInput()`` entry point processes + fuzz inputs +* **Command Fuzzing**: Tests U-Boot commands with generated inputs via + ``fuzz`` command + +Key source files: + +* ``arch/sandbox/cpu/fuzz.c`` - Main fuzzing implementation +* ``drivers/fuzz/`` - Fuzzing engine drivers +* ``test/fuzz/`` - Fuzzing test cases +* ``include/fuzzing_engine.h`` - Fuzzing engine interface + +Running Fuzz Tests +------------------ + +To run fuzzing tests, set the test name via environment variable and run the +fuzzing binary from the build directory: + +1. Change to the build directory:: + + cd /tmp/fuzz + +2. Set the fuzz test to run:: + + export UBOOT_SB_FUZZ_TEST=fuzz_vring + +3. Run the fuzzer:: + + ./u-boot + +The fuzzer will start libFuzzer with coverage-guided input generation. You +should see output similar to:: + + INFO: Running with entropic power schedule (0xFF, 100). + INFO: Seed: 1626867009 + INFO: Loaded 1 modules (104150 inline 8-bit counters): ... + #2 INITED cov: 28 ft: 29 corp: 1/1b exec/s: 0 rss: 318Mb + #4 NEW cov: 29 ft: 30 corp: 2/3b lim: 4 exec/s: 0 rss: 319Mb + +Available fuzz tests include: + +* ``fuzz_vring`` - Tests VirtIO ring buffer handling + +To stop fuzzing, use Ctrl+C. The fuzzer will automatically save any crash- +inducing inputs for later analysis. + +Understanding Fuzzer Output +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The fuzzer output shows: + +* ``cov: N`` - Number of code coverage points reached +* ``ft: N`` - Number of features discovered +* ``corp: N/Mb`` - Corpus size (number of test cases / total bytes) +* ``exec/s: N`` - Executions per second (performance metric) +* ``rss: NMb`` - Memory usage + +Error messages from the target code (like VirtIO "out of range" errors) are +expected and indicate the fuzzer is finding edge cases. + +Adding New Fuzz Tests +--------------------- + +To create a new fuzz test, follow these steps: + +1. **Create the test file** in ``test/fuzz/`` directory:: + + /* SPDX-License-Identifier: GPL-2.0+ */ + #include + + static int fuzz_my_component(const uint8_t *data, size_t size) + { + /* Your fuzzing logic here */ + if (size < 4) + return 0; /* Not enough data */ + + /* Test your component with fuzzed data */ + my_component_function(data, size); + + return 0; + } + FUZZ_TEST(fuzz_my_component, 0); + +2. **Add to Makefile** in ``test/fuzz/Makefile``:: + + obj-$(CONFIG_MY_COMPONENT) += my_component.o + + Or for tests that should always be included:: + + obj-y += my_component.o + +3. **Test the new fuzzer**:: + + export UBOOT_SB_FUZZ_TEST=fuzz_my_component + ./u-boot + +**Best practices for fuzz tests:** + +* **Input validation**: Check minimum data size requirements +* **Error handling**: Handle invalid inputs gracefully, don't panic +* **Resource cleanup**: Free any allocated resources +* **Focused testing**: Target specific functions or code paths +* **Deterministic**: Same input should produce same behavior + +**Example patterns:** + +* Parse structured data (protocols, file formats) +* Test buffer handling with varying sizes +* Exercise error paths with malformed inputs +* Stress test with boundary conditions + +Troubleshooting +--------------- + +**Linker errors about missing libstdc++**: + Install libstdc++ development libraries as shown in Prerequisites. + +**Sanitizer coverage linker errors**: + Ensure LTO is disabled with ``LTO_ENABLE=`` in the make command. + +**Build fails with GCC**: + Fuzzing requires Clang. Ensure both CC and HOSTCC are set to clang. + +**Fuzzer exits with "fdtdec_setup() failed"**: + Run the fuzzer from the build directory where u-boot.dtb is located. + The sandbox requires access to its device tree file. + +Security Considerations +----------------------- + +Fuzzing builds include: + +* **AddressSanitizer**: Detects buffer overflows, use-after-free, and other + memory errors +* **Fuzzer Coverage**: Instruments code for coverage-guided fuzzing +* **Debug Information**: Retained for crash analysis and debugging + +These features significantly increase binary size and runtime overhead, making +fuzzing builds unsuitable for production use. + +Further Reading +--------------- + +* :doc:`/arch/sandbox/sandbox` - General sandbox architecture documentation +* libFuzzer documentation: https://llvm.org/docs/LibFuzzer.html +* AddressSanitizer documentation: + https://clang.llvm.org/docs/AddressSanitizer.html diff --git a/doc/build/index.rst b/doc/build/index.rst index 7a4507b5746..bd380a5e6c2 100644 --- a/doc/build/index.rst +++ b/doc/build/index.rst @@ -9,6 +9,7 @@ Build U-Boot source gcc clang + fuzz reproducible docker tools From patchwork Thu Sep 4 13:04:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 217 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=1756991128; bh=vJzzIoTtNj5v1auTLOarKmawOq8yDioR3MFJomYJM1A=; 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=hhr6eu4oK946BQGEkr2uBaLUD8RuNZ2g6JN4QitQ7wp6NmCCpliHj+TJUtCQsRZ2P bg+j8F/3AvAowFJILHgy1eO+xPSkxuXL+0W/I8r2vmzeshCbNc+UMpeklq6Mlf/ugp hLtRWNcoKkh0iDm3ylWOghcKgTUuQUZO5ZP1vdflNTdeRJunco/7d+47mU+Nltp9WS 47yxzgI5SeTLsDFh7bbwWbjLhQpRoHSlSoFeu2eRYyoesay9g5m18rYTlg8D1rm4EF aoy4yuiedr/+s0ocIw+XpGk+yIp4srE+1jTXmxlvdOxAu3wb7zEW6IspOFE0XWKR/l 7DaCCga6KDMSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D9DC678AB for ; Thu, 4 Sep 2025 07:05:28 -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 58BpZpF7Cn5T for ; Thu, 4 Sep 2025 07:05:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991126; bh=vJzzIoTtNj5v1auTLOarKmawOq8yDioR3MFJomYJM1A=; 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=YOsLQT96TviqcsJgIeCFZ5QjdoRiAy/rOskYnP/rBzCDWFyESPkKL9porZ7CqLh6I Watw9xuhpgB2ou6kvamV6JOmq2fiPunSGC4stGInOvozdHClQPUZ5M+3wcz2ZHbLFH 74AyAmbWfUIPoya9zbn4bKXYbF82i97YT/fVi05AOlVu6O7kcYcqE8mkmW0fMXzTKC 8ivjT9mZW9sAH11eg2rpGNl1w2i4/eV4wrq6D8UV/aFpiB5JDFprdeageeQZxKybce huJtyc9dk13NAPZZbmzlCfiW4Z/aX5I2oZ60F7A8HyJ+Q0Ffq14C9g4EoPq/dT3yEn UaQdjDlnox4dg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71D1F6795E for ; Thu, 4 Sep 2025 07:05:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991123; bh=QQtSX4deElsE9JiJ4RP5Vi9RlVYOtK+6x1H1vGJlovI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKLZ28SVVTk6OPO0HSiQquLJOHCLbrXG3S5Z2ZCXTHkZQZPtQjC9lmVhfgu8ONZoF bwPesO3algl41xq2WrXWCIUH2G2P7Wi8ETZrXgCjmvxji7mrxH+jaix56ncYUNJzJ9 5IA7Jtijn/pI/TAwIJir+m5XDeMshVkOt13X09UDtwLnpTsDYU5X8cH6hy9CSaHa40 G4wrV2ZNWcaXG84DJrtxQVB+VX8mMh8SlMj1ZT1JH+zT7Q1q6KzwdIhta+gmObAJro npCPbZCrpKezlRahvR+olvRqc4TyfRkZC66r2nRrNKZSMpAlDymQePPoL2dpEW3HAc FNA5oXOmivpQA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BB5BB678F6; Thu, 4 Sep 2025 07:05:23 -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 gosJSBCaDZg3; Thu, 4 Sep 2025 07:05:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991120; bh=aLjc36CREpXCWdWiMWqA1Q6EX+IeBkO81RUC4+4UERU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tB0kUFe2U30Kj0Tt4KbNqANLX0FIV30I1lIXN0skwlSNXwMDFVGjpjzxBzljqxXM5 g5um26OwCYlQRWO7jB1dP9asP0qhTvEEFohUCKF3jZvwPl4Strhw6ZwxABkoNUm18d WPOp7bh1z6Gqm57O9ODkCnQaDok9QbAC3LnxMxv+OQqr6eaw7driNiPi4wBi71aTsX sILutH+pit1zAPBsPUmb4i5ExYsiQMaqPOkU8KzJTUOUt8GvQgC175SjmjXQp1mpfQ WcPIUN4SMzLGghr0onm74+TjUa2Q+u8QjYa8DKZc9N4cwHxFLsv0vG8opSjemknhmw vgsOlDkNBze/Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6012B678AB; Thu, 4 Sep 2025 07:05:20 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:35 -0600 Message-ID: <20250904130459.848794-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LOZ23BE6XLUMA3JAIQQZWVQZ64C5U56V X-Message-ID-Hash: LOZ23BE6XLUMA3JAIQQZWVQZ64C5U56V 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/18] board_r: Drop MMC init from the startup sequence 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 should be handled by driver model now. In any case there is nothing special about MMC which indicates that it should be inited and announced at startup. Drop it. Signed-off-by: Simon Glass --- common/board_r.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index de28079a0c5..d60cc7aac70 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -381,15 +381,6 @@ static int initr_onenand(void) } #endif -#ifdef CONFIG_MMC -static int initr_mmc(void) -{ - puts("MMC: "); - mmc_initialize(gd->bd); - return 0; -} -#endif - #ifdef CONFIG_PVBLOCK static int initr_pvblock(void) { @@ -667,9 +658,6 @@ static void initcall_run_r(void) #if CONFIG_IS_ENABLED(CMD_ONENAND) INITCALL(initr_onenand); #endif -#if CONFIG_IS_ENABLED(MMC) - INITCALL(initr_mmc); -#endif #if CONFIG_IS_ENABLED(XEN) INITCALL(xen_init); #endif From patchwork Thu Sep 4 13:04:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 216 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=1756991126; bh=d1DWTtc4E1qPxeaBbbEBaqPATeb+27xMxhHUNxVyv9w=; 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=DrfM4cAQbo0lS0ErOwz+Ytua2e+zTsTxwlAvSZ2YlplC+ifklrjjC8tnYW48WZWA/ UpTbWamKMF7PwgC522JRfVFjMno6WtgojpAcQqAzdl/s6Hbh3xzWxcvq5SBBXJeuJq swBr6vqJXm5NLvGVoRBdm2aC+9RlQoskSU7rmHojK+OGJVC7O3Nbus7qjQBoQ2zdBG 9kS6TdpJFpQDERh24VA28XW3XjXnUNZFD04SYYy4k3ZwU0W0oVj7T1elk7MMbxcog2 JJ0vgU51ZKpamxo1g0Th6VXTYE5IAyDnSvcm7eA+wajUmBq5cx/LaZOG7h8RO7C0qZ F0PL69zYiz8RQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1997B67959 for ; Thu, 4 Sep 2025 07:05:26 -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 NDCCs2KEa58y for ; Thu, 4 Sep 2025 07:05:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991126; bh=d1DWTtc4E1qPxeaBbbEBaqPATeb+27xMxhHUNxVyv9w=; 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=DrfM4cAQbo0lS0ErOwz+Ytua2e+zTsTxwlAvSZ2YlplC+ifklrjjC8tnYW48WZWA/ UpTbWamKMF7PwgC522JRfVFjMno6WtgojpAcQqAzdl/s6Hbh3xzWxcvq5SBBXJeuJq swBr6vqJXm5NLvGVoRBdm2aC+9RlQoskSU7rmHojK+OGJVC7O3Nbus7qjQBoQ2zdBG 9kS6TdpJFpQDERh24VA28XW3XjXnUNZFD04SYYy4k3ZwU0W0oVj7T1elk7MMbxcog2 JJ0vgU51ZKpamxo1g0Th6VXTYE5IAyDnSvcm7eA+wajUmBq5cx/LaZOG7h8RO7C0qZ F0PL69zYiz8RQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0387F678BF for ; Thu, 4 Sep 2025 07:05:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991123; bh=AR4/n4Qyf83TBMhRba0ntLcU2GdM3RjxDWWIhwXRf/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pcr97fuVZP5iAjJzcKirbj7ERy4K4N++VGYlzxiZXOblzRnN2ElOaV4kAlejrFYOa Mm8E9DIsLw+xZtmKXuedZ6wsypncFvoOl6aTTrjD/VFDcVMps1wppy0Z1hqHpFABFf kWey8XLIANb7HU7idQcau/qZtY4t22QBGUdyT7qAeXiuOetvG7FBH1flcbZnnJo/uL yOErQRVHAsv9Ke4Ks2hOdYDtxv1TuKk3K4alV0RhNKsvX5pomrDg4mrqg42Dv+2uzp 4DYL035EC+gtTkfx2Adj3PG5fVHS5ScQLCSIr6tD1FxFuzbMi8TfP8VIBysLrOGHuA 0hdvFTuHGVMSA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BA3EC678BF; Thu, 4 Sep 2025 07:05:23 -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 d_0bf2iVA46a; Thu, 4 Sep 2025 07:05:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991122; bh=IAHMfyEfuEic2Y8ihXLKTGdo+J/V0Zn2pBOMLWkK+kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpPNURCBAZYSsYno+3jWpOp6EtOoFqloXMiJLUgi7syeWm3FcdewsfuVzGsoQ7Okv 1t+kFflHExrFODwLDmby7bkvL+BUYO+m4hbPoA+Nymi6ut6GFeYAoi9hXX9dgW6OLe L221QQHOgqWoKM3l/u1NPtPdvUdS3M1sDOQAkrePopwMA4ix+YTUDqawXXCOGf4wIm DUEa9bZH/m75LAP4+KUTkm+GBdw8ZSvlowzgaBUWwOFMaVzdMTK/KSsTMdiJQ57lMY gtaDSK6vyOTKkZox1udK+7/cDpY/N1BBBoE1gK6SMPzMrqQ3G5IyI05IKiATiUZ5nO 28VJB1u6l8Wog== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3A6FB678C8; Thu, 4 Sep 2025 07:05:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:36 -0600 Message-ID: <20250904130459.848794-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QPVR6FCMGSZEWSQVNIRYCAY52FXCVXCU X-Message-ID-Hash: QPVR6FCMGSZEWSQVNIRYCAY52FXCVXCU 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/18] sandbox: Avoid mon_len being larger than available RAM 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 With the shared library the size can be quite large. Normally sandbox pretends that its code is mapped into emulated RAM, even though it actually isn't. This is fine in most cases, but when mon_len exceeds the RAM size the reservation top starts off at a negative address (i.e. very near the top of the address space), which immediately segfaults. Add a special case for this, for sandbox only. We might consider dropping this mapping altogether, as is down with RISC-V, but that is left for further discussion. With this, the test app boots to a prompt. Signed-off-by: Simon Glass --- common/board_f.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/board_f.c b/common/board_f.c index 3a4fb9a42ef..eac51d61fa1 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -460,7 +460,11 @@ static int reserve_uboot(void) * reserve memory for U-Boot code, data & bss * round down to next 4 kB limit */ - gd->relocaddr -= gd->mon_len; + if (IS_ENABLED(CONFIG_SANDBOX) && gd->mon_len > gd->relocaddr) + log_debug("Cannot reserve space for U-Boot\n"); + else + gd->relocaddr -= gd->mon_len; + gd->relocaddr &= ~(4096 - 1); #if defined(CONFIG_E500) || defined(CONFIG_MIPS) /* round down to next 64 kB limit so that IVPR stays aligned */ From patchwork Thu Sep 4 13:04:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 218 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=1756991130; bh=bHrfOralAswRraLXXOB5hvEemJnvl/AOifCZ14ORUxs=; 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=aDECA0oiiE7H+Xw5bHgmjDbKdy2y+LXeWlg1NqoE0tOE/9ydCQKEy9P+jDHcOBd55 ldHKwOH3zLFtULCKAJB/qMUVc7IpKWdYovGAGjP34l156AMWcj9bcoanrbVDvJLCUK pdEoKJkVDQZ+yRTPSSeFR+2qhBruICLLAcJ4jz9hnMhn9ZnlEIxb1EFB7iKGTpMY6l YuT3UVyuQbl7u1BCdB/ORfukKV20AFJZT9AAtz82vFcXQdbEXkBEeWSLyojU0RZsK7 x4cGwvZbwMsRMwW2HBmnHvK6XrnHQEuIfxbJa4nFYPE+o9u2lpOiIi4Yvu1p3Qkb+k e55WbTzBmINYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DB3986795D for ; Thu, 4 Sep 2025 07:05:30 -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 XCJAMoZxH1rl for ; Thu, 4 Sep 2025 07:05:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991130; bh=bHrfOralAswRraLXXOB5hvEemJnvl/AOifCZ14ORUxs=; 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=aDECA0oiiE7H+Xw5bHgmjDbKdy2y+LXeWlg1NqoE0tOE/9ydCQKEy9P+jDHcOBd55 ldHKwOH3zLFtULCKAJB/qMUVc7IpKWdYovGAGjP34l156AMWcj9bcoanrbVDvJLCUK pdEoKJkVDQZ+yRTPSSeFR+2qhBruICLLAcJ4jz9hnMhn9ZnlEIxb1EFB7iKGTpMY6l YuT3UVyuQbl7u1BCdB/ORfukKV20AFJZT9AAtz82vFcXQdbEXkBEeWSLyojU0RZsK7 x4cGwvZbwMsRMwW2HBmnHvK6XrnHQEuIfxbJa4nFYPE+o9u2lpOiIi4Yvu1p3Qkb+k e55WbTzBmINYg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BDCDD6794A for ; Thu, 4 Sep 2025 07:05:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991128; bh=E70+o6o0XDysoCP4VZ7+aGy7KkMdAIPQJgSLt+ettC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=paNJEXJCIGRfGy7rjMoAaRn69eRjcpqt8JHbIHrbmxaTpfY1qcbz07ZW6qjDf5kPj oOTu5ap+oPlA+otrOd/HIoq+SDhTjIVT1npI58crLzSI+T8x5H0vF5GvfUlbaK8v+3 tCYXaEebOSNDY9RKMW6FX55L+pJQsFr7EjZDfTB2eF4ITkLXfJ3T6LgjMb5mRQ8+Y3 FBofu5ldMY6ZLtwgVRbJFaxhJOS0tUENwQlI63pAX/uf7OjpZbVoNQ8sdN0ekXh6Ra 1eI2QSbtKR4ID4bD+jDzbUF1boK2gfE2iEoz9uAdtdY4PmJecjqyuUgheq5nm3Yugz em25zn+SKtZNw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EE9236795E; Thu, 4 Sep 2025 07:05:28 -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 zKpgEZKzxdR2; Thu, 4 Sep 2025 07:05:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991123; bh=bHPVgjpzKCvriybOo9Dy1Dy/lZ5/v7gAX+1/dc2NLzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EPVd8ykQV0MkxvqK4V0qtXc6Z4rOZbRf+DZN/rGJAhfj/SnNMDEMK9iUnPN1RyMRu fo3hP0X9kTITe9kfxLHfKTIGMuIfy/Uqj8ukXeDDr6kEthvG9DefnyDmQho+sqXT72 y9lHDKHZ1orvdKTpMjvkHj89F3bTl3W3eBejaWLnVe6nw2ELybvmy+xNINxvPutG0G U9tDE+TBNhsQ1EeqGBIrSyowz0BeShYKcQnAK64vTPLzzCodIW0Kdy3y1jL3x+groI FYFTMV3D7en9Pj0mnATMVn9jUhHb6W5hwycIgwhSChSwfmmNdTSN+nVAnV23mQEORK lq9mwz1eJdMnA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 097D56794A; Thu, 4 Sep 2025 07:05:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:37 -0600 Message-ID: <20250904130459.848794-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JWZJMIXKZRU4ZZQJUU63RA4L5BIMIUCV X-Message-ID-Hash: JWZJMIXKZRU4ZZQJUU63RA4L5BIMIUCV 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: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/18] sandbox: Move PCI functions to separate header 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 Move pci_map_physmem(), pci_unmap_physmem(), and sandbox_set_enable_pci_map() from u-boot-sandbox.h to a new file sandbox_pci.h to simplify dependencies. Fix the header order in the PCI emul file while we are here. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/sandbox/cpu/mem.c | 1 + arch/sandbox/include/asm/sandbox_pci.h | 61 +++++++++++++++++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 50 +------------------ drivers/pci/pci-emul-uclass.c | 3 +- test/dm/pci.c | 1 + 5 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 arch/sandbox/include/asm/sandbox_pci.h diff --git a/arch/sandbox/cpu/mem.c b/arch/sandbox/cpu/mem.c index 4e9b629e3aa..b5c7ea6493d 100644 --- a/arch/sandbox/cpu/mem.c +++ b/arch/sandbox/cpu/mem.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/arch/sandbox/include/asm/sandbox_pci.h b/arch/sandbox/include/asm/sandbox_pci.h new file mode 100644 index 00000000000..a4a4eaece8f --- /dev/null +++ b/arch/sandbox/include/asm/sandbox_pci.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2011 The Chromium OS Authors. + */ + +#ifndef _ASM_SANDBOX_PCI_H_ +#define _ASM_SANDBOX_PCI_H_ + +#include + +struct udevice; + +/** + * pci_map_physmem() - map a PCI device into memory + * + * This is used on sandbox to map a device into memory so that it can be + * used with normal memory access. After this call, some part of the device's + * internal structure becomes visible. + * + * This function is normally called from sandbox's map_sysmem() automatically. + * + * @paddr: Physical memory address, normally corresponding to a PCI BAR + * @lenp: On entry, the size of the area to map, On exit it is updated + * to the size actually mapped, which may be less if the device + * has less space + * @devp: Returns the device which mapped into this space + * @ptrp: Returns a pointer to the mapped address. The device's space + * can be accessed as @lenp bytes starting here + * Return: 0 if OK, -ve on error + */ +int pci_map_physmem(phys_addr_t paddr, unsigned long *lenp, + struct udevice **devp, void **ptrp); + +/** + * pci_unmap_physmem() - undo a memory mapping + * + * This must be called after pci_map_physmem() to undo the mapping. + * + * @paddr: Physical memory address, as passed to pci_map_physmem() + * @len: Size of area mapped, as returned by pci_map_physmem() + * @dev: Device to unmap, as returned by pci_map_physmem() + * Return: 0 if OK, -ve on error + */ +int pci_unmap_physmem(const void *addr, unsigned long len, + struct udevice *dev); + +/** + * sandbox_set_enable_pci_map() - Enable / disable PCI address mapping + * + * Since address mapping involves calling every driver, provide a way to + * enable and disable this. It can be handled automatically by the emulator + * uclass, which knows if any emulators are currently active. + * + * If this is disabled, pci_map_physmem() will not be called from + * map_sysmem(). + * + * @enable: 0 to disable, 1 to enable + */ +void sandbox_set_enable_pci_map(int enable); + +#endif /* _ASM_SANDBOX_PCI_H_ */ diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 23eaa3a45e6..3c4347117d4 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -14,6 +14,8 @@ #ifndef _U_BOOT_SANDBOX_H_ #define _U_BOOT_SANDBOX_H_ +#include + /* board/.../... */ int board_init(void); @@ -26,54 +28,6 @@ int sandbox_lcd_sdl_early_init(void); struct udevice; -/** - * pci_map_physmem() - map a PCI device into memory - * - * This is used on sandbox to map a device into memory so that it can be - * used with normal memory access. After this call, some part of the device's - * internal structure becomes visible. - * - * This function is normally called from sandbox's map_sysmem() automatically. - * - * @paddr: Physical memory address, normally corresponding to a PCI BAR - * @lenp: On entry, the size of the area to map, On exit it is updated - * to the size actually mapped, which may be less if the device - * has less space - * @devp: Returns the device which mapped into this space - * @ptrp: Returns a pointer to the mapped address. The device's space - * can be accessed as @lenp bytes starting here - * Return: 0 if OK, -ve on error - */ -int pci_map_physmem(phys_addr_t paddr, unsigned long *lenp, - struct udevice **devp, void **ptrp); - -/** - * pci_unmap_physmem() - undo a memory mapping - * - * This must be called after pci_map_physmem() to undo the mapping. - * - * @paddr: Physical memory address, as passed to pci_map_physmem() - * @len: Size of area mapped, as returned by pci_map_physmem() - * @dev: Device to unmap, as returned by pci_map_physmem() - * Return: 0 if OK, -ve on error - */ -int pci_unmap_physmem(const void *addr, unsigned long len, - struct udevice *dev); - -/** - * sandbox_set_enable_pci_map() - Enable / disable PCI address mapping - * - * Since address mapping involves calling every driver, provide a way to - * enable and disable this. It can be handled automatically by the emulator - * uclass, which knows if any emulators are currently active. - * - * If this is disabled, pci_map_physmem() will not be called from - * map_sysmem(). - * - * @enable: 0 to disable, 1 to enable - */ -void sandbox_set_enable_pci_map(int enable); - /** * sandbox_reset() - reset sandbox * diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index 166ee9fcd43..b0b229595ae 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -7,9 +7,10 @@ #include #include #include -#include #include +#include #include +#include struct sandbox_pci_emul_priv { int dev_count; diff --git a/test/dm/pci.c b/test/dm/pci.c index bcd274d1879..4f7ee8ab845 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include From patchwork Thu Sep 4 13:04:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 219 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=1756991133; bh=1kuPFaEIezKErg4oWpukLFv26JO2YlQ7bBIev64RHRE=; 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=kLk/x/gTYgWhne+KxN3JLblnUHNAeb9qb6DH7GUx3qwCyBRp/1PKVwGPI2bhOQECF KH1evr2S7aZG0W+D2xkEYdckH1Rkp0hhT11MbNEHdAf6Cl9dLwNxgPyiZ6WBNl46xu 03EvMmlIxRbpjxTy61tE4yf5AinnjX9cLIi9dPpSFGUM4VPnhCSwLErrGBIZIIxRBS /DOiXHorGycXqSlsXR/uBXTAkFh9YFzeT5eINvMDQi5d+QXka2zYk/aeUeDDoW8B7P fKFswMlsCwMJllSTrDsU90k3i8pPQ4oRkny/4vTsaBx++kgCUCok5vKaRYi9zhmbh/ 0ObwAniWCmA8g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 628536795D for ; Thu, 4 Sep 2025 07:05: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 10024) with ESMTP id m8od9hZ9cNEy for ; Thu, 4 Sep 2025 07:05:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991133; bh=1kuPFaEIezKErg4oWpukLFv26JO2YlQ7bBIev64RHRE=; 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=kLk/x/gTYgWhne+KxN3JLblnUHNAeb9qb6DH7GUx3qwCyBRp/1PKVwGPI2bhOQECF KH1evr2S7aZG0W+D2xkEYdckH1Rkp0hhT11MbNEHdAf6Cl9dLwNxgPyiZ6WBNl46xu 03EvMmlIxRbpjxTy61tE4yf5AinnjX9cLIi9dPpSFGUM4VPnhCSwLErrGBIZIIxRBS /DOiXHorGycXqSlsXR/uBXTAkFh9YFzeT5eINvMDQi5d+QXka2zYk/aeUeDDoW8B7P fKFswMlsCwMJllSTrDsU90k3i8pPQ4oRkny/4vTsaBx++kgCUCok5vKaRYi9zhmbh/ 0ObwAniWCmA8g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52C6D6795C for ; Thu, 4 Sep 2025 07:05:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991132; bh=UarvyzwTJAC9aKNHGePaQaJtrBuriy2bqYeRt+/F6n0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZRpI+8qYIohRCoLzbhnEokWAXC8x7yfe6YIqnTJ/Hox2YWzmAjJdfvoTXYBnXkD/ hz78QIoA7VZH6PrwaaV+7YELdFDgfUgDNLLdVIdWiFeoSrJyFwMPeh6HZJT9z1tFlj 9ZBj3Grw2UNJ5CpEUzDQ2AlG9vRj4KBk9ni03aRMXvtHZchOKDmTNbVLQMx26gjR3L YbkOKWH+4rM+6su/wYBYeIzm3hqGe5rZbHoA2bjPeh46boLl72PCg0NBF57N3saLQX VJ7amNnCCDhwP4TsegC3lIXMWoU6Nq2CSqp7vdNJjqzw0OtOAtxVykRpq693UbaNWv igI9XZd8DV8nw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1394D6795C; Thu, 4 Sep 2025 07:05:32 -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 FmCZ7sDhZTAj; Thu, 4 Sep 2025 07:05:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991127; bh=KjG+K8Su8X4HLgjJmly9u1igTFDJNZQT7FZZEhXWIkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGVU9l5fqDnfZdTmTTAIFxBd3wMzlF8aUqcLyBlru9SWs47yyqiYCwABW+35yFfp1 rXCc0OXeNEmFlU4Avf0FXFPmXQQToKJj3rRPuKLQSps9zwY+Cb8YZ442RsO3/ltPJV tGzMpPDgmAZWiDhYjDpjwXGGyWlUsCGAdTXUZrZo0Q+Jg8aBW2a6zPLclr9VyZpBFQ n+4uEr1Tuo9NqI32ZRhAKSpCR5BUMtR28Rc3LnJrAbKgCQ6qglpM719DeDvVyTrDxa S5OD8A9I0fNPa3O9Mvgz06gK9F2p+xlnqQ1tgy1yu0bRXAP5/b5uu7EfIa5dJNiyrD L0YfGRibpPhaQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AA54D67886; Thu, 4 Sep 2025 07:05:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:38 -0600 Message-ID: <20250904130459.848794-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FWGEJF3FF3A6TWZ73TL22WNXZMCIUAB3 X-Message-ID-Hash: FWGEJF3FF3A6TWZ73TL22WNXZMCIUAB3 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/18] sandbox: Move main.h contents into u-boot-sandbox 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 It isn't really necessary to have a header file for just one function. This makes it harder to see the full interface provided by sandbox. Move the sandbox_main() declaration into u-boot-sandbox.h Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 2 +- arch/sandbox/include/asm/main.h | 18 ------------------ arch/sandbox/include/asm/u-boot-sandbox.h | 12 ++++++++++++ 3 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 arch/sandbox/include/asm/main.h diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 101d695a556..d1632e6af69 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -30,9 +30,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/arch/sandbox/include/asm/main.h b/arch/sandbox/include/asm/main.h deleted file mode 100644 index 7a2f0d3a8d5..00000000000 --- a/arch/sandbox/include/asm/main.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (c) 2022 Google, Inc. - * Written by Andrew Scull - */ - -#ifndef __ASM_SANDBOX_MAIN_H -#define __ASM_SANDBOX_MAIN_H - -/** - * sandbox_main() - main entrypoint for sandbox - * - * @argc: the number of arguments passed to the program - * @argv: array of argc+1 pointers, of which the last one is null - */ -int sandbox_main(int argc, char *argv[]); - -#endif /* __ASM_SANDBOX_MAIN_H */ diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 3c4347117d4..54f0d9832b1 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -41,4 +41,16 @@ void sandbox_reset(void); /* Exit sandbox (quit U-Boot) */ void __noreturn sandbox_exit(void); +/** + * sandbox_main() - main entrypoint for sandbox + * + * @argc: the number of arguments passed to the program + * @argv: array of argc+1 pointers, of which the last one is null + + * This starts sandbox. It does not return unless something goes wrong. + * + * Return: 1 on error + */ +int sandbox_main(int argc, char *argv[]); + #endif /* _U_BOOT_SANDBOX_H_ */ From patchwork Thu Sep 4 13:04:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 220 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=1756991137; bh=8iomBcgHRQQ4czh6sAsTsUJjG1CLQrJ5UhOSdRpYhPE=; 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=c5wxlmtQ7YNqXyQLVTYFyd/4pnOjGvP8q3xpHzGBsHWcHZDiGlMo0UcADVwz1DZpH Bi4Cn93Gt2nLE7q+A/aL/tKRqGYfYUCw/68kRMp952ZGqW9s16Y07zPUYB2vpUlDq7 NK9uQ+U/ys/02XLOwV2qxGvy8F2J6+gAM0y/NIKVABtBjlUDN85mrB2JRg6usukMST oWz9DHVpNv0oiYhKeeqYixeeoWZadmdOEM9kEp2tUYoBBVBOoCyQfUkdkz4ezgBXhQ 4znYHjc0QLvGtd3Ivod/IghbhswvNYjQrJKh09I4KR9Ob/9iFOU+y/u1TNfh6qEBbV OMv9b3ciU+DSA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DD04E6795C for ; Thu, 4 Sep 2025 07:05: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 kaMsBm10zFAT for ; Thu, 4 Sep 2025 07:05:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991137; bh=8iomBcgHRQQ4czh6sAsTsUJjG1CLQrJ5UhOSdRpYhPE=; 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=c5wxlmtQ7YNqXyQLVTYFyd/4pnOjGvP8q3xpHzGBsHWcHZDiGlMo0UcADVwz1DZpH Bi4Cn93Gt2nLE7q+A/aL/tKRqGYfYUCw/68kRMp952ZGqW9s16Y07zPUYB2vpUlDq7 NK9uQ+U/ys/02XLOwV2qxGvy8F2J6+gAM0y/NIKVABtBjlUDN85mrB2JRg6usukMST oWz9DHVpNv0oiYhKeeqYixeeoWZadmdOEM9kEp2tUYoBBVBOoCyQfUkdkz4ezgBXhQ 4znYHjc0QLvGtd3Ivod/IghbhswvNYjQrJKh09I4KR9Ob/9iFOU+y/u1TNfh6qEBbV OMv9b3ciU+DSA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C71196795E for ; Thu, 4 Sep 2025 07:05:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991136; bh=Jks8s3eJBu2M7bW4kISynsudaY2Jr6ltb48vMSpHAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOrgiGU7qtM4YBe/qgvbKLyNg3T4HudUaQFvUHaOxMyme+nXaW7S3UWVJ27d4k0ab e26p51o6qA9NjHTWnvVThg5DmiJnIVat+T3scRvjOrhw1Nc1Vu4l9gT1BneMe69sb/ +6LgD7j0fx72kbNKlEtMOLufDGxN8Els5jPNstel0Qed4AamF0+Vdf1xjOv+FR+K0G kWsDe9WLxPqxNrGYzS9jzAGYiTszPSkjqyXSaPHySJ/+uPxyVk1UWAmTxerp5825MS Ds2jQnVI+kQ626+5Fxj1veLAtSDTdFDDHpHJiE2t63FkwfxM56cvB+AeIF7Tw22gdC pMKQYo0uq6RQw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0A986795C; Thu, 4 Sep 2025 07:05:36 -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 NLtp9IkMa4BF; Thu, 4 Sep 2025 07:05:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991132; bh=7fWddYT/cH2ic11yhGYXZTA+q8p6IMG4j4RuLWPI57o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K5ZwTZ0cqBqh8um86LFaVmKJU85cOJcskQcfM0Hvya6Rd1L9ofC34N1BZoH7vdb75 qeNBFcbcwGSN389/8rXC1WPb19L1UbAeFA6bEck5J7oz+GIvJD6eK7En7JENVd+rTc tdY6I6Z7qRVbYuPMhtUZGXpPOHyp3aIAq7BpoYnlan4q2uvqETwG+MxKSP6vsOYpVP 1tFqdJv5Csmod4F0LmuBeiembXgqgf96gNt05Aqdj7p+vleLgh3QPvbe3n6m8A3XSA DboCK/MQ3rpZJqDyMdKHlGlH/4wTgMrUa/tm947Ij/UYZo9lhu9IP3DRSTR0xPdmwm IIJ94dc5uh1uA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3D909678AB; Thu, 4 Sep 2025 07:05:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:39 -0600 Message-ID: <20250904130459.848794-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FBO2VEYFO2QESGZTTBWKDEHX7LEPOOP4 X-Message-ID-Hash: FBO2VEYFO2QESGZTTBWKDEHX7LEPOOP4 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: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/18] sandbox: Split main() into separate 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 Normally sandbox includes a main() function so that it can be started correctly. When fuzzing is enabled, main() is not required. When sandbox is built as a library, the main program will be somewhere else so must not be in the library. Split the main() function out into a new main.c file. Split the fuzzing code into a new fuzz.c file. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/sandbox/cpu/Makefile | 7 +- arch/sandbox/cpu/fuzz.c | 81 +++++++++++++++++++++++ arch/sandbox/cpu/main.c | 11 +++ arch/sandbox/cpu/os.c | 74 --------------------- arch/sandbox/cpu/start.c | 1 + arch/sandbox/include/asm/u-boot-sandbox.h | 5 +- 6 files changed, 102 insertions(+), 77 deletions(-) create mode 100644 arch/sandbox/cpu/fuzz.c create mode 100644 arch/sandbox/cpu/main.c diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index 03cdf2ae0f1..35f853776f7 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -6,13 +6,18 @@ # Wolfgang Denk, DENX Software Engineering, wd@denx.de. obj-y := cache.o cpu.o mem.o state.o os.o +ifdef CONFIG_FUZZ +obj-y += fuzz.o +else +obj-y += main.o +endif extra-y := start.o extra-$(CONFIG_SANDBOX_SDL) += sdl.o obj-$(CONFIG_XPL_BUILD) += spl.o obj-$(CONFIG_ETH_SANDBOX_RAW) += eth-raw-os.o # Compile these files with system headers -CFLAGS_USE_SYSHDRS := eth-raw-os.o os.o sdl.o +CFLAGS_USE_SYSHDRS := eth-raw-os.o fuzz.o main.o os.o sdl.o # sdl.c fails to build with -fshort-wchar using musl cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \ diff --git a/arch/sandbox/cpu/fuzz.c b/arch/sandbox/cpu/fuzz.c new file mode 100644 index 00000000000..f017c3a33ad --- /dev/null +++ b/arch/sandbox/cpu/fuzz.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2022 Google, Inc. + * Written by Andrew Scull + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static void *fuzzer_thread(void *ptr) +{ + char cmd[64]; + char *argv[5] = {"./u-boot", "-T", "-c", cmd, NULL}; + const char *fuzz_test; + + /* Find which test to run from an environment variable. */ + fuzz_test = getenv("UBOOT_SB_FUZZ_TEST"); + if (!fuzz_test) + os_abort(); + + snprintf(cmd, sizeof(cmd), "fuzz %s", fuzz_test); + + sandbox_main(4, argv); + os_abort(); + return NULL; +} + +static bool fuzzer_initialized; +static pthread_mutex_t fuzzer_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t fuzzer_cond = PTHREAD_COND_INITIALIZER; +static const uint8_t *fuzzer_data; +static size_t fuzzer_size; + +int sandbox_fuzzing_engine_get_input(const uint8_t **data, size_t *size) +{ + if (!fuzzer_initialized) + return -ENOSYS; + + /* Tell the main thread we need new inputs then wait for them. */ + pthread_mutex_lock(&fuzzer_mutex); + pthread_cond_signal(&fuzzer_cond); + pthread_cond_wait(&fuzzer_cond, &fuzzer_mutex); + *data = fuzzer_data; + *size = fuzzer_size; + pthread_mutex_unlock(&fuzzer_mutex); + return 0; +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + static pthread_t tid; + + pthread_mutex_lock(&fuzzer_mutex); + + /* Initialize the sandbox on another thread. */ + if (!fuzzer_initialized) { + fuzzer_initialized = true; + if (pthread_create(&tid, NULL, fuzzer_thread, NULL)) + os_abort(); + pthread_cond_wait(&fuzzer_cond, &fuzzer_mutex); + } + + /* Hand over the input. */ + fuzzer_data = data; + fuzzer_size = size; + pthread_cond_signal(&fuzzer_cond); + + /* Wait for the inputs to be finished with. */ + pthread_cond_wait(&fuzzer_cond, &fuzzer_mutex); + pthread_mutex_unlock(&fuzzer_mutex); + + return 0; +} diff --git a/arch/sandbox/cpu/main.c b/arch/sandbox/cpu/main.c new file mode 100644 index 00000000000..617295d142c --- /dev/null +++ b/arch/sandbox/cpu/main.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2011 The Chromium OS Authors. + */ + +#include + +int main(int argc, char *argv[]) +{ + return sandbox_main(argc, argv); +} diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index d1632e6af69..1c4e23cb4eb 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -28,7 +27,6 @@ #include #include -#include #include #include #include @@ -1151,75 +1149,3 @@ void os_relaunch(char *argv[]) execv(argv[0], argv); os_exit(1); } - -#ifdef CONFIG_FUZZ -static void *fuzzer_thread(void * ptr) -{ - char cmd[64]; - char *argv[5] = {"./u-boot", "-T", "-c", cmd, NULL}; - const char *fuzz_test; - - /* Find which test to run from an environment variable. */ - fuzz_test = getenv("UBOOT_SB_FUZZ_TEST"); - if (!fuzz_test) - os_abort(); - - snprintf(cmd, sizeof(cmd), "fuzz %s", fuzz_test); - - sandbox_main(4, argv); - os_abort(); - return NULL; -} - -static bool fuzzer_initialized = false; -static pthread_mutex_t fuzzer_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t fuzzer_cond = PTHREAD_COND_INITIALIZER; -static const uint8_t *fuzzer_data; -static size_t fuzzer_size; - -int sandbox_fuzzing_engine_get_input(const uint8_t **data, size_t *size) -{ - if (!fuzzer_initialized) - return -ENOSYS; - - /* Tell the main thread we need new inputs then wait for them. */ - pthread_mutex_lock(&fuzzer_mutex); - pthread_cond_signal(&fuzzer_cond); - pthread_cond_wait(&fuzzer_cond, &fuzzer_mutex); - *data = fuzzer_data; - *size = fuzzer_size; - pthread_mutex_unlock(&fuzzer_mutex); - return 0; -} - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - static pthread_t tid; - - pthread_mutex_lock(&fuzzer_mutex); - - /* Initialize the sandbox on another thread. */ - if (!fuzzer_initialized) { - fuzzer_initialized = true; - if (pthread_create(&tid, NULL, fuzzer_thread, NULL)) - os_abort(); - pthread_cond_wait(&fuzzer_cond, &fuzzer_mutex); - } - - /* Hand over the input. */ - fuzzer_data = data; - fuzzer_size = size; - pthread_cond_signal(&fuzzer_cond); - - /* Wait for the inputs to be finished with. */ - pthread_cond_wait(&fuzzer_cond, &fuzzer_mutex); - pthread_mutex_unlock(&fuzzer_mutex); - - return 0; -} -#else -int main(int argc, char *argv[]) -{ - return sandbox_main(argc, argv); -} -#endif diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 8ee12ed1500..40a3559d244 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 54f0d9832b1..001b00fe41e 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -46,8 +46,9 @@ void __noreturn sandbox_exit(void); * * @argc: the number of arguments passed to the program * @argv: array of argc+1 pointers, of which the last one is null - - * This starts sandbox. It does not return unless something goes wrong. + * + * This calls sandbox_init(), then board_init_f/r(). It does not return unless + * something goes wrong. * * Return: 1 on error */ From patchwork Thu Sep 4 13:04:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 221 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=1756991142; bh=SsDelqBcEWKkpzzZtb5pcRt80zpTpPM4yLz9vJBwkP4=; 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=fwzSEeH5CmzyqU6toSxYbMG8WaPN7TU+pvoA/YMPWT3QJ7gV6lv7qfQPSSGrRl4u3 4LKP0WeJM8rn3D+TjQLze/lxgUW5cGp2gM2TuHbTUfevjvmUNwCNyVSgAyec322Ey7 ACnT3pjzz7q9hIjrcQb4+VLlt3oVTDToB6RqTpfiQtnM3DBbF3Bd8dqRIIrSW9CPtN /lp6dcM82Tf/yiAHpoqYp2d+a7xQEtbSbCRPrcw8FCWlgHv0XpO+4HMyKfJNLvLA8+ mGuK9XC5rDpJs2v9KjmtXMlFy8IRcWdrg6CVJ9zzgD3Lrdd15jX2eyO1X9Uzyzczlk Ce18pY8BQkO+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51EA567961 for ; Thu, 4 Sep 2025 07:05:42 -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 qCc5G1kxkGfd for ; Thu, 4 Sep 2025 07:05:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991142; bh=SsDelqBcEWKkpzzZtb5pcRt80zpTpPM4yLz9vJBwkP4=; 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=fwzSEeH5CmzyqU6toSxYbMG8WaPN7TU+pvoA/YMPWT3QJ7gV6lv7qfQPSSGrRl4u3 4LKP0WeJM8rn3D+TjQLze/lxgUW5cGp2gM2TuHbTUfevjvmUNwCNyVSgAyec322Ey7 ACnT3pjzz7q9hIjrcQb4+VLlt3oVTDToB6RqTpfiQtnM3DBbF3Bd8dqRIIrSW9CPtN /lp6dcM82Tf/yiAHpoqYp2d+a7xQEtbSbCRPrcw8FCWlgHv0XpO+4HMyKfJNLvLA8+ mGuK9XC5rDpJs2v9KjmtXMlFy8IRcWdrg6CVJ9zzgD3Lrdd15jX2eyO1X9Uzyzczlk Ce18pY8BQkO+Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4147A678BF for ; Thu, 4 Sep 2025 07:05:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991140; bh=QSrWlNteS5Us4aEMIOVpbNxnl0uzxkdQMZPOoOHEftY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQfnYaR5z5rJQz5fRqIj0cNyDGEALQqkWg9bDzw4xIUegU2TLXbJEZM8PfVmw2GG5 vBmGTVN/fN+Bujd3Ny2TNqTNpBx3hGeRICbWfoblEHYVh9zgCLMUakb40lUY3QWzxl TXoq6qJjiavpALgCqNzHpQnrz4rCO9mv9gJfV97nDX2ZaYXGlws7oV43VCf/YGFdOG HTpIctfaQZAdF7IpqN6D61F+gtVoEHdwGD6L0zLhWKwltlFY7Jf2SbSwMjvF/pc17W qX17JQKic77TScu8qnR63dAEoV7XYV/v5R4KEQTSAVYR822EwalRqRDxZyTx/IzX3s VOuMhJH2A52Pw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4649C678BF; Thu, 4 Sep 2025 07:05:40 -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 0uMpbBuTPD2p; Thu, 4 Sep 2025 07:05:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991137; bh=PHnZunHayGZmr2oKXzjvWSmKYqNVSS+JpEyFiOMMLPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+cYd2WzBoGXLO7Y+aOtrBvznJzp58Ai3i2b1KAvSQ0Q78GM9YgPj6o/Ua7UballI /FeH14+MQlPAzOOLIa0gIuRWrJvtQcRjNSggkiu7BIxTIHgGWLp6TMkx+KP41SuQIh s2FrN6tfr39rZWSI6HOAogDm3G5xr0uyCC8msfo/D9qq49POC76azU/Sh39PZVwbp8 MYalS1ppHiSgZcDLvJXGode5s6xIgVdv5mP4bRqOOnOKNxlv55Ybqd04jkEpxKK8P9 XMnlk0TzTx391gGRohxgBtu0LH+KRgRMNeQ5x1WDisFMB0FdCQCYc965CJ4orGqzl4 4G8OhN+xaZp+Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E46D9678AB; Thu, 4 Sep 2025 07:05:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:40 -0600 Message-ID: <20250904130459.848794-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DCLVXBBEI4C3L4BUKBQON4ONSK3VZSNT X-Message-ID-Hash: DCLVXBBEI4C3L4BUKBQON4ONSK3VZSNT 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: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/18] sandbox: Extract init code into sandbox_init() 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 Split the init code from sandbox_main() into a separate sandbox_init() function that handles all setup up to the call to board_init_f(). This allows the init to be called independently of the main execution flow. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 25 ++++++++++++++++------- arch/sandbox/include/asm/u-boot-sandbox.h | 21 +++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 40a3559d244..59682b039e5 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -601,18 +601,16 @@ static int last_stage_init(void) } EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init); -int sandbox_main(int argc, char *argv[]) +int sandbox_init(int argc, char *argv[], struct global_data *data) { struct sandbox_state *state; void * text_base; - gd_t data; int size; int ret; text_base = os_find_text_base(); - memset(&data, '\0', sizeof(data)); - gd = &data; + gd = data; /* * This must be the first invocation of os_malloc() to have @@ -620,7 +618,7 @@ int sandbox_main(int argc, char *argv[]) */ ret = state_init(); if (ret) - goto err; + return ret; /* * Copy argv[] so that we can pass the arguments in the original @@ -663,13 +661,13 @@ int sandbox_main(int argc, char *argv[]) if (state->read_state && state->state_fname) { ret = sandbox_read_state(state, state->state_fname); if (ret) - goto err; + return ret; } if (state->handle_signals) { ret = os_setup_signal_handlers(); if (ret) - goto err; + return ret; } if (state->upl) @@ -692,6 +690,19 @@ int sandbox_main(int argc, char *argv[]) /* sandbox test: log functions called before log_init in board_init_f */ log_debug("debug: %s\n", __func__); + return 0; +} + +int sandbox_main(int argc, char *argv[]) +{ + gd_t data; + int ret; + + memset(&data, '\0', sizeof(data)); + ret = sandbox_init(argc, argv, &data); + if (ret) + goto err; + /* Do pre- and post-relocation init */ board_init_f(gd->flags); diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 001b00fe41e..941f35f9e69 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -16,6 +16,8 @@ #include +struct global_data; + /* board/.../... */ int board_init(void); @@ -41,6 +43,22 @@ void sandbox_reset(void); /* Exit sandbox (quit U-Boot) */ void __noreturn sandbox_exit(void); +/** + * sandbox_init() - init sandbox + * + * This function initialises sandbox state, parses arguments, and sets up the + * global data structure, but does not call board_init_f(). + * + * The caller must zero @data before calling this function. This function sets + * gd to point to @data so it must remain valid for the life of sandbox. + * + * @argc: the number of arguments passed to the program + * @argv: array of argc pointers, plus a NULL terminator + * @data: pointer to global data structure to init + * Return: 0 if OK, -ve on error + */ +int sandbox_init(int argc, char *argv[], struct global_data *data); + /** * sandbox_main() - main entrypoint for sandbox * @@ -50,6 +68,9 @@ void __noreturn sandbox_exit(void); * This calls sandbox_init(), then board_init_f/r(). It does not return unless * something goes wrong. * + * @argc: the number of arguments passed to the program + * @argv: array of argc pointers, plus a NULL terminator + * * Return: 1 on error */ int sandbox_main(int argc, char *argv[]); From patchwork Thu Sep 4 13:04:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222 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=1756991145; bh=XPFUyYOz2HWIEms+ii2uqgcVaYQTiF5HJsXYswT1TqQ=; 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=n8RllTeTk6hRgAONuhhmyLSSyfu9+OSfmx6kbQ87+Cfq4lG0A1TjHKdSNbH3s3bt5 Hu6VLV3kJ0y7UoMy0zfLds4CSxIe5LhEyvycVojw34R4vywiJK+PU9UpLdY/nIs9o4 luAXy4l+W0YqMM13nWDYbkwCE1NGAD8PIpIoD7XrqxjLlXOs5bR0l9hgAz9B5exIs1 x3V+w94E33I08aYteO1kf8A9xkdcftJmSkTero4bA/xj/Q+FGTZBlqKDxEAuE9+BQX c3WM5Wzyb9Gqu9KzYiUl0365VFPc1hjEzS9gBm7/osGJQGAfcYPtOYcjZJc85yVXvl aZxyhMl1T7I7g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9CD1467964 for ; Thu, 4 Sep 2025 07:05:45 -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 KWSvuNDShpSC for ; Thu, 4 Sep 2025 07:05:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991145; bh=XPFUyYOz2HWIEms+ii2uqgcVaYQTiF5HJsXYswT1TqQ=; 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=n8RllTeTk6hRgAONuhhmyLSSyfu9+OSfmx6kbQ87+Cfq4lG0A1TjHKdSNbH3s3bt5 Hu6VLV3kJ0y7UoMy0zfLds4CSxIe5LhEyvycVojw34R4vywiJK+PU9UpLdY/nIs9o4 luAXy4l+W0YqMM13nWDYbkwCE1NGAD8PIpIoD7XrqxjLlXOs5bR0l9hgAz9B5exIs1 x3V+w94E33I08aYteO1kf8A9xkdcftJmSkTero4bA/xj/Q+FGTZBlqKDxEAuE9+BQX c3WM5Wzyb9Gqu9KzYiUl0365VFPc1hjEzS9gBm7/osGJQGAfcYPtOYcjZJc85yVXvl aZxyhMl1T7I7g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D52F6795D for ; Thu, 4 Sep 2025 07:05:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991144; bh=r5do5Wpmqa4FfIJZp8dk141Gz1Mw0KTSIc1dIjvIIM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YXPFFIwVIHk/4jnsDx76adzERMs/j3+E8WCwslVFZoH/hEhpi/sql0lFyzuPue0da Db00T1ayODU2vhac82jSVI8Z4sy0I95/qkEwtSG8M5uAgi2uYTru4Ns0HxR5lZ5bd6 vLPslKy2nimt9yxhrnloLIKTzrPwnMyVjGm98jzQpnIMZN7CXfZoK6Ink4+4AnOiwd PROW3LmUQNE5sU7jIvRaYt6ErAjW79HF4jQsUfc7G+gGS2w3Vbu2yWdirWPo1T+W73 /gEsm2bRAXWt51pz7M/86PYgnrePUY+wD1A2cuWeR4gGQqXPVgbcdysvrPqVEKI2Ie ax0wMsWEnEjXg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 931FA678AB; Thu, 4 Sep 2025 07:05:44 -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 0_-z-qZCrqAX; Thu, 4 Sep 2025 07:05:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991139; bh=8OIVkM3FTRkLnkma0IevrXS7voMt6h3GhUAdpqUE+eY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ip6TJF86YmGQ3jCmTxPS/AeL3reEU+pwbnDotQ0K7VH1+twPWi5mw5gg2kZEKvRm0 vYD2PoRKzdRtgUbOcIb1b0sJZbnTJHZsfMU8/A5RlLi+MLGiHMFW3Bx6fp4CZSrsXC zfC5M89NsYqUj5FbhFps8C2N+PNTBHPc5vm7FVjLR/Pvp0NYTtvYElwm3ZuoPvwOLx b68fzfg0hxV70UAhXNVwrfSP5HvoGqJpqMLFDni73dXlGpMpLlg9zAQ/KoLTC/cCC9 V8xIhb5i8OJubMFWR5iX1t+ABoASlLnAHceslM6OzMFoGB5n8fnfM8kQ5T0NFblmVc ZTP8dilIvRFUw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F0B0867959; Thu, 4 Sep 2025 07:05:38 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:41 -0600 Message-ID: <20250904130459.848794-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: N7BPXQDRL4PXRE3LAAH2JYV23PAXKXQL X-Message-ID-Hash: N7BPXQDRL4PXRE3LAAH2JYV23PAXKXQL 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/18] ulib: Add an option to build U-Boot as a 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 It is sometimes useful to create a different main program for U-Boot, or even to use some parts of U-Boot in an entirely different project. Add a new option to allow building a .so from parts of U-Boot. For now this does nothing. Enable it by default for sandbox, excluding the tools-only build, where it has no meaning. Signed-off-by: Simon Glass --- Kconfig | 9 +++++++++ configs/tools-only_defconfig | 1 + 2 files changed, 10 insertions(+) diff --git a/Kconfig b/Kconfig index de9d9ad5653..3b136a5f897 100644 --- a/Kconfig +++ b/Kconfig @@ -98,6 +98,15 @@ config CC_OPTIMIZE_FOR_DEBUG endchoice +config ULIB + bool "Build U-Boot as a library" + default y if SANDBOX + help + Enable this to build a library which can be linked to other programs, + to extend U-Boot's functionality. + + The library is called libu-boot.so + config OPTIMIZE_INLINING bool "Allow compiler to uninline functions marked 'inline' in full U-Boot" help diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig index 20ac1e63f09..9e4866b494c 100644 --- a/configs/tools-only_defconfig +++ b/configs/tools-only_defconfig @@ -5,6 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SYS_LOAD_ADDR=0x0 CONFIG_PCI=y # CONFIG_SANDBOX_SDL is not set +# CONFIG_ULIB is not set # CONFIG_EFI_LOADER is not set CONFIG_ANDROID_BOOT_IMAGE=y CONFIG_TIMESTAMP=y From patchwork Thu Sep 4 13:04:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 223 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=1756991149; bh=kbMcDyIyCJOXnDFmVLo5V3v0s6DdUOMGQFZNv40EfPQ=; 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=CfKD5MtiSD7l3kAZE5I5R4jiCXyRtWNutRPjjsxDYC3Fiq/cSJbMr5LXiL/zIYa8Y nCX9mt22KEwJ9Egp2kNaSBzcEmeE3502j3XOngYZHAFU9JxTL/HWXzcQDrqyQBfxj5 WfhCgvZiYsYLE+mMOMOh+1mwXXOmMVCya33IyatPJqhRyX6jkfb2+I4giMJtFGknhA J+tsWvkUVbq51BulHUCgfbYO2uyLk6W4VW/Qsq2RKTcuPdXWMnV5DR1Szcxe6aD0Ng kStaqXOjmAl2XRpyywEMTZfeFbxtTQUq8oFmabeVjhbwtPa6NbcdOc0wv5mztLBTdB ys2ldmxaBrBgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E2305678AB for ; Thu, 4 Sep 2025 07:05:49 -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 ROAsanRdsV7M for ; Thu, 4 Sep 2025 07:05:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991149; bh=kbMcDyIyCJOXnDFmVLo5V3v0s6DdUOMGQFZNv40EfPQ=; 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=CfKD5MtiSD7l3kAZE5I5R4jiCXyRtWNutRPjjsxDYC3Fiq/cSJbMr5LXiL/zIYa8Y nCX9mt22KEwJ9Egp2kNaSBzcEmeE3502j3XOngYZHAFU9JxTL/HWXzcQDrqyQBfxj5 WfhCgvZiYsYLE+mMOMOh+1mwXXOmMVCya33IyatPJqhRyX6jkfb2+I4giMJtFGknhA J+tsWvkUVbq51BulHUCgfbYO2uyLk6W4VW/Qsq2RKTcuPdXWMnV5DR1Szcxe6aD0Ng kStaqXOjmAl2XRpyywEMTZfeFbxtTQUq8oFmabeVjhbwtPa6NbcdOc0wv5mztLBTdB ys2ldmxaBrBgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D182E6795C for ; Thu, 4 Sep 2025 07:05:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991148; bh=ssgkzgv/lt/r3KfOkakxkj/5uLFdTw0APAUtfHf3sFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzeUJKG9S+gLzkVhCVgs2YxDprn3h6N7Sg2ZQUdXNnkGCxxKApkObVIgXXmwBbwg2 qYY98wD4IRP1/Jtg2Rc/owQuDGbXYksn2QSS6pEm8RW52ZF7FXuw0/3hYMP9iVnnUk UbRvrme3+gWfR6UHI3p8HNKx7GcX9pEGzez5v6EyjP7ZfVs6oku1ciBL2g/rVIvFGQ ZtzcUso9WId6OOqsbim7ILgqHMCEPu5SzwjNK5nhkhGr1KF64SNslxhqfJ+VCTfrcm pxAeB5aB2DijNdKQIGTFZdQBucw+sj+nev3p6P3itfVfKHI9VH81HEcYIbiuK0OZaR m+Kag0MHGLG4A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D4F2678AB; Thu, 4 Sep 2025 07:05:48 -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 bSXBnLc7TaZl; Thu, 4 Sep 2025 07:05:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991143; bh=DziHy7HaedevMpvZM8YVh7WqMuNK/eQCWN+M1/LT/AQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNZDbw4diWneCIAyFDHfBWDOF1Jf7pX6xx5UPtNUQPoUr0BMcTFG7OB6PXRiPYg6N Ys5eknF96yG4h/ydc5jMkp3TDnVsMWiflt2tRSD40VcaCsywKO+IiPTTJZ9ByzBKYm IzCdIcY4+iRifcImTSVlHls9PZ0ioru5/LHqC2NKxVWHLCLRm/V6osGl2O4fYui4W7 hRSsE0zSZre77PiyjkhKI4QVMeE4+ALHIBxY6Pa/Gj8g1GLwYUgK7qGhG96SsY18Ot 3nJvL6y7epkmLHPFxkj++8QzSmSapE/hXWnyDRzwnQsS1BLvXDPM4bMhaxBhk8hivL BxjZ7wXXJyV1A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AC499678BF; Thu, 4 Sep 2025 07:05:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:42 -0600 Message-ID: <20250904130459.848794-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PUOMPN3L6I5KMVUVAZPFBS4O2NZ7BVRA X-Message-ID-Hash: PUOMPN3L6I5KMVUVAZPFBS4O2NZ7BVRA 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/18] ulib: Support building U-Boot as a shared 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 Provide a rule which creates a libu-boot.so file which can be used to provide some of U-Boot's functionality to another program. Move the RISCV up a line so it is clear that it relates to the u-boot target. For now this is not very useful, as everything is bound together, and U-Boot will just start normally when the library is used (including waiting for the user to type commands!). Further work will improve this over time. Signed-off-by: Simon Glass --- Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fb4358b1753..c4f3065d2e6 100644 --- a/Makefile +++ b/Makefile @@ -1043,6 +1043,8 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) +INPUTS-$(CONFIG_ULIB) += libu-boot.so + LDFLAGS_u-boot += $(LDFLAGS_FINAL) # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. @@ -1843,11 +1845,24 @@ ifeq ($(CONFIG_KALLSYMS),y) $(call cmd,u-boot__) common/system_map.o endif $(call cmd,llcheck,u-boot) - ifeq ($(CONFIG_RISCV),y) @tools/prelink-riscv $@ 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 \ + $(u-boot-init) \ + $(KBUILD_LDFLAGS:%=-Wl,%) $(SANITIZERS) $(LTO_FINAL_LDFLAGS) \ + -Wl,--whole-archive \ + $(filter-out %/main.o,$(u-boot-main)) \ + $(u-boot-keep-syms-lto) \ + -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 + $(call if_changed,libu-boot.so) + quiet_cmd_sym ?= SYM $@ cmd_sym ?= $(OBJDUMP) -t $< > $@ u-boot.sym: u-boot FORCE From patchwork Thu Sep 4 13:04:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 224 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=1756991154; bh=smdIMHRaV/cITYEf06tsTp0w7r0o4X2wKehERfwff3A=; 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=bsTeeQRhQ1Rp/ugfOjErpcM4/6qqraPxJSbiW1MHLu9IMtezra4yKz8yKCRjhQ8NU ed1hA313Bm0BDU9HuuPGkGH/JSyhwij55hFokNyP52O4llXer25fL8mY4Mh1IMGLr+ EWxpphukz/nrNoh0lI1LqKJwEXbxqqAi/QfBFv1GnxcMQsIoSqs08JePd988ehC8j3 XkK9Pqo3R8jemfWwUcCEtDpqCtiXUcGOTX2cq5yyEz/8DVis0CLBMaD7TlXIsw7crO KkevaBJl+9k3otEKpkQgBYDJzL5GeoF/ZDrLWkqmT3lD1npgF+wrHHmCkGM5MfjFe1 DQ0FZKGU0LsnQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 363D267961 for ; Thu, 4 Sep 2025 07:05: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 T2GMpIo6ZL2S for ; Thu, 4 Sep 2025 07:05:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991154; bh=smdIMHRaV/cITYEf06tsTp0w7r0o4X2wKehERfwff3A=; 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=bsTeeQRhQ1Rp/ugfOjErpcM4/6qqraPxJSbiW1MHLu9IMtezra4yKz8yKCRjhQ8NU ed1hA313Bm0BDU9HuuPGkGH/JSyhwij55hFokNyP52O4llXer25fL8mY4Mh1IMGLr+ EWxpphukz/nrNoh0lI1LqKJwEXbxqqAi/QfBFv1GnxcMQsIoSqs08JePd988ehC8j3 XkK9Pqo3R8jemfWwUcCEtDpqCtiXUcGOTX2cq5yyEz/8DVis0CLBMaD7TlXIsw7crO KkevaBJl+9k3otEKpkQgBYDJzL5GeoF/ZDrLWkqmT3lD1npgF+wrHHmCkGM5MfjFe1 DQ0FZKGU0LsnQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26B42678C8 for ; Thu, 4 Sep 2025 07:05:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991152; bh=AMdqxMPwnRadzfGYC8pKMNHHsmTNBi7Y/W5weKwQo+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YjWQO30zqjJq5UQBs4K5X9zNDJWiu/OZvEXCnfcDknSXrd/tHy5Xn14GjhXbtCdBQ yAjUzkynHKV4axJdzS0VMqyMMIfKhTfKE0y7OcFCnZDSWFsikfTH2D3RYVwPM7Kbv0 TqCg5E3lRo45NmoN590ZdkxSf/1zjKvHimmnYG2igDk597V2RPXOB7xI11BJP713Q9 xeeG2FtUMPBNymjaPrR96fyCKfRzNnEGDjsY/Re9UmLhaztztPoN73I7fJfb0F+4Tg foMGezItoB4+1uihAJ9LPObZtuiJlj3Rr/J5k70PA1DGReowRQePl/YYEgy/J2EyE3 fr6TyT2JAn7rA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B5506678AB; Thu, 4 Sep 2025 07:05: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 qZUKImB232p2; Thu, 4 Sep 2025 07:05:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991148; bh=79ZJyLHrtOaJZMLlmo7Q8ElwrNQ4FRHaqeZS0P/YYcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qg0fBETiw4DLpjpugt481n62DRsBNSBcFquWM6c4VJ86jXcPzrnd7fKR56wWv2sXq bdI92na0jukMau96kI6iUm6j2NA6GiRfAliJRxpaHc8Tw8wkngBP0FaH952Dgm3fvd vlh1qoSI4/DX3WYOyQrBO0mVB7pqgsqhr9SSB+0Q7LMiWKX5uDFLvCXqubTmMvaOtH BuG9wvWB/aeW60Smn3W4o0CzM0MtZ0LBSlS1FKXX/LXmo6ih9zURLSoLhU85sWpFgV Pz+cQ/YuaKgKkgThzbDr1y+ClTkfcFSNlEPBGbdt/JOXHpAXFnwcsLrQhAWSCyCzoe E8wN/f+xoO+BA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 944A6678BF; Thu, 4 Sep 2025 07:05:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:43 -0600 Message-ID: <20250904130459.848794-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SMNVYXSVJCUB3EFCCRT4UK2UCCYDNGLO X-Message-ID-Hash: SMNVYXSVJCUB3EFCCRT4UK2UCCYDNGLO 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/18] ulib: Create a test program for the shared 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 Provide a host program which can use the shared library. For now this operates similarly to sandbox itself, but future work will make it more flexible. Leave it out of the build, since there are a few other pieces needed. Signed-off-by: Simon Glass --- Makefile | 9 +++++++++ test/ulib/Makefile | 12 ++++++++++++ test/ulib/ulib_test.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 test/ulib/Makefile create mode 100644 test/ulib/ulib_test.c diff --git a/Makefile b/Makefile index c4f3065d2e6..a0a9ce3196b 100644 --- a/Makefile +++ b/Makefile @@ -1863,6 +1863,15 @@ quiet_cmd_libu-boot.so = LD $@ libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) FORCE $(call if_changed,libu-boot.so) +# Build ulib_test that links with shared library +quiet_cmd_ulib_test = HOSTCC $@ + cmd_ulib_test = $(HOSTCC) $(HOSTCFLAGS) \ + -I$(srctree)/arch/sandbox/include -o $@ $< -L$(obj) -lu-boot \ + -Wl,-rpath,$(obj) + +test/ulib/ulib_test: test/ulib/ulib_test.o libu-boot.so FORCE + $(call if_changed,ulib_test) + quiet_cmd_sym ?= SYM $@ cmd_sym ?= $(OBJDUMP) -t $< > $@ u-boot.sym: u-boot FORCE diff --git a/test/ulib/Makefile b/test/ulib/Makefile new file mode 100644 index 00000000000..ae58e01fccd --- /dev/null +++ b/test/ulib/Makefile @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# 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 diff --git a/test/ulib/ulib_test.c b/test/ulib/ulib_test.c new file mode 100644 index 00000000000..dd9cc0bb978 --- /dev/null +++ b/test/ulib/ulib_test.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test application for U-Boot shared library + * + * This demonstrates linking against libu-boot.so + * + * Copyright 2025 Canonical + * Written by Simon Glass + */ + +/* Use system headers, not U-Boot headers */ +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +int main(int argc, char *argv[]) +{ + struct global_data data; + int ret; + + printf("Calling U-Boot initialization via shared library...\n"); + + /* init global data */ + memset(&data, '\0', sizeof(data)); + + ret = sandbox_init(argc, argv, &data); + + /* Do pre- and post-relocation init */ + board_init_f(gd->flags); + board_init_r(data.new_gd, 0); + + return ret; +} From patchwork Thu Sep 4 13:04:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 225 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=1756991159; bh=5sUkLUhrSIBFZbF0ciND4sDB9LJFFFkDxZMVA3IJG1M=; 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=SkEpYr30kIHbCun7RN2hcjMydA9HeWn2hUMD5UhAIltw5yvORm0/uu8vDPUkUkuty zaWdbeIAvm/oRUBrr3/NB2Pqzp7YVmflTsrqQaTGV807xSH6F/aIuYcBA4PnbjXgaq leiHEOKYMIqxIrrvDW/uqsO+oh7yV6ZA3mQa3WsUGq4+BAe2xC1IBVmV0wupEON8KJ fLhS8B3Rld1qOGiPv3hXYiJEPWL3AvgmZjS/hWhXZCoz79yo3rAeoT9ZDlwsp005Pi 4M/V0eCMoEjxEnv75oCbnNTwTDAb8FH1gIhZBb7f/aQYPt03xAWzYvGBqBBO8viEgJ 4zqHxYBllN01Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 87FA467961 for ; Thu, 4 Sep 2025 07:05: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 10024) with ESMTP id d9UJBJi6Qbiv for ; Thu, 4 Sep 2025 07:05:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991159; bh=5sUkLUhrSIBFZbF0ciND4sDB9LJFFFkDxZMVA3IJG1M=; 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=SkEpYr30kIHbCun7RN2hcjMydA9HeWn2hUMD5UhAIltw5yvORm0/uu8vDPUkUkuty zaWdbeIAvm/oRUBrr3/NB2Pqzp7YVmflTsrqQaTGV807xSH6F/aIuYcBA4PnbjXgaq leiHEOKYMIqxIrrvDW/uqsO+oh7yV6ZA3mQa3WsUGq4+BAe2xC1IBVmV0wupEON8KJ fLhS8B3Rld1qOGiPv3hXYiJEPWL3AvgmZjS/hWhXZCoz79yo3rAeoT9ZDlwsp005Pi 4M/V0eCMoEjxEnv75oCbnNTwTDAb8FH1gIhZBb7f/aQYPt03xAWzYvGBqBBO8viEgJ 4zqHxYBllN01Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 77D28678BF for ; Thu, 4 Sep 2025 07:05:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991157; bh=4DDg0QhRWbe/VXgCPP6eRBjplw6ft/Em/O6IawfUJts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hBUYfQqpYMw66dQjV0HDfu6q5Zy+95JAqBxN8XmlG4O+V4tCVIeqbpjLde7RkBnsZ GEfruLnxewz3C7kW7Xjbs/hdSnCv/2+AkQt8VHk3mkCcY7EULv/bYpHPuuwZK2lkgk gnnLmvZdrdclF3PWhB0QtLC27KxcfLIqOXaSiIPb6InqdAzK8Vzb5wYNzlbI2y3u7r 6YmkdKlnqaCEI98Ca9Egh336rmf5hBbPXgH4T/WuF+cB6l412ZPIDBovr+1uccGcXc rACA8A8ck+FHTG5ywQoAmYef6XgBplLAlBHBMroXkxrkhU3ZXQRo/ak5RTVN/Dcu0S dgCo+O6ZeALvw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B0C8267959; Thu, 4 Sep 2025 07:05: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 2P_wKP-bnuXj; Thu, 4 Sep 2025 07:05:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991153; bh=OBd8Y9GgA3W+gcJ/lB1d/87O+OrnUvWjS4lfeb1x6LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChjjghnmvL2YwImZgLOowkOeBCH1JW0zKSQbi+kz3rBTRSCI2QaTjPQvd5A4/ng7u 1Py8WHZEY/fGqlYUd4PR3xYBPfJOHURlzEDpCGy2cQ0cNABx3+ikd/AHFS5SYVpe9N b1CnoNNj9JaAa/LTioqYl57uV77o9QgRCJePXmAltu82Pz2ifuies0Vq1QsPrxlvgf daiBh+VPgeqjkXk0ZZezF+mviggcJFMHSBP/zWugR8xkP6mFEwjgA9q1JJHrB+V4AW /QuJGS/FNcZW2mAp/VhtOVPk9XQzUwbvcG7yTfaUj4lYhT33Tjo7ha6liVP+ZMh5KJ O9wbGvI9AYEDA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 077D6678BF; Thu, 4 Sep 2025 07:05:52 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:44 -0600 Message-ID: <20250904130459.848794-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6QYJHWULSYKFG64BWDIHJ6BEH5YZUZLE X-Message-ID-Hash: 6QYJHWULSYKFG64BWDIHJ6BEH5YZUZLE 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: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/18] ulib: Add linker script for shared library build 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 a proper linker script (u-boot-lib.lds) for building libu-boot.so to ensure correct section alignment and placement, particularly for the linker lists. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/sandbox/cpu/u-boot-lib.lds | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 arch/sandbox/cpu/u-boot-lib.lds diff --git a/arch/sandbox/cpu/u-boot-lib.lds b/arch/sandbox/cpu/u-boot-lib.lds new file mode 100644 index 00000000000..f57292b0a8d --- /dev/null +++ b/arch/sandbox/cpu/u-boot-lib.lds @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2025 Canonical + * Written by Simon Glass + * + * Linker script for U-Boot shared library (libu-boot.so) + */ + +SECTIONS +{ + /* Text sections first */ + .text : { + *(.text*) + } + + . = ALIGN(32); + __u_boot_list : { + KEEP(*(SORT(__u_boot_list*))); + } + + _u_boot_sandbox_getopt : { + *(_u_boot_sandbox_getopt_start) + KEEP(*(_u_boot_sandbox_getopt)) + *(_u_boot_sandbox_getopt_end) + } + + efi_runtime : { + __efi_runtime_start = .; + *(efi_runtime_text) + *(efi_runtime_data) + __efi_runtime_stop = .; + } + + efi_runtime_rel : { + __efi_runtime_rel_start = .; + *(.relefi_runtime_text) + *(.relefi_runtime_data) + __efi_runtime_rel_stop = .; + } + + /* Read-only data */ + . = ALIGN(8); + .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } + + /* Data sections */ + . = ALIGN(8); + .data : { + *(.data*) + } + + /* BSS section */ + . = ALIGN(8); + .bss : { + __bss_start = .; + *(.bss*) + *(COMMON) + . = ALIGN(8); + __bss_end = .; + } + + /* Dynamic linking sections for shared library */ + .dynamic : { *(.dynamic) } + .dynsym : { + __dyn_sym_start = .; + *(.dynsym) + __dyn_sym_end = .; + } + .dynstr : { *(.dynstr) } + .gnu.hash : { *(.gnu.hash) } + .hash : { *(.hash) } + .got : { *(.got) } + .got.plt : { *(.got.plt) } + .plt : { *(.plt) } + .rela.dyn : { *(.rela.dyn) } + .rela.plt : { *(.rela.plt) } + + /* Debugging sections */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_ranges 0 : { *(.debug_ranges) } + .debug_line 0 : { *(.debug_line) } + .debug_str 0 : { *(.debug_str) } + .debug_frame 0 : { *(.debug_frame) } + .debug_loc 0 : { *(.debug_loc) } + + /DISCARD/ : { *(.note*) } +} From patchwork Thu Sep 4 13:04:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 226 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=1756991161; bh=0nkPqCcfc4JL/bRj6/xxNY/qFn1DaAH9AQa67lXx+ZY=; 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=w8swXjXvkjsOg/dqM5998DS+ZcG5B2e8yFPi1mJPx8hZIdueJUtKFspeIFP3pFlsL VCQSu+ITnSMUkKTqU7VDyvMpb3RZJ1dBJ4LnUOB9TAV9P7juGg+pYwpaQe4TAfvla8 Ary6f8liD8LyuhxWuNnnsYGCsBPNfXQgqe88cfY1Ec3nMYN9DgiZvfGnYTsod9xaA8 T0OQlKhY7SllU6AJ18432kEHR8Waq9mNOs3QR+Ql8mEljS4WegHGDdAgYp+tXZ/UxB EsZuxjTz+vGixfaugm8uGciMrInoPS07ZcnTy0oc3TrPnOgOeifMMlx6N0fzLPcNgs gI9COEQQKvBBQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D6F3F6795E for ; Thu, 4 Sep 2025 07:06:01 -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 RnPOsv_wiOe5 for ; Thu, 4 Sep 2025 07:06:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991161; bh=0nkPqCcfc4JL/bRj6/xxNY/qFn1DaAH9AQa67lXx+ZY=; 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=w8swXjXvkjsOg/dqM5998DS+ZcG5B2e8yFPi1mJPx8hZIdueJUtKFspeIFP3pFlsL VCQSu+ITnSMUkKTqU7VDyvMpb3RZJ1dBJ4LnUOB9TAV9P7juGg+pYwpaQe4TAfvla8 Ary6f8liD8LyuhxWuNnnsYGCsBPNfXQgqe88cfY1Ec3nMYN9DgiZvfGnYTsod9xaA8 T0OQlKhY7SllU6AJ18432kEHR8Waq9mNOs3QR+Ql8mEljS4WegHGDdAgYp+tXZ/UxB EsZuxjTz+vGixfaugm8uGciMrInoPS07ZcnTy0oc3TrPnOgOeifMMlx6N0fzLPcNgs gI9COEQQKvBBQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C604A67959 for ; Thu, 4 Sep 2025 07:06:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991159; bh=8N2Km7HkILa+HYEHOJ8ZfgVeSU72K59CZXFKWB7/JKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNa/3hWua5E54KhgjGp1kUV+TPq0fe5RQYsw6OLc1pr2k3RdW8DKwq5jmlbCbxHL6 3AAjrMDdJCirQ5xOcrUXdE6zmicfeHVBhATbcHvZvMcpUa20fEqi61zewuImcnAVkS iG11GdG9vE9sRx3WhqfzJZt3qeDcHPNbrkZOIg3CyAasTmSfanEYuFhhyoGr3TDTin z7XAjZ5fn5/QMPIUwgFDNvoRKMizvSL71arzIusxSotrza/tyen0RA/gwK2joeMEEf wK5D97BO4Ksgi7hel3wVybP+FKfgng9pYeLItwA8iMsfqXSZLztMH+Ulko/2bC+5kA FVlMS7ac0h/og== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6835467959; Thu, 4 Sep 2025 07:05: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 zbWEUeU8ZIIf; Thu, 4 Sep 2025 07:05:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991158; bh=1s8cSNJ4joOXL4zNiVteJyMixFvMRDn+8YX2NNmsDHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhmyVQYW05JOSvhNcb0g7Opu7nz3en3UU4H6HgsRUcqDIkMaSMXhQ2YQ8xlmcuIIg ddjL0H6EBkKH0aLTuYiMwiP9ZnngmBixMAgOvgxvQFmnCjWPHZlXbSVDh/8Y6bpmsI DUY9MKWFus0MeDubdaqcabcB2UsxvFl9EiWBSju3EFK147LwuSGTBYPbyQdBvrooae rGyMiBPYu+NbNhF+T++T7BrJdkiovBhX6X6oxm4YckoinDYny0je64QB37RRV52Gpv Ta3MI1oTnYrkm+VOiygAZOLgtLG1d6V5/cfn4IiAlIicGBxYgvYq1UxuobptMqDItJ 1fFwok+dRRtzw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 02617678BF; Thu, 4 Sep 2025 07:05:57 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:45 -0600 Message-ID: <20250904130459.848794-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FFXDXG7SQRPBVNPB6CMACUECEHIPDJVX X-Message-ID-Hash: FFXDXG7SQRPBVNPB6CMACUECEHIPDJVX 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/18] ulib: efi: Disable relocation or runtime-services 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 cannot work with the shared library at present, since the symbols are not defined. Disable it for now. Signed-off-by: Simon Glass --- lib/efi_loader/efi_runtime.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 58c3ea1870f..2bd2582ede5 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -717,6 +717,10 @@ static __efi_runtime void efi_relocate_runtime_table(ulong offset) /* Relocate EFI runtime to uboot_reloc_base = offset */ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) { + /* Skip EFI runtime relocation when building as a library */ + if (IS_ENABLED(CONFIG_ULIB)) + return; + #ifdef IS_RELA struct elf_rela *rel = (void *)__efi_runtime_rel_start; #else From patchwork Thu Sep 4 13:04:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 227 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=1756991165; bh=4mim2/Rs67Mcp9MtYN4WBLAOeOYMbFOTrmdUEXj1xFA=; 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=ZwqAcbqsXT2cL0qd23u6ukx2liFrkKdMKyw19BIbWdoWanggSVUikfyJQlYiz8Lq2 38iVkSP+qpIU8WFn/OyfVveuNtWBrHXv+szuvCyuBEtM47879PKiyp2YCc23YTr7S8 AyN9UrxKE2SiVSFwt06taKpQx/S4PiKOpfaN97WADeukjm7F3Qk8keiyB/yVzN2Aak bwbtfqZY8TaPaL9Nk0F3EyLDE1kWXsL81AjVB/0h19SuZ23f3ymBAWC8gGKtY9MaaP TkGn3q4fpaux154zedt3uwTTSG47FGa4AyI/NMH+4CDs9+fFvhE2kXuiqXjVv1I2oe VaCYPh0uHqYLg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 335C667966 for ; Thu, 4 Sep 2025 07:06:05 -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 tf4qidJVwXHC for ; Thu, 4 Sep 2025 07:06:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991165; bh=4mim2/Rs67Mcp9MtYN4WBLAOeOYMbFOTrmdUEXj1xFA=; 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=ZwqAcbqsXT2cL0qd23u6ukx2liFrkKdMKyw19BIbWdoWanggSVUikfyJQlYiz8Lq2 38iVkSP+qpIU8WFn/OyfVveuNtWBrHXv+szuvCyuBEtM47879PKiyp2YCc23YTr7S8 AyN9UrxKE2SiVSFwt06taKpQx/S4PiKOpfaN97WADeukjm7F3Qk8keiyB/yVzN2Aak bwbtfqZY8TaPaL9Nk0F3EyLDE1kWXsL81AjVB/0h19SuZ23f3ymBAWC8gGKtY9MaaP TkGn3q4fpaux154zedt3uwTTSG47FGa4AyI/NMH+4CDs9+fFvhE2kXuiqXjVv1I2oe VaCYPh0uHqYLg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2218367961 for ; Thu, 4 Sep 2025 07:06:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991164; bh=WOpMCInsuSd2kR5S5B2I6i/Lj9+vG5hKwvx3Tf8dJJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaBOvAFESRjbitVTuHEiGrAIA3ugDfCKWfpEa2/CGXjHAYaExaeo7LCKD3fhFw1bu vfacY4HOhN21IdU5+42H48/KbzEj/povO0HKLYAJk3n7zEGt1cs2KfCpztu/GS/hB5 Dn7PG1rrK7nPwSWhdnChpcTzfoYtsoBvOjNbLrNUxcpevCFHTjzpWDNDwrcp3njdTS z91uCkq8pPMLS+iKren5DcDMDlKELRhdgH2uw/FUYJQvKz8MkId0l+amrf8KxSiuWT vc6xiI62AfVt7hS+tWOgoJtJXt3GbXDW1zQnNCf0fDaWXMpM/nV2AcWgpTCIqbrwMZ pdGwzLBeQrlEw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21FB86795C; Thu, 4 Sep 2025 07:06: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 ea1UTg6I--O0; Thu, 4 Sep 2025 07:06:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991159; bh=1E0Dh98lmwCjxH7DdnYO1RS53nXpBjRnJVTW9wUC7vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wKfqte58lMb8hFL4l7ZMI34Y/zV+pV6NwgaEtwsJ4GEqQdMDdlIRan8IpoJUYeO/s 0p2HI68YhPQPRw9gN2RDXA6aR0nkSl54Ea7mqSW1iPKNtfNMPh+MQ1sc7LQgfsEV02 tRKLiX9JJGrVl68wx2fPpCOH3T2fn/dHgl4ZRO4XLy/Qzv/O7fY7FIVUkC28mdm6Bm 3Zs86WHh9o5JdCWsZp18D4Fs0WtoccHIf9pE58d3RrxIpv5VsWvu0etG717NWG1unz HhT2DHOTrXStIMWhdl1xmqqL3nHLHBR1yH9fg4Dz6QV23vwhY7vZtZk396G7y2gkOP BNR2v4aCQjYKw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A5CDB67966; Thu, 4 Sep 2025 07:05:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:46 -0600 Message-ID: <20250904130459.848794-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LOOHVXCHJWUOLLB63YCKEBLMIVRAY6L4 X-Message-ID-Hash: LOOHVXCHJWUOLLB63YCKEBLMIVRAY6L4 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/18] ulib: Enable building the ulib 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 Now that the required pieces are in place, add the test program into the build. Provide the linker script too. The library requires CONFIG_CMDLINE, at least initially, so don't attempt to build it when there is no command line. For clang, an error is produced, so disable it in that case too: test/ulib/ulib_test.o: file not recognized: file format not recognized For now the program just crashes on startup, due to mon_len being larger than available RAM. Signed-off-by: Simon Glass --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a0a9ce3196b..b43e028a06e 100644 --- a/Makefile +++ b/Makefile @@ -1043,7 +1043,11 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) -INPUTS-$(CONFIG_ULIB) += libu-boot.so +ifdef CONFIG_CMDLINE +ifneq ($(cc-name),clang) +INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test +endif +endif LDFLAGS_u-boot += $(LDFLAGS_FINAL) @@ -1852,6 +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 \ $(u-boot-init) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(SANITIZERS) $(LTO_FINAL_LDFLAGS) \ -Wl,--whole-archive \ From patchwork Thu Sep 4 13:04:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 228 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=1756991171; bh=4qpY7qiuPm8NhnBWfQWQChG5yIqs2ndsxfl2U1r8UpI=; 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=EHnQtoq1gm5Q8c4qXmgpgu2goJf5xoSG6DKvo7vqBRr+qgYmhL8W1crEzN8U9pNZa wfmNyD23dX9zEifPm8seuTykWPTdEUwCAz7bq6ITzr4y7vFZEAbbk7IRiZGt/s5dIf LHfRAwz35c737sRkMWeHN7sqtuaSKsF/1dCv12Xssglib0KISfY0iVfN3ZZrzakcpu ynV+3B8MI9Gu1XLBQNg2crKohQaNA/ZFZWhpQ9aZ3WI+GaWdAdQyqxc79Cl3wpTl1P aSbSuzIzYQgjz9ZDWYDTfoig0MAJEXu0jrcKGY919F6YJJt1KqsEbETPbo3n8F6ZQA vqDJg6swgZ3QA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 049CB67964 for ; Thu, 4 Sep 2025 07:06: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 yG4lMr4WoBv9 for ; Thu, 4 Sep 2025 07:06:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991170; bh=4qpY7qiuPm8NhnBWfQWQChG5yIqs2ndsxfl2U1r8UpI=; 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=Vq3wv2k39DJr+16kogSTUSllPFh81DqjlVkk2NH5qrsYtVme2eokheSGrjre+ttAA Q0yuiMn9CwMmrHgODB0Bos9S/HY8Q1THmQMQ5uC4a78CndJGQjaidxTNldgCb6uYT/ G/gK4yVNeLkjuU90ob36DHbzcW4C9XUOnmsWD31A//7QQPR6Nlbmhz8efH13K+lkvh PIvofwvxng32GyICHmS8HWlnOqJLb2RF5xXrJeGlc7CRtaR1njKlHPxEjUaRoMudVD 0r3811ivs4UZM8CW6RLDRuJn7c318XSJZBvXBeoqwBMHryb2gYlj8yFi9EMupWreCm t8rwDMut5JDjw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E44E6678BA for ; Thu, 4 Sep 2025 07:06:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991168; bh=7JaiiduOfHc41+2bx3YuCb+0KJWpErE2oO79Aix+8zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/1pOsE/kI9AeLi0fSZ7ToMOroiiTAvsAISev50cQwooKppexXm0zBJkC9+65cgS0 4aNAS/bmhV8IbmLgXN31K0KfKA5vfmi8iFHRvYx8G4tPPlJKCLWJPEh2/puMnPFc2k HzHqBbo08smKXk62qUsc7DD0DKeR1ZtYCMAX5SG7wUbrwabr9jK4wyue7+VchT56IC a2pW78u9zraByvWirpk/OrlGckaNPmLPiQRe2Djewjh4o77Ec5XeZWYhZhvaq24Rt2 35MigTYELHcBeCAUuAC+bT9vRMpRBvB2TKuBMqELtqCQGdwJOJt7DeN+FQZHusHa5p 8THmAEGCu07HQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A4897678AB; Thu, 4 Sep 2025 07:06:08 -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 AJEQJT3bV93H; Thu, 4 Sep 2025 07:06:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991164; bh=KCRI4k9rC5pwEBzYiqRpxMj0mNOEV8bgBfOC0uNiglY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XbO4eHuNn2kfwUluMNad3JgKywkIu6NlvpCCTyVzNcb1x6xBeceg1tm+zCLxTgA0Y 5xzOTHwfRkjSkCGmhHUfKETpUxnTaak5xU6+IlMdUAcAKiB6Fu0iEiAkoo65Yv/6zw kaCI4kH7aoP65afWaKuj5Ht/aFVYrn3DIZtjCCz/dOb3S9+InVTuHYYLLv6j4f1BCc 1+42ymwtby+TGeWH1ZFLeGBfRtF3VVWq1tD5OU5OXmu3Eno0zWwziTBZw4N8cpb5Cs VqK3XkMmEigyWSf+jvAqUq3FYAkt7Pe0d3581UHcxOPXiS7R8RkYQ3vwvHrcTNwUGw Hn5dbXkS5Iofg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5E6A6678BF; Thu, 4 Sep 2025 07:06:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:47 -0600 Message-ID: <20250904130459.848794-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VK55HGY2WQJKUYKXHD6PUY3S3NYUVBZG X-Message-ID-Hash: VK55HGY2WQJKUYKXHD6PUY3S3NYUVBZG 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/18] ulib: Implement GD_FLG_ULIB for library-usage mode 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 a new global_data flag GD_FLG_ULIB to indicate that U-Boot is being used as a shared library. This allows suppressing console output that is inappropriate for library usage while preserving normal boot messages for standalone operation. For now the flag must be enabled by the caller and it has no effect. Signed-off-by: Simon Glass --- include/asm-generic/global_data.h | 12 ++++++++++++ test/ulib/ulib_test.c | 1 + 2 files changed, 13 insertions(+) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index fc99411e5fb..8b59df66ec5 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -758,8 +758,20 @@ enum gd_flags { * drivers shall not be called. */ GD_FLG_HAVE_CONSOLE = 0x8000000, + /** + * @GD_FLG_ULIB: U-Boot is running as a library + * + * For now, this just avoids console output on startup + */ + GD_FLG_ULIB = 0x10000000, }; +#if CONFIG_IS_ENABLED(ULIB) +#define gd_ulib() (gd->flags & GD_FLG_ULIB) +#else +#define gd_ulib() 0 +#endif + #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_GBL_DATA_H */ diff --git a/test/ulib/ulib_test.c b/test/ulib/ulib_test.c index dd9cc0bb978..621bcd49be9 100644 --- a/test/ulib/ulib_test.c +++ b/test/ulib/ulib_test.c @@ -25,6 +25,7 @@ int main(int argc, char *argv[]) /* init global data */ memset(&data, '\0', sizeof(data)); + data.flags = GD_FLG_ULIB; ret = sandbox_init(argc, argv, &data); From patchwork Thu Sep 4 13:04:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 229 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=1756991175; bh=1UrDgJ5G5+d2vEZ0BKSA+Kjd7oRQVNMA2hn+3tWugWA=; 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=ehsWF3jzQX5I3G8MFhfxAmYiYC1vLB4Kt7GstvtXAygVDhu1cmdKgcSwfvcFCFYWh MwsUK3Cbc++WRd/9fspN+PoAiPpgKCNwLEuUzEBZ4ceREEAndk3Sf8NCAFDnqwYJY8 wRqDD+Q2PuFTH61mABHtyH+DLRCcMtRYhWjHBIubHwDDK0ducTdI9Rd00FTSmZcGVR 5+diwlJo7v5Tgx/2anInZpmf8MTsel7lZWAx5NVhqTpZR0EPe879HTXzKwkJl6gaar EcHwRuI0s+zSlWcnWAP+CHyMvl4bf06v7KQE5xG1RG1dQNsrSSetD4ohYaJ+/GsFFL aRj0ke9X0jRSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6516E6795C for ; Thu, 4 Sep 2025 07:06:15 -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 zUd2WHs2cfHN for ; Thu, 4 Sep 2025 07:06:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991175; bh=1UrDgJ5G5+d2vEZ0BKSA+Kjd7oRQVNMA2hn+3tWugWA=; 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=ehsWF3jzQX5I3G8MFhfxAmYiYC1vLB4Kt7GstvtXAygVDhu1cmdKgcSwfvcFCFYWh MwsUK3Cbc++WRd/9fspN+PoAiPpgKCNwLEuUzEBZ4ceREEAndk3Sf8NCAFDnqwYJY8 wRqDD+Q2PuFTH61mABHtyH+DLRCcMtRYhWjHBIubHwDDK0ducTdI9Rd00FTSmZcGVR 5+diwlJo7v5Tgx/2anInZpmf8MTsel7lZWAx5NVhqTpZR0EPe879HTXzKwkJl6gaar EcHwRuI0s+zSlWcnWAP+CHyMvl4bf06v7KQE5xG1RG1dQNsrSSetD4ohYaJ+/GsFFL aRj0ke9X0jRSw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 551BB678C8 for ; Thu, 4 Sep 2025 07:06:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991173; bh=QYcFj1n1bol1tu4ipXk3Xw6U/eCLKNYPmOri5wdZKu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tt9e+SwRhwd10ghtKSUDlLuuB9YkEPzVVxlgW2yQ78IpmX4nb8ABCtcvY56pJTcWE On22dOPT1DA/kgkd4/BejzVd3NWXN8rgYH+mdl/RBOPJ++p71UdXySOH+ybTgS3jiD m0KnCYwubG65fWrWGAZGO66iu0k3CewPP3l4AtUGJYbKmCwWvP0pMrJUy1pfAD3dVL HG6DEZeTHNCHbBTh6XhMRU+NtDipFk2cG2UTGudUX+TrSY0AxDQ5DQCMMmmL/PBQk8 iMhQ6CqbyrS9msrYXyyj/BGD5WARZYwDF43yK3E/t4dugCfZz9J38jAo2IL+slyghv nb9vtP0PliGqg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 613C7678BA; Thu, 4 Sep 2025 07:06: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 QfrCdJkORMgH; Thu, 4 Sep 2025 07:06:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991169; bh=u95kda5zpIxP8T0HYILNI6y1Hxjn9OrJ62SCchp8UgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mXHv3WW3DMqiem8Lgm2rWUksSWCsjxlljjwZOkJr4G7G3oUj2Fvt9rTKKTiH32CR8 D6GDNs0HIz79O1+yqBz2z/PZRb0TBw8bA4C8zIHMc6CZOMvBKw7I1YtgTKyM09k7Wp i96Blyf5LwtROPB4TwbM/LwX7ePrxsapdJ5Oa6oqmGoMFI+WGQXXjpdr5M4z9WwX8n sJgI0R54H84q7T4EAbMkNgVuL6yZMegKxn/WWiEWzpilqpTZtPQn/Cy7VgpfawEnNu heHaCiRDUC9D9D2t3MkyXUI+rl75dJzKoe2gqMxnKQx04uF24RSbjXNhigLEmKLM9V ofupd4TDCuPlA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EA85C67954; Thu, 4 Sep 2025 07:06:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:48 -0600 Message-ID: <20250904130459.848794-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JL6AOHNYSS5RP2NL5SALBPQJAN5XZGGD X-Message-ID-Hash: JL6AOHNYSS5RP2NL5SALBPQJAN5XZGGD 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/18] ulib: Drop the initial banner for the 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 When using the library it should start up silently. Drop the initial banner. Signed-off-by: Simon Glass --- lib/display_options.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/display_options.c b/lib/display_options.c index 9c6722f0c64..7f9dfcc43ee 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -9,11 +9,14 @@ #include #include #include -#include -#include -#include #include #include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; char *display_options_get_banner_priv(bool newlines, const char *build_tag, char *buf, int size) @@ -47,8 +50,10 @@ int display_options(void) { char buf[DISPLAY_OPTIONS_BANNER_LENGTH]; - display_options_get_banner(true, buf, sizeof(buf)); - printf("%s", buf); + if (!gd_ulib()) { + display_options_get_banner(true, buf, sizeof(buf)); + printf("%s", buf); + } return 0; } From patchwork Thu Sep 4 13:04:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 230 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=1756991175; bh=Jja/bZILfVeJwLXFOFbU7ZPQvVEozXtO7CrWX7g8GS0=; 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=Th5eUXbxsNzHl7tohVm31eVUmDUsZBYpmppu/hirxLJGnIp9v2RIbXAjy8oExD0Wb /jwQKXMxP/flHyzSYUhUxcQAPM7nRxT/3oQfQrFTGea8UyUfOfm7VAxKT/UzluKuus VvKRvvynixiQmz3EbgT88dJnil8ZFcldAK3+jDksoQjRV0wVjZG+RUYq7Ja81AOf0A 4ww+FCgVVLceZ88vdXEpBMSejneMv0N37i42vD9TpIupkFtPIolmC7SPyzRsHEC9/F iDuPQ0WaK2j17mvC/ZrfUs917ZvHNAc7rcxvieJ+6nXgxkE3MNvJnBw44XG1FR31r1 f3aCOqwnJyCEA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B74A367976 for ; Thu, 4 Sep 2025 07:06:15 -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 LRbg-iNvaRw1 for ; Thu, 4 Sep 2025 07:06:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991175; bh=Jja/bZILfVeJwLXFOFbU7ZPQvVEozXtO7CrWX7g8GS0=; 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=Th5eUXbxsNzHl7tohVm31eVUmDUsZBYpmppu/hirxLJGnIp9v2RIbXAjy8oExD0Wb /jwQKXMxP/flHyzSYUhUxcQAPM7nRxT/3oQfQrFTGea8UyUfOfm7VAxKT/UzluKuus VvKRvvynixiQmz3EbgT88dJnil8ZFcldAK3+jDksoQjRV0wVjZG+RUYq7Ja81AOf0A 4ww+FCgVVLceZ88vdXEpBMSejneMv0N37i42vD9TpIupkFtPIolmC7SPyzRsHEC9/F iDuPQ0WaK2j17mvC/ZrfUs917ZvHNAc7rcxvieJ+6nXgxkE3MNvJnBw44XG1FR31r1 f3aCOqwnJyCEA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0986678BA for ; Thu, 4 Sep 2025 07:06:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991173; bh=Y7xPTLbWHbFtZNq//HpBbghrLH3C6njiMh6XbDlmrWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BAhDXv8Q8BXBMvSR27K5sB5Mx/p9/tQ2T32egIpg/nJBbO+HfkPKajDl+I4INA6z3 NrHHXoMkUc/8ie58hYYnVhP4r4tPN7ZcvQL1HtfxbjRAXtS+meARSg9+kH7jEub+eo cLAJz3yP9a8hR3+Gi6C3LuH1uSNMM0dOMlzbyCdzSrb111z7Qw4za9dQ84JSfaCYxD Wuiq/mNLCrwAGPbDHFBWsqj9WLJyhS9NDkXqZzSn9jZM0RGHWyGlKweUfIwPHsxCNk GDbQYzzhBlAp1io3ujfr5laO0W1GOCM6F8wIPgM0ae3NeqGTWVMobUCJVMcfFF+Zny IK2f4+FGjdn2w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BB6DA678C8; Thu, 4 Sep 2025 07:06: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 JSZ9-G5A3APy; Thu, 4 Sep 2025 07:06:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991171; bh=jgIR/YZc/W4u1wIiq4eTQfeMCqNeJjA7tEInlDpTCuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=by9ug1dslm82gT2YjDkL+Jr46aVI4LEv/ZpubnJZF7uoAG//HYpYws2T8B/rxgKHL /PTshW6MxeaTRAfiTnpCI+A9Sek3Ms1sbiQYdGYY9pCYIsJs5adSBR4JulmdoN8yNA 4aoymPPnrQbzBDZr6MKYA4GmC1pGSAJJcdQ67WEe634dpiLDBGrIF0przpv7AsGL/9 KiYykJzqhZRhuFSbMDI1ZGF/Pa6Y5IAXvn+z3KKCbC3LiwIbrx8yxo/R3Pk2hN/obS c4gpxdd25xnaEmQ111WmYG/PFzSfP+iJTS6cO+0kV74salXzpHs91WlQxdmweUj1aZ qT4OnBvr3bMNQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7FA9E678AB; Thu, 4 Sep 2025 07:06:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:49 -0600 Message-ID: <20250904130459.848794-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TL6XWESWLTOCV7MAF2LLXXJR3WA4V67F X-Message-ID-Hash: TL6XWESWLTOCV7MAF2LLXXJR3WA4V67F 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/18] ulib: Drop DRAM announcements for the 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 We don't want any initial console output from the library, so check the ULIB flag and skip any output related to DRAM. Note that debug output is unaffected, but this is only visible if debug is enabled. Signed-off-by: Simon Glass --- common/board_f.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index eac51d61fa1..ef8b0ff7ef1 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -181,7 +181,9 @@ static int print_cpuinfo(void) static int announce_dram_init(void) { - puts("DRAM: "); + if (!gd_ulib()) + puts("DRAM: "); + return 0; } @@ -231,13 +233,15 @@ static int show_dram_config(void) } debug("\nDRAM: "); - print_size(gd->ram_size, ""); - if (!sizes_near(gd->ram_size, size)) { - printf(" (total "); - print_size(size, ")"); + if (!gd_ulib()) { + print_size(gd->ram_size, ""); + if (!sizes_near(gd->ram_size, size)) { + printf(" (total "); + print_size(size, ")"); + } + board_add_ram_info(0); + putc('\n'); } - board_add_ram_info(0); - putc('\n'); return 0; } From patchwork Thu Sep 4 13:04:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 231 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=1756991180; bh=2f470gDoDGMHcx9u4RKHSQqhzeCdlorG0bz/c8ZXtWY=; 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=I5XK4Q/NFVdY6jScfEuBKEKwVKZExE6jKJFzocOyo8qb0o2oZ2Io5drDprKLTFUyS 4FXwET8B/IcAiEVUA+AwdxsqAcdP13En3dwHrS4j5QQtIkKcU8wVNzNM4blrbz9XrT bzZkTut33jI7bbdW4dppjRLfpG95IESk7qw2DO+yrOdcgFOmmndGKSni7b3gx1gZky +bdMJitra2L7JAkEih2wu+zHVwWO1YbDEOiBmRY5KLaftxUlK17EUVAjOW03hlMD1f L57UfDCCxvLDpi6rdqUiOkp+brXu/W6oWq2XfVkOTfRsX0BCw/TovofFUvElJLJ61w /RlPE/xHKZkXQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 207106795C for ; Thu, 4 Sep 2025 07:06:20 -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 bDSrKZLTGTGx for ; Thu, 4 Sep 2025 07:06:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991180; bh=2f470gDoDGMHcx9u4RKHSQqhzeCdlorG0bz/c8ZXtWY=; 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=I5XK4Q/NFVdY6jScfEuBKEKwVKZExE6jKJFzocOyo8qb0o2oZ2Io5drDprKLTFUyS 4FXwET8B/IcAiEVUA+AwdxsqAcdP13En3dwHrS4j5QQtIkKcU8wVNzNM4blrbz9XrT bzZkTut33jI7bbdW4dppjRLfpG95IESk7qw2DO+yrOdcgFOmmndGKSni7b3gx1gZky +bdMJitra2L7JAkEih2wu+zHVwWO1YbDEOiBmRY5KLaftxUlK17EUVAjOW03hlMD1f L57UfDCCxvLDpi6rdqUiOkp+brXu/W6oWq2XfVkOTfRsX0BCw/TovofFUvElJLJ61w /RlPE/xHKZkXQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 02606678C8 for ; Thu, 4 Sep 2025 07:06:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991178; bh=Pk+TLnO6YVyzTvY1siXK7sFaE25Vi42I8ggTFDWawSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tAx0HM5An1rvRq/gAgWBzkI7yMCKBtVJa0z1Q3GmvDp/EZCHTyMWnLBf5GU48PWl6 cf7BqWYTJTVUgPuyXZPDjagi8TgiVbbDB/Oz1tIlp/NnX3zQABzpkWqQZR02kAKRXc VMsPjkRzGeGSQj+F/kMBo+UOwKB+URpZCuGcwtwISTWgYelRuvRnZNBH4RrnHYLOON lNvsWtOApn6oWLkPSYJ6yTqtzApL1dSBVxdBpnYduGm5ZWC/SHky3GYeOFiZ/LVD1h gYqf/UV7sQ0BCSE7Z7acp5UfANZoGb4BJkcibqhph+LQORea9XqLd6CwQU9TCXEhkS U4Ox56d2GV/FQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0DD5A678C8; Thu, 4 Sep 2025 07:06: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 aFZTykLXu-H2; Thu, 4 Sep 2025 07:06:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991174; bh=S8amtCiXoV+jt1urOkL+MKVrqlJwfeQ2BZinY+0IbD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YZYiEwEHZXiwlac+GwoJCeXG273vnwbESB7p0f/+/sMXsw3bduEuxuryayFwqquuR DPn76Uxr1LKC118IaxE4wXx5LIhgwsHwJ0hUz1SlR6ozG1QKs4sAx6AFHV006Ua7Gs LZD4YHOlcHAnl5/ppcl01/+TYfiroUpq5zYLH/rJBLfZh1dpjowyP8uMAKBV5ytata 2cpNVu9UpgHWxrAGZb+xKidNj9R7lNyG46yTDCHAv65Dl+3YGJO2w8eZKET9ihT/FM pL8kP38/o0dEJS2lIIYtTJMkZHfsPN0QbtxXl7oifE87v3IEFLs+nc3/9NkwJ9fLk0 hB8bt5S3RgZYg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0D331678AB; Thu, 4 Sep 2025 07:06:14 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:50 -0600 Message-ID: <20250904130459.848794-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WFLYETZH3GGT3MUFURVL565URNCGQ7OV X-Message-ID-Hash: WFLYETZH3GGT3MUFURVL565URNCGQ7OV 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/18] ulib: Allow dropping NAND init from the startup sequence 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 should be handled by driver model now. Some tests rely on this happening early, so just disable it for the shared 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 d60cc7aac70..297fdc29ca9 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -364,6 +364,9 @@ static int initr_flash(void) /* go init the NAND */ static int initr_nand(void) { + if (gd_ulib()) + return 0; + puts("NAND: "); nand_init(); printf("%lu MiB\n", nand_size() / 1024); From patchwork Thu Sep 4 13:04:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 232 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=1756991184; bh=pE2blgvU/G7zu5ht0KQz5RdD5TAhEoOYH5Oi2lnr/50=; 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=cRqX6gbbmA/QQEotxbIuCdft2BMcGnL4/zB+dM68HNcAla+7UDZY0SCy49XdPw4I0 ruKPFqIPvrck5fbfaPXf/AF+LOnsEuwXi4pjehZgmh96YO5YTraSVWvdfd05zKgJQd KmvOllvEDjOg304pvGQtrRLbnasiNeaCGcZt8GLLDEQeRij3wQKlGXZQ6GWmXwv8ZC fEYoiIT4A1fQXRKBonQpmEJ+vyvtgakx5RsKX+CdmgoPc3vZ1xlxbWTNEihCi0oOMn lBsVqhpKpnuwu33gz4Vy6Pc9tKma9YpwKcqZn+TFSFGy6gx6aRB9R9LgUZrIJSk0w/ uzT2OlQbqzIog== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 634B167961 for ; Thu, 4 Sep 2025 07:06:24 -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 t1GYqaz_eFAM for ; Thu, 4 Sep 2025 07:06:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991184; bh=pE2blgvU/G7zu5ht0KQz5RdD5TAhEoOYH5Oi2lnr/50=; 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=cRqX6gbbmA/QQEotxbIuCdft2BMcGnL4/zB+dM68HNcAla+7UDZY0SCy49XdPw4I0 ruKPFqIPvrck5fbfaPXf/AF+LOnsEuwXi4pjehZgmh96YO5YTraSVWvdfd05zKgJQd KmvOllvEDjOg304pvGQtrRLbnasiNeaCGcZt8GLLDEQeRij3wQKlGXZQ6GWmXwv8ZC fEYoiIT4A1fQXRKBonQpmEJ+vyvtgakx5RsKX+CdmgoPc3vZ1xlxbWTNEihCi0oOMn lBsVqhpKpnuwu33gz4Vy6Pc9tKma9YpwKcqZn+TFSFGy6gx6aRB9R9LgUZrIJSk0w/ uzT2OlQbqzIog== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51A3567959 for ; Thu, 4 Sep 2025 07:06:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991182; bh=wxbC04D1iX1SJsgrIQER4eu16qbYtPGcU1a4xXL0iFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TSiajrJfmg4K6jZmbmhLls0/MdRUf78IEp0+NtuW5PIKZqLI/vRlBBeR1V9awaZwr ieqnDRTFCu7yxpmfkw5a6prY55FAbuuebVk2+RnhSZRhECahQ9dkMJ8ol4CLqEkbkZ I86dqTEcHiTahxwTWaT+w1Vf+yU0ipJa+6yKdGnA2la5JXE7a5RrIddYpo9hUYm0EO hhg1rh4iPK/NtUlpbW6IYleWp4sPKInhT6Vdj3z1bpCGP9APPH+kbExAiL3gfwGlVJ 4ShC7PLjCS57u+kKTwFrg1CRYrgLpPMaa21TBoIEjKhEI23hth/MDws9TndH9qHfSv lpPBBhhcVu9nw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 549AE678AB; Thu, 4 Sep 2025 07:06: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 y-RIp38Xz0rC; Thu, 4 Sep 2025 07:06:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991176; bh=ZsAvNTxODu575yxrEc7NTSx1OpniIr+bBTaITV9OluU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aQNIKgYWUE/JbK+o0HOuWhy3ZGk6fMa93l4t0TqjcO/Xf/La3SJ46EX3sSLg7dZz6 D9rUNE6qxl1sqh3SWE/Oy9Xld5WIXmzjoMY5QFoKFxhHpJeBiCGBWlxSAoHiHh3ti+ YVQ8NQsF9NnoFkqnCZCzpiUiNV5CFbksPHPCZ84zjweeLJIbkQHffb6VPXN+1ftnr6 eez57foUO98sbZyDmwDIUS2FvWPtPd/mwSszVsJGtuiuW12Pq1Z/rvCPNzhShEQ8V7 0CJ5XySG+wPQQ7dtDqy+DcS/RRojk5PqUD+32Qy7moRlTozG+Kg2VG20Ebow5oBT6v qqB4ntTlUPuxg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E7C5E67974; Thu, 4 Sep 2025 07:06:15 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:51 -0600 Message-ID: <20250904130459.848794-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5VGXFL6LP5VHA3EOLF45S3WYH6YNFOPI X-Message-ID-Hash: 5VGXFL6LP5VHA3EOLF45S3WYH6YNFOPI 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 18/18] ulib: Drop dm stats for the 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 When using the library it should start up silently. Drop the driver model message about the number of devices, etc. Signed-off-by: Simon Glass --- common/board_r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/board_r.c b/common/board_r.c index 297fdc29ca9..ca1498de11e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -504,7 +504,7 @@ static int dm_announce(void) int device_count; int uclass_count; - if (IS_ENABLED(CONFIG_DM)) { + if (IS_ENABLED(CONFIG_DM) && !gd_ulib()) { dm_get_stats(&device_count, &uclass_count); printf("Core: %d devices, %d uclasses", device_count, uclass_count);