Dell Precision 5680 + Ubutnu 22.04 camera not work

$ sudo add-apt-repository ppa:oem-solutions-engineers/oem-projects-meta

$ sudo apt install oem-somerville-tentacool-meta

$ sudo apt update

$ sudo apt full-upgrade

$ sudo systemctl poweroff

https://www.dell.com/support/kbdoc/en-us/000203830/webcam-is-not-detected-on-xps-13-plus-9320-laptops-running-ubuntu-22-04

then it works

linux quotactl sample

struct dqblk dq;
dq.dqb_valid = QIF_BLIMITS | QIF_BTIME;                                                                                                                                                                
dq.dqb_bhardlimit = hardLimit;
dq.dqb_bsoftlimit = softLimit;
dq.dqb_btime = gracePeriod;

// get userdata file system path from /proc/mounts
std::ifstream in("/proc/mounts");
if (!in.is_open()) {
    return error("Failed to read mounts");
}    
std::string source;
std::string target;
std::string ignored;
while (!in.eof()) {
    std::getline(in, source, ' ');
    std::getline(in, target, ' ');
    std::getline(in, ignored);
    if (target.compare(0, 5, "/data") == 0) { 
        LOG(DEBUG) << "Found /data mount " << source << " at " << target;
        break;
    }
}    

if (quotactl(QCMD(Q_SETQUOTA, USRQUOTA), source.c_str(), userId,
             reinterpret_cast<char*>(&dq)) != 0) { 
    PLOG(ERROR) << "Failed to set quota for " << userId;
    return error("setQuota failed");
} else {
    LOG(DEBUG) << "setQuota for " << userId << ", softLimit: " << softLimit << ", hardLimit: "
        << hardLimit << ", gracePeriod: " << gracePeriod;
}    

I2C communication

most of the case when we communicate with a I2C driver
we prepare a unsigned char buffer to read/write to the I2C file node, since we cannot know the data read/write is positive or negative, so unsigned is the only way to store the value
and also we cannot know the order of the data(little endian or big endian), so char prevent us from doing miss-order

...
typedef struct {
        unsigned char func;
        unsigned char buffer[8];
} S_SensoryLicense;
...
uint32_t *securityChipComms(uint32_t * challenge)
{
        size_t ret = 0;
        int fd = 0;
        S_SensoryLicense SensoryLicense;
        static uint32_t respond[2];

        if (NULL == challenge) {
                printf("challenge is NULL\n");
                return (void *)-1;
        }

        /*
         * do the hardware communication with security IC
         * send challenge to IC
         * get respond from IC and place in 'respond'
         */
        fd = open(I2C_DEVICE_NAME, O_RDWR);
        if (fd < 0) {
                printf("open %s failed\n", I2C_DEVICE_NAME);
                return (void *)-1;
        }
        SensoryLicense.func = CHIP_WRITE;
        memcpy(&SensoryLicense.buffer, challenge, sizeof(uint32_t) * 2);
        ret = write(fd, &SensoryLicense, sizeof(SensoryLicense));
        if (ret < 0) {
                printf("write %s failed: %s\n", I2C_DEVICE_NAME, strerror(errno));
                return (void *)-1;
        }
        /*
         * userspace prepare a 9 bytes unsigned char array
         * sensory_ic read the 0th bytes for register address
         * then sensory_ic copy respond to 0th of the array
         */
        SensoryLicense.func = CHIP_READ;
        ret = read(fd, &SensoryLicense, sizeof(SensoryLicense));
        memcpy(respond, &SensoryLicense, sizeof(SensoryLicense.buffer));
        if (ret < 0) {
                printf("read %s failed: %s\n", I2C_DEVICE_NAME, strerror(errno));
                return (void *)-1;
        }
        close(fd);
        return respond;
}

NAT port forwarding trouble shooting

用 pfSense 設定 port forwarding 之後 ssh 連線沒有成功

在 pfSense 首頁 點選Diagnostics: Show States

搜尋 port forwarding 目標 IP 可以看到相關的連線

我遇到的錯誤訊息是 SYN_SENT:CLOSED

上網找了下說明,我覺得這個頁面的一個回覆說的很棒

https://forum.netgate.com/topic/80385/solved-syn_sent-closed-to-ip-address-i-m-trying-to-connect-to/5

SYN_SENT:CLOSED means nothing is replying. The camera might be missing a default gateway or have the wrong gateway, or have a local firewall, or maybe not listening on port 88 at all

看完之後得到問題大概是我的 port 轉發的目標主機 gateway 錯了,原因大概是因為網路線前幾天插到了另一台子網域的 switch 今天又插了回來主網域的

所以今天我是手動建立一個虛擬網卡手動給IP

但是少設定了 default gateway

所以當目標主機收到 ssh 連線封包之後會回覆到原本子網域 switch 所以沒有透過主網域的 port forwarding 發回來

sudo ip route add default via 192.168.104.1

透過上面指令把主網域 switch 增加為 default gateway 就好了

install paho-mqtt on openWRT

download openWRT source

./scripts/feeds update

./scripts/feeds install python

make

ls -l bin/ipq806x/packages/packages/python*

scp all the python ipk file to openWRT

opkg install python*

then you will find below package not found

* satisfy_dependencies_for: Cannot satisfy the following dependencies for python-codecs:
* libffi *
* opkg_install_cmd: Cannot install package python-codecs.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for python-db:
* libdb47 *
* opkg_install_cmd: Cannot install package python-db.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for python-gdbm:
* libgdbm *
* opkg_install_cmd: Cannot install package python-gdbm.

and my openwrt only have 32MB

so I try another way, just install the module needed while install mqtt

opkg install python-base_2.7.9-6_ipq806x.ipk python-distutils_2.7.9-6_ipq806x.ipk python-light_2.7.9-6_ipq806x.ipk libffi_3.0.13-1_ipq806x.ipk python-email_2.7.9-6_ipq806x.ipk

wget https://pypi.python.org/packages/source/p/paho-mqtt/paho-mqtt-1.1.tar.gz

scp paho-mqtt-1.1.tar.gz root@192.168.1.1:/root/

tar zxf paho-mqtt-1.1.tar.gz

cd paho-mqtt-1.1/

python setup.py install

used 4.8MB for above modules

/dev/ubi0_2 31.5M 4.6M 25.3M 15% /overlay
/dev/ubi0_2 31.5M 9.4M 20.4M 32% /overlay

now I can do import paho in python