U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Caleb Connolly <caleb.connolly@linaro.org>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Lukasz Majewski <lukma@denx.de>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Tom Rini <trini@konsulko.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Sumit Garg <sumit.garg@kernel.org>,
	u-boot@lists.denx.de, u-boot-qcom@groups.io
Subject: Re: [PATCH 2/4] mach-snapdragon: CapsuleUpdate: support all boot methods
Date: Thu, 3 Apr 2025 14:47:45 +0200	[thread overview]
Message-ID: <bade55c2-e34c-4871-bd6e-07a6dc818734@linaro.org> (raw)
In-Reply-To: <CAC_iWjKSFkuHCBFHcd04m7mz+33EbsmPWvSX6+u2Pvo=3nwy5w@mail.gmail.com>



On 4/1/25 14:42, Ilias Apalodimas wrote:
> Hi Caleb
> 
> On Wed, 26 Mar 2025 at 19:41, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>>
>> Expand capsule update support to correctly identify which partition
>> U-Boot is flashed to (between xbl, uefi, and boot including A/B
>> variants).
>>
>> Use qcom_boot_source to determine if we were chainloaded from ABL,
>> meaning U-Boot is on the boot partition, otherwise we assume uefi if
>> it's available, finally leaving the xbl partition.
>>
>> Set a different fw_name based on the target partition to prevent GUID
>> collisions, since a board may support U-Boot flashed to boot or XBL we
>> need to differentiate them since the U-Boot binary must be built
>> differently.
>>
> 
> [...]
> 
> 
>> -               if (!strncmp(info.name, partname, strlen(partname))) {
>> -                       log_debug("Found active %s partition: '%s'!\n", partname, info.name);
>> -                       strlcpy(name, info.name, sizeof(info.name));
>> -                       return partnum;
>> +               desc = dev_get_uclass_plat(dev);
>> +               if (!desc || desc->part_type == PART_TYPE_UNKNOWN)
>> +                       continue;
>> +               for (partnum = 1;; partnum++) {
>> +                       ret = part_get_info(desc, partnum, &info);
>> +                       if (ret)
>> +                               break;
>> +
>> +                       slot_status = (struct part_slot_status *)&info.type_flags;
>> +
>> +                       /*
>> +                        * Qualcomm Linux devices have a "uefi" partition, it's A/B but the
>> +                        * flags might not be set so we assume the A partition unless the B
>> +                        * partition is active.
>> +                        */
>> +                       if (!strncmp(info.name, "uefi", strlen("uefi")))
> 
> since it's a static string, use sizeof() to compute it at build time.

Ahh nice, I'll do that.

> I get what you are trying to do here and automatically detect the boot
> partition, I'll have a closer look in case we can somehow make this
> loop shorter.
> 
> {
>> +                               /*
>> +                                * If U-Boot was chainloaded somehow we can't be flashed to
>> +                                * the uefi partition
>> +                                */
>> +                               if (qcom_boot_source != QCOM_BOOT_SOURCE_XBL)
>> +                                       continue;
>> +
>> +                               *target_part_type = TARGET_PART_UEFI;
>> +                               /*
>> +                                * Found an active UEFI partition, this is where U-Boot is
>> +                                * flashed.
>> +                                */
>> +                               if (slot_status->active)
>> +                                       goto found;
>> +
>> +                               /* Prefer A slot if it's not marked active */
>> +                               if (get_part_slot(info.name) == SLOT_A) {
> 
> SLOT_NONE only applies to non-uefi partitions?

Yes, having a "uefi" partition is only the case on 2 boards that I'm 
aware of, and both have a/b variants. The xbl and boot partitions exist 
on A/B and non-A/B devices so we have to handle all variants there.
> 
>> +                                       /*
>> +                                        * If we found the A slot after the B slot (both
>> +                                        * inactive) then we assume U-Boot is on the A slot.
>> +                                        */
>> +                                       if (uefi_partnum >= 0)
>> +                                               goto found;
>> +
>> +                                       /* Didn't find the B slot yet */
>> +                                       uefi_partnum = partnum;
>> +                                       strlcpy(ptn_name, info.name, 32);
> 
> sizeof(ptn_name)

Thanks
> 
>> +                               } else {
>> +                                       /*
>> +                                        * Found inactive B slot after inactive A slot, return
>> +                                        * the A slot
>> +                                        */
>> +                                       if (uefi_partnum >= 0) {
>> +                                               partnum = uefi_partnum;
>> +                                               goto found;
>> +                                       }
>> +
>> +                                       /*
>> +                                        * Didn't find the A slot yet. Record that we found the
>> +                                        * B slot
> 
> [...]
> 
> Cheers
> /Ilias

-- 
Caleb (they/them)


  reply	other threads:[~2025-04-03 12:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26 17:40 [PATCH 0/4] Qualcomm: expand capsule update support Caleb Connolly
2025-03-26 17:40 ` [PATCH 1/4] mach-snapdragon: track boot source Caleb Connolly
2025-03-31 13:52   ` Neil Armstrong
2025-03-26 17:40 ` [PATCH 2/4] mach-snapdragon: CapsuleUpdate: support all boot methods Caleb Connolly
2025-04-01  8:45   ` Neil Armstrong
2025-04-11 14:48     ` Caleb Connolly
2025-04-01 12:42   ` Ilias Apalodimas
2025-04-03 12:47     ` Caleb Connolly [this message]
2025-03-26 17:40 ` [PATCH 3/4] dfu: scsi: don't call scsi_scan() Caleb Connolly
2025-03-31 13:52   ` Neil Armstrong
2025-03-31 13:53   ` Ilias Apalodimas
2025-03-26 17:40 ` [PATCH 4/4] qcom_defconfig: enable capsule update support Caleb Connolly
2025-03-27  8:46   ` Peng Fan
2025-03-27 12:30     ` Caleb Connolly
2025-03-31 13:52   ` Ilias Apalodimas
2025-03-26 17:44 ` [PATCH 0/4] Qualcomm: expand " Caleb Connolly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bade55c2-e34c-4871-bd6e-07a6dc818734@linaro.org \
    --to=caleb.connolly@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=lukma@denx.de \
    --cc=mkorpershoek@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=sumit.garg@kernel.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox