<p>Evan Green has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/25640">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/qualcomm: Add updated qgpt.py script.<br><br>I'm not sure exactly which pieces of this changed script are truly<br>needed, but this script works for booting from SPI on Cheza.<br><br>BUG=b:74020650<br>TEST=Booting Cheza from SPI flash now works.<br><br>Change-Id: I1d5fd7aaa667d3fc9f10974f704c37ad38911a61<br>---<br>M util/qualcomm/qgpt.py<br>1 file changed, 2 insertions(+), 61 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/25640/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/util/qualcomm/qgpt.py b/util/qualcomm/qgpt.py</span><br><span>index 0f79290..f561eee 100755</span><br><span>--- a/util/qualcomm/qgpt.py</span><br><span>+++ b/util/qualcomm/qgpt.py</span><br><span>@@ -1,40 +1,4 @@</span><br><span> #!/usr/bin/python</span><br><span style="color: hsl(0, 100%, 40%);">-#============================================================================</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span style="color: hsl(0, 100%, 40%);">-#/** @file qgpt.py</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span style="color: hsl(0, 100%, 40%);">-# GENERAL DESCRIPTION</span><br><span style="color: hsl(0, 100%, 40%);">-#   Generates QCom GPT header/tail for wrapping Bootblock</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span style="color: hsl(0, 100%, 40%);">-# Copyright (c) 2018, The Linux Foundation. All rights reserved.</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span style="color: hsl(0, 100%, 40%);">-# Redistribution and use in source and binary forms, with or without</span><br><span style="color: hsl(0, 100%, 40%);">-# modification, are permitted provided that the following conditions are</span><br><span style="color: hsl(0, 100%, 40%);">-# met:</span><br><span style="color: hsl(0, 100%, 40%);">-#     * Redistributions of source code must retain the above copyright</span><br><span style="color: hsl(0, 100%, 40%);">-#       notice, this list of conditions and the following disclaimer.</span><br><span style="color: hsl(0, 100%, 40%);">-#     * Redistributions in binary form must reproduce the above</span><br><span style="color: hsl(0, 100%, 40%);">-#       copyright notice, this list of conditions and the following</span><br><span style="color: hsl(0, 100%, 40%);">-#       disclaimer in the documentation and/or other materials provided</span><br><span style="color: hsl(0, 100%, 40%);">-#       with the distribution.</span><br><span style="color: hsl(0, 100%, 40%);">-#     * Neither the name of The Linux Foundation nor the names of its</span><br><span style="color: hsl(0, 100%, 40%);">-#       contributors may be used to endorse or promote products derived</span><br><span style="color: hsl(0, 100%, 40%);">-#       from this software without specific prior written permission.</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span style="color: hsl(0, 100%, 40%);">-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED</span><br><span style="color: hsl(0, 100%, 40%);">-# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF</span><br><span style="color: hsl(0, 100%, 40%);">-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT</span><br><span style="color: hsl(0, 100%, 40%);">-# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS</span><br><span style="color: hsl(0, 100%, 40%);">-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span><br><span style="color: hsl(0, 100%, 40%);">-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF</span><br><span style="color: hsl(0, 100%, 40%);">-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR</span><br><span style="color: hsl(0, 100%, 40%);">-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span><br><span style="color: hsl(0, 100%, 40%);">-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE</span><br><span style="color: hsl(0, 100%, 40%);">-# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN</span><br><span style="color: hsl(0, 100%, 40%);">-# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span style="color: hsl(0, 100%, 40%);">-#**/</span><br><span style="color: hsl(0, 100%, 40%);">-#</span><br><span> </span><br><span> import os</span><br><span> import math</span><br><span>@@ -42,7 +6,6 @@</span><br><span> import re</span><br><span> import struct</span><br><span> import sys</span><br><span style="color: hsl(0, 100%, 40%);">-import tempfile</span><br><span> </span><br><span> from optparse import OptionParser</span><br><span> from types import *</span><br><span>@@ -237,7 +200,7 @@</span><br><span>     PrimaryGPT[i + 6] = 0xFF                  # sector</span><br><span>     PrimaryGPT[i + 7] = 0xFF                  # cylinder</span><br><span>     PrimaryGPT[i + 8:i + 8 + 4] = [0x01, 0x00, 0x00, 0x00]  # starting sector</span><br><span style="color: hsl(0, 100%, 40%);">-    PrimaryGPT[i + 12:i + 12 + 4] = [0xFF, 0xFF, 0xFF, 0xFF]  # starting sector</span><br><span style="color: hsl(120, 100%, 40%);">+    PrimaryGPT[i + 12:i + 12 + 4] = [0xFF, 0x0F, 0x00, 0x00]  # starting sector</span><br><span> </span><br><span>     # magic byte for MBR partitioning - always at this location regardless of</span><br><span>     # options.sector</span><br><span>@@ -406,7 +369,7 @@</span><br><span>         parser.print_help()</span><br><span>         sys.exit(1)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    options.inputfile = args[0]</span><br><span style="color: hsl(120, 100%, 40%);">+    options.image = args[0]</span><br><span> </span><br><span>     if options.advance_format is True:</span><br><span>         options.sector = 4096</span><br><span>@@ -419,15 +382,6 @@</span><br><span>     if options.type is None:</span><br><span>         options.type = 'DEA0BA2C-CBDD-4805-B4F9-F428251C3E98'</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    #create temp file, this will be deleted later</span><br><span style="color: hsl(0, 100%, 40%);">-    fout_fill = tempfile.NamedTemporaryFile()</span><br><span style="color: hsl(0, 100%, 40%);">-    options.image = fout_fill.name</span><br><span style="color: hsl(0, 100%, 40%);">-    fout_fill.close()</span><br><span style="color: hsl(0, 100%, 40%);">-    fout_fill = openfile(options.image, 'wb')</span><br><span style="color: hsl(0, 100%, 40%);">-    #96768 is for SD boot, this value will differ for SPI-NOR</span><br><span style="color: hsl(0, 100%, 40%);">-    fout_fill.write('\0' * 96768)</span><br><span style="color: hsl(0, 100%, 40%);">-    fout_fill.close()</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>     if os.path.isfile(options.image) == False:</span><br><span>         print("Invalid file name. Exiting...\n")</span><br><span>         parser.print_help()</span><br><span>@@ -445,16 +399,3 @@</span><br><span>     createGPTPartionTable(options)</span><br><span> </span><br><span>     createOut(options)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    bb_statinfo = os.stat(options.image)</span><br><span style="color: hsl(0, 100%, 40%);">-    file_bb= openfile(options.inputfile, 'r+')</span><br><span style="color: hsl(0, 100%, 40%);">-    bb_buffer = file_bb.read(statinfo.st_size)</span><br><span style="color: hsl(0, 100%, 40%);">-    file_gpt= open(options.out, 'rb+')</span><br><span style="color: hsl(0, 100%, 40%);">-    #17408 is for SD boot, this value will differ for SPI-NOR</span><br><span style="color: hsl(0, 100%, 40%);">-    file_gpt.seek(17408)</span><br><span style="color: hsl(0, 100%, 40%);">-    file_gpt.write(bb_buffer)</span><br><span style="color: hsl(0, 100%, 40%);">-    file_gpt.close()</span><br><span style="color: hsl(0, 100%, 40%);">-    file_bb.close()</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    # Delete Temp File</span><br><span style="color: hsl(0, 100%, 40%);">-    os.unlink(fout_fill.name)</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25640">change 25640</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/25640"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1d5fd7aaa667d3fc9f10974f704c37ad38911a61 </div>
<div style="display:none"> Gerrit-Change-Number: 25640 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Evan Green <evgreen@chromium.org> </div>