From patchwork Mon Dec 29 16:06:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1100 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=1767024394; bh=f2Xn115/ps/4igV0Eq/o6EprwboDGo4MOmJeKROkkjg=; 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=FmJk3RBAM1X2KCmA0Bb29fbyAgUFCI4d8AOvYZ00xXkqZqcHrQJUIaC7QTsjRN2IL 4CRVsgql427DZp+ZNstr8QMpwk1Fp8TdDtuCvsmL4KqptEIa+msQelHuGCpp35/X8R +nQWhjHgu8SjMr0jFZQKlvB9OleGimYVMAPJAVY5qfcD2R5qV1RsTq4Fk0paykPsu7 4lvMa18o5qcpCRToU0H6Ry5IJyRK2FWBmTFPfpcfj5Hfvfd4LHXM8gyq5/dcUCPaXL 7Hw9Vz1qkjNF+idApZFQOt18omAbEhjn/UPVi8qCTJ/cJMcFzdtGiNvyRoPV4UkYqW hwcv0qjod/nzA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0EF1568CAD for ; Mon, 29 Dec 2025 09:06:34 -0700 (MST) 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 xjqROSPtEeHo for ; Mon, 29 Dec 2025 09:06:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024393; bh=f2Xn115/ps/4igV0Eq/o6EprwboDGo4MOmJeKROkkjg=; 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=h9aeJtbcF9/Yfra85JKkSbCp4pigifDg2C1S057KFY0yQh8AyFJJZgO2nRMC3jF7C 7GPXCZs9jKR+Z7uwBNm5JV9e8Y8/MY5pGeEKEomUCpNsY0tHL6tktFD8w4RaNwRPr1 TQpKcAcF/3MnslPkyB+Bvcsr30zt2fSfJI9m4MuRPoAoXgTcA/p9JoAs+46w6AflkI eWblWt/Ui0oTVB6BhBKE/1fv1Ibt++W7GukDqNHioYtk7F4yte3Dr7S9qnitTKxnae ksCaWqIO6WNeyPDJRLFbkkrmLBB3QkDFSdDXHkxLFr/x/g4TJ2lsY04VDP6k73CJ8K ReK5Ba9OyKJTg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C70E68CAC for ; Mon, 29 Dec 2025 09:06:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024391; bh=Cy4k8dftu3PaxpmSjvDjta5fKx9dvqEh1A6h5zgWQYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxmbZBoYSR2NhwajOPBWj6EesBwiJ/W3fXUen8/eiJvQXTe+b4Bkg5AB1gGR3jvri Zq75M6JcXns6o3AZ/R5t8u2POOza0l1WCPTddk4rJSiqIFzhhwiLSfmaRkJwaCSbdE OuV6kEau4T0JtF7fA36Mc6vVe4H+evUmU0GL2yCw9AyJtHggpxhLLDdODEzkKRxt7n /lgtAWXS58u4f41opds/qK9s9PTHgSp7jOxx7ghgnde2+1YPxo+sVbRssXtymQrv9Y pyJSdS900zJXMspTKTVik6vQazA2PW5LmtV61Iz5j5YNRruj0KvoVeJQrhMmZq6wKY I8MtIF+UQR5Wg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0049C68CAC; Mon, 29 Dec 2025 09:06:31 -0700 (MST) 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 lNNRkt2xcLW6; Mon, 29 Dec 2025 09:06:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024390; bh=eKV3Kd8GAlnPdNS7+oH7g+iKUJ4TwiFH5hGy0LaqEzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWBztzRD69FyZAYmmhoR9yDjjcSE/zopHCDNyUTk56JPlul2iDA3ydVqDd+qvVbOM G+Ut3Nrw60ZqDmrwDwqr/mhuGvIp/ebnzPOd72Z/DGxBdbJ9LK2YRYOQAPcof10Y21 xtLegt1lcT4sPvOq89Xqq1MhMTKB0/plYZB27Civ25O3fOFbPeF8f3HykW1i9mrWqX 8M591VJNRplU3RujDpObazU/jf2e4rhvlh8QnK1p+s0Ux6syNTXQtxraslB5+pBzlv eJalMaimkjF1Tw9lX3AGeFHt4QYsH/awiT6pGVUxISiKKpRv9zdvcJSAl0UruHCzEI vlyReV/H0WVTw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5C18B64E2A; Mon, 29 Dec 2025 09:06:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Dec 2025 09:06:00 -0700 Message-ID: <20251229160611.3899708-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251229160611.3899708-1-sjg@u-boot.org> References: <20251229160611.3899708-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: A467KRBBZS6JQZETIJO7CLCCFPLDPH4E X-Message-ID-Hash: A467KRBBZS6JQZETIJO7CLCCFPLDPH4E 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 2/9] test: Write the SPI image to the persistent-data directory 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 annoying to have disk images in the source directory since it clutters up the working space. Move spi.bin (used by the SPI tests) into the persistent-data directory, update the driver and add a comment. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/mtd/spi/sandbox.c | 14 +++++++++++--- test/dm/sf.c | 4 +++- test/py/tests/test_ut.py | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c index d9afe77e52d..0b56312bb85 100644 --- a/drivers/mtd/spi/sandbox.c +++ b/drivers/mtd/spi/sandbox.c @@ -126,7 +126,9 @@ static int sandbox_sf_probe(struct udevice *dev) struct dm_spi_slave_plat *slave_plat; struct udevice *bus = dev->parent; const char *spec = NULL; + const char *filename; struct udevice *emul; + char buf[256]; int ret = 0; int cs = -1; @@ -170,10 +172,16 @@ static int sandbox_sf_probe(struct udevice *dev) if (sandbox_sf_0xff[0] == 0x00) memset(sandbox_sf_0xff, 0xff, sizeof(sandbox_sf_0xff)); - sbsf->fd = os_open(pdata->filename, 02); + /* + * Try persistent data directory first, then fall back to the + * filename as given (for absolute paths or current directory) + */ + filename = pdata->filename; + if (!os_persistent_file(buf, sizeof(buf), pdata->filename)) + filename = buf; + sbsf->fd = os_open(filename, 02); if (sbsf->fd < 0) { - printf("%s: unable to open file '%s'\n", __func__, - pdata->filename); + log_err("Unable to open file '%s'\n", filename); ret = -EIO; goto error; } diff --git a/test/dm/sf.c b/test/dm/sf.c index 3684d021709..15a95a2d41e 100644 --- a/test/dm/sf.c +++ b/test/dm/sf.c @@ -27,10 +27,12 @@ static int dm_test_spi_flash(struct unit_test_state *uts) uint map_size; ulong map_base; uint offset; + char pathname[256]; int i; src = map_sysmem(0x20000, full_size); - ut_assertok(os_write_file("spi.bin", src, full_size)); + ut_assertok(os_persistent_file(pathname, sizeof(pathname), "spi.bin")); + ut_assertok(os_write_file(pathname, src, full_size)); ut_assertok(uclass_first_device_err(UCLASS_SPI_FLASH, &dev)); dst = map_sysmem(0x20000 + full_size, full_size); diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 70a748a31f9..da36898d803 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -42,7 +42,7 @@ def test_ut_dm_init(ubman): with open(fn, 'wb') as fh: fh.write(data) - fn = ubman.config.source_dir + '/spi.bin' + fn = ubman.config.persistent_data_dir + '/spi.bin' if not os.path.exists(fn): data = b'\x00' * (2 * 1024 * 1024) with open(fn, 'wb') as fh: