From 4bdc2320a48cd2131fcf7fb3395a2b21002340db Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Tue, 12 Apr 2022 16:54:34 -0600 Subject: [PATCH] util/apcb/apcb_v3_edit.py: Edit APCB based on different SPD magic APCB edit tool edits APCBs with LP4 specific SPDs. Introduce an option to support different SPD magic so that the tool can be used to edit APCBs with LP5 specific SPDs. BUG=None TEST=Build Skyrim board with LP5 specific SPDs. Build Guybrush board with LP4 specific SPDs. Signed-off-by: Karthikeyan Ramasubramanian Change-Id: I8e96c89e4e5ce8e0567a17bf7685b69080fa1708 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63598 Reviewed-by: Raul Rangel Reviewed-by: Rob Barnes Tested-by: build bot (Jenkins) --- util/apcb/apcb_v3_edit.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/util/apcb/apcb_v3_edit.py b/util/apcb/apcb_v3_edit.py index 9a70bace3e..140b23238c 100755 --- a/util/apcb/apcb_v3_edit.py +++ b/util/apcb/apcb_v3_edit.py @@ -14,8 +14,10 @@ import os # Byte 0 = 0x23 = 512 bytes total / 384 bytes used # Byte 1 = 0x11 = Revision 1.1 # Byte 2 = 0x11 = LPDDR4X SDRAM +# = 0x13 = LP5 SDRAM # Byte 3 = 0x0E = Non-DIMM Solution -SPD_MAGIC = bytes.fromhex('2311110E') +LP4_SPD_MAGIC = bytes.fromhex('2311110E') +LP5_SPD_MAGIC = bytes.fromhex('2311130E') EMPTY_SPD = b'\x00' * 512 spd_ssp_struct_fmt = '??B?IIBBBxIIBBBx' @@ -47,6 +49,11 @@ def parseargs(): '--spd_sources', nargs='+', help='List of SPD sources') + parser.add_argument( + '--mem_type', + type=str, + default='lp4', + help='Memory type [lp4|lp5]. Default = lp4') return parser.parse_args() @@ -62,6 +69,8 @@ def inject(orig, insert, offset): def main(): + spd_magic = LP4_SPD_MAGIC + args = parseargs() print(f'Reading input APCB from {args.apcb_in}') @@ -75,6 +84,9 @@ def main(): print(f'Using SPD Sources = {args.spd_sources}') + if args.mem_type == 'lp5': + spd_magic = LP5_SPD_MAGIC + spds = [] for spd_source in args.spd_sources: with open(spd_source, 'rb') as f: @@ -85,7 +97,7 @@ def main(): spd_offset = 0 instance = 0 while True: - spd_offset = apcb.find(SPD_MAGIC, spd_offset) + spd_offset = apcb.find(spd_magic, spd_offset) if spd_offset < 0: print('No more SPD magic numbers in APCB') break