i.MX HABV4 USB Image generation broken since fd9c7cbfe446b0f04aa66bb198c1769045ba2fe5
Hi, Commit fd9c7cbfe446 ("scripts: Add common library functions") intorduced the usage of the common library functions to imx-image, which breaks the HAB USB image generation within barebox. Signed images are still generated fine: OBJCOPYB images/start_imx6ul_ccbv2_512m.pblb CHKFILESIZE images/start_imx6ul_ccbv2_512m.pblb OBJCOPYB images/start_imx6ul_ccbv2_256m.pblb CHKFILESIZE images/start_imx6ul_ccbv2_256m.pblb IMX-IMG images/start_imx6ul_ccbv2_512m.pblb.imximg IMX-IMG images/start_imx6ul_ccbv2_512m.pblb.simximg Input CSF text filename CSF Processed successfully and signed data available in images/start_imx6ul_ccbv2_512m.pblb.simximg.csfbin IMX-IMG images/start_imx6ul_ccbv2_512m.pblb.usimximg Input CSF text filename CSF Processed successfully and signed data available in images/start_imx6ul_ccbv2_512m.pblb.usimximg.csfbin write failed: Bad address make[1]: *** [/home/phoenix/work/ptx/barebox/images/Makefile.imx:38: images/start_imx6ul_ccbv2_512m.pblb.usimximg] Error 1 make[1]: *** Deleting file 'images/start_imx6ul_ccbv2_512m.pblb.usimximg' make: *** [Makefile:703: images] Error 2 I have attached the .config I used to test this, you'll need the i.MX cst tool in your path and the environment configuration to point to certificates. The ptx devel certificates https://git.pengutronix.de/git/ptx-code-signing-dev were what i used for testing. I assume this is the same error that has been fixed in "scripts/common: fix write_file when opened with mmap", however imx-image implements its own xwrite helper and opens files itself, so there is a mismatch there Thanks, Rouven Czerwinski # # Automatically generated file; DO NOT EDIT. # Barebox/arm 2021.10.0 Configuration # CONFIG_ARM=y CONFIG_ARM_LINUX=y CONFIG_ARM_USE_COMPRESSED_DTB=y CONFIG_TEXT_BASE=0x0 # # System Type # # CONFIG_ARCH_AT91 is not set # CONFIG_ARCH_BCM283X is not set # CONFIG_ARCH_CLPS711X is not set # CONFIG_ARCH_DAVINCI is not set # CONFIG_ARCH_DIGIC is not set # CONFIG_ARCH_EP93XX is not set CONFIG_ARCH_IMX=y # CONFIG_ARCH_LAYERSCAPE is not set # CONFIG_ARCH_MVEBU is not set # CONFIG_ARCH_MXS is not set # CONFIG_ARCH_NOMADIK is not set # CONFIG_ARCH_OMAP is not set # CONFIG_ARCH_PXA is not set # CONFIG_ARCH_ROCKCHIP is not set # CONFIG_ARCH_SOCFPGA is not set # CONFIG_ARCH_S3C24xx is not set # CONFIG_ARCH_S5PCxx is not set # CONFIG_ARCH_S3C64xx is not set # CONFIG_ARCH_STM32MP is not set # CONFIG_ARCH_VERSATILE is not set # CONFIG_ARCH_VEXPRESS is not set # CONFIG_ARCH_TEGRA is not set # CONFIG_ARCH_UEMD is not set # CONFIG_ARCH_ZYNQ is not set # CONFIG_ARCH_ZYNQMP is not set # CONFIG_ARCH_ARM64_VIRT is not set # # Processor Type # CONFIG_CPU_32=y CONFIG_CPU_V7=y CONFIG_CPU_32v7=y # # processor features # # CONFIG_BOOT_ENDIANNESS_SWITCH is not set CONFIG_ARCH_HAS_L2X0=y # CONFIG_CACHE_L2X0 is not set CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x CONFIG_ARCH_IMX_IMXIMAGE=y CONFIG_RESET_IMX_SRC=y # # Freescale i.MX System-on-Chip # CONFIG_ARCH_IMX6=y CONFIG_ARCH_IMX6UL=y CONFIG_IMX_MULTI_BOARDS=y # CONFIG_MACH_SCB9328 is not set # CONFIG_MACH_TX25 is not set # CONFIG_MACH_PCA100 is not set # CONFIG_MACH_PCM038 is not set # CONFIG_MACH_KINDLE_MX50 is not set # CONFIG_MACH_CCMX51 is not set # CONFIG_MACH_EFIKA_MX_SMARTBOOK is not set # CONFIG_MACH_EMBEDSKY_E9 is not set # CONFIG_MACH_FREESCALE_MX51_PDK is not set # CONFIG_MACH_CCMX53 is not set # CONFIG_MACH_FREESCALE_MX53_LOCO is not set # CONFIG_MACH_GUF_VINCELL is not set # CONFIG_MACH_TQMA53 is not set # CONFIG_MACH_FREESCALE_MX53_VMX53 is not set # CONFIG_MACH_TX53 is not set # CONFIG_MACH_PHYTEC_SOM_IMX6 is not set # CONFIG_MACH_PROTONIC_IMX6 is not set # CONFIG_MACH_PROTONIC_IMX8M is not set # CONFIG_MACH_KONTRON_SAMX6I is not set # CONFIG_MACH_DFI_FS700_M60 is not set # CONFIG_MACH_GUF_SANTARO is not set # CONFIG_MACH_REALQ7 is not set # CONFIG_MACH_GK802 is not set # CONFIG_MACH_ELTEC_HIPERCAM is not set # CONFIG_MACH_TQMA6X is not set # CONFIG_MACH_TX6X is not set # CONFIG_MACH_SABRELITE is not set # CONFIG_MACH_SABRESD is not set # CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB is not set # CONFIG_MACH_NITROGEN6 is not set # CONFIG_MACH_SOLIDRUN_MICROSOM is not set # CONFIG_MACH_TECHNEXION_PICO_HOBBIT is not set # CONFIG_MACH_TECHNEXION_WANDBOARD is not set # CONFIG_MACH_EMBEST_MARSBOARD is not set # CONFIG_MACH_EMBEST_RIOTBOARD is not set # CONFIG_MACH_UDOO is not set # CONFIG_MACH_UDOO_NEO is not set # CONFIG_MACH_VARISCITE_MX6 is not set # CONFIG_MACH_GW_VENTANA is not set # CONFIG_MACH_CM_FX6 is not set # CONFIG_MACH_ADVANTECH_ROM_742X is not set # CONFIG_MACH_WARP7 is not set # CONFIG_MACH_AC_SXB is not set # CONFIG_MACH_VF610_TWR is not set # CONFIG_MACH_ZII_RDU1 is not set # CONFIG_MACH_ZII_RDU2 is not set # CONFIG_MACH_ZII_IMX8MQ_DEV is not set # CONFIG_MACH_ZII_VF610_DEV is not set # CONFIG_MACH_ZII_IMX7D_DEV is not set # CONFIG_MACH_PHYTEC_PHYCORE_IMX7 is not set # CONFIG_MACH_FREESCALE_MX7_SABRESD is not set # CONFIG_MACH_KAMSTRUP_MX7_CONCENTRATOR is not set #
[PATCH] fixup! video: add MIPI DBI Type C Option 3 support
Readd common code... Signed-off-by: Ahmad Fatoum --- Threw out the baby with the bath water in the rebase.. --- commands/mipi_dbi.c | 104 include/video/mipi_dbi.h | 105 include/video/mipi_display.h | 150 +++ 3 files changed, 359 insertions(+) create mode 100644 commands/mipi_dbi.c create mode 100644 include/video/mipi_dbi.h create mode 100644 include/video/mipi_display.h diff --git a/commands/mipi_dbi.c b/commands/mipi_dbi.c new file mode 100644 index ..b9b665b72151 --- /dev/null +++ b/commands/mipi_dbi.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: © 2022 Ahmad Fatoum + +#include +#include +#include +#include +#include + +static int mipi_dbi_command_show(struct mipi_dbi *dbi, int cmd) +{ + u8 val[4]; + int ret; + size_t len; + + if (!mipi_dbi_command_is_read(dbi, cmd)) + return -EACCES; + + len = mipi_dbi_command_read_len(cmd); + + printf("%02x: ", cmd); + ret = mipi_dbi_command_buf(dbi, cmd, val, len); + if (ret) { + printf("XX\n"); + return ret; + } + printf("%*phN\n", (int)len, val); + + return 0; +} + +static int do_mipi_dbi(int argc, char *argv[]) +{ + struct mipi_dbi *dbi; + int opt, ret, i; + bool write = false; + u8 cmd, val[4]; + + dbi = list_first_entry_or_null(_dbi_list, struct mipi_dbi, list); + + while ((opt = getopt(argc, argv, "wld:")) > 0) { + struct mipi_dbi *tmp; + + switch (opt) { + case 'w': + write = true; + break; + case 'l': + list_for_each_entry(tmp, _dbi_list, list) + printf("%s\n", mipi_dbi_name(tmp)); + return 0; + case 'd': + dbi = NULL; + list_for_each_entry(tmp, _dbi_list, list) { + if (!strcmp(optarg, mipi_dbi_name(tmp))) { + dbi = tmp; + break; + } + } + break; + default: + return COMMAND_ERROR_USAGE; + } + } + + if (!dbi) + return -ENODEV; + + if (optind == argc) { + for (cmd = 0; cmd < 255; cmd++) + mipi_dbi_command_show(dbi, cmd); + return 0; + } + + ret = kstrtou8(argv[optind++], 16, ); + if (ret < 0) + return ret; + + if (optind == argc && !write) + return mipi_dbi_command_show(dbi, cmd); + + for (i = optind; i < argc; i++) { + ret = kstrtou8(argv[optind + i], 16, [i]); + if (ret < 0) + return ret; + } + + return mipi_dbi_command_buf(dbi, cmd, val, argc - optind); +} + +BAREBOX_CMD_HELP_START(mipi_dbi) +BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT ("-l\t", "list all MIPI DBI devices") +BAREBOX_CMD_HELP_OPT ("-d DEVICE", "select specific device (default is first registered)") +BAREBOX_CMD_HELP_OPT ("-w", "issue write command") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(mipi_dbi) + .cmd= do_mipi_dbi, + BAREBOX_CMD_DESC("write/read from MIPI DBI SPI device") + BAREBOX_CMD_OPTS("[-wld] [REG] [DATA...]") + BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) + BAREBOX_CMD_HELP(cmd_mipi_dbi_help) +BAREBOX_CMD_END diff --git a/include/video/mipi_dbi.h b/include/video/mipi_dbi.h new file mode 100644 index ..92fdc500d1ba --- /dev/null +++ b/include/video/mipi_dbi.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * MIPI Display Bus Interface (DBI) LCD controller support + * + * Copyright 2016 Noralf Trønnes + */ + +#ifndef __LINUX_MIPI_DBI_H +#define __LINUX_MIPI_DBI_H + +#include +#include +#include + +struct regulator; +struct fb_videomode; + +/** + * struct mipi_dbi - MIPI DBI interface + */ +struct mipi_dbi { + /** +* @command: Bus specific callback executing commands. +*/ + int (*command)(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num); + + /** +* @read_commands: Array of read commands terminated by a zero entry. +* Reading is disabled if this is NULL. +*/ + const u8 *read_commands; + + /** +* @swap_bytes: Swap bytes in buffer before transfer +*/ + bool swap_bytes; + + /** +* @reset: Optional reset gpio +*/ + int reset; + + /* Type C specific */ + + /** +* @spi: SPI device +*/ + struct spi_device *spi; + + /** +* @dc: Optional D/C gpio. +*/ +
[PATCH v3] fs: jffs2: fix error when reading blocks with offset
This bug resulted in a panic when trying to read a file partially with an offset, e.g. when starting Linux. In such a case a header is loaded by a separate call of jffs2_read(), which then copies only the first n bytes out of the respective block. When the remaining data of the block is then subsequently going to to be read the system deviates in its behaviour from that under Linux by not calling jffs2_read_inode_range() in a 4k-alignment, but with an offset. jffs2_read_inode_range() originates from the Linux jffs2 driver. When being called with an offset it still reads 4096 bytes of data and eventually returns fragments of two consecutive blocks. jffs2_read() then reads this result whilst again applying the offset, therefore returning faulty data. We fix that problem by calling jffs2_get_block() without an offset and therefore reading the whole block. The offset is then applied when we actually perform memcpy with the returned buffer. This fix might also increase the performance since the respective block is likely to be cached from the previous call. Signed-off-by: Holger Assmann Reviewed-by: Ahmad Fatoum --- Changes v1 -> v2: - removed stray spaces - added review acknowledgement Changes v2 -> v3: - use actual "JFFS2_BLOCK_SIZE" instead of "4096" fs/jffs2/fs.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index a267ec0669..0c57f1d07f 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -74,6 +74,9 @@ static int jffs2_get_block(struct jffs2_file *jf, unsigned int pos) struct jffs2_inode_info *f = JFFS2_INODE_INFO(jf->inode); int ret; + /* pos always has to be 4096 bytes aligned here */ + WARN_ON(pos % JFFS2_BLOCK_SIZE != 0); + if (pos != jf->offset) { ret = jffs2_read_inode_range(c, f, jf->buf, pos, JFFS2_BLOCK_SIZE); @@ -98,12 +101,13 @@ static int jffs2_read(struct device_d *_dev, FILE *f, void *buf, /* Read till end of current block */ ofs = f->pos % JFFS2_BLOCK_SIZE; if (ofs) { - ret = jffs2_get_block(jf, pos); + ret = jffs2_get_block(jf, f->pos - ofs); /* Align down block */ if (ret) return ret; now = min(size, JFFS2_BLOCK_SIZE - ofs); + /* Complete block has been read, re-apply ofset now */ memcpy(buf, jf->buf + ofs, now); size -= now; pos += now; -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Aw: Re: blspec - autoboot + timeout/default
Hi > Gesendet: Montag, 07. Februar 2022 um 09:59 Uhr > Von: "Sascha Hauer" > An: "Frank Wunderlich" > Cc: barebox@lists.infradead.org > Betreff: Re: blspec - autoboot + timeout/default > > On Sat, Feb 05, 2022 at 03:58:54PM +0100, Frank Wunderlich wrote: > > Hi, > > > > can i boot directly to blspec-menu (boot -m sd.1) with setting in > > default env and boot a specific entry (by title/filename) after some > > time (e.g.3-5 sec)? > > There is a -t option to the boot command. It seems however that > there is no possibility to select a specfic entry beforehand. The first > one would be booted. mhm, then i need a way to add it...is there anything similar in blspec not implemented in barebox or is this a function that needs to be added to specification too? > > i have defined some blspec files in /mnt/sd.1/loader/entries/ and i > > want to show the menu by default and after some time the entry from > > specific file should be booted. this gives user the possibility to > > modify this conf to define his kernel for autoboot in headless mode. > > > > i tried to modify defaultenv/nv/boot.default, but this needs filenames > > in /env/boot, no commands and if i use a script, it cannot start the > > "boot -m sd.1" because the /env/boot scripts run bootm (tried loading > > barebox with such script - ended with putting a separate script in > > /env/bin/) > > It should work by setting: > > nv boot.default=myboot i want to avoid user environment...it should be defined in builtin env, but afaik i can set the boot.default in this too...but currently i appended only my scripts... i can use the script next as first entry if it is handled correctly > With /env/boot/myboot: > > #!/bin/sh > > boot -m sd.1 -t 3 > > > > > btw. is there a way to load environment from a txt file from a > > specific partition (similar to uboots uEnv.txt)? > > The barebox environment is a directory tree rather than a list of > variables, so there is no way to load a text file as environment. > There is the loadenv command which takes the path to an environment > image as argument. You can generate such an image on the host > with the bareboxenv tool and then load it under barebox with loadenv. binary import is not that userfriendly :) for me no problem. so there should be a way to define a blspec config as default... regards Frank ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2] ARM: imx: add support for TQMa6UL SoM on MBa6ulxl
Hi Trent, On Thu, 2021-06-17 at 17:03 -0700, Trent Piepho wrote: > On Thu, Jun 17, 2021 at 2:25 AM Rouven Czerwinski > wrote: > > + > > +static void setup_uart(void) > > +{ > > + void __iomem *iomuxbase = (void *)MX6_IOMUXC_BASE_ADDR; > > + > > + imx6_ungate_all_peripherals(); > > + > > + imx_setup_pad(iomuxbase, MX6_PAD_UART1_TX_DATA__UART1_DCE_TX); > > + imx_setup_pad(iomuxbase, MX6_PAD_UART1_RX_DATA__UART1_DCE_RX); > > From what I can tell, imx_setup_pad() will program the conf register > with 0. Not a more typical value like 0x1b0b1 that is in most dts > files. Does this actually work? It seems like one needs to OR in the > pad conf value to the pinmux config constant to actually program this > correctly. No, while imx_setup_pad can include the pad control, the mux defines above do not include one and in this case the pad configuration is not written (iomux-v3.h:137). So the imx_setup_pad above only touches the mux configuration, but keeps the pad configuration as is. > > > + imx6_uart_setup((void *)MX6_UART1_BASE_ADDR); > > + pbl_set_putc(imx_uart_putc, (void *)MX6_UART1_BASE_ADDR); > > + > > + pr_debug("\n"); > > Do you actually get the output from this? I'm trying to add a new > imx6ul board and it seems like one needs a delay between the uart > setup and the uart actually working to output data. Or perhaps this > is just my board. Yes, on my board this adds a newline within the PBL console. > > > +static void noinline start_mba6ulx(void) > > +{ > > + setup_uart(); > > Why setup uart when LL_DEBUG is not enabled? This dts should have > this working without any extra setup. Because this boards supports the PBL console and setup_uart is required for the PBL console to work, since the PBL does not parse this information from the DT. > > > + > > + imx6ul_barebox_entry(__dtb_z_imx6ul_mba6ulx_start); > > +} > > + > > +ENTRY_FUNCTION(start_imx6ul_mba6ulx, r0, r1, r2) > > +{ > > + > > + imx6ul_cpu_lowlevel_init(); > > + > > + arm_setup_stack(0x0091); > > + > > + if (IS_ENABLED(CONFIG_DEBUG_LL)) { > > + imx6_uart_setup_ll(); > > Don't you need the muxing and other code in setup_uart() for this to work? No, conveniently the board uses the default configuration for UART one. The muxing setup for the PBL console could be removed. Sascha, what do you think? -- Pengutronix e.K. | Rouven Czerwinski | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] ubifs: Add zstd support
zstd shows a good compression rate and is faster than lzo. This adds UBIFS support for it. Signed-off-by: Sascha Hauer --- fs/ubifs/Kconfig | 5 fs/ubifs/ubifs-media.h | 2 ++ fs/ubifs/ubifs.c | 52 ++ 3 files changed, 59 insertions(+) diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig index ae58c2b7f2..15fcec4459 100644 --- a/fs/ubifs/Kconfig +++ b/fs/ubifs/Kconfig @@ -17,4 +17,9 @@ config FS_UBIFS_COMPRESSION_ZLIB select ZLIB prompt "ZLIB compression support" +config FS_UBIFS_COMPRESSION_ZSTD + bool + select ZSTD_DECOMPRESS + prompt "ZSTD compression support" + endif diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h index 8b7c184401..697b1b8906 100644 --- a/fs/ubifs/ubifs-media.h +++ b/fs/ubifs/ubifs-media.h @@ -348,12 +348,14 @@ enum { * UBIFS_COMPR_NONE: no compression * UBIFS_COMPR_LZO: LZO compression * UBIFS_COMPR_ZLIB: ZLIB compression + * UBIFS_COMPR_ZSTD: ZSTD compression * UBIFS_COMPR_TYPES_CNT: count of supported compression types */ enum { UBIFS_COMPR_NONE, UBIFS_COMPR_LZO, UBIFS_COMPR_ZLIB, + UBIFS_COMPR_ZSTD, UBIFS_COMPR_TYPES_CNT, }; diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index ced3d1f47f..88a4340a38 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "ubifs.h" @@ -33,6 +34,7 @@ struct ubifs_priv { static struct z_stream_s ubifs_zlib_stream; +static ZSTD_DCtx *ubifs_zstd_cctx; /* compress.c */ @@ -48,6 +50,22 @@ static int gzip_decompress(const unsigned char *in, size_t in_len, } #endif +#if defined(CONFIG_ZSTD_DECOMPRESS) +static int zstd_decompress(const unsigned char *in, size_t in_len, + unsigned char *out, size_t *out_len) +{ + size_t olen; + + olen = ZSTD_decompressDCtx(ubifs_zstd_cctx, out, *out_len, in, in_len); + if (ZSTD_isError(olen)) + return -EINVAL; + + *out_len = olen; + + return 0; +} +#endif + /* Fake description object for the "none" compressor */ static struct ubifs_compressor none_compr = { .compr_type = UBIFS_COMPR_NONE, @@ -74,6 +92,15 @@ static struct ubifs_compressor zlib_compr = { #endif }; +static struct ubifs_compressor zstd_compr = { + .compr_type = UBIFS_COMPR_ZSTD, + .name = "zstd", +#ifdef CONFIG_ZSTD_DECOMPRESS + .capi_name = "zstd", + .decompress = zstd_decompress, +#endif +}; + /* All UBIFS compressors */ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; @@ -238,6 +265,10 @@ int __init ubifs_compressors_init(void) if (err) return err; + err = compr_init(_compr); + if (err) + return err; + err = compr_init(_compr); if (err) return err; @@ -492,6 +523,21 @@ static int zlib_decomp_init(void) return 0; } +static int zstd_decomp_init(void) +{ + const size_t wksp_size = ZSTD_DCtxWorkspaceBound(); + void *wksp = malloc(wksp_size); + + if (!wksp) + return -ENOMEM; + + ubifs_zstd_cctx = ZSTD_initDCtx(wksp, wksp_size); + if (!ubifs_zstd_cctx) + return -EINVAL; + + return 0; +} + int ubifs_allow_encrypted; int ubifs_allow_authenticated_unauthenticated; @@ -505,6 +551,12 @@ static int ubifs_init(void) return ret; } + if (IS_ENABLED(CONFIG_ZSTD_DECOMPRESS)) { + ret = zstd_decomp_init(); + if (ret) + return ret; + } + globalvar_add_simple_bool("ubifs.allow_encrypted", _allow_encrypted); globalvar_add_simple_bool("ubifs.allow_authenticated_unauthenticated", _allow_authenticated_unauthenticated); -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] kbuild: replace $(H) with $(pound)
scripts/Kbuild.include defines 'pound', which is equivalent to 'H'. pound := \# Replace $(H) with $(pound), and remove the 'H' definition. Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 13b1789c0..d981d48a2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -339,8 +339,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb $(srctree)/scripts/gen-dtb-s FORCE dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS)) quiet_cmd_dtc = DTC $@ # For compatibility between make 4.2 and 4.3 -H := \# -cmd_dtc = /bin/echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"\n') | \ +cmd_dtc = /bin/echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(pound)include "$(f)"\n') | \ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \ $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ -i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \ -- 2.32.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] setlocalversion: update to Linux 5.16
It has been a long time since this script was updated. Now resync it with Linux 5.16. Signed-off-by: Masahiro Yamada --- scripts/setlocalversion | 103 +++- 1 file changed, 39 insertions(+), 64 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index cce4706cc..6b54e46a0 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -1,8 +1,14 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0 # # This scripts adds local version information from the version # control systems git, mercurial (hg) and subversion (svn). # +# If something goes wrong, send a mail the kernel build mailinglist +# (see MAINTAINERS) and CC Nico Schottelius +# . +# +# usage() { echo "Usage: $0 [--save-scmversion] [srctree]" >&2 @@ -38,11 +44,12 @@ scm_version() fi # Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && + head=$(git rev-parse --verify HEAD 2>/dev/null); then # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile. - if [ -z "`git describe --exact-match 2>/dev/null`" ]; then + if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then # If only the short version is requested, don't bother # running further git commands @@ -52,69 +59,36 @@ scm_version() fi # If we are past a tagged commit (like # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="`git describe 2>/dev/null`"; then - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' - - # If we don't have a tag at all we print -g{commitish}. - else - printf '%s%s' -g $head + if atag="$(git describe 2>/dev/null)"; then + echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}' fi - fi - # Is this git on svn? - if git config --get svn-remote.svn.url >/dev/null; then - printf -- '-svn%s' "`git svn find-rev $head`" + # Add -g and exactly 12 hex chars. + printf '%s%s' -g "$(echo $head | cut -c1-12)" fi - # Update index only on r/w media - [ -w . ] && git update-index --refresh --unmerged > /dev/null - - # Check for uncommitted changes - if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then + # Check for uncommitted changes. + # This script must avoid any write attempt to the source tree, + # which might be read-only. + # You cannot use 'git describe --dirty' because it tries to + # create .git/index.lock . + # First, with git-status, but --no-optional-locks is only + # supported in git >= 2.14, so fall back to git-diff-index if + # it fails. Note that git-diff-index does not refresh the + # index, so it may give misleading results. See + # git-update-index(1), git-diff-index(1), and git-status(1). + if { + git --no-optional-locks status -uno --porcelain 2>/dev/null || + git diff-index --name-only HEAD + } | read dummy; then printf '%s' -dirty fi - - # All done with git - return - fi - - # Check for mercurial and a mercurial repo. - if test -d .hg && hgid=`hg id 2>/dev/null`; then - # Do we have an tagged version? If so, latesttagdistance == 1 - if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then - id=`hg log -r . --template '{latesttag}'` - printf '%s%s' -hg "$id" - else - tag=`printf '%s' "$hgid" | cut -d' ' -f2` - if [ -z "$tag" -o "$tag" = tip ]; then - id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` - printf '%s%s' -hg "$id" - fi - fi - - # Are there uncommitted changes? - # These are represented by + after the changeset id. - case "$hgid" in - *+|*+\ *) printf '%s' -dirty ;; - esac - - # All done with mercurial - return - fi - - # Check for svn and a svn repo. - if rev=`svn info 2>/dev/null | grep '^Last Changed
[PATCH] kvx: remove unused CONFIG_ARCHINFO
This is defined, but not used anywhere. $ git grep ARCHINFO arch/kvx/Kconfig:config ARCHINFO Signed-off-by: Masahiro Yamada --- arch/kvx/Kconfig | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig index 1c3e29a9f..5e7ddeea1 100644 --- a/arch/kvx/Kconfig +++ b/arch/kvx/Kconfig @@ -38,13 +38,6 @@ config ARCH_TEXT_BASE hex default 0x11000 -menu "Kalray specific" - -config ARCHINFO - string - default "coolidge" -endmenu - menu "Board configuration" config BUILTIN_DTB -- 2.32.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] efi: probe devices from the device-tree
The state device-tree may contain devices. For example block devices with a 'barebox,storage-by-uuid' compatible. Probing is necessary to ensure that those devices are available. Call barebox_register_of() instead of of_set_root_node(). It probes the devices after setting the root node. Signed-off-by: Michael Olbrich --- I've tested the series and with this aditional patch it works on EFI, so Tested-by: Michael Olbrich Michael common/efi/payload/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c index 6db6b2389540..1541683186fb 100644 --- a/common/efi/payload/init.c +++ b/common/efi/payload/init.c @@ -349,7 +349,9 @@ static int efi_late_init(void) if (IS_ERR(root)) return PTR_ERR(root); - of_set_root_node(root); + ret = barebox_register_of(root); + if (ret) + pr_warn("Failed to register device-tree: %pe\n", ERR_PTR(ret)); np = of_find_node_by_alias(root, "state"); -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/8] cdev: implement cdev_open()
On 07.02.22 10:49, Sascha Hauer wrote: > Implement cdev_open() with the expected semantics that takes a struct > cdev * argument. We already have an unimplemented prototype > cdev_do_open(), remove this. Reviewed-by: Ahmad Fatoum > > Signed-off-by: Sascha Hauer > --- > fs/devfs-core.c | 16 +++- > include/driver.h | 2 +- > 2 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/fs/devfs-core.c b/fs/devfs-core.c > index 6350c3fa8b..dd6a9585bc 100644 > --- a/fs/devfs-core.c > +++ b/fs/devfs-core.c > @@ -169,6 +169,14 @@ int cdev_find_free_index(const char *basename) > return -EBUSY; /* all indexes are used */ > } > > +int cdev_open(struct cdev *cdev, unsigned long flags) > +{ > + if (cdev->ops->open) > + return cdev->ops->open(cdev, flags); > + > + return 0; > +} > + > struct cdev *cdev_open_name(const char *name, unsigned long flags) > { > struct cdev *cdev; > @@ -178,11 +186,9 @@ struct cdev *cdev_open_name(const char *name, unsigned > long flags) > if (!cdev) > return NULL; > > - if (cdev->ops->open) { > - ret = cdev->ops->open(cdev, flags); > - if (ret) > - return NULL; > - } > + ret = cdev_open(cdev, flags); > + if (ret) > + return NULL; > > return cdev; > } > diff --git a/include/driver.h b/include/driver.h > index b4fae477a6..4f97b943c8 100644 > --- a/include/driver.h > +++ b/include/driver.h > @@ -492,7 +492,7 @@ struct cdev *cdev_by_diskuuid(const char *partuuid); > struct cdev *cdev_open_name(const char *name, unsigned long flags); > struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset); > void cdev_remove_loop(struct cdev *cdev); > -int cdev_do_open(struct cdev *, unsigned long flags); > +int cdev_open(struct cdev *, unsigned long flags); > void cdev_close(struct cdev *cdev); > int cdev_flush(struct cdev *cdev); > ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, > ulong flags); -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/8] rename cdev_open() -> cdev_open_name()
On 07.02.22 10:49, Sascha Hauer wrote: > The cdev_* functions normally take a struct cdev * argument, with the > exception of cdev_open(). Rename cdev_open() to cdev_open_name() to > be able to implement cdev_open() with the expected semantics in the next > step. Nitpick: cdev_open_by_name would align it more with the naming style elsewhere in barebox. Otherwise, Reviewed-by: Ahmad Fatoum > > Signed-off-by: Sascha Hauer > --- > arch/arm/mach-mxs/ocotp.c | 2 +- > arch/arm/mach-omap/xload.c | 4 ++-- > common/filetype.c | 2 +- > fs/devfs-core.c| 2 +- > fs/fs.c| 4 ++-- > include/driver.h | 2 +- > lib/bootstrap/devfs.c | 4 ++-- > 7 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c > index 5f78d9d773..466f8886cd 100644 > --- a/arch/arm/mach-mxs/ocotp.c > +++ b/arch/arm/mach-mxs/ocotp.c > @@ -229,7 +229,7 @@ int mxs_ocotp_read(void *buf, int count, int offset) > struct cdev *cdev; > int ret; > > - cdev = cdev_open(DRIVERNAME, O_RDONLY); > + cdev = cdev_open_name(DRIVERNAME, O_RDONLY); > if (!cdev) > return -ENODEV; > > diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c > index 0fe78883d1..edb094f36f 100644 > --- a/arch/arm/mach-omap/xload.c > +++ b/arch/arm/mach-omap/xload.c > @@ -38,7 +38,7 @@ static void *read_image_head(const char *name) > struct cdev *cdev; > int ret; > > - cdev = cdev_open(name, O_RDONLY); > + cdev = cdev_open_name(name, O_RDONLY); > if (!cdev) { > printf("failed to open %s\n", name); > return NULL; > @@ -86,7 +86,7 @@ static void *read_mtd_barebox(const char *partition) > > to = xmalloc(size); > > - cdev = cdev_open(partition, O_RDONLY); > + cdev = cdev_open_name(partition, O_RDONLY); > if (!cdev) { > printf("failed to open partition\n"); > return NULL; > diff --git a/common/filetype.c b/common/filetype.c > index 8ffcd6adcd..a955d88bc3 100644 > --- a/common/filetype.c > +++ b/common/filetype.c > @@ -438,7 +438,7 @@ enum filetype cdev_detect_type(const char *name) > struct cdev *cdev; > void *buf; > > - cdev = cdev_open(name, O_RDONLY); > + cdev = cdev_open_name(name, O_RDONLY); > if (!cdev) > return type; > > diff --git a/fs/devfs-core.c b/fs/devfs-core.c > index 2475ab959a..6350c3fa8b 100644 > --- a/fs/devfs-core.c > +++ b/fs/devfs-core.c > @@ -169,7 +169,7 @@ int cdev_find_free_index(const char *basename) > return -EBUSY; /* all indexes are used */ > } > > -struct cdev *cdev_open(const char *name, unsigned long flags) > +struct cdev *cdev_open_name(const char *name, unsigned long flags) > { > struct cdev *cdev; > int ret; > diff --git a/fs/fs.c b/fs/fs.c > index 968e77b808..20362c3889 100644 > --- a/fs/fs.c > +++ b/fs/fs.c > @@ -800,7 +800,7 @@ int fsdev_open_cdev(struct fs_device_d *fsdev) > > fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR, > offset); > } else { > - fsdev->cdev = cdev_open(fsdev->backingstore, O_RDWR); > + fsdev->cdev = cdev_open_name(fsdev->backingstore, O_RDWR); > } > if (!fsdev->cdev) { > path_put(); > @@ -3048,7 +3048,7 @@ int umount(const char *pathname) > path_put(); > > if (!fsdev) { > - struct cdev *cdev = cdev_open(pathname, O_RDWR); > + struct cdev *cdev = cdev_open_name(pathname, O_RDWR); > > if (cdev) { > cdev_close(cdev); > diff --git a/include/driver.h b/include/driver.h > index 3ef8bfb8a3..b4fae477a6 100644 > --- a/include/driver.h > +++ b/include/driver.h > @@ -489,7 +489,7 @@ struct cdev *cdev_readlink(struct cdev *cdev); > struct cdev *cdev_by_device_node(struct device_node *node); > struct cdev *cdev_by_partuuid(const char *partuuid); > struct cdev *cdev_by_diskuuid(const char *partuuid); > -struct cdev *cdev_open(const char *name, unsigned long flags); > +struct cdev *cdev_open_name(const char *name, unsigned long flags); > struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset); > void cdev_remove_loop(struct cdev *cdev); > int cdev_do_open(struct cdev *, unsigned long flags); > diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c > index 6d28b1cb4d..e26a3d831d 100644 > --- a/lib/bootstrap/devfs.c > +++ b/lib/bootstrap/devfs.c > @@ -32,7 +32,7 @@ static void *read_image_head(const char *name) > struct cdev *cdev; > int ret; > > - cdev = cdev_open(name, O_RDONLY); > + cdev = cdev_open_name(name, O_RDONLY); > if (!cdev) { > bootstrap_err("failed to open partition\n"); > goto free_header; > @@ -124,7 +124,7 @@ void* bootstrap_read_devfs(char *devname, bool use_bb, > int offset, > > to = xmalloc(size); > > - cdev =
Re: [PATCH 8/8] misc: Add storage-by-uuid driver
On Mon, Feb 07, 2022 at 10:49:53AM +0100, Sascha Hauer wrote: > This adds a driver which matches to a "barebox,storage-by-uuid" > compatible node. The driver looks for a storage device matching the > given UUID and when found registers a new cdev for the device. > > This driver solved a very specific problem. On EFI the storage devices > are not connected to any device tree node. barebox-state however expects > a node to use as its backend. The obvious solution would be to create > a partition with a specific partuuid and use that for state, in our > special usecase though the storage device is partitioned with a MBR > which doesn't have any space left to create a new partition. As this > driver parses the of partition binding we can use that to create > a partition in an unallocated are of the disk which is then used for > state. > > This driver has the problem that it depends on storage devices which > are not described in the device tree. This means it cannot work with > deep probe. This is not a problem on EFI though. It's a special purpose > driver, it's not recommended for general use. > > Signed-off-by: Sascha Hauer > --- > drivers/misc/Kconfig | 23 > drivers/misc/Makefile | 1 + > drivers/misc/storage-by-uuid.c | 199 + > 3 files changed, 223 insertions(+) > create mode 100644 drivers/misc/storage-by-uuid.c > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > index 5ab0506cd9..78c9c193d8 100644 > --- a/drivers/misc/Kconfig > +++ b/drivers/misc/Kconfig > @@ -47,4 +47,27 @@ config STARFIVE_PWRSEQ > be accessed over /dev/mem or used from kernels which still depend > on bootloader for initialization. > > +static struct of_device_id storage_by_uuid_dt_ids[] = { > + { > + .compatible = "barebox,storage-by-uuid", > + }, { NAK. Don't add new device tree bindings without adding documentation to Documentation/devicetree/bindings/ :( Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 1/8] cdev: rename partuuid to uuid
From: Michael Olbrich Partitions are not the only devices that can have UUIDs. Change the name to something more generic to prepare for other users. Signed-off-by: Michael Olbrich Link: https://lore.barebox.org/20220124100458.2924679-2-m.olbr...@pengutronix.de Signed-off-by: Sascha Hauer --- common/bootm.c | 6 +++--- common/partitions.c| 2 +- common/partitions/parser.h | 2 +- fs/devfs-core.c| 2 +- fs/fs.c| 4 ++-- include/driver.h | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 89e3e93f2c..4652467448 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -709,15 +709,15 @@ int bootm_boot(struct bootm_data *bootm_data) const char *root_dev_name = devpath_to_name(bootm_data->root_dev); const struct cdev *root_cdev = cdev_by_name(root_dev_name); - if (root_cdev && root_cdev->partuuid[0] != 0) { - rootarg = basprintf("root=PARTUUID=%s", root_cdev->partuuid); + if (root_cdev && root_cdev->uuid[0] != 0) { + rootarg = basprintf("root=PARTUUID=%s", root_cdev->uuid); } else { rootarg = ERR_PTR(-EINVAL); if (!root_cdev) pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name); - else if (!root_cdev->partuuid[0]) + else if (!root_cdev->uuid[0]) pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", root_dev_name); } diff --git a/common/partitions.c b/common/partitions.c index b579559672..9cca5c4a15 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -51,7 +51,7 @@ static int register_one_partition(struct block_device *blk, cdev->flags |= DEVFS_PARTITION_FROM_TABLE; cdev->dos_partition_type = part->dos_partition_type; - strcpy(cdev->partuuid, part->partuuid); + strcpy(cdev->uuid, part->partuuid); free(partition_name); diff --git a/common/partitions/parser.h b/common/partitions/parser.h index 69508932b3..d67f8e1d6a 100644 --- a/common/partitions/parser.h +++ b/common/partitions/parser.h @@ -17,7 +17,7 @@ struct partition { char name[MAX_PARTITION_NAME]; u8 dos_partition_type; - char partuuid[MAX_PARTUUID_STR]; + char partuuid[MAX_UUID_STR]; uint64_t first_sec; uint64_t size; }; diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 2d016e0e48..82e4811b38 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -101,7 +101,7 @@ struct cdev *cdev_by_partuuid(const char *partuuid) return NULL; list_for_each_entry(cdev, _list, list) { - if (!strcasecmp(cdev->partuuid, partuuid)) + if (cdev->master && !strcasecmp(cdev->uuid, partuuid)) return cdev; } return NULL; diff --git a/fs/fs.c b/fs/fs.c index 60fdb29078..968e77b808 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -2999,8 +2999,8 @@ int mount(const char *device, const char *fsname, const char *pathname, cdev_is_mci_main_part_dev(fsdev->cdev->master)) str = get_linux_mmcblkdev(fsdev); - if (!str && fsdev->cdev->partuuid[0] != 0) - str = basprintf("root=PARTUUID=%s", fsdev->cdev->partuuid); + if (!str && fsdev->cdev->uuid[0] != 0) + str = basprintf("root=PARTUUID=%s", fsdev->cdev->uuid); if (str) fsdev_set_linux_rootarg(fsdev, str); diff --git a/include/driver.h b/include/driver.h index 1215a2d57a..62a1782847 100644 --- a/include/driver.h +++ b/include/driver.h @@ -451,7 +451,7 @@ struct cdev_operations { int (*truncate)(struct cdev*, size_t size); }; -#define MAX_PARTUUID_STR sizeof("00112233-4455-6677-8899-AABBCCDDEEFF") +#define MAX_UUID_STR sizeof("00112233-4455-6677-8899-AABBCCDDEEFF") struct cdev { const struct cdev_operations *ops; @@ -464,7 +464,7 @@ struct cdev { char *partname; /* the partition name, usually the above without the * device part, i.e. name = "nand0.barebox" -> partname = "barebox" */ - char partuuid[MAX_PARTUUID_STR]; + char uuid[MAX_UUID_STR]; loff_t offset; loff_t size; unsigned int flags; -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 8/8] misc: Add storage-by-uuid driver
This adds a driver which matches to a "barebox,storage-by-uuid" compatible node. The driver looks for a storage device matching the given UUID and when found registers a new cdev for the device. This driver solved a very specific problem. On EFI the storage devices are not connected to any device tree node. barebox-state however expects a node to use as its backend. The obvious solution would be to create a partition with a specific partuuid and use that for state, in our special usecase though the storage device is partitioned with a MBR which doesn't have any space left to create a new partition. As this driver parses the of partition binding we can use that to create a partition in an unallocated are of the disk which is then used for state. This driver has the problem that it depends on storage devices which are not described in the device tree. This means it cannot work with deep probe. This is not a problem on EFI though. It's a special purpose driver, it's not recommended for general use. Signed-off-by: Sascha Hauer --- drivers/misc/Kconfig | 23 drivers/misc/Makefile | 1 + drivers/misc/storage-by-uuid.c | 199 + 3 files changed, 223 insertions(+) create mode 100644 drivers/misc/storage-by-uuid.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 5ab0506cd9..78c9c193d8 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -47,4 +47,27 @@ config STARFIVE_PWRSEQ be accessed over /dev/mem or used from kernels which still depend on bootloader for initialization. +config STORAGE_BY_UUID + bool "storage by UUID" + depends on OFDEVICE + help + This adds a driver which matches to a "barebox,storage-by-uuid" + compatible node. The driver looks for a storage device matching the + given UUID and when found registers a new cdev for the device. + + This driver solved a very specific problem. On EFI the storage devices + are not connected to any device tree node. barebox-state however expects + a node to use as its backend. The obvious solution would be to create + a partition with a specific partuuid and use that for state, in our + special usecase though the storage device is partitioned with a MBR + which doesn't have any space left to create a new partition. As this + driver parses the of partition binding we can use that to create + a partition in an unallocated are of the disk which is then used for + state. + + This driver has the problem that it depends on storage devices which + are not described in the device tree. This means it cannot work with + deep probe. This is not a problem on EFI though. It's a special purpose + driver, it's not recommended for general use. + endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 6326e784fc..986f7b1b38 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_STATE_DRV) += state.o obj-$(CONFIG_DEV_MEM) += mem.o obj-$(CONFIG_UBOOTVAR) += ubootvar.o obj-$(CONFIG_STARFIVE_PWRSEQ) += starfive-pwrseq.o +obj-$(CONFIG_STORAGE_BY_UUID) += storage-by-uuid.o diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c new file mode 100644 index 00..c9dd6e9793 --- /dev/null +++ b/drivers/misc/storage-by-uuid.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include +#include +#include +#include + +static LIST_HEAD(sbu_list); + +struct sbu { + char *uuid; + struct device_d *dev; + struct cdev *rcdev; + struct cdev cdev; + struct list_head list; +}; + +void storage_by_uuid_check_exist(struct cdev *cdev); + +static ssize_t sbu_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags) +{ + struct sbu *sbu = cdev->priv; + + return cdev_read(sbu->rcdev, buf, count, offset, flags); +} + +static ssize_t sbu_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) +{ + struct sbu *sbu = cdev->priv; + + return cdev_write(sbu->rcdev, buf, count, offset, flags); +} + +static int sbu_ioctl(struct cdev *cdev, int request, void *buf) +{ + struct sbu *sbu = cdev->priv; + + return cdev_ioctl(sbu->rcdev, request, buf); +} + +static int sbu_open(struct cdev *cdev, unsigned long flags) +{ + struct sbu *sbu = cdev->priv; + + return cdev_open(sbu->rcdev, flags); +} + +static int sbu_close(struct cdev *cdev) +{ + struct sbu *sbu = cdev->priv; + + cdev_close(sbu->rcdev); + + return 0; +} + +static int sbu_flush(struct cdev *cdev) +{ + struct sbu *sbu = cdev->priv; + + return cdev_flush(sbu->rcdev); +} + +static int sbu_erase(struct cdev *cdev, loff_t count, loff_t offset) +{ + struct sbu *sbu = cdev->priv; + +
[PATCH 5/8] driver: Add functions to free devices
struct device_d has some dynamically allocated members, namely .name and .unique_name. These are normally not freed when a device is freed. Add two functions to free these resources. free_device_res() only frees the allocated members, but not the device itself. This is suitable for cases where the device is embedded in another struct. free_device() frees the allocated members along with the device itself. This can be called when the device itself has been directly allocated. Some users which should use these functions are also fixed in this patch. Signed-off-by: Sascha Hauer --- drivers/base/driver.c | 30 ++ drivers/of/base.c | 2 +- drivers/of/platform.c | 3 ++- drivers/usb/core/usb.c | 1 + include/driver.h | 4 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/base/driver.c b/drivers/base/driver.c index f54f4d0b37..2347b5c71f 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -270,6 +270,36 @@ int unregister_device(struct device_d *old_dev) } EXPORT_SYMBOL(unregister_device); +/** + * free_device_res - free dynamically allocated device members + * @dev: The device + * + * This frees dynamically allocated resources allocated during device + * lifetime, but not the device itself. + */ +void free_device_res(struct device_d *dev) +{ + free(dev->name); + dev->name = NULL; + free(dev->unique_name); + dev->unique_name = NULL; +} +EXPORT_SYMBOL(free_device_res); + +/** + * free_device - free a device + * @dev: The device + * + * This frees dynamically allocated resources allocated during device + * lifetime and finally the device itself. + */ +void free_device(struct device_d *dev) +{ + free_device_res(dev); + free(dev); +} +EXPORT_SYMBOL(free_device); + /* * Loop over list of deferred devices as long as at least one * device is successfully probed. Devices that again request diff --git a/drivers/of/base.c b/drivers/of/base.c index 80465d6d50..2591610c3f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2383,7 +2383,7 @@ static void of_platform_device_create_root(struct device_node *np) ret = platform_device_register(dev); if (ret) - free(dev); + free_device(dev); } static const struct of_device_id reserved_mem_matches[] = { diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 3a82809cb3..0e718469db 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -155,7 +155,7 @@ struct device_d *of_platform_device_create(struct device_node *np, np->dev = NULL; - free(dev); + free_device(dev); if (num_reg) free(res); return NULL; @@ -278,6 +278,7 @@ static struct device_d *of_amba_device_create(struct device_node *np) return >dev; amba_err_free: + free_device_res(>dev); free(dev); return NULL; } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 4eede13a11..34a0f004f7 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -534,6 +534,7 @@ void usb_free_device(struct usb_device *usbdev) { dma_free(usbdev->descriptor); dma_free(usbdev->setup_packet); + free_device_res(>dev); free(usbdev); } diff --git a/include/driver.h b/include/driver.h index 4f97b943c8..93de4f676e 100644 --- a/include/driver.h +++ b/include/driver.h @@ -141,6 +141,10 @@ void device_detect_all(void); */ int unregister_device(struct device_d *); +void free_device_res(struct device_d *dev); +void free_device(struct device_d *dev); + + /* Iterate over a devices children */ #define device_for_each_child(dev, child) \ -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 3/8] rename cdev_open() -> cdev_open_name()
The cdev_* functions normally take a struct cdev * argument, with the exception of cdev_open(). Rename cdev_open() to cdev_open_name() to be able to implement cdev_open() with the expected semantics in the next step. Signed-off-by: Sascha Hauer --- arch/arm/mach-mxs/ocotp.c | 2 +- arch/arm/mach-omap/xload.c | 4 ++-- common/filetype.c | 2 +- fs/devfs-core.c| 2 +- fs/fs.c| 4 ++-- include/driver.h | 2 +- lib/bootstrap/devfs.c | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c index 5f78d9d773..466f8886cd 100644 --- a/arch/arm/mach-mxs/ocotp.c +++ b/arch/arm/mach-mxs/ocotp.c @@ -229,7 +229,7 @@ int mxs_ocotp_read(void *buf, int count, int offset) struct cdev *cdev; int ret; - cdev = cdev_open(DRIVERNAME, O_RDONLY); + cdev = cdev_open_name(DRIVERNAME, O_RDONLY); if (!cdev) return -ENODEV; diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c index 0fe78883d1..edb094f36f 100644 --- a/arch/arm/mach-omap/xload.c +++ b/arch/arm/mach-omap/xload.c @@ -38,7 +38,7 @@ static void *read_image_head(const char *name) struct cdev *cdev; int ret; - cdev = cdev_open(name, O_RDONLY); + cdev = cdev_open_name(name, O_RDONLY); if (!cdev) { printf("failed to open %s\n", name); return NULL; @@ -86,7 +86,7 @@ static void *read_mtd_barebox(const char *partition) to = xmalloc(size); - cdev = cdev_open(partition, O_RDONLY); + cdev = cdev_open_name(partition, O_RDONLY); if (!cdev) { printf("failed to open partition\n"); return NULL; diff --git a/common/filetype.c b/common/filetype.c index 8ffcd6adcd..a955d88bc3 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -438,7 +438,7 @@ enum filetype cdev_detect_type(const char *name) struct cdev *cdev; void *buf; - cdev = cdev_open(name, O_RDONLY); + cdev = cdev_open_name(name, O_RDONLY); if (!cdev) return type; diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 2475ab959a..6350c3fa8b 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -169,7 +169,7 @@ int cdev_find_free_index(const char *basename) return -EBUSY; /* all indexes are used */ } -struct cdev *cdev_open(const char *name, unsigned long flags) +struct cdev *cdev_open_name(const char *name, unsigned long flags) { struct cdev *cdev; int ret; diff --git a/fs/fs.c b/fs/fs.c index 968e77b808..20362c3889 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -800,7 +800,7 @@ int fsdev_open_cdev(struct fs_device_d *fsdev) fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR, offset); } else { - fsdev->cdev = cdev_open(fsdev->backingstore, O_RDWR); + fsdev->cdev = cdev_open_name(fsdev->backingstore, O_RDWR); } if (!fsdev->cdev) { path_put(); @@ -3048,7 +3048,7 @@ int umount(const char *pathname) path_put(); if (!fsdev) { - struct cdev *cdev = cdev_open(pathname, O_RDWR); + struct cdev *cdev = cdev_open_name(pathname, O_RDWR); if (cdev) { cdev_close(cdev); diff --git a/include/driver.h b/include/driver.h index 3ef8bfb8a3..b4fae477a6 100644 --- a/include/driver.h +++ b/include/driver.h @@ -489,7 +489,7 @@ struct cdev *cdev_readlink(struct cdev *cdev); struct cdev *cdev_by_device_node(struct device_node *node); struct cdev *cdev_by_partuuid(const char *partuuid); struct cdev *cdev_by_diskuuid(const char *partuuid); -struct cdev *cdev_open(const char *name, unsigned long flags); +struct cdev *cdev_open_name(const char *name, unsigned long flags); struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset); void cdev_remove_loop(struct cdev *cdev); int cdev_do_open(struct cdev *, unsigned long flags); diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c index 6d28b1cb4d..e26a3d831d 100644 --- a/lib/bootstrap/devfs.c +++ b/lib/bootstrap/devfs.c @@ -32,7 +32,7 @@ static void *read_image_head(const char *name) struct cdev *cdev; int ret; - cdev = cdev_open(name, O_RDONLY); + cdev = cdev_open_name(name, O_RDONLY); if (!cdev) { bootstrap_err("failed to open partition\n"); goto free_header; @@ -124,7 +124,7 @@ void* bootstrap_read_devfs(char *devname, bool use_bb, int offset, to = xmalloc(size); - cdev = cdev_open(partname, O_RDONLY); + cdev = cdev_open_name(partname, O_RDONLY); if (!cdev) { bootstrap_err("%s: failed to open %s\n", devname, partname); goto free_memory; -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org
[PATCH 6/8] cdev: Create missing cdev_* functions
We have several functions like cdev_read(), cdev_write() and others. For consistency create the remaining functions: cdev_lseek(), cdev_protect(), cdev_discard_range(), cdev_memmap() and cdev_truncate() Signed-off-by: Sascha Hauer --- fs/devfs-core.c | 61 fs/devfs.c | 46 +--- include/driver.h | 5 3 files changed, 72 insertions(+), 40 deletions(-) diff --git a/fs/devfs-core.c b/fs/devfs-core.c index dd6a9585bc..c9a8529737 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -239,6 +239,67 @@ int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset) return cdev->ops->erase(cdev, count, cdev->offset + offset); } +int cdev_lseek(struct cdev *cdev, loff_t pos) +{ + int ret; + + if (cdev->ops->lseek) { + ret = cdev->ops->lseek(cdev, pos + cdev->offset); + if (ret < 0) + return ret; + } + + return 0; +} + +int cdev_protect(struct cdev *cdev, size_t count, loff_t offset, int prot) +{ + if (!cdev->ops->protect) + return -ENOSYS; + + return cdev->ops->protect(cdev, count, offset + cdev->offset, prot); +} + +int cdev_discard_range(struct cdev *cdev, loff_t count, loff_t offset) +{ + if (!cdev->ops->discard_range) + return -ENOSYS; + + if (cdev->flags & DEVFS_PARTITION_READONLY) + return -EPERM; + + if (offset >= cdev->size) + return 0; + + if (count + offset > cdev->size) + count = cdev->size - offset; + + return cdev->ops->discard_range(cdev, count, offset + cdev->offset); +} + +int cdev_memmap(struct cdev *cdev, void **map, int flags) +{ + int ret = -ENOSYS; + + if (!cdev->ops->memmap) + return -EINVAL; + + ret = cdev->ops->memmap(cdev, map, flags); + + if (!ret) + *map = (void *)((unsigned long)*map + (unsigned long)cdev->offset); + + return ret; +} + +int cdev_truncate(struct cdev *cdev, size_t size) +{ + if (cdev->ops->truncate) + return cdev->ops->truncate(cdev, size); + + return -EPERM; +} + int devfs_create(struct cdev *new) { struct cdev *cdev; diff --git a/fs/devfs.c b/fs/devfs.c index df229cca48..d205881765 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -57,15 +57,8 @@ static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t s static int devfs_lseek(struct device_d *_dev, FILE *f, loff_t pos) { struct cdev *cdev = f->priv; - int ret; - if (cdev->ops->lseek) { - ret = cdev->ops->lseek(cdev, pos + cdev->offset); - if (ret < 0) - return ret; - } - - return 0; + return cdev_lseek(cdev, pos); } static int devfs_erase(struct device_d *_dev, FILE *f, loff_t count, loff_t offset) @@ -81,14 +74,11 @@ static int devfs_erase(struct device_d *_dev, FILE *f, loff_t count, loff_t offs return cdev_erase(cdev, count, offset); } -static int devfs_protect(struct device_d *_dev, FILE *f, size_t count, loff_t offset, int prot) +static int devfs_protect(struct device_d *dev, FILE *f, size_t count, loff_t offset, int prot) { struct cdev *cdev = f->priv; - if (!cdev->ops->protect) - return -ENOSYS; - - return cdev->ops->protect(cdev, count, offset + cdev->offset, prot); + return cdev_protect(cdev, count, offset, prot); } static int devfs_discard_range(struct device_d *dev, FILE *f, loff_t count, @@ -96,35 +86,14 @@ static int devfs_discard_range(struct device_d *dev, FILE *f, loff_t count, { struct cdev *cdev = f->priv; - if (!cdev->ops->discard_range) - return -ENOSYS; - - if (cdev->flags & DEVFS_PARTITION_READONLY) - return -EPERM; - - if (offset >= cdev->size) - return 0; - - if (count + offset > cdev->size) - count = cdev->size - offset; - - return cdev->ops->discard_range(cdev, count, offset + cdev->offset); + return cdev_discard_range(cdev, count, offset); } static int devfs_memmap(struct device_d *_dev, FILE *f, void **map, int flags) { struct cdev *cdev = f->priv; - int ret = -ENOSYS; - if (!cdev->ops->memmap) - return -EINVAL; - - ret = cdev->ops->memmap(cdev, map, flags); - - if (!ret) - *map = (void *)((unsigned long)*map + (unsigned long)cdev->offset); - - return ret; + return cdev_memmap(cdev, map, flags); } static int devfs_open(struct device_d *_dev, FILE *f, const char *filename) @@ -183,10 +152,7 @@ static int devfs_truncate(struct device_d *dev, FILE *f, loff_t size) { struct cdev *cdev = f->priv; - if (cdev->ops->truncate) - return cdev->ops->truncate(cdev, size); - - return -EPERM; + return cdev_truncate(cdev,
[PATCH 7/8] cdev: create iterator for cdev list
This creates an iterator to iterate over all availabe cdevs. Signed-off-by: Sascha Hauer --- fs/devfs-core.c | 10 +- fs/devfs.c | 4 +--- include/driver.h | 4 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/devfs-core.c b/fs/devfs-core.c index c9a8529737..2f2882dcc8 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -37,7 +37,7 @@ int devfs_partition_complete(struct string_list *sl, char *instr) len = strlen(instr); - list_for_each_entry(cdev, _list, list) { + for_each_cdev(cdev) { if (cdev->master && !strncmp(instr, cdev->name, len)) { string_list_add_asprintf(sl, "%s ", cdev->name); @@ -62,7 +62,7 @@ struct cdev *lcdev_by_name(const char *filename) { struct cdev *cdev; - list_for_each_entry(cdev, _list, list) { + for_each_cdev(cdev) { if (!strcmp(cdev->name, filename)) return cdev; } @@ -84,7 +84,7 @@ struct cdev *cdev_by_device_node(struct device_node *node) { struct cdev *cdev; - list_for_each_entry(cdev, _list, list) { + for_each_cdev(cdev) { if (!cdev->device_node) continue; if (cdev->device_node == node) @@ -100,7 +100,7 @@ struct cdev *cdev_by_partuuid(const char *partuuid) if (!partuuid) return NULL; - list_for_each_entry(cdev, _list, list) { + for_each_cdev(cdev) { if (cdev->master && !strcasecmp(cdev->uuid, partuuid)) return cdev; } @@ -114,7 +114,7 @@ struct cdev *cdev_by_diskuuid(const char *diskuuid) if (!diskuuid) return NULL; - list_for_each_entry(cdev, _list, list) { + for_each_cdev(cdev) { if (!cdev->master && !strcasecmp(cdev->uuid, diskuuid)) return cdev; } diff --git a/fs/devfs.c b/fs/devfs.c index d205881765..deb244feea 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -35,8 +35,6 @@ struct devfs_inode { struct cdev *cdev; }; -extern struct list_head cdev_list; - static int devfs_read(struct device_d *_dev, FILE *f, void *buf, size_t size) { struct cdev *cdev = f->priv; @@ -179,7 +177,7 @@ static int devfs_iterate(struct file *file, struct dir_context *ctx) dir_emit_dots(file, ctx); - list_for_each_entry(cdev, _list, list) { + for_each_cdev(cdev) { dir_emit(ctx, cdev->name, strlen(cdev->name), 1 /* FIXME */, DT_REG); } diff --git a/include/driver.h b/include/driver.h index b9b0b8497d..79d287ec31 100644 --- a/include/driver.h +++ b/include/driver.h @@ -510,6 +510,10 @@ int cdev_memmap(struct cdev*, void **map, int flags); int cdev_truncate(struct cdev*, size_t size); loff_t cdev_unallocated_space(struct cdev *cdev); +extern struct list_head cdev_list; +#define for_each_cdev(c) \ + list_for_each_entry(cdev, _list, list) + #define DEVFS_PARTITION_FIXED (1U << 0) #define DEVFS_PARTITION_READONLY (1U << 1) #define DEVFS_IS_CHARACTER_DEV (1U << 3) -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 2/8] cdev: add diskuuid support
From: Michael Olbrich This allows identifying disks by UUID. For disks with GPT the disk GUID is used. For DOS partition tables the NT signature ist used, similar to how the partuuid is generated. Signed-off-by: Michael Olbrich Link: https://lore.barebox.org/20220124100458.2924679-3-m.olbr...@pengutronix.de Signed-off-by: Sascha Hauer --- common/partitions/dos.c | 3 +++ common/partitions/efi.c | 2 ++ fs/devfs-core.c | 14 ++ include/driver.h| 1 + 4 files changed, 20 insertions(+) diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 597d7bf9bc..566c8dd949 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -182,6 +182,9 @@ static void dos_partition(void *buf, struct block_device *blk, struct disk_signature_priv *dsp; uint32_t signature = get_unaligned_le32(buf + 0x1b8); + if (signature) + sprintf(blk->cdev.uuid, "%08x", signature); + table = (struct partition_entry *)[446]; for (i = 0; i < 4; i++) { diff --git a/common/partitions/efi.c b/common/partitions/efi.c index 6d811bfb3b..0787b93f12 100644 --- a/common/partitions/efi.c +++ b/common/partitions/efi.c @@ -445,6 +445,8 @@ static void efi_partition(void *buf, struct block_device *blk, return; } + snprintf(blk->cdev.uuid, sizeof(blk->cdev.uuid), "%pUl", >disk_guid); + nb_part = le32_to_cpu(gpt->num_partition_entries); if (nb_part > MAX_PARTITION) { diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 82e4811b38..2475ab959a 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -107,6 +107,20 @@ struct cdev *cdev_by_partuuid(const char *partuuid) return NULL; } +struct cdev *cdev_by_diskuuid(const char *diskuuid) +{ + struct cdev *cdev; + + if (!diskuuid) + return NULL; + + list_for_each_entry(cdev, _list, list) { + if (!cdev->master && !strcasecmp(cdev->uuid, diskuuid)) + return cdev; + } + return NULL; +} + /** * device_find_partition - find a partition belonging to a physical device * diff --git a/include/driver.h b/include/driver.h index 62a1782847..3ef8bfb8a3 100644 --- a/include/driver.h +++ b/include/driver.h @@ -488,6 +488,7 @@ struct cdev *lcdev_by_name(const char *filename); struct cdev *cdev_readlink(struct cdev *cdev); struct cdev *cdev_by_device_node(struct device_node *node); struct cdev *cdev_by_partuuid(const char *partuuid); +struct cdev *cdev_by_diskuuid(const char *partuuid); struct cdev *cdev_open(const char *name, unsigned long flags); struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset); void cdev_remove_loop(struct cdev *cdev); -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 4/8] cdev: implement cdev_open()
Implement cdev_open() with the expected semantics that takes a struct cdev * argument. We already have an unimplemented prototype cdev_do_open(), remove this. Signed-off-by: Sascha Hauer --- fs/devfs-core.c | 16 +++- include/driver.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 6350c3fa8b..dd6a9585bc 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -169,6 +169,14 @@ int cdev_find_free_index(const char *basename) return -EBUSY; /* all indexes are used */ } +int cdev_open(struct cdev *cdev, unsigned long flags) +{ + if (cdev->ops->open) + return cdev->ops->open(cdev, flags); + + return 0; +} + struct cdev *cdev_open_name(const char *name, unsigned long flags) { struct cdev *cdev; @@ -178,11 +186,9 @@ struct cdev *cdev_open_name(const char *name, unsigned long flags) if (!cdev) return NULL; - if (cdev->ops->open) { - ret = cdev->ops->open(cdev, flags); - if (ret) - return NULL; - } + ret = cdev_open(cdev, flags); + if (ret) + return NULL; return cdev; } diff --git a/include/driver.h b/include/driver.h index b4fae477a6..4f97b943c8 100644 --- a/include/driver.h +++ b/include/driver.h @@ -492,7 +492,7 @@ struct cdev *cdev_by_diskuuid(const char *partuuid); struct cdev *cdev_open_name(const char *name, unsigned long flags); struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset); void cdev_remove_loop(struct cdev *cdev); -int cdev_do_open(struct cdev *, unsigned long flags); +int cdev_open(struct cdev *, unsigned long flags); void cdev_close(struct cdev *cdev); int cdev_flush(struct cdev *cdev); ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags); -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2] Documentation: user: barebox: mention generic dt 2nd stage support
Am 7. Februar 2022 09:34:40 MEZ schrieb Sascha Hauer : >On Mon, Feb 07, 2022 at 09:14:51AM +0100, Ahmad Fatoum wrote: >> Hello Sascha, >> >> On 07.02.22 09:00, Sascha Hauer wrote: >> > On Sun, Feb 06, 2022 at 12:19:30AM +0100, Ahmad Fatoum wrote: >> >> Most users interested in chainloading barebox will probably want >to use >> >> the generic DT format for that: It will pass the checks the boot >command >> >> may have and it will ensure the system is in the correct state, >e.g. >> >> that caches are disabled. >> >> >example: >> >> + >> >> +.. code-block:: console >> >> + >> >> + U-Boot: tftp $kernel_addr barebox-dt-2nd.img >> >> + U-Boot: tftp $fdt_addr my-board.dtb >> >> + U-Boot: booti $kernel_addr - $fdt_addr >> >> + >> This is what the documentation is saying right now. It only appeared >> in the diff, because I rephrased the start a bit. I don't have a >> 32-bit ARM U-Boot here to test, so I'd rather not rewrite that part >> myself. > >Well you've introduced the part to use the bootm command yourself :) > >commit 3a14fb79153af84323fee8308989011cd05c7d96 >Author: Ahmad Fatoum >Date: Mon Jun 17 16:18:46 2019 +0200 > >However, I obviously failed to review this properly. I'll create a >patch >for that. > >Sascha In barebox "bootm flashable.img" works, in uboot it is booti with barebox-dt-2nd.img +fdt like example. I have a armhf bananapi r2 (mt7623),but it looks not supported by barebox regards Frank ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] state: add deep probe aware helpers to get state
On Wed, Feb 02, 2022 at 12:19:32PM +0100, Ahmad Fatoum wrote: > state_by_name itself can't be made deep probe aware as it doesn't have > enough information on what to probe. Board code calling it must instead > itself ensure that the state has been proved (either via initcall > ordering or by calling e.g. of_ensure_probed_by_alias). For > state_by_node we can do it better: We can ensure probe of the supplied > device node. For most purposes, users just want to probe the default > state. This can now be done with state_by_alias("state"). > > Signed-off-by: Ahmad Fatoum > --- > common/state/state.c | 20 +++- > include/state.h | 12 +--- > 2 files changed, 28 insertions(+), 4 deletions(-) Applied, thanks Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: blspec - autoboot + timeout/default
On Sat, Feb 05, 2022 at 03:58:54PM +0100, Frank Wunderlich wrote: > Hi, > > can i boot directly to blspec-menu (boot -m sd.1) with setting in > default env and boot a specific entry (by title/filename) after some > time (e.g.3-5 sec)? There is a -t option to the boot command. It seems however that there is no possibility to select a specfic entry beforehand. The first one would be booted. > > i have defined some blspec files in /mnt/sd.1/loader/entries/ and i > want to show the menu by default and after some time the entry from > specific file should be booted. this gives user the possibility to > modify this conf to define his kernel for autoboot in headless mode. > > i tried to modify defaultenv/nv/boot.default, but this needs filenames > in /env/boot, no commands and if i use a script, it cannot start the > "boot -m sd.1" because the /env/boot scripts run bootm (tried loading > barebox with such script - ended with putting a separate script in > /env/bin/) It should work by setting: nv boot.default=myboot With /env/boot/myboot: #!/bin/sh boot -m sd.1 -t 3 > > btw. is there a way to load environment from a txt file from a > specific partition (similar to uboots uEnv.txt)? The barebox environment is a directory tree rather than a list of variables, so there is no way to load a text file as environment. There is the loadenv command which takes the path to an environment image as argument. You can generate such an image on the host with the bareboxenv tool and then load it under barebox with loadenv. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] Documentation: Describe how to generate a uImage for use with bootm
U-Boot's bootm command doesn't take raw barebox images. Describe how to generate a uImage from them which then can be started with bootm. Signed-off-by: Sascha Hauer --- Documentation/user/barebox.rst | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/user/barebox.rst b/Documentation/user/barebox.rst index 4abcf79c6d..a890aa4dbe 100644 --- a/Documentation/user/barebox.rst +++ b/Documentation/user/barebox.rst @@ -217,7 +217,18 @@ like a Linux kernel that is passed an external device tree. For example: For non-DT enabled-bootloaders or other architectures, often the normal barebox binaries can also be used as they are designed to be startable second stage from another bootloader, where possible. For example, if you have U-Boot running -on your board, you can start barebox with U-Boot's ``bootm`` command: +on your board, you can start barebox with U-Boot's ``bootm`` command. The bootm +command doesn't support the barebox binaries directly, they first have to be +converted to uImage format using the mkimage tool provided with U-Boot: + +.. code-block:: console + sh: mkimage -n barebox -A arm -T kernel -C none -a 0x8000 -d \ + build/images/barebox-freescale-imx53-loco.img image + +U-Boot expects the start address of the binary to be given in the image using the +``-a`` option. The address depends on the board and must be an address which isn't +used by U-Boot. You can pick the same address you would use for generating a kernel +image for that board. The image can then be started with ``bootm``: .. code-block:: console -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2] Documentation: user: barebox: mention generic dt 2nd stage support
On 07.02.22 09:34, Sascha Hauer wrote: > On Mon, Feb 07, 2022 at 09:14:51AM +0100, Ahmad Fatoum wrote: >> Hello Sascha, >> >> On 07.02.22 09:00, Sascha Hauer wrote: >>> On Sun, Feb 06, 2022 at 12:19:30AM +0100, Ahmad Fatoum wrote: Most users interested in chainloading barebox will probably want to use the generic DT format for that: It will pass the checks the boot command may have and it will ensure the system is in the correct state, e.g. that caches are disabled. Signed-off-by: Ahmad Fatoum --- Documentation/user/barebox.rst | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/user/barebox.rst b/Documentation/user/barebox.rst index 8634d8e48eef..4abcf79c6d2a 100644 --- a/Documentation/user/barebox.rst +++ b/Documentation/user/barebox.rst @@ -203,9 +203,21 @@ Starting barebox Bringing barebox to a board for the first time is highly board specific, see your board documentation for initial bringup. -barebox binaries are, where possible, designed to be startable second stage from another -bootloader. For example, if you have U-Boot running on your board, you can start barebox -with U-Boot's ``bootm`` command: +For ARM and RISC-V, the barebox build can additionally generate a generic DT image +(enable ``CONFIG_BOARD_ARM_GENERIC_DT`` or ``CONFIG_BOARD_RISCV_GENERIC_DT``, +respectively). The resulting ``images/barebox-dt-2nd.img`` can be booted just +like a Linux kernel that is passed an external device tree. For example: + +.. code-block:: console + + U-Boot: tftp $kernel_addr barebox-dt-2nd.img + U-Boot: tftp $fdt_addr my-board.dtb + U-Boot: booti $kernel_addr - $fdt_addr + +For non-DT enabled-bootloaders or other architectures, often the normal barebox +binaries can also be used as they are designed to be startable second stage +from another bootloader, where possible. For example, if you have U-Boot running +on your board, you can start barebox with U-Boot's ``bootm`` command: >>> >>> Hm, that seems wrong. U-Boot's bootm command starts images generated >>> with U-Boot's mkimage tool. A raw barebox image cannot be started with >>> this command, one has to create a uImage from it before. >> >> This is what the documentation is saying right now. It only appeared >> in the diff, because I rephrased the start a bit. I don't have a >> 32-bit ARM U-Boot here to test, so I'd rather not rewrite that part >> myself. > > Well you've introduced the part to use the bootm command yourself :) > > commit 3a14fb79153af84323fee8308989011cd05c7d96 > Author: Ahmad Fatoum > Date: Mon Jun 17 16:18:46 2019 +0200 > > However, I obviously failed to review this properly. I'll create a patch > for that. Aua :D > > Sascha > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2 1/5] test: self: printf: log skipped tests
On Mon, Feb 07, 2022 at 09:27:57AM +0100, Ahmad Fatoum wrote: > Report number of skipped tests as well as skip reason. > > Signed-off-by: Ahmad Fatoum > --- > v1 -> v2: > - reword commit message to be more accurate. > --- > test/self/printf.c | 10 -- > 1 file changed, 8 insertions(+), 2 deletions(-) Applied, thanks Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2] Documentation: user: barebox: mention generic dt 2nd stage support
On Mon, Feb 07, 2022 at 09:14:51AM +0100, Ahmad Fatoum wrote: > Hello Sascha, > > On 07.02.22 09:00, Sascha Hauer wrote: > > On Sun, Feb 06, 2022 at 12:19:30AM +0100, Ahmad Fatoum wrote: > >> Most users interested in chainloading barebox will probably want to use > >> the generic DT format for that: It will pass the checks the boot command > >> may have and it will ensure the system is in the correct state, e.g. > >> that caches are disabled. > >> > >> Signed-off-by: Ahmad Fatoum > >> --- > >> Documentation/user/barebox.rst | 18 +++--- > >> 1 file changed, 15 insertions(+), 3 deletions(-) > >> > >> diff --git a/Documentation/user/barebox.rst > >> b/Documentation/user/barebox.rst > >> index 8634d8e48eef..4abcf79c6d2a 100644 > >> --- a/Documentation/user/barebox.rst > >> +++ b/Documentation/user/barebox.rst > >> @@ -203,9 +203,21 @@ Starting barebox > >> Bringing barebox to a board for the first time is highly board specific, > >> see your > >> board documentation for initial bringup. > >> > >> -barebox binaries are, where possible, designed to be startable second > >> stage from another > >> -bootloader. For example, if you have U-Boot running on your board, you > >> can start barebox > >> -with U-Boot's ``bootm`` command: > >> +For ARM and RISC-V, the barebox build can additionally generate a generic > >> DT image > >> +(enable ``CONFIG_BOARD_ARM_GENERIC_DT`` or > >> ``CONFIG_BOARD_RISCV_GENERIC_DT``, > >> +respectively). The resulting ``images/barebox-dt-2nd.img`` can be booted > >> just > >> +like a Linux kernel that is passed an external device tree. For example: > >> + > >> +.. code-block:: console > >> + > >> + U-Boot: tftp $kernel_addr barebox-dt-2nd.img > >> + U-Boot: tftp $fdt_addr my-board.dtb > >> + U-Boot: booti $kernel_addr - $fdt_addr > >> + > >> +For non-DT enabled-bootloaders or other architectures, often the normal > >> barebox > >> +binaries can also be used as they are designed to be startable second > >> stage > >> +from another bootloader, where possible. For example, if you have U-Boot > >> running > >> +on your board, you can start barebox with U-Boot's ``bootm`` command: > > > > Hm, that seems wrong. U-Boot's bootm command starts images generated > > with U-Boot's mkimage tool. A raw barebox image cannot be started with > > this command, one has to create a uImage from it before. > > This is what the documentation is saying right now. It only appeared > in the diff, because I rephrased the start a bit. I don't have a > 32-bit ARM U-Boot here to test, so I'd rather not rewrite that part > myself. Well you've introduced the part to use the bootm command yourself :) commit 3a14fb79153af84323fee8308989011cd05c7d96 Author: Ahmad Fatoum Date: Mon Jun 17 16:18:46 2019 +0200 However, I obviously failed to review this properly. I'll create a patch for that. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v2 5/5] test: self: add device tree manipulation test
We had recently gained support for two extra helpers: of_property_sprintf and of_property_write_strings. Add tests for them as well as for general OF creation and unflattening. Signed-off-by: Ahmad Fatoum --- v1 -> v2: - s/of_property_write_string/of_property_write_strings/ in commit message --- test/self/Kconfig | 6 ++ test/self/Makefile| 1 + test/self/of_manipulation.c | 111 ++ test/self/of_manipulation.dts | 30 + 4 files changed, 148 insertions(+) create mode 100644 test/self/of_manipulation.c create mode 100644 test/self/of_manipulation.dts diff --git a/test/self/Kconfig b/test/self/Kconfig index dfaa32dda009..3340a9146ee2 100644 --- a/test/self/Kconfig +++ b/test/self/Kconfig @@ -37,6 +37,12 @@ config SELFTEST_PRINTF help Tests barebox vsnprintf() functionality +config SELFTEST_OF_MANIPULATION + bool "OF manipulation selftest" + select OFTREE + help + Tests barebox device tree manipulation functionality + config SELFTEST_PROGRESS_NOTIFIER bool "progress notifier selftest" diff --git a/test/self/Makefile b/test/self/Makefile index e78ccc3cfb90..05a2a6a236ec 100644 --- a/test/self/Makefile +++ b/test/self/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_SELFTEST) += core.o obj-$(CONFIG_SELFTEST_PRINTF) += printf.o obj-$(CONFIG_SELFTEST_PROGRESS_NOTIFIER) += progress-notifier.o +obj-$(CONFIG_SELFTEST_OF_MANIPULATION) += of_manipulation.o of_manipulation.dtb.o diff --git a/test/self/of_manipulation.c b/test/self/of_manipulation.c new file mode 100644 index ..1bcd593c8628 --- /dev/null +++ b/test/self/of_manipulation.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BSELFTEST_GLOBALS(); + +static void assert_different(struct device_node *a, struct device_node *b, int expect) +{ + int ret; + + total_tests++; + + ret = of_diff(a, b, -1); + if (ret == expect) + return; + + pr_warn("comparison of %s and %s failed: %u differences expected, %u found.\n", + a->full_name, b->full_name, expect, ret); + of_diff(a, b, 1); + failed_tests++; +} + +#define assert_equal(a, b) assert_different(a, b, 0) + +static void test_of_basics(struct device_node *root) +{ + struct device_node *node1, *node2, *node21; + + node1 = of_new_node(root, "node1"); + node2 = of_new_node(root, "node2"); + + assert_equal(node1, node2); + + of_property_write_bool(node2, "property1", true); + + assert_different(node1, node2, 1); + + node21 = of_new_node(node2, "node21"); + + assert_different(node1, node2, 2); + assert_equal(node1, node21); + + of_new_node(node1, "node21"); + + assert_different(node1, node2, 1); + + of_property_write_bool(node1, "property1", true); + + assert_equal(node1, node2); +} + +static void test_of_property_strings(struct device_node *root) +{ + struct device_node *np1, *np2, *np3; + char properties[] = "ayy\0bee\0sea"; + + np1 = of_new_node(root, "np1"); + np2 = of_new_node(root, "np2"); + np3 = of_new_node(root, "np3"); + + of_property_sprintf(np1, "property-single", "%c%c%c", 'a', 'y', 'y'); + + of_property_write_string(np2, "property-single", "ayy"); + + assert_equal(np1, np2); + + of_set_property(np2, "property-multi", properties, sizeof(properties), 1); + + of_property_write_strings(np3, "property-single", "ayy", NULL); + of_property_write_strings(np3, "property-multi", + "ayy", "bee", "sea", NULL); + + assert_equal(np2, np3); + + of_set_property(np1, "property-multi", properties, sizeof(properties), 1); + + assert_equal(np1, np2); + + of_set_property(np1, "property-multi", properties, sizeof(properties) - 1, 0); + + assert_different(np1, np2, 1); +} + +static void __init test_of_manipulation(void) +{ + extern char __dtb_of_manipulation_start[], __dtb_of_manipulation_end[]; + struct device_node *root = of_new_node(NULL, NULL); + struct device_node *expected; + + test_of_basics(root); + test_of_property_strings(root); + + expected = of_unflatten_dtb(__dtb_of_manipulation_start, + __dtb_of_manipulation_end - __dtb_of_manipulation_start); + + assert_equal(root, expected); + + of_delete_node(root); + of_delete_node(expected); +} +bselftest(core, test_of_manipulation); diff --git a/test/self/of_manipulation.dts b/test/self/of_manipulation.dts new file mode 100644 index ..3b690bb7f0fe --- /dev/null +++ b/test/self/of_manipulation.dts @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/dts-v1/; + +/ { + node1 { +
[PATCH v2 3/5] of: report whether of_diff found differences in return code
Tests may want to leverage of_diff to verify that fixups proceeded as expected. of_diff lends itself nicely to that by being silent in case of success and just reporting diff on error. Add a return code to make it usable in follow-up tests. Signed-off-by: Ahmad Fatoum --- v1 -> v2: - invert of_diff command error code (success on match, error on diff) --- commands/of_diff.c | 4 +--- drivers/of/base.c | 13 ++--- include/of.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/commands/of_diff.c b/commands/of_diff.c index fa99fcd641da..6a78263200d7 100644 --- a/commands/of_diff.c +++ b/commands/of_diff.c @@ -77,9 +77,7 @@ static int do_of_diff(int argc, char *argv[]) goto out; } - of_diff(a, b, 0); - - ret = 0; + ret = of_diff(a, b, 0) ? COMMAND_ERROR : COMMAND_SUCCESS; out: if (a && a != root) of_delete_node(a); diff --git a/drivers/of/base.c b/drivers/of/base.c index 80465d6d5062..99be24254203 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2077,15 +2077,16 @@ static void of_print_close(struct device_node *node, int *printed) * This function compares two device trees against each other and prints * a diff-like result. */ -void of_diff(struct device_node *a, struct device_node *b, int indent) +int of_diff(struct device_node *a, struct device_node *b, int indent) { struct property *ap, *bp; struct device_node *ca, *cb; - int printed = 0; + int printed = 0, diff = 0; list_for_each_entry(ap, >properties, list) { bp = of_find_property(b, ap->name, NULL); if (!bp) { + diff++; of_print_parents(a, ); printf("- "); __of_print_property(ap, indent); @@ -2093,6 +2094,7 @@ void of_diff(struct device_node *a, struct device_node *b, int indent) } if (ap->length != bp->length || memcmp(of_property_get_value(ap), of_property_get_value(bp), bp->length)) { + diff++; of_print_parents(a, ); printf("- "); __of_print_property(ap, indent); @@ -2104,6 +2106,7 @@ void of_diff(struct device_node *a, struct device_node *b, int indent) list_for_each_entry(bp, >properties, list) { ap = of_find_property(a, bp->name, NULL); if (!ap) { + diff++; of_print_parents(a, ); printf("+ "); __of_print_property(bp, indent); @@ -2113,8 +2116,9 @@ void of_diff(struct device_node *a, struct device_node *b, int indent) for_each_child_of_node(a, ca) { cb = of_get_child_by_name(b, ca->name); if (cb) { - of_diff(ca, cb, indent + 1); + diff += of_diff(ca, cb, indent + 1); } else { + diff++; of_print_parents(a, ); __of_print_nodes(ca, indent, "- "); } @@ -2122,12 +2126,15 @@ void of_diff(struct device_node *a, struct device_node *b, int indent) for_each_child_of_node(b, cb) { if (!of_get_child_by_name(a, cb->name)) { + diff++; of_print_parents(a, ); __of_print_nodes(cb, indent, "+ "); } } of_print_close(a, ); + + return diff; } struct device_node *of_new_node(struct device_node *parent, const char *name) diff --git a/include/of.h b/include/of.h index 216d0ee76368..b449d10ec774 100644 --- a/include/of.h +++ b/include/of.h @@ -107,7 +107,7 @@ void of_print_cmdline(struct device_node *root); void of_print_nodes(struct device_node *node, int indent); void of_print_properties(struct device_node *node); -void of_diff(struct device_node *a, struct device_node *b, int indent); +int of_diff(struct device_node *a, struct device_node *b, int indent); int of_probe(void); int of_parse_dtb(struct fdt_header *fdt); struct device_node *of_unflatten_dtb(const void *fdt, int size); -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v2 4/5] of: silence of_diff output for negative indents
Negative indents just led to strange behavior so far. Repurpose them to mean that the caller is not interested in console output. This makes them useful for negative tests (Sanity check that two different nodes are indeed different). Signed-off-by: Ahmad Fatoum --- v1 -> v2: - use silent variable instead of opencoding indent < 0 (Sascha) --- drivers/of/base.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 99be24254203..51984d7d8f61 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2082,11 +2082,14 @@ int of_diff(struct device_node *a, struct device_node *b, int indent) struct property *ap, *bp; struct device_node *ca, *cb; int printed = 0, diff = 0; + bool silent = indent < 0; list_for_each_entry(ap, >properties, list) { bp = of_find_property(b, ap->name, NULL); if (!bp) { diff++; + if (silent) + continue; of_print_parents(a, ); printf("- "); __of_print_property(ap, indent); @@ -2095,6 +2098,8 @@ int of_diff(struct device_node *a, struct device_node *b, int indent) if (ap->length != bp->length || memcmp(of_property_get_value(ap), of_property_get_value(bp), bp->length)) { diff++; + if (silent) + continue; of_print_parents(a, ); printf("- "); __of_print_property(ap, indent); @@ -2107,6 +2112,8 @@ int of_diff(struct device_node *a, struct device_node *b, int indent) ap = of_find_property(a, bp->name, NULL); if (!ap) { diff++; + if (silent) + continue; of_print_parents(a, ); printf("+ "); __of_print_property(bp, indent); @@ -2116,9 +2123,11 @@ int of_diff(struct device_node *a, struct device_node *b, int indent) for_each_child_of_node(a, ca) { cb = of_get_child_by_name(b, ca->name); if (cb) { - diff += of_diff(ca, cb, indent + 1); + diff += of_diff(ca, cb, silent ? indent : indent + 1); } else { diff++; + if (silent) + continue; of_print_parents(a, ); __of_print_nodes(ca, indent, "- "); } @@ -2127,12 +2136,15 @@ int of_diff(struct device_node *a, struct device_node *b, int indent) for_each_child_of_node(b, cb) { if (!of_get_child_by_name(a, cb->name)) { diff++; + if (silent) + continue; of_print_parents(a, ); __of_print_nodes(cb, indent, "+ "); } } - of_print_close(a, ); + if (!silent) + of_print_close(a, ); return diff; } -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v2 1/5] test: self: printf: log skipped tests
Report number of skipped tests as well as skip reason. Signed-off-by: Ahmad Fatoum --- v1 -> v2: - reword commit message to be more accurate. --- test/self/printf.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/self/printf.c b/test/self/printf.c index 52fe6ac0faf9..ec74df32ee4b 100644 --- a/test/self/printf.c +++ b/test/self/printf.c @@ -247,8 +247,11 @@ uuid(void) const char uuid[16] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; - if (!IS_ENABLED(CONFIG_PRINTF_UUID)) + if (!IS_ENABLED(CONFIG_PRINTF_UUID)) { + pr_info("skipping UUID tests: disabled in config\n"); + skipped_tests += 4; return; + } test("00010203-0405-0607-0809-0a0b0c0d0e0f", "%pUb", uuid); test("00010203-0405-0607-0809-0A0B0C0D0E0F", "%pUB", uuid); @@ -265,8 +268,11 @@ errptr(void) /* Check that %pe with a non-ERR_PTR gets treated as ordinary %p. */ BUILD_BUG_ON(IS_ERR(PTR)); - if (!IS_ENABLED(CONFIG_ERRNO_MESSAGES)) + if (!IS_ENABLED(CONFIG_ERRNO_MESSAGES)) { + pr_info("skipping errno messages tests: disabled in config\n"); + skipped_tests += 2; return; + } test("(Operation not permitted)", "(%pe)", ERR_PTR(-EPERM)); test("Requested probe deferral", "%pe", ERR_PTR(-EPROBE_DEFER)); } -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v2 2/5] test: self: printf: add tests for %*ph prints
This modifier was recently added. Turn the description from its commit message into a test. Signed-off-by: Ahmad Fatoum --- test/self/printf.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/test/self/printf.c b/test/self/printf.c index ec74df32ee4b..7a74660868c2 100644 --- a/test/self/printf.c +++ b/test/self/printf.c @@ -277,6 +277,23 @@ errptr(void) test("Requested probe deferral", "%pe", ERR_PTR(-EPROBE_DEFER)); } +static void __init +test_hexstr(void) +{ + u8 buf[4] = { 0, 1, 2, 3 }; + + if (!IS_ENABLED(CONFIG_PRINTF_HEXSTR)) { + pr_info("skipping hexstr tests: disabled in config\n"); + skipped_tests += 4; + return; + } + + test("[00 01 02 03]", "[%*ph]", (int)sizeof(buf), buf); + test("[00:01:02:03]", "[%*phC]", (int)sizeof(buf), buf); + test("[00-01-02-03]", "[%*phD]", (int)sizeof(buf), buf); + test("[00010203]","[%*phN]", (int)sizeof(buf), buf); +} + static void __init test_pointer(void) { @@ -299,6 +316,7 @@ static void __init test_printf(void) test_number(); test_string(); test_pointer(); + test_hexstr(); free(alloced_buffer); } -- 2.30.2 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/5] of: silence of_diff output for negative indents
On 07.02.22 09:22, Sascha Hauer wrote: > On Mon, Feb 07, 2022 at 09:17:30AM +0100, Sascha Hauer wrote: >> On Mon, Feb 07, 2022 at 08:56:20AM +0100, Ahmad Fatoum wrote: >>> Negative indents just led to strange behavior so far. Repurpose them to >>> mean that the caller is not interested in console output. This makes >>> them useful for negative tests (Sanity check that two different nodes >>> are indeed different). >>> >>> Signed-off-by: Ahmad Fatoum >>> --- >>> drivers/of/base.c | 15 +-- >>> 1 file changed, 13 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/of/base.c b/drivers/of/base.c >>> index 99be24254203..ffa79785f80e 100644 >>> --- a/drivers/of/base.c >>> +++ b/drivers/of/base.c >>> @@ -2087,6 +2087,8 @@ int of_diff(struct device_node *a, struct device_node >>> *b, int indent) >> >> Can we add a >> >> bool do_print = indent >= 0; >> >> variable and use it for the tests below? I think this makes the code a >> bit clearer. > > Changed while applying, so when you agree with this we are good to go. I'd have called it silent to avoid having negative conditions. I did the change locally as well as fixed two typos. I will send a v2. > > Sascha > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/5] of: silence of_diff output for negative indents
On Mon, Feb 07, 2022 at 09:17:30AM +0100, Sascha Hauer wrote: > On Mon, Feb 07, 2022 at 08:56:20AM +0100, Ahmad Fatoum wrote: > > Negative indents just led to strange behavior so far. Repurpose them to > > mean that the caller is not interested in console output. This makes > > them useful for negative tests (Sanity check that two different nodes > > are indeed different). > > > > Signed-off-by: Ahmad Fatoum > > --- > > drivers/of/base.c | 15 +-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/of/base.c b/drivers/of/base.c > > index 99be24254203..ffa79785f80e 100644 > > --- a/drivers/of/base.c > > +++ b/drivers/of/base.c > > @@ -2087,6 +2087,8 @@ int of_diff(struct device_node *a, struct device_node > > *b, int indent) > > Can we add a > > bool do_print = indent >= 0; > > variable and use it for the tests below? I think this makes the code a > bit clearer. Changed while applying, so when you agree with this we are good to go. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/5] of: silence of_diff output for negative indents
On Mon, Feb 07, 2022 at 08:56:20AM +0100, Ahmad Fatoum wrote: > Negative indents just led to strange behavior so far. Repurpose them to > mean that the caller is not interested in console output. This makes > them useful for negative tests (Sanity check that two different nodes > are indeed different). > > Signed-off-by: Ahmad Fatoum > --- > drivers/of/base.c | 15 +-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index 99be24254203..ffa79785f80e 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2087,6 +2087,8 @@ int of_diff(struct device_node *a, struct device_node > *b, int indent) Can we add a bool do_print = indent >= 0; variable and use it for the tests below? I think this makes the code a bit clearer. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2] Documentation: user: barebox: mention generic dt 2nd stage support
Hello Sascha, On 07.02.22 09:00, Sascha Hauer wrote: > On Sun, Feb 06, 2022 at 12:19:30AM +0100, Ahmad Fatoum wrote: >> Most users interested in chainloading barebox will probably want to use >> the generic DT format for that: It will pass the checks the boot command >> may have and it will ensure the system is in the correct state, e.g. >> that caches are disabled. >> >> Signed-off-by: Ahmad Fatoum >> --- >> Documentation/user/barebox.rst | 18 +++--- >> 1 file changed, 15 insertions(+), 3 deletions(-) >> >> diff --git a/Documentation/user/barebox.rst b/Documentation/user/barebox.rst >> index 8634d8e48eef..4abcf79c6d2a 100644 >> --- a/Documentation/user/barebox.rst >> +++ b/Documentation/user/barebox.rst >> @@ -203,9 +203,21 @@ Starting barebox >> Bringing barebox to a board for the first time is highly board specific, >> see your >> board documentation for initial bringup. >> >> -barebox binaries are, where possible, designed to be startable second stage >> from another >> -bootloader. For example, if you have U-Boot running on your board, you can >> start barebox >> -with U-Boot's ``bootm`` command: >> +For ARM and RISC-V, the barebox build can additionally generate a generic >> DT image >> +(enable ``CONFIG_BOARD_ARM_GENERIC_DT`` or >> ``CONFIG_BOARD_RISCV_GENERIC_DT``, >> +respectively). The resulting ``images/barebox-dt-2nd.img`` can be booted >> just >> +like a Linux kernel that is passed an external device tree. For example: >> + >> +.. code-block:: console >> + >> + U-Boot: tftp $kernel_addr barebox-dt-2nd.img >> + U-Boot: tftp $fdt_addr my-board.dtb >> + U-Boot: booti $kernel_addr - $fdt_addr >> + >> +For non-DT enabled-bootloaders or other architectures, often the normal >> barebox >> +binaries can also be used as they are designed to be startable second stage >> +from another bootloader, where possible. For example, if you have U-Boot >> running >> +on your board, you can start barebox with U-Boot's ``bootm`` command: > > Hm, that seems wrong. U-Boot's bootm command starts images generated > with U-Boot's mkimage tool. A raw barebox image cannot be started with > this command, one has to create a uImage from it before. This is what the documentation is saying right now. It only appeared in the diff, because I rephrased the start a bit. I don't have a 32-bit ARM U-Boot here to test, so I'd rather not rewrite that part myself. Cheers, Ahmad > > Sascha > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] mtd: mtdram: discard superfluous code
On Mon, Feb 07, 2022 at 08:56:29AM +0100, Ahmad Fatoum wrote: > We don't need to get the exact same resource, we just requested. > > Signed-off-by: Ahmad Fatoum > --- > drivers/mtd/devices/mtdram.c | 13 ++--- > 1 file changed, 2 insertions(+), 11 deletions(-) Applied, thanks Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] sandbox: symlink stickypage.bin into build directory
On Mon, Feb 07, 2022 at 08:56:03AM +0100, Ahmad Fatoum wrote: > Sandbox will try to access a stickypage.bin in the same directory if > possible. Instead of relying on users to copy it there, just create a > symlink. > > Signed-off-by: Ahmad Fatoum > --- > .gitignore| 1 + > arch/sandbox/Makefile | 6 ++ > 2 files changed, 7 insertions(+) Applied, thanks Sascha > > diff --git a/.gitignore b/.gitignore > index d551a610d4c0..0382202bf716 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -90,3 +90,4 @@ GTAGS > /allrandom.config > /allyes.config > /compile_commands.json > +/stickypage.bin > diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile > index 2cf51fa34917..aee6bccc9c14 100644 > --- a/arch/sandbox/Makefile > +++ b/arch/sandbox/Makefile > @@ -74,6 +74,12 @@ cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS) > > common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/ > > +stickypage.bin: > + @$(kecho) " LN stickypage.bin" > + @ln -fs arch/sandbox/board/stickypage.bin stickypage.bin > + > +KBUILD_IMAGE := barebox stickypage.bin > + > common-$(CONFIG_OFTREE) += arch/sandbox/dts/ > > CLEAN_FILES += $(BOARD)/barebox.lds > -- > 2.30.2 > > > ___ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] Kbuild: add bareboxversion target to Makefile
On Sun, Feb 06, 2022 at 04:07:16PM +0100, Frank Wunderlich wrote: > From: Frank Wunderlich > > This allows getting version string with make bareboxversion > like for linux and uboot. > > Signed-off-by: Frank Wunderlich > --- > Makefile | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) Applied, thanks Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3 0/6] refactore rpi board code
On Thu, Feb 03, 2022 at 11:45:46AM +0100, Oleksij Rempel wrote: > changes v3: > - make bcm2835 mbox to probe on first request solve dependency issue. > - remove phybases from clk driver > - move deep-probe to the separate patch > > changes v2: > - rework clk driver to properly support deep-probe > - remove currently not supported compatibles from board code > - reduce struct size > - rework rpi_get_dcfg to return *dcfg directly > > Oleksij Rempel (6): > ARM: rpi: convert board code to a driver > ARM: bcm2835 mbox: drop driver mode and probe on first request > ARM: rpi: move clk support to a separate driver > ARM: rpi: validate devicetree compatible instead of changing model > name > ARM: rpi: set host name based on DT compatible > ARM: rpi: enable deep-probe support Applied, thanks Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2] Documentation: user: barebox: mention generic dt 2nd stage support
On Sun, Feb 06, 2022 at 12:19:30AM +0100, Ahmad Fatoum wrote: > Most users interested in chainloading barebox will probably want to use > the generic DT format for that: It will pass the checks the boot command > may have and it will ensure the system is in the correct state, e.g. > that caches are disabled. > > Signed-off-by: Ahmad Fatoum > --- > Documentation/user/barebox.rst | 18 +++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/Documentation/user/barebox.rst b/Documentation/user/barebox.rst > index 8634d8e48eef..4abcf79c6d2a 100644 > --- a/Documentation/user/barebox.rst > +++ b/Documentation/user/barebox.rst > @@ -203,9 +203,21 @@ Starting barebox > Bringing barebox to a board for the first time is highly board specific, see > your > board documentation for initial bringup. > > -barebox binaries are, where possible, designed to be startable second stage > from another > -bootloader. For example, if you have U-Boot running on your board, you can > start barebox > -with U-Boot's ``bootm`` command: > +For ARM and RISC-V, the barebox build can additionally generate a generic DT > image > +(enable ``CONFIG_BOARD_ARM_GENERIC_DT`` or ``CONFIG_BOARD_RISCV_GENERIC_DT``, > +respectively). The resulting ``images/barebox-dt-2nd.img`` can be booted just > +like a Linux kernel that is passed an external device tree. For example: > + > +.. code-block:: console > + > + U-Boot: tftp $kernel_addr barebox-dt-2nd.img > + U-Boot: tftp $fdt_addr my-board.dtb > + U-Boot: booti $kernel_addr - $fdt_addr > + > +For non-DT enabled-bootloaders or other architectures, often the normal > barebox > +binaries can also be used as they are designed to be startable second stage > +from another bootloader, where possible. For example, if you have U-Boot > running > +on your board, you can start barebox with U-Boot's ``bootm`` command: Hm, that seems wrong. U-Boot's bootm command starts images generated with U-Boot's mkimage tool. A raw barebox image cannot be started with this command, one has to create a uImage from it before. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox