AsteroidOS / meta-smartwatch

OpenEmbedded layer that provides support for various smartwatches.
25 stars 18 forks source link

Add a sparrow mainline machine config #169

Closed FlorentRevest closed 1 year ago

FlorentRevest commented 1 year ago

Display isn't working but this boots to the rootfs with a RNDIS USB connection so others can pick up the work from here.

The "upstream" kernel is actually a branch on top of 6.0 written by z3ntu, originally for PostmarketOS. A lot of this is in the actual mainline kernel but this branch has a few extra patches to, for example, get the lenok display working. This is unconsequential for sparrow but I anticipate that the same kernel would also work on lenok and sturgeon (I don't own these watches so I can't test it) and figured it would be a good base for other qualcomm mainline ports.

Note that in this upstream setup, the kernel needs to be appended with an appropriate device tree blob. The machine configuration specifies which is the DTB to compile and cat at the end of the zImage. Replicating this setup on lenok/sturgeon should be a simple matter of designating another of the mainlined dts. On another qcom watch, one would need to write a new dts (but the msm8226 bits are shared quite extensively so it seems within reach).

The img_info is the same as on the "normal" sparrow but with an empty command line, indeed, boot.img offsets are all the same but these android specific command line flags don't make sense upstream.

The defconfig is simply the arch/arm/configs/qcom_defconfig distributed in that branch. Importantly (compared to the mainline qcom_defconfig) it has CONFIG_USB_ETH=y meaning that as soon as the kernel boots it shows up as a RNDIS/CDC device.

Because upstream kernels don't have support for ADB gadget USB functions, this also modifies the initramfs script to configure a telnet CDC instead of adbd. This is actually a bit hacky and we should rather unify all our init scripts to detect what is available and configure things accordingly... But not today.

On the android kernel, the initramfs machine.conf specifies a hardcoded userdata partition path (mmcblk0p29) but I have noticed that occasionally (once every 10 boots or so) the device node for that partition is named mmcblk1p29 instead... I circumvented this by setting sdcard_partition to mmcblk*p29 (#hackerman) but this made me realize we should rather refactor our initramfs script to discover the partition automatically rather than relying on a hardcoded path. But... not today either.

Our usb-moded setup also assumes Android kernel features... There's quite some work that'd need to be done here like disabling the ADB mode entirely or consolidating our /usr/bin/init_ffs and /usr/bin/init_gfs (it's not even clear whether they are needed, it seems that usb-moded should be able to do everything they do). Anyway, I could not get usb-moded to work like I wanted (directions to look into for whoever wants to pick it up from here: adding --debug to /lib/systemd/system/usb-moded.service and tweaking /etc/usb-moded/dyn-modes/developer_mode.ini) so instead I modified init_gfs to statically configure the usb line with a fixed IP address and wait into an infinite loop to prevent the usb_moded daemon from even starting. This expects the user does a ifconfig interface 192.168.2.1 on their computer before they can SSH into the watch. Admitedly, this is really not great but after 7 days of trying to get usb-moded to work, I just want to push this work and never look back again.

Finally, this removes a dependency of pulseaudio to a hybris plugin. Instead, the default should be that pulseaudio does not depend on that plugin and every hybris-watch should install it but it'd be a larger refactoring that I'm not willing to tackle in the scope of this change.