Samsung Galaxy Note 3 Charge and USB-OTG simultaneously

I’d like to charge my phone and use USB devices at the same time, but it seems like it requires a 64.9kOhm resistor from sensor ID pin (micro USB) to ground. Instead of melting a USB-OTG cable, I bought an this adapter

micro USB3.0 Type B Male to USB3.0 Type A Female adapter

Schematics so that I can have direct access to the ID pin. This is a USB 3.0 give that I have a Galaxy Note 3. The same principles apply to the USB 2.0 versions for Galaxy Note 4.


According to this website, fsa9480_i2c.h has the table for the resistor ID values. Turns out 64.9kOhm is the one for both charging (slowly) and using USB devices (like mouse, network adapter, etc.).

RID_USB_OTG_MODE,	/* 0 0 0 0 0 	GND

USB OTG Mode

              */
RID_AUD_SEND_END_BTN,	/* 0 0 0 0 1 	2K		Audio Send_End Button*/
RID_AUD_REMOTE_S1_BTN,	/* 0 0 0 1 0 	2.604K		Audio Remote S1 Button */
RID_AUD_REMOTE_S2_BTN,	/* 0 0 0 1 1 	3.208K		Audio Remote S2 Button                         */
RID_AUD_REMOTE_S3_BTN,	/* 0 0 1 0 0 	4.014K		Audio Remote S3 Button */
RID_AUD_REMOTE_S4_BTN,	/* 0 0 1 0 1 	4.82K		Audio Remote S4 Button */
RID_AUD_REMOTE_S5_BTN,	/* 0 0 1 1 0 	6.03K		Audio Remote S5 Button */
RID_AUD_REMOTE_S6_BTN,	/* 0 0 1 1 1 	8.03K		Audio Remote S6 Button */
RID_AUD_REMOTE_S7_BTN,	/* 0 1 0 0 0 	10.03K		Audio Remote S7 Button */
RID_AUD_REMOTE_S8_BTN,	/* 0 1 0 0 1 	12.03K		Audio Remote S8 Button */
RID_AUD_REMOTE_S9_BTN,	/* 0 1 0 1 0 	14.46K		Audio Remote S9 Button */
RID_AUD_REMOTE_S10_BTN,	/* 0 1 0 1 1 	17.26K		Audio Remote S10 Button */
RID_AUD_REMOTE_S11_BTN,	/* 0 1 1 0 0 	20.5K		Audio Remote S11 Button */
RID_AUD_REMOTE_S12_BTN,	/* 0 1 1 0 1 	24.07K		Audio Remote S12 Button */
RID_RESERVED_1,		/* 0 1 1 1 0 	28.7K		Reserved Accessory #1 */
RID_RESERVED_2,		/* 0 1 1 1 1 	34K 		Reserved Accessory #2 */
RID_RESERVED_3,		/* 1 0 0 0 0 	40.2K		Reserved Accessory #3 */
RID_RESERVED_4,		/* 1 0 0 0 1 	49.9K		Reserved Accessory #4 */
RID_RESERVED_5,		/* 1 0 0 1 0 	64.9K		Reserved Accessory #5 */
RID_AUD_DEV_TY_2,	/* 1 0 0 1 1 	80.07K		Audio Device Type 2 */
RID_PHONE_PWD_DEV,	/* 1 0 1 0 0 	102K		Phone Powered Device */
RID_TTY_CONVERTER,	/* 1 0 1 0 1 	121K		TTY Converter */
RID_UART_CABLE,		/* 1 0 1 1 0 	150K		UART Cable */
RID_CEA936A_TY_1,	/* 1 0 1 1 1 	200K		CEA936A Type-1 Charger(1) */
RID_FM_BOOT_OFF_USB,	/* 1 1 0 0 0 	255K		Factory Mode Boot OFF-USB */
RID_FM_BOOT_ON_USB,	/* 1 1 0 0 1 	301K		Factory Mode Boot ON-USB */
RID_AUD_VDO_CABLE,	/* 1 1 0 1 0 	365K		Audio/Video Cable */
RID_CEA936A_TY_2,	/* 1 1 0 1 1 	442K		CEA936A Type-2 Charger(1) */
RID_FM_BOOT_OFF_UART,	/* 1 1 1 0 0 	523K		Factory Mode Boot OFF-UART */
RID_FM_BOOT_ON_UART,	/* 1 1 1 0 1 	619K		Factory Mode Boot ON-UART */
RID_AUD_DEV_TY_1_REMOTE,	/* 1 1 1 1 0 	1000.07K	Audio Device Type 1 with Remote(1) */
RID_AUD_DEV_TY_1_SEND = RID_AUD_DEV_TY_1_REMOTE ,		/* 1 1 1 1 0 	1002K		Audio Device Type 1 / Only Send-End(2) */
RID_USB_MODE,		/* 1 1 1 1 1 	Open		USB Mode, Dedicated Charger or Accessory Detach */

 

11 total views, 1 views today

Windows path length limit

Windows has a path length limit that are typically at the order of 250 (260 for Windows 10) that’s a pain in the butt when moving files. Despite you can override it, it’s no fun when you copy a jillion files just to find out a few can’t make it because the path is too long and you have to find out which ones are not copied!

There’s a short command to check if the path exceed certain number of characters, which I recommend testing for 240 character so you can at least have a 10+ character folder on the root folder to put the files in:

powershell: cmd /c dir /s /b |? {$_.length -gt 240}

7 total views, 1 views today

Dual-booting: Linux and Windows fight for the system clock

Turns out it’s a common problem when dual-booting Windows and Linux, they keep changing the hardware system clock on each other (unless you live in GMT+0 zone) because Windows assume the system time is the one at the set timezone while Linux think the system time is the UTC+0 time (and offset it afterwards).

Linux updates the time through NTP server blindly while Windows 7 check if the current time is within 1hr from the NTP server to avoid unintended time changes (I have to give Microsoft credit for that). EDIT: Windows 10 blindly updates the time like Linux too.

The easy solution is to have Linux follow Windows’ suit:

timedatectl set-local-rtc 1 --adjust-system-clock

11 total views, 2 views today

X11VNC for Linux setup notes

x11vnc is a relatively smooth experience, but there are quite a few common use cases that would have been automated away if it’s a Windows program, namely have it start as a service on boot (before logging in)

It’s from babelmonk’s solution on StackExchange. Paraphrased here to make it easier to understand:

After installation, create the password file with -storepasswd switch AND specify the where you want the password saved as an optional argument, and I prefer /etc/x11vnc.pass:

sudo x11vnc -storepasswd {your password goes here} /etc/x11vnc.pass

which will be read by -rfbauth switch for the x11vnc program.


Build your own (systemctl) service by creating /etc/systemd/system/x11vnc.service:

[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2

[Install]
WantedBy=multi-user.target

Then, start with:

sudo systemctl daemon-reload
sudo systemctl start x11vnc

Enable the service (if not already done by previous commands) so it will start on boot

sudo systemctl enable x11vnc

15 total views, 1 views today

Acrobat reader on Linux

Adobe gave up supporting Acrobat reader for Linux long time ago, so it’s stuck at the old 32-bit version (9.5.5):

http://ardownload.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i386linux_enu.deb

ftp://ftp.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i386linux_enu.deb

The tutorial websites tells you to use wget, but sometimes you might run into authentication problems. You can simply use the links above and double-click the .deb file to install.

Nonetheless, it doesn’t work right out of the box in modern 64-bit Linux. You’ll run into a missing library

libxml2

on run because you didn’t install the 32-bit version of it. Enable i386 (x86 or 32-bit) packages first then get the 32-bit library:

dpkg --add-architecture i386
apt-get install libxml2:i386 ia32-libs

There are some GTK complaints if you run it on a command line, but it doesn’t affect the uses so you can safely ignore them

16 total views, no views today

systemd-resolved DNS resolution nightmare

Linux Mint 19 does not resolve local hostsnames (nothing to do with SMB, which does not rely exclusively on DNS) out of the box! Damn. MX Linux does.

systemd-resolve, which act as a local DNS server on 127.0.0.53, despite it points to the DNS server assigned by the router’s DHCP (aka, the router’s IP address itself), managed not to resolve the local hostnames out of the box!

Time to disable this mofo (no need to mess with /etc/nsswitch.conf and install Winbind to use WINS):

Disable and stop the systemd-resolved service:

sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved

Then put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf:

dns=default

Delete the symlink /etc/resolv.conf

sudo rm /etc/resolv.conf

Restart NetworkManager

sudo systemctl restart NetworkManager

I know it has good reason to exist (like breaking VPN ties), but if Linux Mint decide to have it on as out-of-the-box defaults, but unfortunately this choice caters the 5% elite at the expense of frustrating 95% of the target audience!

29 total views, 1 views today

Windscribe Linux breaks internet (messed up DNS resolution) on first use

I lost the internet (actually just DNS not resolving correctly) after installing Winscribe for Linux and disconnecting the session. WTF windscribe! I know it’s beta version, but at least you’ll check if it bricks people’s internet after a fresh install and first use!

Turns out that on first connection, it re-binds /etc/resolv.conf to /run/resolvconf/resolv.conf which has this line:

# Generated by resolvconf
nameserver 10.255.255.2

So like systemd-resolve, Windscribe lets resolvconf steal the DNS redirection that’s supposed to go straight to my router to an intermediary 10.255.255.2 that doesn’t do the job! Aargh!

To fix it (needs to be done every time after a Windscribe connection, so I’m getting rid of this lamely written Windscribe CLI for now), remove the symlink /etc/resolv.conf:

sudo rm /etc/resolv.conf

and restart NetworkManager

sudo systemctl restart NetworkManager

so NetworkManager will re-generate /etc/resolv.conf directly (no symlink) with the correct name server from the GUI config program (in my case, automatically obtained from my router).

Turns out it’s a common scene that in Linux, many DNS resolution program fight over the control over /etc/resolv.conf. NetworkManager kicks in after you disabled the rest.

16 total views, 2 views today

Bitlocker for Linux (Dislocker)

I regularly consolidate my disk drives to higher capacities as they are available to reduce the complexity managing many controllers, so I’ll often have to wipe the drives before I sell them (trade up). Often they are sold at very little moment’s notice, sanitizing the data might take too long. I learned that if I encrypt my data drives, I don’t really have to do much other than just clearing out the partition before I sell them, and there’s little performance penalty for Bitlocker in modern hardware.

Right now dislocker (Linux version of bitlocker) does not have a GUI to automatically unlock and mount the encrypted drives. Here’s the script that has the form “BL_{drive name}.sh” that will unencrypt the device and mount it and at the same time creating the script in the same folder to unwind (unmount & lock) the drive.

#!/bin/bash

# Extracting partition name from file name (BL_*.sh)
FN_base="$(basename -- $0)"
FN_bare="${FN_base%.*}"
partition=${FN_bare/BL_/}

# TODO: Check with /dev to make sure it's legit
echo $partition
dev_partition="/dev/$partition"

# Unlock the device into a raw image 'file'
path_raw="/media/dislocker/raw_$partition"
sudo mkdir -p $path_raw

file_raw="$path_raw/dislocker-file"
sudo dislocker $dev_partition -u -- $path_raw

# Mount the image file as a disk
path_mount="/media/dislocker/mount_$partition"
sudo mkdir -p $path_mount

sudo mount -o loop $file_raw $path_mount

# Build wind down file
script_unwind="unwind_$partition.sh"
# Leave /media/dislocker there for isolation
echo "#!/bin/bash"             > $script_unwind
echo "sudo umount $path_mount">> $script_unwind
echo "sudo rmdir $path_mount" >> $script_unwind
# Note that the website is wrong. umount the path, not the dislocker-file
echo "sudo umount $path_raw"  >> $script_unwind
echo "sudo rmdir $path_raw"   >> $script_unwind
# Make sure the "$0" is literal including the $ sign or it will
# delete this file instead of the unwind_sd*.sh file
echo "sudo rm -- \"\$0\""     >> $script_unwind
chmod +x $script_unwind


 

10 total views, 2 views today

General Linux Setup Notes

Install these:

  • Putty (or remember to use ssh -l loginName)
  • Install freerdp-x11 before installing KRDC (Remote desktop client)

Foobar2000 requires snapd to install. It doesn’t have a GUI package manager (either use “sudo snap install” or use Snap Store to find the app and click ‘Install’ directly from there)

There’s a chicken-and-egg problem with snap store though. On Linux Mint, snap-store needs to be installed with command line before the button on the web page works correctly. So there’s no way around doing this command line once: “sudo snap install snap-store”

You’d be better off just doing “sudo snap install foobar2000” if you are not going to use SnapCraft store again later.

My other favorite Windows app Notepad++ is also on snap store. Unfortunately, these are both Wine applications that Cinnamon doesn’t scale them properly with HiDPI mode. I’ll use NotepadQQ instead.

It’s a pain in the butt to deal with snap store because it won’t automatically create shorcuts on the panel or desktop. Then you cannot directly run it in the command line either because the apps are install under /snap/bin and it’s not in the path either! Add it in /etc/environment and RE-LOGIN!

There are websites that teaches you to extend the path in /etc/profile.  It’s not necessary if you did /etc/environment already. Doing both will have the path added twice!

Finally, the icons files are hidden in: /var/lib/snapd/desktop/applications and the panel icons can be anebled by linking the .desktop folders:

sudo ln -s /var/lib/snapd/desktop/applications/ /usr/share/applications/snap 

Geeze! A windows program this broken these days are not the norm. They never work right out of the box for the most natural and common use cases!


Only Evolution Mail Client supports Google accounts from GNOME online account services. Install Evolution first before adding accounts or they will be called “Unnamed” and there’s no way to change it until you remove the account and re-add.

8 total views, no views today

Input Methods (IME) in Linux: Fcitx

IBus is considered as retiring, but it’s still the default in MX Linux. Because the only Cantonese IME in Linux that allows me to swear is Andrew Choi’s CAP, which runs on fcitx, I settled for fcitx as my default IME engine.

Languages

  • Cantonese: Download the debian package for CAP
  • Japanese: Mozc is already installed
  • Simplified Chinese: Pinyin is already installed

Shortcuts (Very much like Windows):

  • Ctrl + Space: turn it on/off
  • Ctrl + Shift: switch between languages
  • Shift: in and out of temporary English mode (inactivate) within the language

8 total views, no views today