Lenovo ThinkSmart View ROM/OS Development

Not at the moment.
The hack I came up with previously is here: wip: TAS5872M codec · kaechele/msm8953-mainline-linux@25b1a5c · GitHub
But after a bit more careful study it looks like the TAS5805M is different enough to warrant some more extensive changes to properly support the TAS5782M that’s in the TSV. I’m especially hoping to speed up waking the codec from sleep. Right now the TAS5805M driver always re-programs the DSP registers (which isn’t necessary), and uses delays that can be shortened or removed for the TAS5782M. Also, the TI5805M needs the firmware split up in specific portions and has a static header that isn’t static on TAS5782M firmwares that I’ve seen. So that needs some figuring out as well.
So right now, with the hack, it misses a chunk of the audio at the beginning of a new audio stream. I’m hoping a proper implementation can fix this.
But TI likes to play 4D Chess with their register map (two nested levels of indirect register access they call “book” and “page”) and the Kernel doesn’t have a neat way to deal with it. Existing TI drivers re-implement parts of the regmap interface in the Kernel to work around it, but I’m trying to find a way that doesn’t require as much manual labour.

@csdvrx
I did see your email yesterday. I just haven’t gotten to it yet.
The bit-banging itself is done via the i2c-gpio driver. This is already setup on the device. So you should be able to talk to the sensor using the regular i2c tools. It shows up as a normal I2C bus and the accelerometer connected to it works and is enabled.
The sensor is being disabled here, so if you’re brave you can edit it and rebuild the kernel.
The easiest way to build the kernel is with envkernel.sh. My incantation (from within a cloned msm8953-mainline/linux repo) usually looks like this:

  1. . ../pmbootstrap/helpers/envkernel.sh (I have pmbootstrap cloned in a directory one level below the msm8953-mainline/linux folder)
  2. make menuconfig and/or make -j24
  3. pmbootstrap build --envkernel linux-postmarketos-qcom-msm8953 (makes a temporary package of the kernel)
  4. pmbootstrap sideload linux-postmarketos-qcom-msm8953 (installs it on the device, might need --host if you want to do it via WiFi instead of USB)

You may be able to get the sensor working from userspace by speaking directly via I2C to it. Just do a GitHub search for vcnl4200. There’s stuff like this: vcnl4200/vcnl4200.py at 1baa7b24ffc9b5ed275a8fe1846ba4d24b7fe4b5 · petermankowski510/vcnl4200 · GitHub

As for the USB-OTG thing:
I use exactly the breakout board you posted. Works great.
I’m not sure if simply applying 5V on VBUS will trigger OTG host mode. I doubt it, because that’s what USB ID is for and that’s probably also the default configuration for the host controller. You can check some of my experimentation with it here: re-enable USB · kaechele/msm8953-mainline-linux@de61f09 · GitHub
Essentially I looked if I can use GPIO4 or 5 to fake a USB ID trigger. It generally works (by pulling GPIO4 or 5 to GND), but you lose the ability to do UART through those pins within Linux then. UART still works in the bootloader phase, obviously. The USB-C pins that connect through to GPIO 4 and 5 seem 5V tolerant, so I didn’t fry the board by piping 5V into it.

I’ll have to see if I still have some images flying around from before the systemd switch.
You’re right about that, not all desktop environments are currently working properly with systemd. So far, I only had luck with plasma-mobile.

@FelixKa Thanks a lot for all the pointers! No need to waste time looking for a pre-systemd image: I wanted to try the latest postmarketos image just because I prefer systemd (I’m not familiar with openrc)

If it’s possible to start phosh manually, then as soon as I have a reliable way to connect to the Thinksmart, I will find a way to reliably start phosh on boot with a systemd service, then fix the other boot errors as they might impact networking. I’m familiar with systemd and writing services, so as soon as I can login one way or another, it shouldn’t take long.

For the USB OTG, I don’t have the block diagram so I can’t say for sure if it would work; I just quoted the wiki from Lenovo ThinkSmart View (lenovo-cd-18781y) - postmarketOS Wiki

If I understand correctly, you remap the UART GPIOs to trigger the USB ID and get USB OTG working as it should? Then I could add a switch to manually do that and keep the UART, but it may be overkill: the main interest of the UART is in the bootloader phase for the dmesg.

After the bootloader, the USB device mode could be used instead, so if the UART may cause any problems for the USB OTG, it’s better to do without it and have a reliable USB connection

I believe it would be far simpler to have the USB OTG host/device work well, and in device mode simply offer an adb access (for login + file transfer), or maybe a usb-gadget composite mode.

I’m not sure how familiar you are with composite modes - basically it’s 1 physical USB device pretending to be several devices at one.

This is done on some embedded systems with libcomposite and configfs: the ThinkSmart could then pretend to be say both a CDC Serial and a CDC ACM or CDC RNDIS, with a getty listening on the virtual serial port, and a dhcp server on the virtual network interface which could be managed by systemd-network.

Then, there would be no need for the UART past the bootloader: just plugging the ThinkSmart into a computer would trigger the USB device mode, and enumerate both virtual USB devices, exposing a serial port (for maintenance) AND a network interface (for file transfer, etc)

What would you think about that?

If you like the idea, I will see what can do to make it work using the openrc image you currently have on your website. If we can get at least the CDC ACM mode working in a systemd image, I could use that to login as root, see more precisely what’s going wrong, then fix the services.

PostmarketOS already does that out of the box: USB Network - postmarketOS Wiki

You should be able to ssh into 172.16.42.1. I don’t know off the top of my head what the default username and password is.

Send it if you can (please give me command to write it to device). I mounted the img file to view it. Some folders are empty like:


Could it be that pmbootstrap prepared corrupted img? How important it is to have edl cable ? I am doing everything with just some common usb-a to usb-c cable.
@csdvrx I can’t go pass lk2nd Fastboot display. I am unable to boot into system. The Continue entry is grayed out.
I am sending my img: https://drive.google.com/file/d/17OK_opKOQbCWMb4pi6qmfV8-FC3kZlLb/view
and the scan for it: VirusTotal

@mikart143 I don’t think any new functions have been added, so why not simply use the bootloader image lk2nd-lenovo-cd-18781y-latest.img from felix site: thinksmart

You can mix and match: on my device it works even with the latest systemd based image, although you will just get a blank screen with a blinking cursor for now.

BTW if you can’t boot and get stuck to this screen, please make sure you are not accidently flashing .xz compressed image files in the userdata: file will tell you what the type is:

$ file lk2nd-lenovo-cd-18781y-latest.img
lk2nd-lenovo-cd-18781y-latest.img: Android bootimg, kernel, page size: 2048, cmdline (lk2nd)

$ md5sum lk2nd-lenovo-cd-18781y-latest.img
028c2468833b4107d9ca06361c204d42  lk2nd-lenovo-cd-18781y-latest.img

$ file pmos-lenovo-cd-18781y-testing-latest.img
pmos-lenovo-cd-18781y-testing-latest.img: DOS/MBR boot sector; partition 1 : ID=0x83, active, start-CHS (0x4,4,1), end-CHS (0x3d3,210,2), startsector 2048, 497664 sectors; partition 2 : ID=0x83, start-CHS (0x3d3,211,1), end-CHS (0x3ff,254,2), startsector 499712, 4368384 sectors

$ file 20250124-1029-postmarketOS-edge-phosh-22.5-qcom-msm8953.img
20250124-1029-postmarketOS-edge-phosh-22.5-qcom-msm8953.img: DOS/MBR boot sector; partition 1 : ID=0xef, active, start-CHS (0x4,4,1), end-CHS (0x3d3,210,2), startsector 2048, 497664 sectors; partition 2 : ID=0x83, start-CHS (0x3d3,211,1), end-CHS (0x3ff,254,2), startsector 499712, 4300800 sectors

@FelixKa: thanks, I didn’t know PostmarketOS did that! if there’s already ssh it makes little sense to also add a virtual serial port with a getty, but it could be helpful when having boot issues (like here with what seems like networking problems) as the stack would be lighter

I’ll see what I can do, right now I’m moving my code from pyblue to bleak - it’s so much better!

@FelixKa @csdvrx with the data coming from @FelixKa I was able to successfully boot into system. After trial and error couple of edge build I was able to get sth to work (I see that there is no rule which image will pass the Fastboot screen). Thank you for help! Nothing that I compile myself via pmbootstrap is bootable. What is more on newest lk2nd the welcome screen in phosh image from @FelixKa is not responsive

@mikart143 Did some tests as well. The only UI I can successfully boot at this moment is plasma-mobile. But it generates a relatively large image that leaves almost no space for anything else.
I have generated a new image and lk2nd that I have verified to work:

Username pmos / Password 1234

Made sure to not forget my SSH keys in there. I think one of the other image had it.
Weirdly, pmbootstrap config ssh_keys False does not work. I can’t get it to switch to False, it just stays at True. So I just removed the ssh_key_glob config, so it can’t find my SSH keys any longer :stuck_out_tongue:

The image only comes with fbkeyboard, so no GUI. But I was able to connect to my WiFi successfully using nmtui. That way you can try installing anything you’d want using apk. I have a feeling that installing any of the non-working UIs will also not magically make them work, even if they are installed after the fact. I guess we just need to wait for pmOS to stabilize after the systemd switch.

1 Like

not exactly sure how, but i managed to get gnome-mobile running from a fresh flash using your latest lk2nd image and my own pmbootstrap’d image, and running pmbootstrap flasher flash_rootfs while in lk2nd.

edit: the graphics are freaking the hell out, this is trippy

Yeah, don’t do Gnome Shell. It’s no bueno on that GPU :face_with_spiral_eyes:

I think I found a bug :sweat_smile:

Indeed, with just a normal USB-C to A cable, the CDC mode works fine with your openrc image from June: in lsusb it enumerates as “18d1:d001 Google Inc. Nexus 4 (fastboot)”, and I see in the dmesg: “cdc_ncm 2-1.4:1.0 usb0: register ‘cdc_ncm’ at usb-0000:00:14.0-1.4, CDC NCM (NO ZLP)”

However, with the postmarketOS systemd phosh image, I can’t see anything at all in either lsusb or the dmesg, so I think this image is configured VERY incorrectly: even if /etc/NetworkManager/system-connections/USB Networking.nmconnection is missing, I should at least be able see something in lsusb!

While waiting for my USB-C breaker boards, I can’t do anything at all to try fixing this systemd image - but when I’ll have it, even if the UART works, I think I won’t be able to use it: after loop mounting the image, I see no trace that a getty is setup to listen on the UART. For that, the image would need at least something like /etc/systemd/system/[email protected] (or ttyHSL0 or whatever name is used for it)

Today , I’ve tried to compile the bootloader to see if the recovery mode could be used (Android Recovery - postmarketOS Wiki)

I’ve successfully compiled lk2nd 20.0-next-b9c007bb-20250123-dirty, I can select recovery with volume up, and it goes into recovery - but the default recovery that is installed (8.1.0/OPM1.171019.026/penghu10061543) doesn’t seem to offer any option I could use to connect, mount the userdata partition and start fixing the systemd services manually.

@mikart143 reports “Nothing that I compile myself via pmbootstrap is bootable” and given what I can see from the systemd image, it may require some work.

@FelixKa, would you have some recovery image that would have anything I could use to connect to the running image and type commands?

I could get an image of the recovery partition by edl r recovery recovery.img which I used to bake a custom recovery by extracting a few binaries from postmarketos, creating a initramfs.cpio.gz, which I then packaged with the kernel into an img file with bootimgtool -c -k zImage -r initramfs -p parameters.cfg ../customrecovery.img

This customrecovery was then signed it with ../../lk2nd/lk2nd/scripts/bootsignature.py -s -c ../../lk2nd/lk2nd/certs/verity.x509.pem -k ../../lk2nd/lk2nd/certs/verity.pk8 -i ../customrecovery.img -o ../customrecovery.img.signed -t /recovery and flashed with edl w recovery customrecovery.img.signed

However, while I can still boot to the normal (broken) postmarketOS systemd, I can’t get to the lk2nd menu by pressing Vol+ on boot - it’s as if my custom recovery partition prevented even showing the menu.

lk2nd menu works fine if I flash the original recovery.img, so I think it may be due to the signing step.

If you have a working recovery with adbd, telnet (or ANYTHING AT ALL!), that would be faster than trying to recreate a minimal signed working recovery

If you don’t, any hint would be appreciated :slight_smile:

1 Like

you could use EDL to install the LineageOS recovery partition, that’s what my device uses.

Well, if we can login and tweak things, we can try make them work!

I’ve just tried your image, but it’s an openrc image.

Do you think you could make a similar minimal image for systemd?

I just tried this image to see if I could get a connection - but no “adb: device unauthorized”

The sideload would only help blindly write to the partition, while I would like to type a few commands as root to fix the systemd problem

Given how lineage recovery works so well, I wonder what I did work with my custom recovery image :confused:

I managed to re-enable volume key waking on my device with the following udev rules, inspired by this blog post from phosh:

ACTION=="remove", GOTO="volume_keys_end"
KERNEL!="event*", GOTO="volume_keys_end"

KERNELS=="input*", ENV{ID_PATH}=="platform-gpio-keys|*resin", ENV{GM_WAKEUP_KEY_114}="1", ENV{GM_WAKEUP_KEY_115}="1"

LABEL="volume_keys_end"
1 Like

Awesome! I meant to try this again after the systemd change. Because before that pmOS actually didn’t have a full udev implementation that supported those rules.
Glad that it works!

i don’t think my ThinkSmart even runs systemd - i pmbootstrapped my own image without it because it kept failing to bootstrap a systemd repo.

I would like to try fixing the issues, but that would work better if I could observe them on a running system.