Re: Issue with mmc_power_on() and reference counter of regulator
Hi, Thank you for the quick response. On Sat, Sep 2, 2023 at 10:45 PM Jonas Karlman wrote: > > Hi, > > On 2023-09-02 13:35, Kenta Sato wrote: > > Hi, > > > > I am using the FriendlyElec NanoPi R4S board. > > When I updated U-Boot to a recent version (0fe0395922), it failed to > > boot from MMC. Here is the log: > > > > > > U-Boot TPL 2023.10-rc3 (Sep 02 2023 - 08:21:08) > > lpddr4_set_rate: change freq to 400MHz 0, 1 > > Channel 0: LPDDR4, 400MHz > > BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB > > Channel 1: LPDDR4, 400MHz > > BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB > > 256B stride > > lpddr4_set_rate: change freq to 800MHz 1, 0 > > Trying to boot from BOOTROM > > Returning to boot ROM... > > > > U-Boot SPL 2023.10-rc3 (Sep 02 2023 - 08:21:08 +) > > Trying to boot from MMC1 > > spl_load_fit_image: Skip load 'atf-5': image size is 0! > > NOTICE: BL31: v2.9(release): > > NOTICE: BL31: Built : 08:19:59, Sep 2 2023 > > > > > > U-Boot 2023.10-rc3 (Sep 02 2023 - 08:21:08 +) > > > > SoC: Rockchip rk3399 > > Reset cause: POR > > Model: FriendlyElec NanoPi R4S > > DRAM: 4 GiB (effective 3.9 GiB) > > PMIC: RK808 > > Core: 264 devices, 23 uclasses, devicetree: separate > > MMC: mmc@fe32: 1 > > Loading Environment from nowhere... OK > > In:serial,usbkbd > > Out: serial,vidconsole > > Err: serial,vidconsole > > Model: FriendlyElec NanoPi R4S > > Net: > > Error: ethernet@fe30 address not set. > > No ethernet found. > > > > Hit any key to stop autoboot: 0 > > Error enabling VMMC supply : -114 > > Error enabling VMMC supply : -114 > > Error enabling VMMC supply : -114 > > Error enabling VMMC supply : -114 > > Error enabling VMMC supply : -114 > > Error enabling VMMC supply : -114 > > > > > > Does anyone know how to fix the issue? > > > > I looked into commit logs and the mailing list so far, and I found the > > below commit that adds the reference counter to the regulator. I could > > remove the above error by reverting this change. Of course, it should > > not be the proper way. > > Maybe we could replace regulator_set_enable() in mmc_power_on() by > > regulator_set_enable_if_allowed(). However, I have no confidence about > > it as I'm not familiar with the U-Boot source code. > > I sent patches to fix such situation back in July, see [1]. Those > patches was merged into next, but should probably have gone into master. > > Please try next, and/or apply patches at [1] and report back result. > > [1] https://patchwork.ozlabs.org/project/uboot/list/?series=364753&state=* I tried the next branch. The issue seems to be solved. U-Boot TPL 2023.10-rc3 (Sep 02 2023 - 22:00:13) lpddr4_set_rate: change freq to 400MHz 0, 1 Channel 0: LPDDR4, 400MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: LPDDR4, 400MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride lpddr4_set_rate: change freq to 800MHz 1, 0 Trying to boot from BOOTROM Returning to boot ROM... U-Boot SPL 2023.10-rc3 (Sep 02 2023 - 22:00:13 +) Trying to boot from MMC1 spl_load_fit_image: Skip load 'atf-5': image size is 0! NOTICE: BL31: v2.9(release): NOTICE: BL31: Built : 22:00:05, Sep 2 2023 U-Boot 2023.10-rc3 (Sep 02 2023 - 22:00:13 +) SoC: Rockchip rk3399 Reset cause: POR Model: FriendlyElec NanoPi R4S DRAM: 4 GiB (effective 3.9 GiB) PMIC: RK808 Core: 264 devices, 23 uclasses, devicetree: separate MMC: mmc@fe32: 1 Loading Environment from nowhere... OK In:serial,usbkbd Out: serial,vidconsole Err: serial,vidconsole Model: FriendlyElec NanoPi R4S Net: Error: ethernet@fe30 address not set. No ethernet found. Hit any key to stop autoboot: 0 ** Booting bootflow 'mmc@fe32.bootdev.part_1' with extlinux 1: Arch Linux Retrieving file: /vmlinuz-linux-nanopi-r4s Retrieving file: /initramfs-linux-nanopi-r4s.img (...) I hope those patches will be in the master and the next release soon. Thank you! Kenta > > Regards, > Jonas > > > > > > > commit 4fcba5d556b4224ad65a249801e4c9594d1054e8 > > Author: Eugen Hristev > > Date: Wed Apr 19 16:45:24 2023 +0300 > > > > regulator: implement basic reference counter > > > > Some devices share a regulator supply, when the first one will request > > regulator disable, the second device will have it's supply cut off > > before > > graciously shutting down. Hence there will be timeouts and other failed > > operations. > > Implement a reference counter mechanism similar with what is done in > > Linux, to keep track of enable and disable requests, and only disable > > the > > regulator when the last of the consumers has requested shutdown. > > > > Signed-off-by: Eugen Hristev > > Reviewed-by: Simon Glass > > Reviewed-by: Patrice Chotard > >
[PATCH 2/2] configs: rockchip: add DOS_PARTITION to RK3308 boards defconfig
Without DOS_PARTITION support U-Boot is not able to boot an OS stored into an SD card with MBR partitions table. This is still a quite common case, so add DOS_PARTITION (only for U-Boot proper build) to Rockchip RK3308 EVB and Firefly roc-rk3308-cc board: they are the only RK boards missing of DOS_PARTITION. Signed-off-by: Massimo Pegorer --- configs/evb-rk3308_defconfig| 2 +- configs/roc-cc-rk3308_defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/evb-rk3308_defconfig b/configs/evb-rk3308_defconfig index a13a809c1e..c6472a2c9c 100644 --- a/configs/evb-rk3308_defconfig +++ b/configs/evb-rk3308_defconfig @@ -47,7 +47,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_ITEST is not set # CONFIG_CMD_SETEXPR is not set # CONFIG_CMD_SLEEP is not set -# CONFIG_DOS_PARTITION is not set +# CONFIG_SPL_DOS_PARTITION is not set # CONFIG_ISO_PARTITION is not set CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=64 CONFIG_SPL_OF_CONTROL=y diff --git a/configs/roc-cc-rk3308_defconfig b/configs/roc-cc-rk3308_defconfig index 9a789b212f..ca92b8f744 100644 --- a/configs/roc-cc-rk3308_defconfig +++ b/configs/roc-cc-rk3308_defconfig @@ -47,7 +47,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_ITEST is not set # CONFIG_CMD_SETEXPR is not set # CONFIG_CMD_SLEEP is not set -# CONFIG_DOS_PARTITION is not set +# CONFIG_SPL_DOS_PARTITION is not set # CONFIG_ISO_PARTITION is not set CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=64 CONFIG_SPL_OF_CONTROL=y -- 2.34.1
[PATCH 1/2] configs: rockchip: add DOS_PARTITION to rock-pi-s defconfig
Without DOS_PARTITION support U-Boot is not able to boot an OS stored into an SD card with MBR partitions table. This is still a quite common case so add DOS_PARTITION (only for U-Boot proper build) to ROCK Pi S defconfig. Reported-by: Jayantajit Gogoi Signed-off-by: Massimo Pegorer --- configs/rock-pi-s-rk3308_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/rock-pi-s-rk3308_defconfig b/configs/rock-pi-s-rk3308_defconfig index cc3274a98b..1c1fdc6611 100644 --- a/configs/rock-pi-s-rk3308_defconfig +++ b/configs/rock-pi-s-rk3308_defconfig @@ -48,7 +48,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_ITEST is not set # CONFIG_CMD_SETEXPR is not set # CONFIG_CMD_SLEEP is not set -# CONFIG_DOS_PARTITION is not set +# CONFIG_SPL_DOS_PARTITION is not set # CONFIG_ISO_PARTITION is not set CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=64 CONFIG_SPL_OF_CONTROL=y -- 2.34.1
[PATCH 2/2] doc: rockchip: Update and complete info about RK3308
Update documentation about build steps for RK3308, using an external TPL. Add RK3308 case to rST document. Add ROCK Pi S in the list of supported boards. Signed-off-by: Massimo Pegorer --- doc/README.rockchip | 4 ++-- doc/board/rockchip/rockchip.rst | 10 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/README.rockchip b/doc/README.rockchip index 52b5140eca..cfbd858c3b 100644 --- a/doc/README.rockchip +++ b/doc/README.rockchip @@ -38,16 +38,16 @@ Building (or you can use another cross compiler if you prefer) 2. To build RK3308 board: + - Get the rkbin => git clone https://github.com/rockchip-linux/rkbin.git - Compile U-Boot => cd /path/to/u-boot => export BL31=/path/to/rkbin/bin/rk33/rk3308_bl31_v2.22.elf + => export ROCKCHIP_TPL=/path/to/rkbin/bin/rk33/rk3308_ddr_589MHz_uart2_m0_v1.26.bin => make roc-cc-rk3308_defconfig => make CROSS_COMPILE=aarch64-linux-gnu- all - => ./tools/mkimage -n rk3308 -T rksd -d /path/to/rkbin/bin/rk33/rk3308_ddr_589MHz_uart2_m0_v1.26.bin idbloader.img - => cat spl/u-boot-spl.bin >> idbloader.img 3. To build RK3399 board: diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst index de9fe8e642..b38c3d3136 100644 --- a/doc/board/rockchip/rockchip.rst +++ b/doc/board/rockchip/rockchip.rst @@ -53,6 +53,7 @@ List of mainline supported Rockchip boards: - Google Speedy (chromebook_speedy) - Amarula Vyasa-RK3288 (vyasa-rk3288) * rk3308 + - Radxa ROCK Pi S (rock-pi-s-rk3308) - Rockchip Evb-RK3308 (evb-rk3308) - Roc-cc-RK3308 (roc-cc-rk3308) * rk3326 @@ -172,6 +173,15 @@ To build rk3288 boards: make evb-rk3288_defconfig make CROSS_COMPILE=arm-linux-gnueabihf- +To build rk3308 boards: + +.. code-block:: bash + +export BL31=../rkbin/bin/rk33/rk3308_bl31_vX.YZ.elf +export ROCKCHIP_TPL=../rkbin/bin/rk33/rk3308_ddr_589MHz_uart0_m0_vX.YZ.bin +make evb-rk3308_defconfig +make CROSS_COMPILE=aarch64-linux-gnu- + To build rk3328 boards: .. code-block:: bash -- 2.34.1
[PATCH 1/2] rockchip: Use an external TPL binary on RK3308
There is no support to initialize DRAM on RK3308 SoC using U-Boot TPL and therefore an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image. Imply ROCKCHIP_EXTERNAL_TPL by default for RK3308 builds. Remove useless TPL_SERIAL. Signed-off-by: Massimo Pegorer --- arch/arm/mach-rockchip/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index a279582f4f..e8584de258 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -159,6 +159,7 @@ config ROCKCHIP_RK3308 select SPL_ATF select SPL_ATF_NO_PLATFORM_PARAM select SPL_LOAD_FIT + imply ROCKCHIP_EXTERNAL_TPL imply ROCKCHIP_COMMON_BOARD imply SPL_ROCKCHIP_COMMON_BOARD imply SPL_CLK @@ -166,7 +167,6 @@ config ROCKCHIP_RK3308 imply SPL_SYSCON imply SPL_RAM imply SPL_SERIAL - imply TPL_SERIAL imply SPL_SEPARATE_BSS help The Rockchip RK3308 is a ARM-based Soc which embedded with quad -- 2.34.1
[PATCH 0/2] rockchip: Use an external TPL binary on RK3308
There is no support to initialize DRAM on RK3308 SoC using U-Boot TPL and therefore an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image. Imply ROCKCHIP_EXTERNAL_TPL by default for RK3308. Remove useless TPL_SERIAL for RK3308. Update documentation about build steps for RK3308. Add ROCK Pi S in the list of supported boards. Massimo Pegorer (2): rockchip: Use an external TPL binary on RK3308 doc: rockchip: Update and complete info about RK3308 arch/arm/mach-rockchip/Kconfig | 2 +- doc/README.rockchip | 4 ++-- doc/board/rockchip/rockchip.rst | 10 ++ 3 files changed, 13 insertions(+), 3 deletions(-) -- 2.34.1
[PATCH v3 6/7] doc: add documentation for gen_compile_commands.py
This documentation briefly explains what is a compilation database, and how to use the script to generate one. This is not a portage, as there was no original documentation in the Linux sources. Acknowledge the documentation in the script's header and in doc/build index. Signed-off-by: Joao Marcos Costa --- doc/build/gen_compile_commands.rst | 46 ++ doc/build/index.rst| 1 + scripts/gen_compile_commands.py| 1 + 3 files changed, 48 insertions(+) create mode 100644 doc/build/gen_compile_commands.rst diff --git a/doc/build/gen_compile_commands.rst b/doc/build/gen_compile_commands.rst new file mode 100644 index 00..6b32eb678a --- /dev/null +++ b/doc/build/gen_compile_commands.rst @@ -0,0 +1,46 @@ +.. SPDX-License-Identifier: GPL-2.0-only + + +gen_compile_commands + + +gen_compile_commands (scripts/gen_compile_commands.py) is a script used to +generate a compilation database (compile_commands.json). This database consists +of an array of "command objects" describing how each translation unit was +compiled. + +Example:: + + { + "command": "gcc -Wp,-MD,arch/x86/cpu/.lapic.o.d -nostdinc -isystem (...)" + "directory": "/home/jmcosta/u-boot", + "file": "/home/jmcosta/u-boot/arch/x86/cpu/lapic.c" + } + +Such information comes from parsing the respective .cmd file of each translation +unit. In the previous example, that would be `arch/x86/cpu/.lapic.o.cmd`. + +The compilation database is quite useful for text editors (and IDEs) that use +Clangd LSP. It allows jumping to definitions and declarations. Since it relies +on parsing .cmd files, one needs to have a target (e.g. configs/xxx_defconfig) +built before running the script. + +Example:: + + make sandbox_defconfig + make + ./scripts/gen_compile_commands.py + +The database will be in the root of the repository. No further modifications are +needed for it to be usable by the LSP, unless you set a name for the database +other than it's default one (compile_commands.json). + +Options +=== + +For further details on how to use the script and its options, please refer to +its help message, as in the example below. + +Help:: + + ./scripts/gen_compile_commands.py --help diff --git a/doc/build/index.rst b/doc/build/index.rst index 64e66491bd..7a4507b574 100644 --- a/doc/build/index.rst +++ b/doc/build/index.rst @@ -14,3 +14,4 @@ Build U-Boot tools buildman documentation + gen_compile_commands diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 1a9c49b34a..aa52e88e18 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -5,6 +5,7 @@ # # Author: Tom Roeder # Ported and modified for U-Boot by Joao Marcos Costa +# Briefly documented at doc/build/gen_compile_commands.rst # """A tool for generating compile_commands.json in U-Boot.""" -- 2.41.0
[PATCH v3 7/7] doc: add new section to build/tools
Add 'Integration with IDEs' section. For now, this section is mostly a reference to the documentation of gen_compile_commands, also in doc/build, but it can be futurely used as a guide for other IDE-friendly features. Signed-off-by: Joao Marcos Costa --- doc/build/gen_compile_commands.rst | 1 + doc/build/tools.rst| 13 + 2 files changed, 14 insertions(+) diff --git a/doc/build/gen_compile_commands.rst b/doc/build/gen_compile_commands.rst index 6b32eb678a..da812525fe 100644 --- a/doc/build/gen_compile_commands.rst +++ b/doc/build/gen_compile_commands.rst @@ -1,4 +1,5 @@ .. SPDX-License-Identifier: GPL-2.0-only +.. _gen-compile-commands-label: gen_compile_commands diff --git a/doc/build/tools.rst b/doc/build/tools.rst index ec01722925..5cdbf27d83 100644 --- a/doc/build/tools.rst +++ b/doc/build/tools.rst @@ -45,3 +45,16 @@ Launch the MSYS2 shell of the MSYS2 environment, and do the following:: $ make tools-only_defconfig $ make tools-only + +Integration with IDEs +- + +IDEs and text editors (e.g., VSCode, Emacs, Vim, Neovim) typically offer +plugins to enhance the development experience, such as Clangd LSP. These +plugins provide features like code navigation (i.e., jumping to definitions +and declarations), code completion, and code formatting. + +U-Boot provides a script (i.e., scripts/gen_compile_commands.py) that +generates a compilation database to be utilized by Clangd LSP for code +navigation. For detailed usage instructions, please refer to the script's +documentation: :ref:`gen-compile-commands-label`. -- 2.41.0
[PATCH v3 4/7] scripts/gen_compile_commands.py: add acknowledgments
Add acknowledgments for porting and modifying the script. Of course, the license, author, and copyright notice remain the same as in the original script. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 63d036a773..1a9c49b34a 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -4,6 +4,7 @@ # Copyright (C) Google LLC, 2018 # # Author: Tom Roeder +# Ported and modified for U-Boot by Joao Marcos Costa # """A tool for generating compile_commands.json in U-Boot.""" -- 2.41.0
[PATCH v3 3/7] scripts/gen_compile_commands.py: fix docstring
The referred tool is now in U-Boot. Replace "the Linux kernel" by "U-Boot" to make the docstring coherent. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 0227522959..63d036a773 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -5,7 +5,7 @@ # # Author: Tom Roeder # -"""A tool for generating compile_commands.json in the Linux kernel.""" +"""A tool for generating compile_commands.json in U-Boot.""" import argparse import json -- 2.41.0
[PATCH v3 5/7] .gitignore: add compile_commands.json
Add Clang's compilation database file (i.e. compile_commands.json) to .gitignore, at the root of the repository. Signed-off-by: Joao Marcos Costa --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 002f95de4f..261a1d6754 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,6 @@ __pycache__ # moveconfig database /moveconfig.db + +# Clang's compilation database file +/compile_commands.json -- 2.41.0
[PATCH v3 2/7] scripts/gen_compile_commands.py: adapt _LINE_PATTERN
For U-Boot's context, the regular expression defined by _LINE_PATTERN should be adapted. Replace 'savedcmd' by 'cmd'. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 15ba56527a..0227522959 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it. -- 2.41.0
[PATCH v3 1/7] scripts: Port Linux's gen_compile_commands.py to U-Boot
This script generates a database of compiler flags, namely compile_commands.json. It is quite useful for text editors that use clangd LSP (e.g. Vim, Neovim). It was ported from Linux's sources: - tag: v6.4 - revision 6995e2de6891c724bfeb2db33d7b87775f913ad1 Modifications for U-Boot compatibility will be added in a follow-up commit. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 228 1 file changed, 228 insertions(+) create mode 100755 scripts/gen_compile_commands.py diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py new file mode 100755 index 00..15ba56527a --- /dev/null +++ b/scripts/gen_compile_commands.py @@ -0,0 +1,228 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) Google LLC, 2018 +# +# Author: Tom Roeder +# +"""A tool for generating compile_commands.json in the Linux kernel.""" + +import argparse +import json +import logging +import os +import re +import subprocess +import sys + +_DEFAULT_OUTPUT = 'compile_commands.json' +_DEFAULT_LOG_LEVEL = 'WARNING' + +_FILENAME_PATTERN = r'^\..*\.cmd$' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] +# The tools/ directory adopts a different build system, and produces .cmd +# files in a different format. Do not support it. +_EXCLUDE_DIRS = ['.git', 'Documentation', 'include', 'tools'] + +def parse_arguments(): +"""Sets up and parses command-line arguments. + +Returns: +log_level: A logging level to filter log output. +directory: The work directory where the objects were built. +ar: Command used for parsing .a archives. +output: Where to write the compile-commands JSON file. +paths: The list of files/directories to handle to find .cmd files. +""" +usage = 'Creates a compile_commands.json database from kernel .cmd files' +parser = argparse.ArgumentParser(description=usage) + +directory_help = ('specify the output directory used for the kernel build ' + '(defaults to the working directory)') +parser.add_argument('-d', '--directory', type=str, default='.', +help=directory_help) + +output_help = ('path to the output command database (defaults to ' + + _DEFAULT_OUTPUT + ')') +parser.add_argument('-o', '--output', type=str, default=_DEFAULT_OUTPUT, +help=output_help) + +log_level_help = ('the level of log messages to produce (defaults to ' + + _DEFAULT_LOG_LEVEL + ')') +parser.add_argument('--log_level', choices=_VALID_LOG_LEVELS, +default=_DEFAULT_LOG_LEVEL, help=log_level_help) + +ar_help = 'command used for parsing .a archives' +parser.add_argument('-a', '--ar', type=str, default='llvm-ar', help=ar_help) + +paths_help = ('directories to search or files to parse ' + '(files should be *.o, *.a, or modules.order). ' + 'If nothing is specified, the current directory is searched') +parser.add_argument('paths', type=str, nargs='*', help=paths_help) + +args = parser.parse_args() + +return (args.log_level, +os.path.abspath(args.directory), +args.output, +args.ar, +args.paths if len(args.paths) > 0 else [args.directory]) + + +def cmdfiles_in_dir(directory): +"""Generate the iterator of .cmd files found under the directory. + +Walk under the given directory, and yield every .cmd file found. + +Args: +directory: The directory to search for .cmd files. + +Yields: +The path to a .cmd file. +""" + +filename_matcher = re.compile(_FILENAME_PATTERN) +exclude_dirs = [ os.path.join(directory, d) for d in _EXCLUDE_DIRS ] + +for dirpath, dirnames, filenames in os.walk(directory, topdown=True): +# Prune unwanted directories. +if dirpath in exclude_dirs: +dirnames[:] = [] +continue + +for filename in filenames: +if filename_matcher.match(filename): +yield os.path.join(dirpath, filename) + + +def to_cmdfile(path): +"""Return the path of .cmd file used for the given build artifact + +Args: +Path: file path + +Returns: +The path to .cmd file +""" +dir, base = os.path.split(path) +return os.path.join(dir, '.' + base + '.cmd') + + +def cmdfiles_for_a(archive, ar): +"""Generate the iterator of .cmd files associated with the archive. + +Parse the given archive, and yield every .cmd file used to build it. + +Args: +archive: The archive to parse + +Yields: +The path to every .cmd file found +""" +for obj in subprocess.check_output([ar, '-t', archive]).decode().split(): +yield to_cmdfile(obj) + + +def cmdfiles_for_modorder(modorder): +"""Generate the
[PATCH v3 0/7] Port gen_compile_commands.py from Linux to U-Boot
Hello U-Boot community, I'm submitting a patch series that ports the gen_compile_commands.py script from the Linux kernel's sources to U-Boot. This script, originally located in scripts/clang-tools/gen_compile_commands.py, enables the generation of compile_commands.json file for improved code navigation and analysis. The series consists of the initial script import, the necessary modifications for U-Boot compatibility, and finally some documentation. Your feedback on these contributions would be greatly appreciated. Best regards, Changes in v3: - Add documentation to index and fix syntax issues - Add reference to documentation in doc/build/tools Changes in v2: - Add compile_commands.json to gitignore - Add documentation Joao Marcos Costa (7): scripts: Port Linux's gen_compile_commands.py to U-Boot scripts/gen_compile_commands.py: adapt _LINE_PATTERN scripts/gen_compile_commands.py: fix docstring scripts/gen_compile_commands.py: add acknowledgments .gitignore: add compile_commands.json doc: add documentation for gen_compile_commands.py doc: add new section to build/tools .gitignore | 3 + doc/build/gen_compile_commands.rst | 47 ++ doc/build/index.rst| 1 + doc/build/tools.rst| 13 ++ scripts/gen_compile_commands.py| 230 + 5 files changed, 294 insertions(+) create mode 100644 doc/build/gen_compile_commands.rst create mode 100755 scripts/gen_compile_commands.py -- 2.41.0
Re: [PATCH v2 6/6] doc: add documentation for gen_compile_commands.py
On Sat, Sep 02, 2023 at 03:38:13PM +0200, João Marcos Costa wrote: > Hello, > > Em sáb., 2 de set. de 2023 às 15:11, Tom Rini escreveu: > > > > > This isn't included in one of the index files, which will be the first > > error 'make htmldocs' throws, and I think I saw other syntax errors as > > well in the file. The docs themselves look fine, thanks. > > > > -- > > Tom > > > > I'm not sure what's the most pertinent category in 'develop/index.rst'. > > Would 'general' be a good idea? I thought about putting it in the same > category as checkpatch, but this isn't refactoring per se. So, the main use case is to make integration with IDEs easier? Maybe put it under doc/build/ or referenced from doc/build/tools.rst with a small section like "Integration with IDEs" and a few words about how some IDEs such as ... use Clangd LSP for ... and see :doc:... for more information on how to generate these files. -- Tom signature.asc Description: PGP signature
Re: Issue with mmc_power_on() and reference counter of regulator
Hi, On 2023-09-02 13:35, Kenta Sato wrote: > Hi, > > I am using the FriendlyElec NanoPi R4S board. > When I updated U-Boot to a recent version (0fe0395922), it failed to > boot from MMC. Here is the log: > > > U-Boot TPL 2023.10-rc3 (Sep 02 2023 - 08:21:08) > lpddr4_set_rate: change freq to 400MHz 0, 1 > Channel 0: LPDDR4, 400MHz > BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB > Channel 1: LPDDR4, 400MHz > BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB > 256B stride > lpddr4_set_rate: change freq to 800MHz 1, 0 > Trying to boot from BOOTROM > Returning to boot ROM... > > U-Boot SPL 2023.10-rc3 (Sep 02 2023 - 08:21:08 +) > Trying to boot from MMC1 > spl_load_fit_image: Skip load 'atf-5': image size is 0! > NOTICE: BL31: v2.9(release): > NOTICE: BL31: Built : 08:19:59, Sep 2 2023 > > > U-Boot 2023.10-rc3 (Sep 02 2023 - 08:21:08 +) > > SoC: Rockchip rk3399 > Reset cause: POR > Model: FriendlyElec NanoPi R4S > DRAM: 4 GiB (effective 3.9 GiB) > PMIC: RK808 > Core: 264 devices, 23 uclasses, devicetree: separate > MMC: mmc@fe32: 1 > Loading Environment from nowhere... OK > In:serial,usbkbd > Out: serial,vidconsole > Err: serial,vidconsole > Model: FriendlyElec NanoPi R4S > Net: > Error: ethernet@fe30 address not set. > No ethernet found. > > Hit any key to stop autoboot: 0 > Error enabling VMMC supply : -114 > Error enabling VMMC supply : -114 > Error enabling VMMC supply : -114 > Error enabling VMMC supply : -114 > Error enabling VMMC supply : -114 > Error enabling VMMC supply : -114 > > > Does anyone know how to fix the issue? > > I looked into commit logs and the mailing list so far, and I found the > below commit that adds the reference counter to the regulator. I could > remove the above error by reverting this change. Of course, it should > not be the proper way. > Maybe we could replace regulator_set_enable() in mmc_power_on() by > regulator_set_enable_if_allowed(). However, I have no confidence about > it as I'm not familiar with the U-Boot source code. I sent patches to fix such situation back in July, see [1]. Those patches was merged into next, but should probably have gone into master. Please try next, and/or apply patches at [1] and report back result. [1] https://patchwork.ozlabs.org/project/uboot/list/?series=364753&state=* Regards, Jonas > > > commit 4fcba5d556b4224ad65a249801e4c9594d1054e8 > Author: Eugen Hristev > Date: Wed Apr 19 16:45:24 2023 +0300 > > regulator: implement basic reference counter > > Some devices share a regulator supply, when the first one will request > regulator disable, the second device will have it's supply cut off before > graciously shutting down. Hence there will be timeouts and other failed > operations. > Implement a reference counter mechanism similar with what is done in > Linux, to keep track of enable and disable requests, and only disable the > regulator when the last of the consumers has requested shutdown. > > Signed-off-by: Eugen Hristev > Reviewed-by: Simon Glass > Reviewed-by: Patrice Chotard > > > Any help would be greatly appreciated. > Thank you! > > Kenta Sato
Re: [PATCH v2 6/6] doc: add documentation for gen_compile_commands.py
Hello, Em sáb., 2 de set. de 2023 às 15:11, Tom Rini escreveu: > > This isn't included in one of the index files, which will be the first > error 'make htmldocs' throws, and I think I saw other syntax errors as > well in the file. The docs themselves look fine, thanks. > > -- > Tom > I'm not sure what's the most pertinent category in 'develop/index.rst'. Would 'general' be a good idea? I thought about putting it in the same category as checkpatch, but this isn't refactoring per se. Thanks. -- Atenciosamente, João Marcos Costa www.linkedin.com/in/jmarcoscosta/ https://github.com/jmarcoscosta
Re: [PATCH v2 6/6] doc: add documentation for gen_compile_commands.py
On Fri, Sep 01, 2023 at 10:03:53PM +0200, Joao Marcos Costa wrote: > This documentation briefly explains what is a compilation database, > and how to use the script to generate one. > > This is not a portage, as there was no original documentation in the > Linux sources. > > Acknowledge the documentation in the script's header. > > Signed-off-by: Joao Marcos Costa > --- > doc/develop/gen_compile_commands.rst | 46 This isn't included in one of the index files, which will be the first error 'make htmldocs' throws, and I think I saw other syntax errors as well in the file. The docs themselves look fine, thanks. -- Tom signature.asc Description: PGP signature
Re: [MASTER] Pull request doc-2023-10-rc4-2
On Sat, Sep 02, 2023 at 09:55:09AM +0200, Heinrich Schuchardt wrote: > Dear Tom, > > The following changes since commit 0fe0395922d859730eb7ddfcff6ed8d3ac4b2937: > > Merge branch '2023-08-28-assorted-important-fixes' (2023-08-29 > 10:06:08 -0400) > > are available in the Git repository at: > > https://source.denx.de/u-boot/custodians/u-boot-efi.git > tags/doc-2023-10-rc4-2 > > for you to fetch changes up to 44c5d7764bf458ef0a8093ddf3422dfebbf7b00c: > > doc: Add gpt command documentation (2023-09-02 09:44:04 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [NEXT] Pull request doc-next
On Sat, Sep 02, 2023 at 09:51:56AM +0200, Heinrich Schuchardt wrote: > Dear Tom, > > The following changes since commit b8b512a45358d50bce2e17b5941c5e39b52a0594: > > Merge branch '2023-08-31-replace-more-init-hooks-with-events' into > next (2023-08-31 15:10:42 -0400) > > are available in the Git repository at: > > https://source.denx.de/u-boot/custodians/u-boot-efi.git tags/doc-next > > for you to fetch changes up to edd8149cc686f749c51fafcfbb7802da73b42aea: > > doc: board: ti: am64x: Fix build step numbering (2023-09-02 06:14:34 > +0200) > > Gitlab CI showed no issues: > https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/17599 > Applied to u-boot/next, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH 1/2] thermal: k3-j72xx-bandgap: Add support for vtm
Hi Nishanth, On 9/2/2023 12:40 AM, Nishanth Menon wrote: On 23:43-20230901, Kumar, Udit wrote: On 9/1/2023 11:03 PM, Nishanth Menon wrote: On 22:54-20230901, Kumar, Udit wrote: +static const struct udevice_id of_k3_j72xx_bandgap_match[] = { + { + .compatible = "ti,j721e-vtm", + .data = (ulong)&k3_j72xx_bandgap_j721e_data, So what happens to drivers/misc/k3_avs.c ? Could you help me to understand this comment. Do you mean, why we can not add this support in AVS driver or need of this porting ? How I see, AVS driver to run at SPL/R5 time and this driver to be probed in Main/A72 u-boot when needed. you are saying the drivers are mutually exclusive - how about detecting over-temp scenario at R5 boot? switching on A53 will be a mistake at that point, no? Yes these are mutually exclusive. Let me see, how I can add TSHUT value programming in avs driver to avoid above. But in case, temperature reading is needed from u-boot shell, we still need this code. One approach might be to merge the two. I think merging of these two feature could be done in one file, as one driver or two. But on execution/feature side, from R5/SPL we need to set voltage for A72 (OPP or AVS) before releasing A72 core. Also can program TSHUT value for thermal overrun protection. For A72/Main u-boot, provide function of temperature reporting from shell.
Issue with mmc_power_on() and reference counter of regulator
Hi, I am using the FriendlyElec NanoPi R4S board. When I updated U-Boot to a recent version (0fe0395922), it failed to boot from MMC. Here is the log: U-Boot TPL 2023.10-rc3 (Sep 02 2023 - 08:21:08) lpddr4_set_rate: change freq to 400MHz 0, 1 Channel 0: LPDDR4, 400MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: LPDDR4, 400MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride lpddr4_set_rate: change freq to 800MHz 1, 0 Trying to boot from BOOTROM Returning to boot ROM... U-Boot SPL 2023.10-rc3 (Sep 02 2023 - 08:21:08 +) Trying to boot from MMC1 spl_load_fit_image: Skip load 'atf-5': image size is 0! NOTICE: BL31: v2.9(release): NOTICE: BL31: Built : 08:19:59, Sep 2 2023 U-Boot 2023.10-rc3 (Sep 02 2023 - 08:21:08 +) SoC: Rockchip rk3399 Reset cause: POR Model: FriendlyElec NanoPi R4S DRAM: 4 GiB (effective 3.9 GiB) PMIC: RK808 Core: 264 devices, 23 uclasses, devicetree: separate MMC: mmc@fe32: 1 Loading Environment from nowhere... OK In:serial,usbkbd Out: serial,vidconsole Err: serial,vidconsole Model: FriendlyElec NanoPi R4S Net: Error: ethernet@fe30 address not set. No ethernet found. Hit any key to stop autoboot: 0 Error enabling VMMC supply : -114 Error enabling VMMC supply : -114 Error enabling VMMC supply : -114 Error enabling VMMC supply : -114 Error enabling VMMC supply : -114 Error enabling VMMC supply : -114 Does anyone know how to fix the issue? I looked into commit logs and the mailing list so far, and I found the below commit that adds the reference counter to the regulator. I could remove the above error by reverting this change. Of course, it should not be the proper way. Maybe we could replace regulator_set_enable() in mmc_power_on() by regulator_set_enable_if_allowed(). However, I have no confidence about it as I'm not familiar with the U-Boot source code. commit 4fcba5d556b4224ad65a249801e4c9594d1054e8 Author: Eugen Hristev Date: Wed Apr 19 16:45:24 2023 +0300 regulator: implement basic reference counter Some devices share a regulator supply, when the first one will request regulator disable, the second device will have it's supply cut off before graciously shutting down. Hence there will be timeouts and other failed operations. Implement a reference counter mechanism similar with what is done in Linux, to keep track of enable and disable requests, and only disable the regulator when the last of the consumers has requested shutdown. Signed-off-by: Eugen Hristev Reviewed-by: Simon Glass Reviewed-by: Patrice Chotard Any help would be greatly appreciated. Thank you! Kenta Sato
Re: [PATCH] usb: host: ohci-generic: Make usage of clock/reset bulk() API
Is the change of behaviour intended when a clock or reset is not found ? (see below) El Wed, Aug 30, 2023 at 10:01:49AM +0200, Fabrice Gasnier deia: > Make usage of clock and reset bulk API in order to simplify the code > > Signed-off-by: Fabrice Gasnier > --- > > drivers/usb/host/ohci-generic.c | 92 +++-- > 1 file changed, 29 insertions(+), 63 deletions(-) > > diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c > index 2d8d38ce9a40..95aa608d8c19 100644 > --- a/drivers/usb/host/ohci-generic.c > +++ b/drivers/usb/host/ohci-generic.c > @@ -16,75 +16,41 @@ > > struct generic_ohci { > ohci_t ohci; > - struct clk *clocks; /* clock list */ > - struct reset_ctl *resets; /* reset list */ > + struct clk_bulk clocks; /* clock list */ > + struct reset_ctl_bulk resets; /* reset list */ > struct phy phy; > - int clock_count;/* number of clock in clock list */ > - int reset_count;/* number of reset in reset list */ > }; > > static int ohci_usb_probe(struct udevice *dev) > { > struct ohci_regs *regs = dev_read_addr_ptr(dev); > struct generic_ohci *priv = dev_get_priv(dev); > - int i, err, ret, clock_nb, reset_nb; > - > - err = 0; > - priv->clock_count = 0; > - clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells", > -0); > - if (clock_nb > 0) { > - priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk), > - GFP_KERNEL); > - if (!priv->clocks) > - return -ENOMEM; > - > - for (i = 0; i < clock_nb; i++) { > - err = clk_get_by_index(dev, i, &priv->clocks[i]); > - if (err < 0) > - break; > - Please note the old code was tolerant of not finding some clocks. It ignored any clock not found and any other listed after it in the "clocks" property and enabled the clocks before it. The clk_get_bulk() function instead returns an error when any clock in "clocks" is not found and releases (disables again and frees) those before it. I'm not aware of any case that breaks because of this, but I once saw a case of ehci not working and ohci working because one of the listed clocks not being found (ehci called clk_get_bulk(), clk_enable_blk()). In that case, a fix by ignoring the missing clock in ehci was rejected, so maybe that criteria applies here as well and your patch is deemed correct. I don't know. That case won't break now, I think, either with or without your patch, because after another fix, that clock will be found. But I don't know if there might be similar cases. I just wanted to point out the change in behaviour. If the change is intended, then all is fine. > - err = clk_enable(&priv->clocks[i]); > - if (err && err != -ENOSYS) { > - dev_err(dev, "failed to enable clock %d\n", i); > - clk_free(&priv->clocks[i]); > - goto clk_err; > - } > - priv->clock_count++; > - } > - } else if (clock_nb != -ENOENT) { > - dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb); > - return clock_nb; > + int err, ret; > + > + ret = clk_get_bulk(dev, &priv->clocks); > + if (ret && ret != -ENOENT) { > + dev_err(dev, "Failed to get clocks (ret=%d)\n", ret); > + return ret; > + } > + > + err = clk_enable_bulk(&priv->clocks); > + if (err) { > + dev_err(dev, "Failed to enable clocks (err=%d)\n", err); > + goto clk_err; > } > > - priv->reset_count = 0; > - reset_nb = dev_count_phandle_with_args(dev, "resets", "#reset-cells", > -0); > - if (reset_nb > 0) { > - priv->resets = devm_kcalloc(dev, reset_nb, > - sizeof(struct reset_ctl), > - GFP_KERNEL); > - if (!priv->resets) > - return -ENOMEM; > - > - for (i = 0; i < reset_nb; i++) { > - err = reset_get_by_index(dev, i, &priv->resets[i]); > - if (err < 0) > - break; > - Similar here. > - err = reset_deassert(&priv->resets[i]); > - if (err) { > - dev_err(dev, "failed to deassert reset %d\n", > i); > - reset_free(&priv->resets[i]); > - goto reset_err; > - } > - priv->reset_count++; > - } > - } else if (reset_nb != -ENOENT) { > - dev_err(dev, "failed to get reset phandle(%d)\n", reset_nb); > +
[MASTER] Pull request doc-2023-10-rc4-2
Dear Tom, The following changes since commit 0fe0395922d859730eb7ddfcff6ed8d3ac4b2937: Merge branch '2023-08-28-assorted-important-fixes' (2023-08-29 10:06:08 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-efi.git tags/doc-2023-10-rc4-2 for you to fetch changes up to 44c5d7764bf458ef0a8093ddf3422dfebbf7b00c: doc: Add gpt command documentation (2023-09-02 09:44:04 +0200) Pull request doc-2023-10-rc4-2 * Man-page for gpt command * Fix long text help of gpt command * Add events to HTML documentation * Update Toradex documentation Heinrich Schuchardt (3): dm: event: document all events doc: add events.h to documentation video: fix typo in video_sync_all documentation Joshua Watt (2): cmd: gpt: Remove confusing help text doc: Add gpt command documentation Marcel Ziswiler (2): doc: board: toradex: minor documentation update doc: board: toradex: verdin-am62: document update u-boot wrapper cmd/gpt.c | 2 - doc/api/event.rst | 9 ++ doc/api/index.rst | 1 + doc/board/toradex/apalis-imx8.rst | 22 - doc/board/toradex/colibri-imx8x.rst | 31 -- doc/board/toradex/colibri_imx7.rst | 38 doc/board/toradex/verdin-am62.rst | 22 - doc/board/toradex/verdin-imx8mm.rst | 9 +- doc/board/toradex/verdin-imx8mp.rst | 9 +- doc/usage/cmd/gpt.rst | 184 doc/usage/index.rst | 1 + include/event.h | 97 +-- include/video.h | 2 +- 13 files changed, 372 insertions(+), 55 deletions(-) create mode 100644 doc/api/event.rst create mode 100644 doc/usage/cmd/gpt.rst
[NEXT] Pull request doc-next
Dear Tom, The following changes since commit b8b512a45358d50bce2e17b5941c5e39b52a0594: Merge branch '2023-08-31-replace-more-init-hooks-with-events' into next (2023-08-31 15:10:42 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-efi.git tags/doc-next for you to fetch changes up to edd8149cc686f749c51fafcfbb7802da73b42aea: doc: board: ti: am64x: Fix build step numbering (2023-09-02 06:14:34 +0200) Gitlab CI showed no issues: https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/17599 Pull request doc-next * Update TI am64x documentation Nishanth Menon (2): doc: board: ti: am64x: provide image alt text doc: board: ti: am64x: Fix build step numbering doc/board/ti/am64x_evm.rst | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH v2 3/4] cmd: gpt: fix calc_parts_list_len()
* Avoid incrementing by moving comma into strlen("uuid_disk=,") and considering NUL byte. * Appending a UUID only adds UUID_STR_LEN bytes. Don't count the terminating NUL. * The length of the hexadecimal representation of lba_int is 2 * sizeof(lba_int). * We don't use a 'MiB' postfix but a '0x' prefix. * The uuid field is only needed if configured. Fixes: 2fcaa413b3f6 ("gpt: harden set_gpt_info() against non NULL-terminated strings") Signed-off-by: Heinrich Schuchardt --- v2: new patch --- cmd/gpt.c | 33 - 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/cmd/gpt.c b/cmd/gpt.c index 092f7defff..e7a53747fc 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -162,22 +162,29 @@ static bool found_key(const char *str, const char *key) return result; } +/** + * calc_parts_list_len() - get size of partition table description + * + * @numparts: number of partitions + * Return: string size including terminating NUL + */ static int calc_parts_list_len(int numparts) { - int partlistlen = UUID_STR_LEN + 1 + strlen("uuid_disk="); - /* for the comma */ - partlistlen++; - - /* per-partition additions; numparts starts at 1, so this should be correct */ - partlistlen += numparts * (strlen("name=,") + PART_NAME_LEN + 1); + /* number of hexadecimal digits of the lbaint_t representation */ + const int lbaint_size = 2 * sizeof(lbaint_t); + int partlistlen; + + /* media description including terminating NUL */ + partlistlen = strlen("uuid_disk=;") + UUID_STR_LEN + 1; + /* per-partition descriptions; numparts */ + partlistlen += numparts * (strlen("name=,") + PART_NAME_LEN); /* see part.h for definition of struct disk_partition */ - partlistlen += numparts * (strlen("start=MiB,") + sizeof(lbaint_t) + 1); - partlistlen += numparts * (strlen("size=MiB,") + sizeof(lbaint_t) + 1); - partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN + 1); - /* for the terminating null */ - partlistlen++; - debug("Length of partitions_list is %d for %d partitions\n", partlistlen, - numparts); + partlistlen += numparts * (strlen("start=0x,") + lbaint_size); + partlistlen += numparts * (strlen("size=0x,") + lbaint_size); + if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) + partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN); + debug("Length of partitions_list is %d for %d partitions\n", + partlistlen, numparts); return partlistlen; } -- 2.40.1
[PATCH v2 4/4] cmd: gpt: fix gpt read
To partition a block device the partition type GUIDs are needed but 'gpt read' does not provide these. Add the missing parts. Signed-off-by: Heinrich Schuchardt --- v2: use accessor for type_guid field --- cmd/gpt.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/gpt.c b/cmd/gpt.c index e7a53747fc..8e1de24845 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -182,7 +182,9 @@ static int calc_parts_list_len(int numparts) partlistlen += numparts * (strlen("start=0x,") + lbaint_size); partlistlen += numparts * (strlen("size=0x,") + lbaint_size); if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) - partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN); + partlistlen += numparts * (strlen("uuid=,") + UUID_STR_LEN); + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) + partlistlen += numparts * (strlen("type=;") + UUID_STR_LEN); debug("Length of partitions_list is %d for %d partitions\n", partlistlen, numparts); return partlistlen; @@ -221,6 +223,9 @@ static struct disk_part *allocate_disk_part(struct disk_partition *info, if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) disk_partition_set_uuid(&newpart->gpt_part_info, disk_partition_uuid(info)); + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) + disk_partition_set_type_guid(&newpart->gpt_part_info, +disk_partition_type_guid(info)); newpart->partnum = partnum; return newpart; @@ -259,6 +264,9 @@ static void print_gpt_info(void) if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) printf("UUID %s\n", disk_partition_uuid(&curr->gpt_part_info)); + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) + printf("Type GUID %s\n", + disk_partition_type_guid(&curr->gpt_part_info)); printf("\n"); } } @@ -308,6 +316,12 @@ static int create_gpt_partitions_list(int numparts, const char *guid, disk_partition_uuid(&curr->gpt_part_info), UUID_STR_LEN + 1); } + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { + strcat(partitions_list, ",type="); + strncat(partitions_list, + disk_partition_type_guid(&curr->gpt_part_info), + UUID_STR_LEN + 1); + } strcat(partitions_list, ";"); } return 0; -- 2.40.1
[PATCH v2 2/4] cmd: gpt: use UUID accessor more consistently
disk_partition_uuid() and disk_partition_set_uuid() were introduced to let us avoid the usage of #ifdef when dealing with the field uuid of struct disk_partition. In allocate_disk_part() commit c5f1d005f517 ("part: Add accessors for struct disk_partition uuid") missed to use the setter. print_gpt_info() and create_gpt_partitions_list() are further functions where we should use the getter. Fixes: c5f1d005f517 ("part: Add accessors for struct disk_partition uuid") Signed-off-by: Heinrich Schuchardt --- v2: new patch --- cmd/gpt.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/gpt.c b/cmd/gpt.c index 8969efba8c..092f7defff 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -211,10 +211,9 @@ static struct disk_part *allocate_disk_part(struct disk_partition *info, PART_TYPE_LEN); newpart->gpt_part_info.type[PART_TYPE_LEN - 1] = '\0'; newpart->gpt_part_info.bootable = info->bootable; - if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) { - strlcpy(newpart->gpt_part_info.uuid, disk_partition_uuid(info), - UUID_STR_LEN + 1); - } + if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) + disk_partition_set_uuid(&newpart->gpt_part_info, + disk_partition_uuid(info)); newpart->partnum = partnum; return newpart; @@ -250,9 +249,9 @@ static void print_gpt_info(void) curr->gpt_part_info.name); printf("Type %s, bootable %d\n", curr->gpt_part_info.type, curr->gpt_part_info.bootable & PART_BOOTABLE); -#ifdef CONFIG_PARTITION_UUIDS - printf("UUID %s\n", curr->gpt_part_info.uuid); -#endif + if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) + printf("UUID %s\n", + disk_partition_uuid(&curr->gpt_part_info)); printf("\n"); } } @@ -296,10 +295,12 @@ static int create_gpt_partitions_list(int numparts, const char *guid, (unsigned long long)curr->gpt_part_info.size * curr->gpt_part_info.blksz); strncat(partitions_list, partstr, PART_NAME_LEN + 1); - - strcat(partitions_list, ",uuid="); - strncat(partitions_list, curr->gpt_part_info.uuid, - UUID_STR_LEN + 1); + if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) { + strcat(partitions_list, ",uuid="); + strncat(partitions_list, + disk_partition_uuid(&curr->gpt_part_info), + UUID_STR_LEN + 1); + } strcat(partitions_list, ";"); } return 0; -- 2.40.1
[PATCH v2 1/4] part: rename disk_partition_type_uuid()
Rename disk_partition_type_uuid to disk_partition_type_guid. Provide function descriptions for the getter and setter. Fixes: bcd645428c34 ("part: Add accessors for struct disk_partition type_uuid") Signed-off-by: Heinrich Schuchardt --- v2: new patch --- disk/part_efi.c | 2 +- include/part.h | 26 +++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 39382c5fae..b7aef3731b 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -299,7 +299,7 @@ int part_get_info_efi(struct blk_desc *desc, int part, } if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b, - (char *)disk_partition_type_uuid(info), + (char *)disk_partition_type_guid(info), UUID_STR_FORMAT_GUID); } diff --git a/include/part.h b/include/part.h index f321479a5e..db34bc6bb7 100644 --- a/include/part.h +++ b/include/part.h @@ -108,18 +108,38 @@ static inline void disk_partition_clr_uuid(struct disk_partition *info) } /* Accessors for struct disk_partition field ->type_guid */ -extern char *__invalid_use_of_disk_partition_type_uuid; +extern char *__invalid_use_of_disk_partition_type_guid; +/** + * disk_partition_type_guid() - get partition type GUID + * + * By using this function to get the partition type GUID we can use + * 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of + * '#ifdef CONFIG_PARTITION_TYPE_GUID'. + * + * @info: partition information + * Return: partition type GUID + */ static inline const -char *disk_partition_type_uuid(const struct disk_partition *info) +char *disk_partition_type_guid(const struct disk_partition *info) { #ifdef CONFIG_PARTITION_TYPE_GUID return info->type_guid; #else - return __invalid_use_of_disk_partition_type_uuid; + return __invalid_use_of_disk_partition_type_guid; #endif } +/** + * disk_partition_set_type_guid() - set partition type GUID + * + * By using this function to set the partition type GUID we can use + * 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of + * '#ifdef CONFIG_PARTITION_TYPE_GUID'. + * + * @info: partition information + * @val: partition type GUID as string + */ static inline void disk_partition_set_type_guid(struct disk_partition *info, const char *val) { -- 2.40.1
[PATCH v2 0/4] cmd: gpt: fix gpt read
To partition a block device the partition type GUIDs are needed but 'gpt read' does not provide these. Add the missing parts. v2: Rename disk_partition_type_uuid() to disk_partition_type_guid(). Use setter for type_guid in allocate_disk_part(). Fix calculation of the size of the partition table descriptor. Use accessor for type_guid field. *** BLURB HERE *** Heinrich Schuchardt (4): part: rename disk_partition_type_uuid() cmd: gpt: use UUID accessor more consistently cmd: gpt: fix calc_parts_list_len() cmd: gpt: fix gpt read cmd/gpt.c | 70 - disk/part_efi.c | 2 +- include/part.h | 26 +++--- 3 files changed, 70 insertions(+), 28 deletions(-) -- 2.40.1