USB-C Charging on the PBP?
#31
(12-04-2020, 02:39 PM)wrzomar Wrote: Is there a simple way to debug USB-C PD on the Pinebook Pro?
Simple.  Doubt that...

It uses a FUSB302 to control the USB PD bus.  There is a datasheet for it and it can be accessed over I2C.  So you could see what is going on if you can read a datasheet and use i2cset and i2cget to inspect the device.  You can also look around in /sys/bus/i2c/devices/4-0022/typec
#32
(12-07-2020, 05:08 AM)xyzzy Wrote:
(12-04-2020, 02:39 PM)wrzomar Wrote: Is there a simple way to debug USB-C PD on the Pinebook Pro?
Simple.  Doubt that...

It uses a FUSB302 to control the USB PD bus.  There is a datasheet for it and it can be accessed over I2C.  So you could see what is going on if you can read a datasheet and use i2cset and i2cget to inspect the device.  You can also look around in /sys/bus/i2c/devices/4-0022/typec
Simple enough, thanks. I've written a simple C++ program to read some text files from the location, you've mentioned, to add to my already bloated conkyrc to conveniently monitor what's going on with USB-C.
Code:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <string>

using namespace std;

const string MASTER_PATH = "/sys/bus/i2c/devices/4-0022/typec/port0/";
const string DATA_ROLE_F = "data_role";
const string ORIENTATION_F = "orientation";
const string PORT_TYPE_F = "port_type";
const string POWER_OPERATION_MODE_F = "power_operation_mode";
const string POWER_ROLE_F = "power_role";
const string PREFERRED_ROLE_F = "preferred_role";
const string SUPPORTED_ACCESSORY_MODES_F = "supported_accessory_modes";
const string UEVENT_F = "uevent";
const string USB_POWER_DELIVERY_REVISION_F = "usb_power_delivery_revision";
const string USB_TYPEC_REVISION_F = "usb_typec_revision";
const string VCONN_SOURCE_F = "vconn_source";

constexpr int FILENAMES_SIZE = 4;
const string FILENAMES[FILENAMES_SIZE] = {ORIENTATION_F, DATA_ROLE_F, POWER_ROLE_F, POWER_OPERATION_MODE_F};
const string SHORTCUTS[FILENAMES_SIZE] = {"O", "DR", "PR", "POM"};

bool printFromFile(const int index);

int main()
{
    for(int i = 0; i < FILENAMES_SIZE; i++)
    {
        bool result = printFromFile(i);
        if(i < FILENAMES_SIZE - 1){
            if(i == 2 || i == 3 || i == 6)
                cout << endl;
        }
        if(!result)
            break;
    }
    cout << endl;
    return 0;
}

bool printFromFile(const int index)
{
    cout << SHORTCUTS[index] << ":";
    ifstream file;
    file.open(MASTER_PATH + FILENAMES[index]);
    if(!file){
        cout << "!file ";
    }
    else{
        stringstream stringStream;
        stringStream << file.rdbuf();
        file.close();
        string contents = stringStream.str();
        if(!contents.empty() && contents[contents.length() - 1] == '\n'){
            contents.erase(contents.length() - 1);
        }
        int openBracket = contents.find('[');
        int closeBracket = contents.find(']');
        if(openBracket != string::npos && closeBracket != string::npos && openBracket < closeBracket){
            string strbetween = contents.substr(openBracket+1, closeBracket-openBracket-1);
            contents = strbetween;
        }
        cout << contents << " ";
        if(index == 0 && contents == "unknown")
            return(false);
        else
            return(true);
    }
}
It's just reading some text file: orientation, data_role, power_role and power_operation_mode. If orientation contains 'unknown', the code ignores the rest, because it is outdated anyway.
For a few days everything worked fine and I didn't have to reboot, but today I had to reboot twice. When it's charging using USB 3.0 but other USB-C functions aren't working (including charging using USB-C port on the powebank with Power Delivery), the 'orientation' file contains 'unknown'. If everything is fine, the 'orientation' file contains 'unknown' only when unplugged and 'normal' or 'reverse' when plugged. I didn't read the datasheet yet. I didn't check if FUSB302 is working at all when this happens.
#33
(12-11-2020, 01:06 PM)wrzomar Wrote: When it's charging using USB 3.0 but other USB-C functions aren't working

What do you mean by that exactly? USB 3.0 aka SuperSpeed USB normally refers to the data bus type and doesn't involve charging. The USB-C connector has a USB 2.0 interface, USB 3.0 interface, Display Port interface, as well as the ability to source or sink power.

The USB 3.0 type A connector, on the left, also has a USB 2.0 interface and USB 3.0 interface. I think it can only source power, but I'm not sure about that.

When you say "charging using USB 3.0", do you mean using the USB 3.0 type A connector? Or are you charging using the USB type C connector?

If the latter, then you must have a dock of some kind, since with a charger directly connected to the USB-C connector there'd be no way to use it for anything else.
#34
(12-11-2020, 02:41 PM)xyzzy Wrote:
(12-11-2020, 01:06 PM)wrzomar Wrote: When it's charging using USB 3.0 but other USB-C functions aren't working

What do you mean by that exactly?  USB 3.0 aka SuperSpeed USB normally refers to the data bus type and doesn't involve charging.  The USB-C connector has a USB 2.0 interface, USB 3.0 interface, Display Port interface, as well as the ability to source or sink power.

The USB 3.0 type A connector, on the left, also has a USB 2.0 interface and USB 3.0 interface.  I think it can only source power, but I'm not sure about that.

When you say "charging using USB 3.0", do you mean using the USB 3.0 type A connector?  Or are you charging using the USB type C connector?

If the latter, then you must have a dock of some kind, since with a charger directly connected to the USB-C connector there'd be no way to use it for anything else.
By the USB 3.0 I've meant USB type A on this model of powerbank with USB-C, it's can use some kind of fast charging, but it isn't Power Delivery used with the USB-C port on the same powerbank. When the chip responsible for power delivery is not responding the PBP is not charging from the C type port of the powerbank (when connected directly) and it cannot power the dock I'm using, so I don't know if anything else is working because powered devices work better. I didn't tried connecting any power supply to the USB-C port on the dock and then connecting the dock to the PBP when the damn chip isn't working, yet. But I can try it now, because it is happening again.
The dock works somehow, there is Ethernet working, I will try HDMI next. The odd thing is the USB-C power meter I'm using connected between PBP and the dock didn't turn on the display, but the powerbank is connected to the dock with USB-C - USB-C cable and it turned on instantly before plugging it to the PBP. HDMI isn't working. The flash drive plugged to the dock is blinking, but didn't appear in the devices. So, only Ethernet is working somehow. I'll reboot now and also will check if power delivery charging works with powered down PBP.

PS. PD-PD charging works when the PBP is turned off.
PPS. I've another powerbank with USB-C port, but it is not described as PD port, it works as power input or output, sometimes it tries to charge another device that is simultaneously connected to the multi-port charger (when it's not plugged to AC). The chip in PBP says (in port_type) that it is 'dual' but preferred_role is 'sink'. You can put here Risitas's laugh meme, because the PBP acts as a source to this powerbank when connected with USB-C - USB-C cable Big Grin It tries to act as a source, but the PBP overrides it.


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo P{inebook Pro not charging Ome Ko 6 2,925 11-09-2023, 03:29 PM
Last Post: tomekdev
  Pine Book Pro Charging Problems balin 7 8,013 12-15-2022, 02:15 PM
Last Post: tomasgreenro
  Very low battery (but charging) causes boot failures Phillip Bell 7 5,623 02-22-2022, 11:20 AM
Last Post: wdt
  Pinebook Pro Stopped Charging via USB-C MickTheGeek 4 5,131 08-25-2021, 02:51 PM
Last Post: MickTheGeek
  HArdware issues while charging user18130814200115 2 3,282 05-01-2021, 04:13 AM
Last Post: gabeeg
  PineBookPro does not charging floppy_rofling 0 1,846 02-03-2021, 05:29 AM
Last Post: floppy_rofling
  Screen flicker with USB-C charging bchenlee609 5 6,730 01-25-2021, 08:48 PM
Last Post: bchenlee609
  Charging via USB-C Port tyha 15 22,547 07-22-2020, 08:15 PM
Last Post: iscmob
  Battery not charging via AC Adapter laissezfarrell 1 3,560 05-30-2020, 06:05 PM
Last Post: tllim
  Charging via USB GloriousCoffee 7 9,715 04-03-2020, 12:01 PM
Last Post: GloriousCoffee

Forum Jump:


Users browsing this thread: 3 Guest(s)