summaryrefslogtreecommitdiff
path: root/l-loader
diff options
context:
space:
mode:
Diffstat (limited to 'l-loader')
-rw-r--r--l-loader/.gitignore3
-rw-r--r--l-loader/COPYING25
-rw-r--r--l-loader/Makefile15
-rw-r--r--l-loader/README.md6
-rwxr-xr-xl-loader/gen_loader.py268
-rwxr-xr-xl-loader/gen_loader_hikey.py184
-rwxr-xr-xl-loader/generate_ptable.sh195
-rw-r--r--l-loader/hikey.mk31
-rw-r--r--l-loader/hikey960.mk19
-rw-r--r--l-loader/l-loader.lds32
-rwxr-xr-xl-loader/recovery-fastboot.binbin39816 -> 0 bytes
-rw-r--r--l-loader/start.S100
12 files changed, 0 insertions, 878 deletions
diff --git a/l-loader/.gitignore b/l-loader/.gitignore
deleted file mode 100644
index b282a0e1..00000000
--- a/l-loader/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/*.o
-/*.img
-/*.bin
diff --git a/l-loader/COPYING b/l-loader/COPYING
deleted file mode 100644
index 4ad3f200..00000000
--- a/l-loader/COPYING
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2014-2016, Linaro Ltd. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-* Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/l-loader/Makefile b/l-loader/Makefile
deleted file mode 100644
index 5331c399..00000000
--- a/l-loader/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-.PHONY: hikey
-hikey:
- $(MAKE) -f hikey.mk
-
-.PHONY: hikey-clean
-hikey-clean:
- $(MAKE) -f hikey.mk clean
-
-.PHONY: hikey960
-hikey960:
- $(MAKE) -f hikey960.mk
-
-.PHONY: hikey960-clean
-hikey960-clean:
- $(MAKE) -f hikey960.mk clean
diff --git a/l-loader/README.md b/l-loader/README.md
deleted file mode 100644
index e5dcd990..00000000
--- a/l-loader/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# l-loader
-
-Used to switch from aarch32 to aarch64 and boot. First image to be flashed
-when in recovery mode.
-
-HiKey specific.
diff --git a/l-loader/gen_loader.py b/l-loader/gen_loader.py
deleted file mode 100755
index 2d763ca9..00000000
--- a/l-loader/gen_loader.py
+++ /dev/null
@@ -1,268 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import os.path
-import sys, getopt
-import binascii
-import struct
-import string
-
-class generator(object):
- #
- # struct l_loader_head {
- # unsigned int first_instr;
- # unsigned char magic[16]; @ BOOTMAGICNUMBER!
- # unsigned int l_loader_start;
- # unsigned int l_loader_end;
- # };
- file_header = [0, 0, 0, 0, 0, 0, 0]
-
- #
- # struct entry_head {
- # unsigned char magic[8]; @ ENTY
- # unsigned char name[8]; @ loader/bl1
- # unsigned int start_lba;
- # unsigned int count_lba;
- # unsigned int flag; @ boot partition or not
- # };
-
- s1_entry_name = ['loader', 'bl1']
- s2_entry_name = ['primary', 'second']
-
- block_size = 512
-
- stage = 0
-
- # set in self.add()
- idx = 0
-
- # set in self.parse()
- ptable_lba = 0
- stable_lba = 0
-
- # file pointer
- p_entry = 0
- p_file = 0
-
- def __init__(self, out_img):
- try:
- self.fp = open(out_img, "wb+")
- except IOError, e:
- print "*** file open error:", e
- sys.exit(3)
- else:
- self.entry_hd = [[0 for col in range(7)] for row in range(5)]
-
- def __del__(self):
- self.fp.close()
-
- # parse partition from the primary ptable
- def parse(self, fname):
- try:
- fptable = open(fname, "rb")
- except IOError, e:
- print "*** file open error:", e
- sys.exit(3)
- else:
- # skip the first block in primary partition table
- # that is MBR protection information
- fptable.read(self.block_size)
- # check whether it's a primary paritition table
- data = struct.unpack("8s", fptable.read(8))
- efi_magic = 'EFI PART'
- if cmp("EFI PART", data[0]):
- print "It's not partition table image."
- fptable.close()
- sys.exit(4)
- # skip 16 bytes
- fptable.read(16)
- # get lba of both primary partition table and secondary partition table
- data = struct.unpack("QQQQ", fptable.read(32))
- self.ptable_lba = data[0] - 1
- self.stable_lba = data[3] + 1
- # skip 24 bytes
- fptable.read(24)
- data = struct.unpack("i", fptable.read(4))
- pentries = data[0]
- # skip the reset in this block
- fptable.read(self.block_size - 84)
-
- for i in range(1, pentries):
- # name is encoded as UTF-16
- d0,lba,d2,name = struct.unpack("32sQ16s72s", fptable.read(128))
- plainname = unicode(name, "utf-16")
- if (not cmp(plainname[0:7], 'l-loader'[0:7])):
- print 'bl1_lba: ', lba
- self.bl1_lba = lba
- sys.exit(1)
-
- fptable.close()
-
- def add(self, lba, fname):
- try:
- fsize = os.path.getsize(fname)
- except IOError, e:
- print "*** file open error:", e
- sys.exit(4)
- else:
- blocks = (fsize + self.block_size - 1) / self.block_size
- if (self.stage == 1):
- # Boot Area1 in eMMC
- bootp = 1
- if self.idx == 0:
- self.p_entry = 28
- elif (self.stage == 2):
- # User Data Area in eMMC
- bootp = 0
- # create an empty block only for stage2
- # This empty block is used to store entry head
- print 'p_file: ', self.p_file, 'p_entry: ', self.p_entry
- if self.idx == 0:
- self.fp.seek(self.p_file)
- for i in range (0, self.block_size):
- zero = struct.pack('x')
- self.fp.write(zero)
- self.p_file += self.block_size
- self.p_entry = 0
- else:
- print "wrong stage ", stage, "is specified"
- sys.exit(4)
- # Maybe the file size isn't aligned. So pad it.
- if (self.idx == 0) and (self.stage == 1):
- if fsize > 2048:
- print 'loader size exceeds 2KB. file size: ', fsize
- sys.exit(4)
- else:
- left_bytes = 2048 - fsize
- else:
- left_bytes = fsize % self.block_size
- if left_bytes:
- left_bytes = self.block_size - left_bytes
- print 'lba: ', lba, 'blocks: ', blocks, 'bootp: ', bootp, 'fname: ', fname
- # write images
- fimg = open(fname, "rb")
- for i in range (0, blocks):
- buf = fimg.read(self.block_size)
- self.fp.seek(self.p_file)
- self.fp.write(buf)
- # p_file is the file pointer of the new binary file
- # At last, it means the total block size of the new binary file
- self.p_file += self.block_size
-
- if (self.idx == 0) and (self.stage == 1):
- self.p_file = 2048
- print 'p_file: ', self.p_file, 'last block is ', fsize % self.block_size, 'bytes', ' tell: ', self.fp.tell(), 'left_bytes: ', left_bytes
- if left_bytes:
- for i in range (0, left_bytes):
- zero = struct.pack('x')
- self.fp.write(zero)
- print 'p_file: ', self.p_file, ' pad to: ', self.fp.tell()
-
- # write entry information at the header
- if self.stage == 1:
- byte = struct.pack('8s8siii', 'ENTRYHDR', self.s1_entry_name[self.idx], lba, blocks, bootp)
- elif self.stage == 2:
- byte = struct.pack('8s8siii', 'ENTRYHDR', self.s2_entry_name[self.idx], lba, blocks, bootp)
- self.fp.seek(self.p_entry)
- self.fp.write(byte)
- self.p_entry += 28
- self.idx += 1
-
- fimg.close()
-
- def hex2(self, data):
- return data > 0 and hex(data) or hex(data & 0xffffffff)
-
- def end(self):
- if self.stage == 1:
- self.fp.seek(20)
- start,end = struct.unpack("ii", self.fp.read(8))
- print "start: ", self.hex2(start), 'end: ', self.hex2(end)
- end = start + self.p_file
- print "start: ", self.hex2(start), 'end: ', self.hex2(end)
- self.fp.seek(24)
- byte = struct.pack('i', end)
- self.fp.write(byte)
- self.fp.close()
-
- def create_stage1(self, img_loader, img_bl1, output_img):
- print '+-----------------------------------------------------------+'
- print ' Input Images:'
- print ' loader: ', img_loader
- print ' bl1: ', img_bl1
- print ' Ouput Image: ', output_img
- print '+-----------------------------------------------------------+\n'
-
- self.stage = 1
-
- # The first 2KB is reserved
- # The next 2KB is for loader image
- self.add(4, img_loader) # img_loader doesn't exist in partition table
- print 'self.idx: ', self.idx
- # bl1.bin starts from 4KB
- self.add(8, img_bl1) # img_bl1 doesn't exist in partition table
-
- def create_stage2(self, img_prm_ptable, img_sec_ptable, output_img):
- print '+-----------------------------------------------------------+'
- print ' Input Images:'
- print ' primary partition table: ', img_prm_ptable
- print ' secondary partition table: ', img_sec_ptable
- print ' Ouput Image: ', output_img
- print '+-----------------------------------------------------------+\n'
-
- self.stage = 2
- self.parse(img_prm_ptable)
- self.add(self.ptable_lba, img_prm_ptable)
- if (cmp(img_sec_ptable, 'secondary partition table')):
- # Doesn't match. It means that secondary ptable is specified.
- self.add(self.stable_lba, img_sec_ptable)
- else:
- print 'Don\'t need secondary partition table'
-
-def main(argv):
- stage1 = 0
- stage2 = 0
- img_prm_ptable = "primary partition table"
- img_sec_ptable = "secondary partition table"
- try:
- opts, args = getopt.getopt(argv,"ho:",["img_loader=","img_bl1=","img_prm_ptable=","img_sec_ptable="])
- except getopt.GetoptError:
- print 'gen_loader.py -o <l-loader.bin> --img_loader <l-loader> --img_bl1 <bl1.bin> --img_prm_ptable <prm_ptable.img> --img_sec_ptable <sec_ptable.img>'
- sys.exit(2)
- for opt, arg in opts:
- if opt == '-h':
- print 'gen_loader.py -o <l-loader.bin> --img_loader <l-loader> --img_bl1 <bl1.bin> --img_prm_ptable <prm_ptable.img> --img_sec_ptable <sec_ptable.img>'
- sys.exit(1)
- elif opt == '-o':
- output_img = arg
- elif opt in ("--img_loader"):
- img_loader = arg
- stage1 = 1
- elif opt in ("--img_bl1"):
- img_bl1 = arg
- stage1 = 1
- elif opt in ("--img_prm_ptable"):
- img_prm_ptable = arg
- stage2 = 1
- elif opt in ("--img_sec_ptable"):
- img_sec_ptable = arg
-
- loader = generator(output_img)
- loader.idx = 0
-
- if (stage1 == 1) and (stage2 == 1):
- print 'There are only loader & BL1 in stage1.'
- print 'And there are primary partition table, secondary partition table and FIP in stage2.'
- sys.exit(1)
- elif (stage1 == 0) and (stage2 == 0):
- print 'No input images are specified.'
- sys.exit(1)
- elif stage1 == 1:
- loader.create_stage1(img_loader, img_bl1, output_img)
- elif stage2 == 1:
- loader.create_stage2(img_prm_ptable, img_sec_ptable, output_img)
-
- loader.end()
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/l-loader/gen_loader_hikey.py b/l-loader/gen_loader_hikey.py
deleted file mode 100755
index a07eb986..00000000
--- a/l-loader/gen_loader_hikey.py
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import os.path
-import sys, getopt
-import binascii
-import struct
-import string
-
-# --------------------------
-# | loader | BL1 | NS BL1U |
-# --------------------------
-
-class generator(object):
- #
- # struct l_loader_head {
- # unsigned int first_instr;
- # unsigned char magic[16]; @ BOOTMAGICNUMBER!
- # unsigned int l_loader_start; @ start of loader
- # unsigned int l_loader_end; @ end of BL1 (without ns_bl1u)
- # };
- file_header = [0, 0, 0, 0, 0, 0, 0]
-
- #
- # struct entry_head {
- # unsigned char magic[8]; @ ENTY
- # unsigned char name[8]; @ loader/bl1/ns_bl1u
- # unsigned int start_lba;
- # unsigned int count_lba;
- # unsigned int flag; @ boot partition or not
- # };
- # size of struct entry_head is 28
- #
-
- s1_entry_name = ['loader', 'bl1', 'ns_bl1u']
-
- block_size = 512
-
- # set in self.add()
- idx = 0
-
- # file pointer
- p_entry = 0 # pointer in header
- p_file = 0 # pointer in file
- p_loader_end = 0 # pointer in header
-
- def __init__(self, out_img):
- try:
- self.fp = open(out_img, "wb+")
- except IOError, e:
- print "*** file open error:", e
- sys.exit(3)
- else:
- self.entry_hd = [[0 for col in range(7)] for row in range(5)]
-
- def __del__(self):
- self.fp.close()
-
- def add(self, lba, fname):
- try:
- fsize = os.path.getsize(fname)
- except IOError, e:
- print "*** file open error:", e
- sys.exit(4)
- else:
- blocks = (fsize + self.block_size - 1) / self.block_size
- # Boot Area1 in eMMC
- bootp = 1
- if self.idx == 0:
- # both loader and bl1.bin locates in l-loader.bin bias 2KB
- self.p_entry = 28
- elif (self.idx > 1):
- # image: ns_bl1u
- # Record the end of loader & BL1. ns_bl1u won't be loaded by BootROM.
- self.p_loader_end = self.p_file
- # ns_bl1u should locates in l-loader.bin bias 2KB too
- if (self.p_file < (lba * self.block_size - 2048)):
- self.p_file = lba * self.block_size - 2048
-
- # Maybe the file size isn't aligned. So pad it.
- if (self.idx == 0):
- if fsize > 2048:
- print 'loader size exceeds 2KB. file size: ', fsize
- sys.exit(4)
- else:
- left_bytes = 2048 - fsize
- else:
- left_bytes = fsize % self.block_size
- if left_bytes:
- left_bytes = self.block_size - left_bytes
- print 'lba: ', lba, 'blocks: ', blocks, 'bootp: ', bootp, 'fname: ', fname
- # write images
- fimg = open(fname, "rb")
- for i in range (0, blocks):
- buf = fimg.read(self.block_size)
- # loader's p_file is 0 at here
- self.fp.seek(self.p_file)
- self.fp.write(buf)
- # p_file is the file pointer of the new binary file
- # At last, it means the total block size of the new binary file
- self.p_file += self.block_size
-
- if (self.idx == 0):
- self.p_file = 2048
- print 'p_file: ', self.p_file, 'last block is ', fsize % self.block_size, 'bytes', ' tell: ', self.fp.tell(), 'left_bytes: ', left_bytes
- if left_bytes:
- for i in range (0, left_bytes):
- zero = struct.pack('x')
- self.fp.write(zero)
- print 'p_file: ', self.p_file, ' pad to: ', self.fp.tell()
-
- # write entry information at the header
- byte = struct.pack('8s8siii', 'ENTRYHDR', self.s1_entry_name[self.idx], lba, blocks, bootp)
- self.fp.seek(self.p_entry)
- self.fp.write(byte)
- self.p_entry += 28
- self.idx += 1
-
- fimg.close()
-
- def hex2(self, data):
- return data > 0 and hex(data) or hex(data & 0xffffffff)
-
- def end(self):
- self.fp.seek(20)
- start,end = struct.unpack("ii", self.fp.read(8))
- print "start: ", self.hex2(start), 'end: ', self.hex2(end)
- end = start + self.p_loader_end
- print "start: ", self.hex2(start), 'end: ', self.hex2(end)
- self.fp.seek(24)
- byte = struct.pack('i', end)
- self.fp.write(byte)
- self.fp.close()
-
- def create(self, img_loader, img_bl1, img_ns_bl1u, output_img):
- print '+-----------------------------------------------------------+'
- print ' Input Images:'
- print ' loader: ', img_loader
- print ' bl1: ', img_bl1
- print ' ns_bl1u: ', img_ns_bl1u
- print ' Ouput Image: ', output_img
- print '+-----------------------------------------------------------+\n'
-
- self.stage = 1
-
- # The first 2KB is reserved
- # The next 2KB is for loader image
- self.add(4, img_loader)
- print 'self.idx: ', self.idx
- # bl1.bin starts from 4KB
- self.add(8, img_bl1)
- if img_ns_bl1u != 0:
- # ns_bl1u.bin starts from 96KB
- self.add(192, img_ns_bl1u)
-
-def main(argv):
- img_ns_bl1u = 0
- try:
- opts, args = getopt.getopt(argv,"ho:",["img_loader=","img_bl1=","img_ns_bl1u="])
- except getopt.GetoptError:
- print 'gen_loader.py -o <l-loader.bin> --img_loader <l-loader> --img_bl1 <bl1.bin> --img_ns_bl1u <ns_bl1u.bin>'
- sys.exit(2)
- for opt, arg in opts:
- if opt == '-h':
- print 'gen_loader.py -o <l-loader.bin> --img_loader <l-loader> --img_bl1 <bl1.bin> --img_ns_bl1u <ns_bl1u.bin>'
- sys.exit(1)
- elif opt == '-o':
- output_img = arg
- elif opt in ("--img_loader"):
- img_loader = arg
- elif opt in ("--img_bl1"):
- img_bl1 = arg
- elif opt in ("--img_ns_bl1u"):
- img_ns_bl1u = arg
-
- loader = generator(output_img)
- loader.idx = 0
-
- loader.create(img_loader, img_bl1, img_ns_bl1u, output_img)
-
- loader.end()
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/l-loader/generate_ptable.sh b/l-loader/generate_ptable.sh
deleted file mode 100755
index f8a6a207..00000000
--- a/l-loader/generate_ptable.sh
+++ /dev/null
@@ -1,195 +0,0 @@
-#!/bin/sh
-#
-# Generate partition table for HiKey eMMC or HiKey960 UFS
-#
-# tiny: for testing purpose.
-# aosp: (same as linux with userdata).
-# linux: (same as aosp without userdata).
-# swap: (similar to asop, drop reserved, 1.5G of swap)
-
-PTABLE=${PTABLE:-aosp}
-SECTOR_SIZE=${SECTOR_SIZE:-512}
-SGDISK=${SGDISK:-sgdisk}
-TEMP_FILE=$(mktemp /tmp/${PTABLE}.XXXXXX)
-# 128 entries at most
-ENTRIES_IN_SECTOR=$(expr ${SECTOR_SIZE} / 128)
-ENTRY_SECTORS=$(expr 128 / ${ENTRIES_IN_SECTOR})
-PRIMARY_SECTORS=$(expr ${ENTRY_SECTORS} + 2)
-SECONDARY_SECTORS=$(expr ${ENTRY_SECTORS} + 1)
-
-case ${PTABLE} in
- tiny)
- SECTOR_NUMBER=81920
- ;;
- aosp-4g|linux-4g)
- SECTOR_NUMBER=7471104
- ;;
- aosp-8g|linux-8g|swap-8g)
- SECTOR_NUMBER=15269888
- ;;
- aosp-32g*|linux-32g)
- SECTOR_NUMBER=62447650 # count with 512-byte block size
- ;;
- aosp-64g|linux-64g)
- SECTOR_NUMBER=124895300 # count with 512-byte block size
- ;;
-esac
-
-SECTOR_ALIGNMENT=$(expr ${SECTOR_SIZE} / 512)
-SECTOR_NUMBER=$(expr '(' ${SECTOR_NUMBER} '*' 512 + ${SECTOR_SIZE} - 1 ')' / ${SECTOR_SIZE})
-
-# get the partition table
-case ${PTABLE} in
- tiny)
- dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} conv=sparse
- fakeroot ${SGDISK} -U -R -v ${TEMP_FILE}
- fakeroot ${SGDISK} -n 1:2048:4095 -t 1:0700 -u 1:F9F21F01-A8D4-5F0E-9746-594869AEC3E4 -c 1:"vrl" -p ${TEMP_FILE}
- fakeroot ${SGDISK} -n 2:4096:6143 -t 2:0700 -u 2:F9F21F02-A8D4-5F04-9746-594869AEC3E4 -c 2:"vrl_backup" -p ${TEMP_FILE}
- ;;
- aosp-4g|aosp-8g)
- dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} conv=sparse
- fakeroot ${SGDISK} -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
- #[1: vrl: 1M-2M]
- fakeroot ${SGDISK} -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE}
- #[2: vrl_backup: 2M-3M]
- fakeroot ${SGDISK} -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE}
- #[3: mcuimage: 3M-4M]
- fakeroot ${SGDISK} -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE}
- #[4: fastboot: 4M-12M]
- fakeroot ${SGDISK} -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE}
- #[5: nvme: 12M-14M]
- fakeroot ${SGDISK} -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
- #[6: boot: 14M-78M]
- fakeroot ${SGDISK} -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
- #[7: vendor: 78M-334M]
- fakeroot ${SGDISK} -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"vendor" ${TEMP_FILE}
- #[8: cache: 334M-590M]
- fakeroot ${SGDISK} -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE}
- #[9: system: 590M-2126M]
- fakeroot ${SGDISK} -n 9:0:+1536M -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
- #[10: userdata: 2126M-End]
- fakeroot ${SGDISK} -n -E -t 10:8300 -u 10:064111F6-463B-4CE1-876B-13F3684CE164 -c 10:"userdata" -p ${TEMP_FILE}
- ;;
- linux-4g|linux-8g)
- dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} conv=sparse
- fakeroot ${SGDISK} -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
- #[1: vrl: 1M-2M]
- fakeroot ${SGDISK} -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE}
- #[2: vrl_backup: 2M-3M]
- fakeroot ${SGDISK} -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE}
- #[3: mcuimage: 3M-4M]
- fakeroot ${SGDISK} -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE}
- #[4: fastboot: 4M-12M]
- fakeroot ${SGDISK} -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE}
- #[5: nvme: 12M-14M]
- fakeroot ${SGDISK} -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
- #[6: boot: 14M-78M]
- fakeroot ${SGDISK} -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
- #[7: reserved: 78M-334M]
- fakeroot ${SGDISK} -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"reserved" ${TEMP_FILE}
- #[8: cache: 334M-590M]
- fakeroot ${SGDISK} -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE}
- #[9: system: 590M-End]
- fakeroot ${SGDISK} -n -E -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
- ;;
- swap-8g)
- dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} conv=sparse
- fakeroot ${SGDISK} -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
- #[1: vrl: 1M-2M]
- fakeroot ${SGDISK} -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE}
- #[2: vrl_backup: 2M-3M]
- fakeroot ${SGDISK} -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE}
- #[3: mcuimage: 3M-4M]
- fakeroot ${SGDISK} -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE}
- #[4: fastboot: 4M-12M]
- fakeroot ${SGDISK} -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE}
- #[5: nvme: 12M-14M]
- fakeroot ${SGDISK} -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
- #[6: boot: 14M-78M]
- fakeroot ${SGDISK} -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
- #[7: cache: 78M-384M]
- fakeroot ${SGDISK} -n 7:0:+256M -t 7:8301 -u 7:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 7:"cache" ${TEMP_FILE}
- #[8: swap: 384M-1920M]
- fakeroot ${SGDISK} -n 8:0:+1536M -t 8:8200 -u 8:FC56E344-2E8E-49AE-B2F8-5B9D263FE377 -c 8:"swap" ${TEMP_FILE}
- #[9: system: 1920M-3556M]
- fakeroot ${SGDISK} -n 9:0:+1536M -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
- #[10: userdata: 3556M-End]
- fakeroot ${SGDISK} -n -E -t 10:8300 -u 10:064111F6-463B-4CE1-876B-13F3684CE164 -c 10:"userdata" -p ${TEMP_FILE}
- ;;
- aosp-32g*|aosp-64g)
- dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} conv=sparse
- fakeroot ${SGDISK} -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
- #[1: xloader_reserved1: 1M-2M]
- fakeroot ${SGDISK} -n 1:0:+1M -t 1:0700 -u 1:697c41e0-7a59-4dfa-a9a6-aa43ac5be684 -c 1:"xloader_reserved1" ${TEMP_FILE}
- #[2: fastboot: 2M-14M]
- fakeroot ${SGDISK} -n 2:0:+12M -t 2:0700 -u 2:3f5f8c48-4402-4ace-9058-30bfea4fa53f -c 2:"fastboot" ${TEMP_FILE}
- #[3: nvme: 14M-20M]
- fakeroot ${SGDISK} -n 3:0:+6M -t 3:0700 -u 3:e2f5e2a9-c9b7-4089-9859-4498f1d3ef7e -c 3:"nvme" ${TEMP_FILE}
- #[4: fip: 20M-32M]
- fakeroot ${SGDISK} -n 4:0:+12M -t 3:0700 -u 4:dc1a888e-f17c-4964-92d6-f8fcc402ed8b -c 4:"fip" ${TEMP_FILE}
- #[5: cache: 32M-288M]
- fakeroot ${SGDISK} -n 5:0:+256M -t 5:0700 -u 5:10cc3268-05f0-4db2-aa00-707361427fc8 -c 5:"cache" ${TEMP_FILE}
- #[6: fw_lpm3: 288M-289M]
- fakeroot ${SGDISK} -n 6:0:+1M -t 6:0700 -u 6:5d8481d4-c170-4aa8-9438-8743c73ea8f5 -c 6:"fw_lpm3" ${TEMP_FILE}
- #[7: boot: 289M-353M]
- fakeroot ${SGDISK} -n 7:0:+64M -t 7:EF00 -u 7:d3340696-9b95-4c64-8df6-e6d4548fba41 -c 7:"boot" ${TEMP_FILE}
- #[8: dts: 353M-369M]
- fakeroot ${SGDISK} -n 8:0:+16M -t 8:0700 -u 8:6e53b0bb-fa7e-4206-b607-5ae699e9f066 -c 8:"dts" ${TEMP_FILE}
- #[9: trustfirmware: 369M-371M]
- fakeroot ${SGDISK} -n 9:0:+2M -t 9:0700 -u 9:f1e126a6-ceef-45c1-aace-29f33ac9cf13 -c 9:"trustfirmware" ${TEMP_FILE}
- #[10: system: 371M-5059M]
- fakeroot ${SGDISK} -n 10:0:+4688M -t 10:8300 -u 10:c3e50923-fb85-4153-b925-759614d4dfcd -c 10:"system" ${TEMP_FILE}
- #[11: vendor: 5059M-5843M]
- fakeroot ${SGDISK} -n 11:0:+784M -t 11:0700 -u 11:919d7080-d71a-4ae1-9227-e4585210c837 -c 11:"vendor" ${TEMP_FILE}
- #[12: reserved: 5843M-5844M]
- fakeroot ${SGDISK} -n 12:0:+1M -t 12:0700 -u 12:611eac6b-bc42-4d72-90ac-418569c8e9b8 -c 12:"reserved" ${TEMP_FILE}
- case ${PTABLE} in
- aosp-32g)
- #[13: userdata: 5844M-End]
- fakeroot ${SGDISK} -n -E -t 13:8300 -u 13:fea80d9c-f3e3-45d9-aed0-1d06e4abd77f -c 13:"userdata" ${TEMP_FILE}
- ;;
- aosp-32g-spare)
- #[13: userdata: 5844M-9844M]
- fakeroot ${SGDISK} -n 13:0:+1000M -t 13:8300 -u 13:fea80d9c-f3e3-45d9-aed0-1d06e4abd77f -c 13:"userdata" ${TEMP_FILE}
- #[14: swap: 9844M-End]
- fakeroot ${SGDISK} -n -E -t 14:8300 -u 14:9501eade-20fb-4bc7-83d3-62c1be3ed92d -c 14:"swap" ${TEMP_FILE}
- ;;
- esac
- ;;
- linux-32g|linux-64g)
- dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} conv=sparse
- fakeroot ${SGDISK} -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
- #[1: vrl: 1M-2M]
- fakeroot ${SGDISK} -n 1:0:+1M -t 1:0700 -u 1:697c41e0-7a59-4dfa-a9a6-aa43ac5be684 -c 1:"vrl" ${TEMP_FILE}
- #[2: fastboot: 2M-14M]
- fakeroot ${SGDISK} -n 2:0:+12M -t 2:0700 -u 2:3f5f8c48-4402-4ace-9058-30bfea4fa53f -c 2:"fastboot" ${TEMP_FILE}
- #[3: nvme: 14M-20M]
- fakeroot ${SGDISK} -n 3:0:+6M -t 3:0700 -u 3:e2f5e2a9-c9b7-4089-9859-4498f1d3ef7e -c 3:"nvme" ${TEMP_FILE}
- #[4: fip: 20M-32M]
- fakeroot ${SGDISK} -n 4:0:+12M -t 3:0700 -u 4:dc1a888e-f17c-4964-92d6-f8fcc402ed8b -c 4:"fip" ${TEMP_FILE}
- #[5: cache: 32M-288M]
- fakeroot ${SGDISK} -n 5:0:+256M -t 5:0700 -u 5:10cc3268-05f0-4db2-aa00-707361427fc8 -c 5:"cache" ${TEMP_FILE}
- #[6: fw_lpm3: 288M-289M]
- fakeroot ${SGDISK} -n 6:0:+1M -t 6:0700 -u 6:5d8481d4-c170-4aa8-9438-8743c73ea8f5 -c 6:"fw_lpm3" ${TEMP_FILE}
- #[7: boot: 289M-353M]
- fakeroot ${SGDISK} -n 7:0:+64M -t 7:EF00 -u 7:d3340696-9b95-4c64-8df6-e6d4548fba41 -c 7:"boot" ${TEMP_FILE}
- #[8: dts: 353M-369M]
- fakeroot ${SGDISK} -n 8:0:+16M -t 8:0700 -u 8:6e53b0bb-fa7e-4206-b607-5ae699e9f066 -c 8:"dts" ${TEMP_FILE}
- #[9: trustfirmware: 369M-371M]
- fakeroot ${SGDISK} -n 9:0:+2M -t 9:0700 -u 9:f1e126a6-ceef-45c1-aace-29f33ac9cf13 -c 9:"trustfirmware" ${TEMP_FILE}
- #[10: system: 371M-5059M]
- fakeroot ${SGDISK} -n 10:0:+4688M -t 10:8300 -u 10:c3e50923-fb85-4153-b925-759614d4dfcd -c 10:"system" ${TEMP_FILE}
- #[11: vendor: 5059M-5843M]
- fakeroot ${SGDISK} -n 11:0:+784M -t 11:0700 -u 11:919d7080-d71a-4ae1-9227-e4585210c837 -c 11:"vendor" ${TEMP_FILE}
- #[12: reserved: 5843M-5844M]
- fakeroot ${SGDISK} -n 12:0:+1M -t 12:0700 -u 12:611eac6b-bc42-4d72-90ac-418569c8e9b8 -c 12:"reserved" ${TEMP_FILE}
- ;;
-esac
-
-# get the primary partition table
-dd if=${TEMP_FILE} of=prm_ptable.img bs=${SECTOR_SIZE} count=${PRIMARY_SECTORS}
-
-BK_PTABLE_LBA=$(expr ${SECTOR_NUMBER} - ${SECONDARY_SECTORS})
-dd if=${TEMP_FILE} of=sec_ptable.img skip=${BK_PTABLE_LBA} bs=${SECTOR_SIZE} count=${SECONDARY_SECTORS}
-
-rm -f ${TEMP_FILE}
diff --git a/l-loader/hikey.mk b/l-loader/hikey.mk
deleted file mode 100644
index 16c1d975..00000000
--- a/l-loader/hikey.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-CROSS_COMPILE?=arm-linux-gnueabihf-
-CC=$(CROSS_COMPILE)gcc
-LD=$(CROSS_COMPILE)ld
-OBJCOPY=$(CROSS_COMPILE)objcopy
-CFLAGS=-march=armv7-a
-
-BL1=bl1.bin
-NS_BL1U=recovery-fastboot.bin
-PTABLE_LST?=aosp-8g aosp-4g
-
-.PHONY: all
-all: l-loader.bin prm_ptable.img
-
-%.o: %.S
- $(CC) $(CFLAGS) -c -o $@ $<
-
-l-loader.bin: start.o $(BL1) $(NS_BL1U)
- $(LD) -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader
- $(OBJCOPY) -O binary loader temp
- python gen_loader_hikey.py -o $@ --img_loader=temp --img_bl1=$(BL1) --img_ns_bl1u=$(NS_BL1U)
- rm -f loader temp
-
-prm_ptable.img:
- for ptable in $(PTABLE_LST); do \
- PTABLE=$${ptable} SECTOR_SIZE=512 bash -x generate_ptable.sh;\
- cp prm_ptable.img ptable-$${ptable}.img;\
- done
-
-.PHONY: clean
-clean:
- rm -f *.o *.img l-loader.bin
diff --git a/l-loader/hikey960.mk b/l-loader/hikey960.mk
deleted file mode 100644
index e378b75e..00000000
--- a/l-loader/hikey960.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-BL1=bl1.bin
-NS_BL1U=BL33_AP_UEFI.fd
-PTABLE_LST:=aosp-32g aosp-32g-spare linux-32g
-
-.PHONY: all
-all: l-loader.bin prm_ptable.img
-
-l-loader.bin: $(BL1) $(NS_BL1U)
- python gen_loader_hikey960.py -o $@ --img_bl1=$(BL1) --img_ns_bl1u=$(NS_BL1U)
-
-prm_ptable.img:
- for ptable in $(PTABLE_LST); do \
- PTABLE=$${ptable} SECTOR_SIZE=4096 SGDISK=./sgdisk bash -x generate_ptable.sh;\
- cp prm_ptable.img ptable-$${ptable}.img;\
- done
-
-.PHONY: clean
-clean:
- rm -f *.img l-loader.bin
diff --git a/l-loader/l-loader.lds b/l-loader/l-loader.lds
deleted file mode 100644
index 41eb16f5..00000000
--- a/l-loader/l-loader.lds
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2014 Linaro Ltd.
- */
-
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-ENTRY(_start)
-SECTIONS
-{
- . = 0xf9800800;
- LLOADER_START = .;
-
- .text :
- {
- *(.text)
- *(.rodata)
- }
-
- .data ALIGN(4):
- {
- *(.data)
- }
-
- . = ALIGN(4);
-
- .bss ALIGN(4):
- {
- *(.bss)
- }
-
- LLOADER_BL1_BIN = 0xf9801000;
-}
diff --git a/l-loader/recovery-fastboot.bin b/l-loader/recovery-fastboot.bin
deleted file mode 100755
index fe562622..00000000
--- a/l-loader/recovery-fastboot.bin
+++ /dev/null
Binary files differ
diff --git a/l-loader/start.S b/l-loader/start.S
deleted file mode 100644
index a0d838a3..00000000
--- a/l-loader/start.S
+++ /dev/null
@@ -1,100 +0,0 @@
- .text
-
-/*
- * The head of l-loader is defined in below.
- * struct l_loader_head {
- * unsigned int first_instr;
- * unsigned char magic[16]; @ BOOTMAGICNUMBER!
- * unsigned int l_loader_start;
- * unsigned int l_loader_end;
- * };
- */
-
-#define CPU0_CTRL_OFFSET 0x100
-#define CPU7_CTRL_OFFSET 0x800
-#define CPU0_RVBARADDR_OFFSET 0x158
-#define CPU7_RVBARADDR_OFFSET 0x858
-
-#define CPU_CTRL_AARCH64_MODE (1 << 7)
-
-#define SC_PERIPH_CLKEN3 0x230
-#define SC_PERIPH_RSTDIS3 0x334
- .global _start
-_start:
- b reset
-@ Android magic number: "BOOTMAGICNUMBER!"
-android_magic:
- .word 0x544f4f42
- .word 0x4947414d
- .word 0x4d554e43
- .word 0x21524542
- .word LLOADER_START @ LLOADER_START in RAM
- .word 0 @ LLOADER_END in RAM
-
-entries:
- @ 5 entries with 7 words
- .space 140
-
- .align 7
-
-reset:
- ldr r8, =(0xf9800000 + 0x700)
- str r0, [r8] @ download mode (1:usb,2:uart,0:boot)
-
- ldr r4, =0xf6504000 @ ACPU_CTRL register base
- @ set RVBAR for cpu0
- ldr r5, =CPU0_RVBARADDR_OFFSET
- ldr r6, =LLOADER_BL1_BIN
- mov r6, r6, lsr #2
- str r6, [r4, r5]
-1:
- ldr r0, [r4, r5]
- cmp r0, r6
- bne 1b
-
- mov r5, #CPU0_CTRL_OFFSET
- mov r6, #CPU7_CTRL_OFFSET
-2:
- ldr r0, [r4, r5] @ Load ACPU_SC_CPUx_CTRL
- orr r0, r0, #CPU_CTRL_AARCH64_MODE
- str r0, [r4, r5] @ Save to ACPU_SC_CPUx_CTRL
- ldr r0, [r4, r5]
-
- add r5, r5, #0x100 @ Iterate ACPU_SC_CPUx_CTRL
- cmp r5, r6
- ble 2b
-
- /*
- * Prepare UART2 & UART3 without baud rate initialization.
- * So always output on UART0 in l-loader.
- */
- ldr r4, =0xf70100e0 @ UART2_RXD IOMG register
- mov r0, #0
- str r0, [r4]
- str r0, [r4, #4] @ UART2_TXD IOMG register
- ldr r0, [r4]
-
- ldr r4, =0xf7010188 @ UART3_RXD IOMG register
- mov r0, #1
- str r0, [r4]
- str r0, [r4, #4] @ UART3_TXD IOMG register
- ldr r1, [r4]
-
- ldr r4, =0xf7030000 @ PERI_CTRL register base
- @ By default, CLK_TXCO is the parent of CLK_UART3 in SC_CLK_SEL0
-
- ldr r5, =SC_PERIPH_RSTDIS3 @ unreset
- ldr r6, =SC_PERIPH_CLKEN3 @ enable PCLK
- mov r0, #(3 << 6) @ bit'6' & bit'7' (UART2 & UART3)
- str r0, [r4, r5]
- str r0, [r4, r6]
-
- @ execute warm reset to switch aarch64
- mov r2, #3
- mcr p15, 0, r2, c12, c0, 2
- wfi
-panic:
- b panic
-
-str_aarch64:
- .asciz "\nSwitch to aarch64 mode. CPU0 executes at 0x"