From 9d1c2ed39c0b516c9abadd2a2b3f817db652c6c2 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 19 Jan 2021 21:45:35 +0300 Subject: debian: use firmware-qcom-dragonboard845c as a base for firmware-qcom-rb5 Signed-off-by: Dmitry Baryshkov --- debian/ath10k_helpers/ath10k-bdencoder | 173 +++++++++++++++++---- debian/ath10k_helpers/generate_board-2_json.sh | 14 +- debian/changelog | 6 + debian/compat | 2 +- debian/control | 23 ++- debian/eth-mac-addr.conf | 2 - debian/firmware-qcom-dragonboard845c.install | 5 - debian/firmware-qcom-rb5.install | 12 ++ debian/firmware-qcom-rb5.postrm | 9 ++ debian/firmware-qcom-rb5.preinst | 9 ++ .../network-manager-config-dragonboard845c.install | 1 - debian/rules | 9 +- 12 files changed, 206 insertions(+), 59 deletions(-) delete mode 100644 debian/eth-mac-addr.conf delete mode 100644 debian/firmware-qcom-dragonboard845c.install create mode 100644 debian/firmware-qcom-rb5.install create mode 100644 debian/firmware-qcom-rb5.postrm create mode 100644 debian/firmware-qcom-rb5.preinst delete mode 100644 debian/network-manager-config-dragonboard845c.install (limited to 'debian') diff --git a/debian/ath10k_helpers/ath10k-bdencoder b/debian/ath10k_helpers/ath10k-bdencoder index fe32eda..d613f63 100755 --- a/debian/ath10k_helpers/ath10k-bdencoder +++ b/debian/ath10k_helpers/ath10k-bdencoder @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (c) 2015 Qualcomm Atheros, Inc. # Copyright (c) 2018, The Linux Foundation. All rights reserved. @@ -28,11 +28,14 @@ import subprocess import logging import sys import shutil +import mailbox MAX_BUF_LEN = 2000000 # the signature length also includes null byte and padding -ATH10K_BOARD_SIGNATURE = "QCA-ATH10K-BOARD" +ATH10K_BOARD_SIGNATURE = b"QCA-ATH10K-BOARD" +ATH11K_BOARD_SIGNATURE = b"QCA-ATH11K-BOARD" +BOARD_SIGNATURE = b'' ATH10K_BOARD_SIGNATURE_LEN = 20 PADDING_MAGIC = 0x6d @@ -40,6 +43,10 @@ DEFAULT_BD_API = 2 DEFAULT_BOARD_FILE = 'board-%d.bin' % DEFAULT_BD_API DEFAULT_JSON_FILE = 'board-%d.json' % DEFAULT_BD_API TYPE_LENGTH_SIZE = 8 +BIN_SUFFIX = '.bin' + +ATH10K_FIRMWARE_URL = 'https://github.com/kvalo/ath10k-firmware/commit' +ATH11K_FIRMWARE_URL = 'https://github.com/kvalo/ath11k-firmware/commit' ATH10K_BD_IE_BOARD = 0 ATH10K_BD_IE_BOARD_EXT = 1 @@ -68,12 +75,20 @@ def add_ie(buf, offset, id, value): struct.pack_into(' buf_len: - print 'Error: Buffer too short (%d + %d > %d)' % (offset, + print('Error: Buffer too short (%d + %d > %d)' % (offset, ie_len, - buf_len) + buf_len)) return 1 # FIXME: create separate ExtenderBoard() class and @@ -362,7 +389,7 @@ class BoardContainer: self.validate() - print "board binary file '%s' is created" % name + print("board binary file '%s' is created" % name) def get_bin(self): buf = ctypes.create_string_buffer(MAX_BUF_LEN) @@ -422,18 +449,18 @@ def cmd_extract(args): b['data'] = filename mapping.append(b) - f = open(filename, 'w') + f = open(filename, 'wb') f.write(board.data.data) f.close() - print "%s created size: %d" % (filename, len(board.data.data)) + print("%s created size: %d" % (filename, len(board.data.data))) filename = DEFAULT_JSON_FILE f = open(filename, 'w') f.write(json.dumps(mapping, indent=4)) f.close() - print "%s created" % (filename) + print("%s created" % (filename)) def cmd_info(args): @@ -441,7 +468,7 @@ def cmd_info(args): cont = BoardContainer().open(filename) - print cont.get_summary() + print(cont.get_summary()) def cmd_diff(args): @@ -452,7 +479,7 @@ def cmd_diff(args): filename1 = args.diffstat[0] filename2 = args.diffstat[1] - print diff_boardfiles(filename1, filename2, args.diff) + print(diff_boardfiles(filename1, filename2, args.diff)) def diff_boardfiles(filename1, filename2, diff): @@ -460,11 +487,11 @@ def diff_boardfiles(filename1, filename2, diff): container1 = BoardContainer().open(filename1) (temp1_fd, temp1_pathname) = tempfile.mkstemp() - os.write(temp1_fd, container1.get_summary(sort=True)) + os.write(temp1_fd, container1.get_summary(sort=True).encode()) container2 = BoardContainer().open(filename2) (temp2_fd, temp2_pathname) = tempfile.mkstemp() - os.write(temp2_fd, container2.get_summary(sort=True)) + os.write(temp2_fd, container2.get_summary(sort=True).encode()) # this function is used both with --diff and --diffstat if diff: @@ -480,13 +507,13 @@ def diff_boardfiles(filename1, filename2, diff): if e.returncode == 1: output = e.output else: - print 'Failed to run wdiff: %d\n%s' % (e.returncode, e.output) + print('Failed to run wdiff: %d\n%s' % (e.returncode, e.output)) return 1 except OSError as e: - print 'Failed to run wdiff: %s' % (e) + print('Failed to run wdiff: %s' % (e)) return 1 - result += '%s\n' % (output) + result += '%s\n' % (output.decode()) # create simple statistics about changes in board images @@ -547,14 +574,14 @@ def cmd_create(args): def cmd_add_board(args): if len(args.add_board) < 3: - print 'error: --add-board requires 3 or more arguments, only %d given' % (len(args.add_board)) + print('error: --add-board requires 3 or more arguments, only %d given' % (len(args.add_board))) sys.exit(1) board_filename = args.add_board[0] new_filename = args.add_board[1] new_names = args.add_board[2:] - f = open(new_filename, 'r') + f = open(new_filename, 'rb') new_data = f.read() f.close() @@ -566,13 +593,92 @@ def cmd_add_board(args): container.add_board(new_data, new_names) container.write(board_filename) - print diff_boardfiles(temp_pathname, board_filename, False) + print(diff_boardfiles(temp_pathname, board_filename, False)) os.remove(temp_pathname) +def git_get_head_id(): + return subprocess.check_output(['git', 'log', '--format=format:%H', '-1']) + + +def cmd_add_mbox(args): + if args.mode == 10: + firmware_url = ATH10K_FIRMWARE_URL + elif args.mode == 11: + firmware_url = ATH11K_FIRMWARE_URL + + board_filename = args.add_mbox[0] + mbox_filename = args.add_mbox[1] + + mbox = mailbox.mbox(mbox_filename) + + for msg in mbox: + board_files = {} + + for part in msg.walk(): + filename = part.get_filename() + + if not filename: + # not an attachment + continue + + if not filename.endswith(BIN_SUFFIX): + continue + + name = filename.rstrip(BIN_SUFFIX) + board_files[name] = part.get_payload(decode=True) + + print('Found mail "%s" with %d board files' % (msg['Subject'], + len(board_files))) + + # copy the original file for diff + (temp_fd, temp_pathname) = tempfile.mkstemp() + shutil.copyfile(board_filename, temp_pathname) + + container = BoardContainer.open(board_filename) + for name, data in board_files.items(): + names = [name] + container.add_board(data, names) + + container.write(board_filename) + + applied_msg = '' + + if args.commit: + cmd = ['git', 'commit', '--quiet', '-m', msg['Subject'], board_filename] + subprocess.check_call(cmd) + + applied_msg += 'Thanks, added to %s:\n\n' % (board_filename) + + applied_msg += diff_boardfiles(temp_pathname, board_filename, False) + applied_msg += '\n\n' + + if args.commit: + applied_msg += '%s/%s\n\n' % (ATH10K_FIRMWARE_URL, git_get_head_id()) + + os.remove(temp_pathname) + + print('----------------------------------------------') + print(applied_msg) + print('----------------------------------------------') + + xclip(applied_msg) + + +def mode_parse(v): + if v == 'ath10k': + return 10 + elif v == 'ath11k': + return 11 + else: + raise argparse.ArgumentTypeError('ath10k or ath11k expected.') + + def main(): - description = '''ath10k board-N.bin files manegement tool + global BOARD_SIGNATURE + + description = '''ath10k/ath11k board-N.bin files management tool ath10k-bdencoder is for creating (--create), listing (--info) and comparing (--diff, --diffstat) ath10k board-N.bin files. The @@ -612,17 +718,30 @@ can use --extract switch to see examples from real board-N.bin files. cmd_group.add_argument('-a', '--add-board', metavar='NAME', nargs='+', help='add a board file to an existing board-N.bin, first argument is the filename of board-N.bin to add to, second is the filename board file (board.bin) to add and then followed by one or more arguments are names used in board-N.bin') + cmd_group.add_argument('-A', '--add-mbox', metavar='FILENAME', nargs=2, + help='FIXME') + + parser.add_argument('-C', '--commit', action='store_true', + help='commit changes to a git repository') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose (debug) messages') parser.add_argument("-o", "--output", metavar="BOARD_FILE", help='name of the output file, otherwise the default is: %s' % (DEFAULT_BOARD_FILE)) + parser.add_argument("-m", "--mode", metavar='MODE', + help='select between ath10k and ath11k mode (default: ath10k)', + default=10, type=mode_parse) args = parser.parse_args() if args.verbose: logging.basicConfig(level=logging.DEBUG) + if args.mode == 10: + BOARD_SIGNATURE = ATH10K_BOARD_SIGNATURE + elif args.mode == 11: + BOARD_SIGNATURE = ATH11K_BOARD_SIGNATURE + if args.create: return cmd_create(args) elif args.extract: @@ -635,6 +754,8 @@ can use --extract switch to see examples from real board-N.bin files. return cmd_diff(args) elif args.add_board: return cmd_add_board(args) + elif args.add_mbox: + return cmd_add_mbox(args) if __name__ == "__main__": main() diff --git a/debian/ath10k_helpers/generate_board-2_json.sh b/debian/ath10k_helpers/generate_board-2_json.sh index 3a1d532..5cbe94d 100644 --- a/debian/ath10k_helpers/generate_board-2_json.sh +++ b/debian/ath10k_helpers/generate_board-2_json.sh @@ -1,21 +1,21 @@ +#!/bin/sh + JSON="$2" iter=0 echo "[" > "${JSON}" -for file in $1/bdwlan.*; do - [[ $file == *.txt ]] && continue - +for file in $1/bdwlan.elf $1/bdwlan.e* ; do iter=$((iter+1)) [ $iter -ne 1 ] && echo " }," >> "${JSON}" echo " {" >> "${JSON}" echo " \"data\": \"$file\"," >> "${JSON}" - if [[ $file == */bdwlan.bin ]]; then - file_ext="ff" + if [ `basename $file` == "bdwlan.elf" ]; then + file_ext="255" else - file_ext="$(printf '%x\n' "$(basename "${file}" | sed -E 's:^.*\.b?([0-9a-f]*)$:0x\1:')")" + file_ext="$(printf '%d\n' "$(basename "${file}" | sed -E 's:^.*\.e?([0-9a-f]*)$:0x\1:')")" fi - echo " \"names\": [\"bus=snoc,qmi-board-id=${file_ext}\"]" >> "${JSON}" + echo " \"names\": [\"bus=pci,qmi-chip-id=0,qmi-board-id=${file_ext}\"]" >> "${JSON}" done echo " }" >> "${JSON}" diff --git a/debian/changelog b/debian/changelog index e7f4c4a..5b35fe3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +linux-board-support-package-rb5 (20210118133815-v2) unstable; urgency=medium + + * Add initial firmware package for rb5. + + -- Dmitry Baryshkov Tue, 19 Jan 2021 09:58:17 +0300 + linux-board-support-package-dragonboard845c (20190529180356-v4+linaro6) unstable; urgency=medium * Fix installation of renesas firmware. diff --git a/debian/compat b/debian/compat index ec63514..f599e28 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -9 +10 diff --git a/debian/control b/debian/control index 7e6ee77..815c11c 100644 --- a/debian/control +++ b/debian/control @@ -1,20 +1,15 @@ -Source: linux-board-support-package-dragonboard845c +Source: linux-board-support-package-rb5 Section: non-free/kernel Priority: optional Maintainer: Anibal Limon -Standards-Version: 3.9.5 -Build-Depends: unzip, mtools, debhelper (>= 5), bash, python2 -Vcs-Browser: https://git.linaro.org/landing-teams/working/qualcomm/pkg/linux-board-support-package-dragonboard845c.git +Standards-Version: 4.5.1 +Build-Depends: unzip, debhelper (>= 10~), python3 +Vcs-Browser: https://git.linaro.org/landing-teams/working/qualcomm/pkg/linux-board-support-package-rb5.git -Package: firmware-qcom-dragonboard845c +Package: firmware-qcom-rb5 Architecture: all -Section: non-free/kernel -Description: Binary firmware for various Qualcomm drivers used on Dragonboard 845c - This package contains the binary firmware for GPU, USB, Venus, DSP hardware - coprocessors found on SDM845, which is the main SoC on the Dragonboard 845c. +Depends: ${misc:Depends} +Description: Binary firmware for various Qualcomm drivers used on Robotics RB5 + This package contains the binary firmware for GPU, Venus, DSP hardware + coprocessors found on SM8250, which is the main SoC on the Robotics RB5. . - -Package: network-manager-config-dragonboard845c -Architecture: all -Section: net -Description: Network Manager configuration to generate MAC ethernet address on Dragonboard 845c. diff --git a/debian/eth-mac-addr.conf b/debian/eth-mac-addr.conf deleted file mode 100644 index b152cf0..0000000 --- a/debian/eth-mac-addr.conf +++ /dev/null @@ -1,2 +0,0 @@ -[connection-mac-randomization] -ethernet.cloned-mac-address=stable diff --git a/debian/firmware-qcom-dragonboard845c.install b/debian/firmware-qcom-dragonboard845c.install deleted file mode 100644 index 9423cc3..0000000 --- a/debian/firmware-qcom-dragonboard845c.install +++ /dev/null @@ -1,5 +0,0 @@ -RB3_firmware_20190529180356-v4+linaro6/renesas_usb_fw.mem lib/firmware/ -RB3_firmware_20190529180356-v4+linaro6/18-adreno-fw/a630_zap*.* lib/firmware/qcom -RB3_firmware_20190529180356-v4+linaro6/20-adsp_split/firmware/adsp*.* lib/firmware/qcom/sdm845/ -RB3_firmware_20190529180356-v4+linaro6/21-cdsp_split/firmware/cdsp*.* lib/firmware/qcom/sdm845/ -board-2.bin lib/firmware/ath10k/WCN3990/hw1.0/ diff --git a/debian/firmware-qcom-rb5.install b/debian/firmware-qcom-rb5.install new file mode 100644 index 0000000..7269c10 --- /dev/null +++ b/debian/firmware-qcom-rb5.install @@ -0,0 +1,12 @@ +RB5_firmware_*/18-adreno-fw/a650_gmu.bin lib/firmware/qcom +RB5_firmware_*/18-adreno-fw/a650_sqe.fw lib/firmware/qcom +RB5_firmware_*/18-adreno-fw/a650_zap.mdt lib/firmware/qcom +RB5_firmware_*/18-adreno-fw/a650_zap.b* lib/firmware/qcom +# dh_install can not rename files, so make a copy in rules, file a650_zap.elf +a650_zap.mbn lib/firmware/qcom/sm8250/ +RB5_firmware_*/20-adsp_split/adsp*.* lib/firmware/qcom/sm8250/ +RB5_firmware_*/21-cdsp_split/cdsp*.* lib/firmware/qcom/sm8250/ +RB5_firmware_*/39-jsn/adsp*.jsn lib/firmware/qcom/sm8250/ +RB5_firmware_*/39-jsn/cdsp*.jsn lib/firmware/qcom/sm8250/ +RB5_firmware_*/33-venus_split/ lib/firmware/qcom/vpu-1.0/ +board-2.bin lib/firmware/ath11k/QCA6390/hw2.0/ diff --git a/debian/firmware-qcom-rb5.postrm b/debian/firmware-qcom-rb5.postrm new file mode 100644 index 0000000..a124108 --- /dev/null +++ b/debian/firmware-qcom-rb5.postrm @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +if [ "$1" = "purge" -o "$1" = "remove" ]; then + dpkg-divert --package #PACKAGE# --remove --rename /lib/firmware/ath11k/QCA6390/hw2.0/board-2.bin +fi + +#DEBHELPER# diff --git a/debian/firmware-qcom-rb5.preinst b/debian/firmware-qcom-rb5.preinst new file mode 100644 index 0000000..fac2234 --- /dev/null +++ b/debian/firmware-qcom-rb5.preinst @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +if [ "$1" = "install" ]; then + dpkg-divert --package #PACKAGE# --add --rename /lib/firmware/ath11k/QCA6390/hw2.0/board-2.bin +fi + +#DEBHELPER# diff --git a/debian/network-manager-config-dragonboard845c.install b/debian/network-manager-config-dragonboard845c.install deleted file mode 100644 index 533b3fb..0000000 --- a/debian/network-manager-config-dragonboard845c.install +++ /dev/null @@ -1 +0,0 @@ -debian/eth-mac-addr.conf usr/lib/NetworkManager/conf.d/ diff --git a/debian/rules b/debian/rules index c3c9111..ca0b931 100755 --- a/debian/rules +++ b/debian/rules @@ -2,7 +2,7 @@ SHELL := sh -e VERSION := $(shell dpkg-parsechangelog -SVersion) -UPSTREAM_SOURCE = RB3_firmware +UPSTREAM_SOURCE = RB5_firmware DIR_ORIG = $(UPSTREAM_SOURCE)_$(VERSION) ZIP_ORIG = $(UPSTREAM_SOURCE)_$(VERSION).zip @@ -14,13 +14,16 @@ override_dh_auto_build: mkdir -p bdf cp ./$(DIR_ORIG)/38-bdwlan_split/bdwlan*.* bdf bash ./debian/ath10k_helpers/generate_board-2_json.sh bdf board-2.json - python2 ./debian/ath10k_helpers/ath10k-bdencoder -c board-2.json -o board-2.bin + python3 ./debian/ath10k_helpers/ath10k-bdencoder -m ath11k -c board-2.json -o board-2.bin - cp ./$(DIR_ORIG)/17-USB3-201-202-FW/K2026090.mem ./$(DIR_ORIG)/renesas_usb_fw.mem + cp ./$(DIR_ORIG)/18-adreno-fw/a650_zap.elf a650_zap.mbn override_dh_auto_clean: + if [ -d $(DIR_ORIG) ] ; then chmod u+w $(DIR_ORIG) -R ; fi rm -rf $(DIR_ORIG) + rm -rf bdf board-2.bin board-2.json rm -f debian/copyright + rm -f a650_zap.mbn %: dh $@ -- cgit v1.2.3