Coder Social home page Coder Social logo

Comments (10)

vartom avatar vartom commented on July 26, 2024

brcm_patchram_plus -d --patchram /lib/firmware/bcm4350c0.hcd --enable_lpm --enable_hci --use_baudrate_for_download --bd_addr 11:22:33:44:55:66 --no2bytes --tosleep 1000 /dev/ttyTHS2
The log shows that this command does not work. Most likely it works in the system and not before it starts.

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

@vartom I have already tried that command after the system is booted. Unfortunately it doesn't work. Do you have any idea?

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

I still can't figure out why it doesn't work...

[root@alarm ~]# ./brcm_patchram_plus -d --patchram ./BCM4354_003.001.012.0306.0659.hcd --no2bytes --enable_hci --enable_lpm --scopcm=1,2,0,1,1,0,0,0,0,0 --baudrate 3000000 --use_baudrate_for_download --tosleep=50000 /dev/ttyTHS2
option patchram with arg ./BCM4354_003.001.012.0306.0659.hcd
option no2bytes
option enable_hci
option enable_lpm
option scopcm with arg 1,2,0,1,1,0,0,0,0,0
option baudrate with arg 3000000
option use_baudrate_for_download
option tosleep with arg 50000
/dev/ttyTHS2 
writing
01 03 0c 00 
writing
01 03 0c 00 
writing
01 03 0c 00 
[root@alarm bin]# ./hciconfig hci0   
hci0:   Type: BR/EDR  Bus: SDIO
        BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
        DOWN 
        RX bytes:0 acl:0 sco:0 events:0 errors:0
        TX bytes:0 acl:0 sco:0 commands:0 errors:0
[root@alarm bin]# ./hciconfig hci0 up
Can't init device hci0: Input/output error (5)
[root@alarm bin]# dmesg | grep -i brcm
[    3.461471] brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac4354-sdio.bin for chip 0x004354(17236) rev 0x000001
[    5.711640] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac4354-sdio.clm_blob failed with error -2
[    5.712241] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available(err=-2), device may have limited channels available
[    5.713491] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Jun  5 2017 08:54:22 version 7.35.101.6 (r702795) FWID 01-1fb17091
[   16.019192] brcmfmac: brcmf_p2p_create_p2pdev: set p2p_disc error
[   16.041450] brcmfmac: brcmf_cfg80211_add_iface: add iface p2p-dev-wlan0 type 10 failed: err=-52
[root@alarm bin]# dmesg | grep -i bluetooth
[    3.242850] Bluetooth: HCI UART driver ver 2.3
[    3.242875] Bluetooth: HCI UART protocol H4 registered
[    3.243127] Bluetooth: HCI UART protocol Broadcom registered
[    3.243927] Bluetooth: Generic Bluetooth SDIO driver ver 0.1
[    3.365057] Bluetooth: RFCOMM TTY layer initialized
[    3.365090] Bluetooth: RFCOMM socket layer initialized
[    3.365137] Bluetooth: RFCOMM ver 1.11
[    3.365172] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    3.365202] Bluetooth: HIDP socket layer initialized

from linux-on-pixel-c.

aunali1 avatar aunali1 commented on July 26, 2024

According to the brcmfmac wiki BCM4354 support was dropped in Linux 4.1.

EDIT: Nvm, thats the unreleased PCIe variant.

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

@aunali1 Thanks for your comment
If that was the case, Wi-Fi shouldn't work either, but it does: #3

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

From L4T:

echo 1 > /proc/bluetooth/sleep/lpm
	. /var/run/nvbcm
	if [ "$BCMCHIP" = "0x4329" ]; then
		exec /usr/sbin/brcm_patchram_plus --enable_hci --scopcm=0,2,0,0,0,0,0,0,0,0 --baudrate 3000000 --patchram /lib/firmware/bcm4329.hcd --enable_lpm --tosleep=50000 /dev/ttyTHS2
	elif [ "$BCMCHIP" = "0x4330" ]; then
		exec /usr/sbin/brcm_patchram_plus --enable_hci --use_baudrate_for_download --scopcm=0,2,0,0,0,0,0,0,0,0  --baudrate 3000000 --patchram /lib/firmware/bcm4330.hcd --no2bytes --enable_lpm --tosleep=50000 /dev/ttyTHS2
	elif [ "$BCMCHIP" = "0x4324" ]; then
		exec /usr/sbin/brcm_patchram_plus --enable_hci --use_baudrate_for_download --scopcm=0,2,0,0,0,0,0,0,0,0  --baudrate 3000000 --patchram /lib/firmware/bcm4324.hcd --no2bytes --enable_lpm --tosleep=50000 /dev/ttyTHS2
	elif [ "$BCMCHIP" = "0x4354" ]; then
		exec /usr/sbin/brcm_patchram_plus --enable_hci --use_baudrate_for_download --scopcm=0,2,0,0,0,0,0,0,0,0  --baudrate 3000000 --patchram /lib/firmware/bcm4354.hcd --no2bytes --enable_lpm --tosleep=50000 /dev/ttyTHS3
	fi

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

nvwifint.sh

#!/bin/bash

# Copyright (c) 2016, NVIDIA CORPORATION.  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.
#  * Neither the name of NVIDIA CORPORATION nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 OWNER 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.


# description: "NVIDIA bluetooth/wifi init script"

if [ -f "/proc/bluetooth/sleep/lpm" ] ; then
	echo 1 > /proc/bluetooth/sleep/lpm
fi

if [ -f "/var/run/nvbcm" ] ; then
	. /var/run/nvbcm
fi

if [ -e "/usr/sbin/brcm_patchram_plus" ] ; then
	if [ "$BCMCHIP" = "0x4329" ]; then
		exec /usr/sbin/brcm_patchram_plus \
			--enable_hci --scopcm=0,2,0,0,0,0,0,0,0,0 \
			--baudrate 3000000 --patchram /lib/firmware/bcm4329.hcd \
			--enable_lpm --tosleep=50000 /dev/ttyTHS2
	elif [ "$BCMCHIP" = "0x4330" ]; then
		exec /usr/sbin/brcm_patchram_plus \
			--enable_hci --use_baudrate_for_download \
			--scopcm=0,2,0,0,0,0,0,0,0,0 --baudrate 3000000 \
			--patchram /lib/firmware/bcm4330.hcd --no2bytes \
			--enable_lpm --tosleep=50000 /dev/ttyTHS2
	elif [ "$BCMCHIP" = "0x4324" ]; then
		exec /usr/sbin/brcm_patchram_plus \
			--enable_hci --use_baudrate_for_download \
			--scopcm=0,2,0,0,0,0,0,0,0,0 --baudrate 3000000 \
			--patchram /lib/firmware/bcm4324.hcd --no2bytes \
			--enable_lpm --tosleep=50000 /dev/ttyTHS2
	elif [ "$BCMCHIP" = "0x4354" ]; then
		exec /usr/sbin/brcm_patchram_plus \
			--enable_hci --use_baudrate_for_download \
			--scopcm=0,2,0,0,0,0,0,0,0,0 --baudrate 3000000 \
			--patchram /lib/firmware/bcm4354.hcd --no2bytes \
			--enable_lpm --tosleep=50000 /dev/ttyTHS3
	fi
fi

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

Status update

Partially fixed in denysvitali/linux-smaug@883f87c, denysvitali/linux-smaug@35173d0, denysvitali/linux-smaug@731a2ab.

Instructions

BCM4354.hcd (attached) must be placed in /lib/firmware/brcm/BCM4354.hcd.

BT is enabled w/ an utility named hciconfig (which Arch wiki says it's deprecated, but apparently no other tool seem to work), which must be installed with the attached bluez-utils-compat-5.49-1 package.

Install bluez-utils-compat

Download the file, then do pacman -U bluez-utils-compat-5.49-1-aarch64.pkg.tar.xz

hciconfig hci0 up
hciconfig hci0 piscan
hcitool lescan # Scans for BTLE devices
hcitool scan # Scans for BT devices
hcitool cc 94:65:2D:C2:85:DC; hcitool auth 94:65:2D:C2:85:DC # Connect and authenticate to non-BTLE device
hcitool lecc E8:88:57:D5:E8:96 # Connect to a BTLE device

What's working

BT Scanning

[root@alarm bluez-utils-compat]# hcitool scan
Scanning ...
        94:65:2D:C2:85:DC       OnePlus 5T

BTLE Scanning

[root@alarm ~]# hcitool lescan
LE Scan ...
E8:88:57:D5:E8:96 Pixel C Keyboard
E8:88:57:D5:E8:96 (unknown)
E8:88:57:D5:E8:96 Pixel C Keyboard
E8:88:57:D5:E8:96 (unknown)
E8:88:57:D5:E8:96 Pixel C Keyboard
E8:88:57:D5:E8:96 (unknown)
E8:88:57:D5:E8:96 Pixel C Keyboard
E8:88:57:D5:E8:96 (unknown)
E8:88:57:D5:E8:96 Pixel C Keyboard
(...)
[bcm4354.hcd.zip](https://github.com/denysvitali/linux-on-pixel-c/files/1962163/bcm4354.hcd.zip)

Current problems

Dmesg:

[   13.584988] Bluetooth: hci0: BCM: Reset failed (-110)

Connection to a BTLE device doesn't work

Unfortunately connection to a BTLE device (like E8:88:57:D5:E8:96, my Pixel C keyboard) returns the following error:

Could not create connection: Input/output error

hcidump:

[root@alarm ~]# hcidump
HCI sniffer - Bluetooth packet analyzer ver 5.49
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< HCI Command: LE Create Connection (0x08|0x000d) plen 25
    bdaddr E8:88:57:D5:E8:96 type 0
    interval 4 window 4 initiator_filter 0
    own_bdaddr_type 0 min_interval 15 max_interval 15
    latency 0 supervision_to 3200 min_ce 1 max_ce 1
> HCI Event: Command Status (0x0f) plen 4
    LE Create Connection (0x08|0x000d) status 0x0c ncmd 1
    Error: Command Disallowed

Connection to a BT device doesn't work

Connection to a non-BTLE doesn't work.

hcitool cc 04:88:E2:89:81:C4; hcitool auth 04:88:E2:89:81:C4

results in:

Can't create connection: Input/output error
Not connected.

hcidump:

> HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Read Remote Extended Features (0x23) plen 13
    status 0x00 handle 11 page 1 max 1
    Features: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< HCI Command: Authentication Requested (0x01|0x0011) plen 2
    handle 11
< ACL data: handle 11 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
> HCI Event: Command Status (0x0f) plen 4
    Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> HCI Event: Link Key Request (0x17) plen 6
    bdaddr 04:88:E2:89:81:C4
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr 04:88:E2:89:81:C4 mode 2 clkoffset 0x0000
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> ACL data: handle 11 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x00b8
        Enhanced Retransmission mode
        Streaming mode
        FCS Option
        Fixed Channels
< ACL data: handle 11 flags 0x00 dlen 10
    L2CAP(s): Info req: type 3
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 04:88:E2:89:81:C4 name 'BeatsPill'
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 11 packets 2
> ACL data: handle 11 flags 0x02 dlen 20
    L2CAP(s): Info rsp: type 3 result 0
      Fixed channel list 0x00000076
        L2CAP Signalling Channel
        L2CAP Connless
< HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 11 reason 0x13
    Reason: Remote User Terminated Connection
> HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Auth Complete (0x06) plen 3
    status 0x16 handle 11
    Error: Connection Terminated by Local Host
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 11 reason 0x16
    Reason: Connection Terminated by Local Host

btmgmt doesn't work

[root@alarm ~]# btmgmt
[mgmt]# select index 0
Selected index 0
[hci0]# select index 0[hci0]# power on
Set Powered for hci0 failed with status 0x11 (Invalid Index)
[hci0]# le on
Set Low Energy for hci0 failed with status 0x11 (Invalid Index)
[hci0]# info
Reading hci0 info failed with status 0x11 (Invalid Index)
[hci0]# 

Files:
bcm4354.hcd
boot-linux-4.17-rc2-883f87c7e7fc_20180430_210635.img.unsigned
bluez-utils-compat-5.49-1-aarch64.pkg.tar.xz

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

Probably related:
Dunedan/mbp-2016-linux#29

from linux-on-pixel-c.

denysvitali avatar denysvitali commented on July 26, 2024

Related indeed. Fixed in denysvitali/linux-smaug@0040834
Credits to @lategoodbye (original commit: lategoodbye/rpi-zero@ed5900296dfb)

Video proof

bluez-utils-compat-5.49-1-aarch64.pkg.tar.xz isn't needed anymore.

Connect to the Pixel C keyboard

$bluetoothctl
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# discoverable on
Changing discoverable on succeeded
[bluetooth]# pairable on
Changing pairable on succeeded
[bluetooth]# agent NoInputNoOutput
Agent registered
[bluetooth]# default-agent 
Default agent request successful
[bluetooth]# scan on
Discovery started
[NEW] Device E8:88:57:D5:E8:96 Pixel C Keyboard
[bluetooth]# scan off
Discovery stopped
[bluetooth]# pair E8:88:57:D5:E8:96
Attempting to pair with E8:88:57:D5:E8:96
[CHG] Device E8:88:57:D5:E8:96 Connected: yes
[agent] Passkey: 032578
### INPUT the passkey, followed by the [ENTER] key on your Google Pixel C Keyboard ###
[CHG] Device E8:88:57:D5:E8:96 UUIDs: 00001530-1212-efde-1523-785feabcd123
[CHG] Device E8:88:57:D5:E8:96 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device E8:88:57:D5:E8:96 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device E8:88:57:D5:E8:96 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Device E8:88:57:D5:E8:96 UUIDs: 0000180f-0000-1000-8000-00805f9b34fb
[CHG] Device E8:88:57:D5:E8:96 UUIDs: 00001812-0000-1000-8000-00805f9b34fb
[CHG] Device E8:88:57:D5:E8:96 ServicesResolved: yes
[CHG] Device E8:88:57:D5:E8:96 Modalias: usb:v18D1p5018d0001
[CHG] Device E8:88:57:D5:E8:96 Paired: yes
Pairing successful

Enjoy!

from linux-on-pixel-c.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.