USB-C Charging on the PBP?
#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.


Messages In This Thread
USB-C Charging on the PBP? - by Paulie420 - 09-24-2020, 09:13 PM
RE: USB-C Charging on the PBP? - by MtnSk8 - 09-24-2020, 09:52 PM
RE: USB-C Charging on the PBP? - by jiyong - 09-25-2020, 05:12 AM
RE: USB-C Charging on the PBP? - by as400 - 09-25-2020, 05:25 AM
RE: USB-C Charging on the PBP? - by wdt - 09-25-2020, 09:11 AM
RE: USB-C Charging on the PBP? - by as400 - 09-28-2020, 07:07 AM
RE: USB-C Charging on the PBP? - by Paulie420 - 09-25-2020, 10:53 AM
RE: USB-C Charging on the PBP? - by moonwalkers - 09-25-2020, 06:46 PM
RE: USB-C Charging on the PBP? - by jiyong - 09-25-2020, 05:28 PM
RE: USB-C Charging on the PBP? - by bastafari - 09-26-2020, 09:49 AM
RE: USB-C Charging on the PBP? - by xmixahlx - 09-26-2020, 10:37 AM
RE: USB-C Charging on the PBP? - by Paulie420 - 09-26-2020, 12:03 PM
RE: USB-C Charging on the PBP? - by moonwalkers - 09-27-2020, 12:14 AM
RE: USB-C Charging on the PBP? - by lot378 - 09-28-2020, 07:28 AM
RE: USB-C Charging on the PBP? - by as400 - 09-28-2020, 08:39 AM
RE: USB-C Charging on the PBP? - by MtnSk8 - 09-29-2020, 11:28 AM
RE: USB-C Charging on the PBP? - by bastafari - 09-29-2020, 12:25 PM
RE: USB-C Charging on the PBP? - by bastafari - 09-29-2020, 05:32 PM
RE: USB-C Charging on the PBP? - by moonwalkers - 09-29-2020, 09:50 PM
RE: USB-C Charging on the PBP? - by MtnSk8 - 09-30-2020, 04:16 PM
RE: USB-C Charging on the PBP? - by moonwalkers - 09-30-2020, 11:26 PM
RE: USB-C Charging on the PBP? - by MtnSk8 - 09-29-2020, 04:48 PM
RE: USB-C Charging on the PBP? - by Idaho - 09-30-2020, 01:05 PM
RE: USB-C Charging on the PBP? - by MtnSk8 - 10-01-2020, 09:00 AM
RE: USB-C Charging on the PBP? - by moonwalkers - 10-02-2020, 09:02 AM
RE: USB-C Charging on the PBP? - by wdt - 10-01-2020, 11:03 AM
RE: USB-C Charging on the PBP? - by as400 - 10-02-2020, 02:33 AM
RE: USB-C Charging on the PBP? - by lot378 - 10-02-2020, 10:08 AM
RE: USB-C Charging on the PBP? - by moonwalkers - 10-02-2020, 04:20 PM
RE: USB-C Charging on the PBP? - by wrzomar - 12-04-2020, 02:39 PM
RE: USB-C Charging on the PBP? - by xyzzy - 12-07-2020, 05:08 AM
RE: USB-C Charging on the PBP? - by wrzomar - 12-11-2020, 01:06 PM
RE: USB-C Charging on the PBP? - by xyzzy - 12-11-2020, 02:41 PM
RE: USB-C Charging on the PBP? - by wrzomar - 12-12-2020, 02:20 PM

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

Forum Jump:


Users browsing this thread: 1 Guest(s)