Skip to contentSkip to conversation

tools: qcom: mkmbn: Updates to support ipq5210

PATCH Superseded Varadarajan Narayanan 3 participants 8 messages Sep 10 – Sep 11

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover tools: qcom: mkmbn: Updates to support ipq5210

As part of adding Qualcomm ipq5210 SoC U-Boot SPL & U-Boot proper support, the mkmbn script has to be upgraded to create images that can be used in the ipq5210 SoC.

These changes are to address the feedback in the 'Qualcomm IPQ5210 SoC bringup' series [1] to use mkbn.

1 - https://lore.kernel.org/u-boot/[email protected]/

While at it, fix the MBN version number for ipq5424.

v2:
- Remove 'load address' from MbnData and get it from .config
- Add qcom_sm8550_defconfig
- Use 4K alignment for padding the MBN images
- Remove '--melfs' option and make them positional
Link for v1: https://lore.kernel.org/u-boot/[email protected]/

---
Varadarajan Narayanan (4):
tools: qcom: mkmbn: Fix ipq5424 MBN version
configs: add qcom_sm8550_defconfig and debug fragment
tools: qcom: mkmbn: Add support for ipq5210
tools: qcom: mkmbn: Add support to create multi-elf

 board/qualcomm/config.mk      |  2 +-
 configs/qcom_sm8550_defconfig | 15 +++++++++++++
 tools/qcom/mkmbn/mkmbn.py     | 51 +++++++++++++++++++++++++++++++++----------
 3 files changed, 56 insertions(+), 12 deletions(-)

---
base-commit: 914dd2f5d18a3a89e4ddb6d1d97b2743618ae5ee
change-id: 20260714-ipq5210-52e1da5af9fc

Best regards,

Signature · 1 line
Varadarajan Narayanan <[email protected]>
#1 lore raw

PATCH v2 1/4 tools: qcom: mkmbn: Fix ipq5424 MBN version

Since ipq5424 uses MBN version 7, update the ipq5424 entry in the 'boards' table accordingly.

---
 tools/qcom/mkmbn/mkmbn.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/qcom/mkmbn/mkmbn.py +1 -1
index e4484b539b0..8d2078acc30 100755
@@ -85,7 +85,7 @@ boards: dict[bytes, MbnData] = {
     b"qcom,sm8550\0": MbnData(0xA7000000, 7, SwId.uefi),  # C8550
     b"qcom,sm8650\0": MbnData(0xA7000000, 7, SwId.uefi),  # SM8650
     b"qcom,qcs615\0": MbnData(0x9FC00000, 6, SwId.uefi),  # Dragonwing IQ6
-    b"qcom,ipq5424\0": MbnData(0x8a380000, 6, SwId.aboot),
+    b"qcom,ipq5424\0": MbnData(0x8a380000, 7, SwId.aboot),
     b"qcom,ipq9574\0": MbnData(0x4A240000, 6, SwId.aboot),
 
     # msm8916/apq8016 has an "aboot" partition but the process is the same
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/4 configs: add qcom_sm8550_defconfig and debug fragment

In reply to Varadarajan Narayanan

Add a defconfig for running on sm5650 as the first stage bootloader and associated debug config fragment.

---
 configs/qcom_sm8550_defconfig | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
configs/qcom_sm8550_defconfig new file +15 -0
new file mode 100644
index 00000000000..30d11f36eb3
@@ -0,0 +1,15 @@
+# Configuration for building U-Boot to be flashed
+# to the uefi partition of QCM6490 dev boards with
+# the "Linux Embedded" partition layout (which have
+# a dedicated "uefi" partition for edk2/U-Boot)
+
+#include "qcom_defconfig"
+
+# Otherwise buildman thinks this isn't an ARM platform
+CONFIG_ARM=y
+
+# Address where U-Boot will be loaded
+CONFIG_TEXT_BASE=0xa7000000
+CONFIG_REMAKE_ELF=y
+
+CONFIG_DEFAULT_DEVICE_TREE="qcom/sm8550-hdk"
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v2 2/4] configs: add qcom_sm8550_defconfig and debug fragment

Quoted 17 lines · Varadarajan Narayanan

Add a defconfig for running on sm5650 as the first stage bootloader and associated debug config fragment.

---
  configs/qcom_sm8550_defconfig | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
configs/qcom_sm8550_defconfig new file +3 -0
new file mode 100644
index 00000000000..30d11f36eb3
@@ -0,0 +1,15 @@
+# Configuration for building U-Boot to be flashed
+# to the uefi partition of QCM6490 dev boards with
+# the "Linux Embedded" partition layout (which have

configs/qcom_sm8550_defconfig line 13

Quoted 10 lines
configs/qcom_sm8550_defconfig new file +10 -0
+# a dedicated "uefi" partition for edk2/U-Boot)
+
+#include "qcom_defconfig"
+
+# Otherwise buildman thinks this isn't an ARM platform
+CONFIG_ARM=y
+
+# Address where U-Boot will be loaded
+CONFIG_TEXT_BASE=0xa7000000
+CONFIG_REMAKE_ELF=y

CONFIG_QCOM_GENERATE_MBN??> +

Quoted 2 lines
configs/qcom_sm8550_defconfig new file +1 -0
+CONFIG_DEFAULT_DEVICE_TREE="qcom/sm8550-hdk"
#4 lore raw

PATCH v2 3/4 tools: qcom: mkmbn: Add support for ipq5210

In reply to Varadarajan Narayanan

- Add ipq5210 entry to the 'boards' table
- Add an argument to specify the SPL load address
- ipq5210's boot rom expects the SPL image size to be 4-byte aligned. To support this add an argument to specify the image size alignment to enable the mkmbn script to pad the image accordingly.

---
 board/qualcomm/config.mk  |  2 +-
 tools/qcom/mkmbn/mkmbn.py | 34 ++++++++++++++++++++++++----------
 2 files changed, 25 insertions(+), 11 deletions(-)
board/qualcomm/config.mk +1 -1
index 769e4a51ca0..dd61ffd98e8 100644
@@ -8,7 +8,7 @@
 # Create Qualcomm signed elf images
 CMD_MKMBN = $(srctree)/tools/qcom/mkmbn/mkmbn.py
 quiet_cmd_mkmbn = MBN     $@
-      cmd_mkmbn = $(CMD_MKMBN) $<
+      cmd_mkmbn = $(CMD_MKMBN) -l $(CONFIG_TEXT_BASE) $<
 
 u-boot.mbn: u-boot.bin FORCE
 	$(call if_changed,mkmbn)
tools/qcom/mkmbn/mkmbn.py +24 -10
index 8d2078acc30..6fe66fc4e55 100755
@@ -18,6 +18,8 @@ import sys
 from enum import Enum
 import struct
 
+MBN_ALIGN_SIZE = 4096
+
 verbose = False
 
 def log(*args, **kwargs):
@@ -63,19 +65,17 @@ class MbnData:
 
 
 """
-This dictionary is used to map a board or platform to the appropriate load address and
-other MBN metadata. When adding support for a new platform to U-Boot, the appropriate
-data should be filled out here. The load address can typically be determined by looking
-at the uefi.elf or xbl.elf for the platform. For the uefi.elf it is the load address, and
-for xbl.elf it is typically the RWX section in the middle, just BEFORE the section loaded
-at 0x1495xxxx or similar. Looking at similar platforms in the table below may help.
+This dictionary is used to map a board or platform to the appropriate MBN
+metadata. When adding support for a new platform to U-Boot, the appropriate data
+should be filled out here. Looking at similar platforms in the table below may
+help.
 """
 boards: dict[bytes, MbnData] = {
     # Exact matches for boards, these are preferred
-    b"qcom,qcs6490-rb3gen2\0": MbnData(0x9FC00000, 6, SwId.uefi),
-    b"qcom,qcs9100-ride-r3\0": MbnData(0xAF000000, 6, SwId.uefi),  # Dragonwing IQ9
-    b"qcom,qcs8300-ride\0": MbnData(0xAF000000, 6, SwId.uefi),  # Dragonwing IQ8
-    b"qcom,qcs615-ride\0": MbnData(0x9FC00000, 6, SwId.uefi),  # Dragonwing IQ6
+    b"qcom,qcs6490-rb3gen2\0": MbnData(6, SwId.uefi),
+    b"qcom,qcs9100-ride-r3\0": MbnData(6, SwId.uefi),  # Dragonwing IQ9
+    b"qcom,qcs8300-ride\0": MbnData(6, SwId.uefi),  # Dragonwing IQ8
+    b"qcom,qcs615-ride\0": MbnData(6, SwId.uefi),  # Dragonwing IQ6
     # Fallback/generic matches since most boards for a platform will
     # use the same load address
     b"qcom,qcm6490\0": MbnData(0x9FC00000, 6, SwId.uefi),  # rb3gen2, rubikpi3
@@ -85,6 +85,7 @@ boards: dict[bytes, MbnData] = {
     b"qcom,sm8550\0": MbnData(0xA7000000, 7, SwId.uefi),  # C8550
     b"qcom,sm8650\0": MbnData(0xA7000000, 7, SwId.uefi),  # SM8650
     b"qcom,qcs615\0": MbnData(0x9FC00000, 6, SwId.uefi),  # Dragonwing IQ6
+    b"qcom,ipq5210\0": MbnData(0x87980000, 7, SwId.aboot),
     b"qcom,ipq5424\0": MbnData(0x8a380000, 7, SwId.aboot),
     b"qcom,ipq9574\0": MbnData(0x4A240000, 6, SwId.aboot),
 
@@ -100,6 +101,9 @@ parser = argparse.ArgumentParser(
 """
 )
 parser.register("type", "hex", lambda s: int(s, 16))
+parser.add_argument(
+    "-l", "--load", type=lambda x: int(x, 0), default=0, help="Load address"
+)
 parser.add_argument(
     "-o", "--output", type=Path, default="u-boot.mbn", help="Output file"
 )
@@ -149,8 +153,18 @@ if not mbn:
     args.output.unlink(missing_ok=True)
     exit(1)
 
+if args.load == 0:
+    error(
+        "Cannot proceed without load address.\n"
+        "Ensure CONFIG_TEXT_BASE/CONFIG_SPL_TEXT_BASE is set\n")
+    exit(1)
+else:
+    mbn.loadaddr = args.load
+
 log(f"Detected board {match.decode('UTF-8')} with load address {mbn.loadaddr:#x}")
 
+data += b'\x00' * (-len(data) % MBN_ALIGN_SIZE)
+
 elf.phdrs.append(Phdr.from_bin(data, mbn.loadaddr))
 elf.ehdr.e_entry = mbn.loadaddr
 elf.update()
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v2 3/4] tools: qcom: mkmbn: Add support for ipq5210

Hi Varadarajan,

Quoted 67 lines · Varadarajan Narayanan

- Add ipq5210 entry to the 'boards' table
- Add an argument to specify the SPL load address
- ipq5210's boot rom expects the SPL image size to be 4-byte aligned. To support this add an argument to specify the image size alignment to enable the mkmbn script to pad the image accordingly.

---
  board/qualcomm/config.mk  |  2 +-
  tools/qcom/mkmbn/mkmbn.py | 34 ++++++++++++++++++++++++----------
  2 files changed, 25 insertions(+), 11 deletions(-)
board/qualcomm/config.mk +1 -1
index 769e4a51ca0..dd61ffd98e8 100644
@@ -8,7 +8,7 @@
  # Create Qualcomm signed elf images
  CMD_MKMBN = $(srctree)/tools/qcom/mkmbn/mkmbn.py
  quiet_cmd_mkmbn = MBN     $@
-      cmd_mkmbn = $(CMD_MKMBN) $<
+      cmd_mkmbn = $(CMD_MKMBN) -l $(CONFIG_TEXT_BASE) $<
 
  u-boot.mbn: u-boot.bin FORCE
  	$(call if_changed,mkmbn)
tools/qcom/mkmbn/mkmbn.py +10 -10
index 8d2078acc30..6fe66fc4e55 100755
@@ -18,6 +18,8 @@ import sys
  from enum import Enum
  import struct
 
+MBN_ALIGN_SIZE = 4096
+
  verbose = False
 
  def log(*args, **kwargs):
@@ -63,19 +65,17 @@ class MbnData:
 
 
  """
-This dictionary is used to map a board or platform to the appropriate load address and
-other MBN metadata. When adding support for a new platform to U-Boot, the appropriate
-data should be filled out here. The load address can typically be determined by looking
-at the uefi.elf or xbl.elf for the platform. For the uefi.elf it is the load address, and
-for xbl.elf it is typically the RWX section in the middle, just BEFORE the section loaded
-at 0x1495xxxx or similar. Looking at similar platforms in the table below may help.
+This dictionary is used to map a board or platform to the appropriate MBN
+metadata. When adding support for a new platform to U-Boot, the appropriate data
+should be filled out here. Looking at similar platforms in the table below may
+help.
  """
  boards: dict[bytes, MbnData] = {
      # Exact matches for boards, these are preferred
-    b"qcom,qcs6490-rb3gen2\0": MbnData(0x9FC00000, 6, SwId.uefi),
-    b"qcom,qcs9100-ride-r3\0": MbnData(0xAF000000, 6, SwId.uefi),  # Dragonwing IQ9
-    b"qcom,qcs8300-ride\0": MbnData(0xAF000000, 6, SwId.uefi),  # Dragonwing IQ8
-    b"qcom,qcs615-ride\0": MbnData(0x9FC00000, 6, SwId.uefi),  # Dragonwing IQ6
+    b"qcom,qcs6490-rb3gen2\0": MbnData(6, SwId.uefi),
+    b"qcom,qcs9100-ride-r3\0": MbnData(6, SwId.uefi),  # Dragonwing IQ9
+    b"qcom,qcs8300-ride\0": MbnData(6, SwId.uefi),  # Dragonwing IQ8
+    b"qcom,qcs615-ride\0": MbnData(6, SwId.uefi),  # Dragonwing IQ6
      # Fallback/generic matches since most boards for a platform will
      # use the same load address
      b"qcom,qcm6490\0": MbnData(0x9FC00000, 6, SwId.uefi),  # rb3gen2, rubikpi3

tools/qcom/mkmbn/mkmbn.py boards: dict[bytes, MbnData] = { · line 85

Quoted 1 line
tools/qcom/mkmbn/mkmbn.py +0 -0
@@ -85,6 +85,7 @@ boards: dict[bytes, MbnData] = {
      b"qcom,sm8550\0": MbnData(0xA7000000, 7, SwId.uefi),  # C8550

Can't we remove the load address from MbnData for non-IQ targets also? Pls tell if i miss anything.

Regards,

Balaji

Quoted 36 lines
tools/qcom/mkmbn/mkmbn.py +14 -0
      b"qcom,sm8650\0": MbnData(0xA7000000, 7, SwId.uefi),  # SM8650
      b"qcom,qcs615\0": MbnData(0x9FC00000, 6, SwId.uefi),  # Dragonwing IQ6
+    b"qcom,ipq5210\0": MbnData(0x87980000, 7, SwId.aboot),
      b"qcom,ipq5424\0": MbnData(0x8a380000, 7, SwId.aboot),
      b"qcom,ipq9574\0": MbnData(0x4A240000, 6, SwId.aboot),
 
@@ -100,6 +101,9 @@ parser = argparse.ArgumentParser(
  """
  )
  parser.register("type", "hex", lambda s: int(s, 16))
+parser.add_argument(
+    "-l", "--load", type=lambda x: int(x, 0), default=0, help="Load address"
+)
  parser.add_argument(
      "-o", "--output", type=Path, default="u-boot.mbn", help="Output file"
  )
@@ -149,8 +153,18 @@ if not mbn:
      args.output.unlink(missing_ok=True)
      exit(1)
 
+if args.load == 0:
+    error(
+        "Cannot proceed without load address.\n"
+        "Ensure CONFIG_TEXT_BASE/CONFIG_SPL_TEXT_BASE is set\n")
+    exit(1)
+else:
+    mbn.loadaddr = args.load
+
  log(f"Detected board {match.decode('UTF-8')} with load address {mbn.loadaddr:#x}")
 
+data += b'\x00' * (-len(data) % MBN_ALIGN_SIZE)
+
  elf.phdrs.append(Phdr.from_bin(data, mbn.loadaddr))
  elf.ehdr.e_entry = mbn.loadaddr
  elf.update()
#6 lore raw

PATCH v2 4/4 tools: qcom: mkmbn: Add support to create multi-elf

In reply to Varadarajan Narayanan

Add a command line argument to take a list of files to be combined to create a multi-elf expected by the boot rom.

---
 tools/qcom/mkmbn/mkmbn.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/qcom/mkmbn/mkmbn.py +15 -0
index 6fe66fc4e55..6b0ea3a4239 100755
@@ -104,6 +104,9 @@ parser.register("type", "hex", lambda s: int(s, 16))
 parser.add_argument(
     "-l", "--load", type=lambda x: int(x, 0), default=0, help="Load address"
 )
+parser.add_argument(
+    "-m", "--melfs", nargs='+', default=[], help="List of ELFs to include in multi-elf"
+)
 parser.add_argument(
     "-o", "--output", type=Path, default="u-boot.mbn", help="Output file"
 )
@@ -116,6 +119,18 @@ parser.add_argument(
 args = parser.parse_args()
 verbose = args.verbose
 
+if (len(args.melfs)):
+    try:
+        with open(args.output, "wb") as f:
+            for path in args.melfs:
+                with open(path, 'rb') as tmp:
+                    f.write(tmp.read())
+    except Exception as e:
+        print(f"Error: {e}")
+        sys.exit(1)
+
+    sys.exit(0)
+
 elf = Elf()
 
 data: bytes = args.bin.read()
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v2 4/4] tools: qcom: mkmbn: Add support to create multi-elf

Hi Varadarajan,

Quoted 13 lines · Varadarajan Narayanan

Add a command line argument to take a list of files to be combined to create a multi-elf expected by the boot rom.

---
  tools/qcom/mkmbn/mkmbn.py | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
tools/qcom/mkmbn/mkmbn.py +0 -0
index 6fe66fc4e55..6b0ea3a4239 100755

tools/qcom/mkmbn/mkmbn.py parser.register("type", "hex", lambda s: int(s, 16)) · line 109

Quoted 6 lines
tools/qcom/mkmbn/mkmbn.py +3 -0
@@ -104,6 +104,9 @@ parser.register("type", "hex", lambda s: int(s, 16))
  parser.add_argument(
      "-l", "--load", type=lambda x: int(x, 0), default=0, help="Load address"
  )
+parser.add_argument(
+    "-m", "--melfs", nargs='+', default=[], help="List of ELFs to include in multi-elf"
+)

In cover letter, in v2 changelog its mentioned: "

Remove '--melfs' option and make them positional

",

but here we are adding it. Request to say if this correct.

Regards,

Balaji

Quoted 23 lines
tools/qcom/mkmbn/mkmbn.py +12 -0
  parser.add_argument(
      "-o", "--output", type=Path, default="u-boot.mbn", help="Output file"
  )
@@ -116,6 +119,18 @@ parser.add_argument(
  args = parser.parse_args()
  verbose = args.verbose
 
+if (len(args.melfs)):
+    try:
+        with open(args.output, "wb") as f:
+            for path in args.melfs:
+                with open(path, 'rb') as tmp:
+                    f.write(tmp.read())
+    except Exception as e:
+        print(f"Error: {e}")
+        sys.exit(1)
+
+    sys.exit(0)
+
  elf = Elf()
 
  data: bytes = args.bin.read()