Difference between revisions of "PineNote Development/Building Kernel"

From PINE64
Jump to navigation Jump to search
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Building the Kernel =
= Building the Kernel =


Hello geniuses. You've bought a pinenote (told you you were a genius!), followed Dorian's directions to get Arch installed, but then you've seen someone playing DOOM (TODO link) and you want to learn how to do that too. To get your PN running this smoothly, we'll need to build our own kernel. There are two kernel efforts underway right now:
After followed [https://github.com/DorianRudolph/pinenotes#starter-guide Dorian's directions] to get Arch installed you've seen someone [https://github.com/m-weigand/mw_pinenote_misc/blob/main/videos/20220808_bw_dither_mode_picture_doom_video_small.mp4 playing DOOMand you want to learn how to get the features that enable that kind of performance. To get your PN running this smoothly, we'll need to build our own kernel. There are two kernel efforts underway right now:


# pgwipeout: https://gitlab.com/pgwipeout/linux-next
# pgwipeout: https://gitlab.com/pgwipeout/linux-next
# smaeul: https://github.com/smaeul/linux/tree/rk35/pinenote-next
# smaeul: https://github.com/smaeul/linux/tree/rk35/pinenote-next


We'll be using smaeul's kernel + some additional patches provided by DorianRudolph, pgwipeout, Maximilian Weigand, occam_razor, and hrdl (did I forget anyone?). Thanks so much to them, and all the other users who have worked on piecing together drivers, twiddling configs, answering questions, and sharing their work in other ways. Brava!
We'll be using smaeul's kernel + some additional patches provided by DorianRudolph, pgwipeout, Maximilian Weigand, occam_razor, and hrdl. Thanks so much to them, and all the other users who have worked on piecing together drivers, twiddling configs, answering questions, and sharing their work in other ways. Brava!
 
Perhaps the main component of the kernel is the DRM driver. You can read more about the driver by reading [https://lore.kernel.org/linux-rockchip/20220413221916.50995-1-samuel@sholland.org/T/ Smaeul's RFC].


=== A small warning ===
=== A small warning ===
Line 12: Line 14:
This guide is completely based off of the scripts provided by Maximilian. We'll be cloning and running them, but he owns them and he -- or others -- might change them. It's smart to have a look at what's going on, check when this page was last updated vs when his scripts were last updated, etc. Be nimble!
This guide is completely based off of the scripts provided by Maximilian. We'll be cloning and running them, but he owns them and he -- or others -- might change them. It's smart to have a look at what's going on, check when this page was last updated vs when his scripts were last updated, etc. Be nimble!


Additionally, as Maximilian warns [https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches here], these changes are all experimental and may damage your panel. <strong>If anyone reading this has recommended reading for how we can understand what may damage our panels (IE is the risk in fast updates? The types of updates? something more complicated?), please add it here!</strong>
Additionally, as Maximilian warns [https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches here], these changes are all experimental and may damage your panel.  
 
{{info|If anyone reading this has recommended reading for how we can understand what may damage our panels (IE is the risk in fast updates? The types of updates? something more complicated?), please add it here!}}


== What you should have already done ==
== What you should have already done ==


I assume you've already got an operating system installed on your Pinenote other than the stock Android. Doing this isn't trivial, but it is well understood -- you will be following the footsteps of many others. Dorian Rudolph made a guide for doing this, available here (TODO link).  
I assume you've already got an operating system installed on your Pinenote other than the stock Android. Doing this isn't trivial, but it is well understood -- you will be following the footsteps of many others. Dorian Rudolph made a guide for doing this, available [https://github.com/DorianRudolph/pinenotes#starter-guide here].


== What do you need to know? ==
== What do you need to know? ==


If you followed Dorian's guide to get here and felt semi-comfortable, you'll be fine. This is no more complicated than that. If you are intimidated, that's okay! I'll still encourage you to try :) you will learn a lot, just be patient and don't put any data on your PineNote that you wouldn't be okay losing. If you run into trouble, ask for help in the Discord/Matrix (TODO link). Please try to solve problems on your own first, and if nobody replies, please be patient and ask again soon. You can reach me at @aarondabomb on Matrix. Please edit this document if you think something could be clearer or you see a great opportunity for a joke! Have fun :)
If you followed Dorian's guide to get here and felt semi-comfortable, you'll be fine. This is no more complicated than that. If you are intimidated, that's okay! I'll still encourage you to try :) you will learn a lot, just be patient and don't put any data on your PineNote that you wouldn't be okay losing. If you run into trouble, ask for help in the [https://discord.com/invite/pine64 Discord]/[https://matrix.to/#/#pinenote:matrix.org Matrix]. Please try to solve problems on your own first, and then ask for help -- if nobody replies, please be patient and ask again soon.


= Getting Started =
== Steps to build ==


<ol>
<ol>
Line 33: Line 37:
</pre>
</pre>
<li> Compile the kernel: </li>
<li> Compile the kernel: </li>
<pre> $ sh ../mw-pinenote_misc/custom_kernel/compile.sh </pre>
<pre> $ sh ./mw_pinenote_misc/custom_kernel/compile.sh </pre>
<li> Next we want to perform the work captured in <code>install_to_pn.sh</code>, but the work may vary slightly from person to person. For example, I believe Maximilian is running Arch Sid, and I am running Manjaro -- because of this, and personal preference, some of our files live at different places. As long as you put them somewhere and configure your <code>extlinux.conf</code> to point at it, things will be okay. Looking at <code>install_to_pn.sh</code>, we can see that there are three pieces to installing the kernel: the kernel image (called <code>Image</code>), the device tree (<code>rk3566-pinenote-v1.2.dtb</code>), and the modules. All of these files have been compiled and placed into the <code>linux/pack</code> folder. The easiest way to send these over is by using scp or rsync -- read the script and decide how you would like to get your files in the correct location. You may need to install rsync on your PineNote if it doesn't already have it.
<li> Next we want to perform the work captured in <code>install_to_pn.sh</code>, but the work may vary slightly from person to person. For example, I believe Maximilian is running Debian Sid, and I am running Manjaro -- because of this, and personal preference, some of our files live at different places. As long as you put them somewhere and configure your <code>extlinux.conf</code> to point at it, things will be okay. Looking at <code>install_to_pn.sh</code>, we can see that there are three pieces to installing the kernel: the kernel image (called <code>Image</code>), the device tree (<code>rk3566-pinenote-v1.2.dtb</code>), and the modules. All of these files have been compiled and placed into the <code>linux/pack</code> folder. The easiest way to send these over is by using scp or rsync -- read the script and decide how you would like to get your files in the correct location. You may need to install rsync on your PineNote if it doesn't already have it.
   <ol><li>If it helps, I installed my dtb like this: <code>$ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/</code></li>
   <ol><li>If it helps, I installed my dtb like this: <code>$ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/</code></li>
       <li>After installing the dtb as above, I updated my <code>/boot/extlinux/extlinux.conf</code> to point to this new file (previously, my dtb did not have the <code>-v1.2</code> on the end).</li>
       <li>After installing the dtb as above, I updated my <code>/boot/extlinux/extlinux.conf</code> to point to this new file (previously, my dtb did not have the <code>-v1.2</code> on the end).</li>
</li>
</li>
<li> (Perhaps not necessary?) The last step is to generate a new initrd image. (If you're like me and don't know what initrd is, the [https://en.wikipedia.org/wiki/Initial_ramdisk wiki] is very enlightening.) This is done on the PineNote itself. Send Maximilian's installation script over and run it. Then place the generated image (from the last step of the shell script) into your boot partition and update <code>extlinux.conf</code> if needed to point at this new file. 
<pre>
$ scp initrd/gen_uboot_image.sh root@pinenote:/root # Do this part on local to put script on PN
$ ssh root@pinenote # Or use UART, the dongle + picocom, and change to root
$ cd /root
$ ./gen_uboot_image.sh
$ mv initrd.img /boot/initrd.img
$ vim /boot/extlinux/extlinux.conf # Update this to reference this new initrd image
</pre>
<li> At this point your kernel is in place! However, there are a few more steps you may need to complete to ensure the display and networking continue to work:
<li> At this point your kernel is in place! However, there are a few more steps you may need to complete to ensure the display and networking continue to work:
<ol>
<ol>
Line 44: Line 57:
</ol>
</ol>
</li>
</li>
<li> Next, we need to install a patched version of Mesa. occam_razor was kind enough to provide
<li> This part technically isn't kernel specific, but we need to install a patched version of Mesa. If you are running an Arch based system, you're in luck! occam_razor provides prebuilt patched packages (say that 5 times fast) [https://github.com/0cc4m/pinenote-misc/releases here]. Simply extract these files, send them to PN, and install them using the package manager. You can also patch it yourself by looking at Maximilian's [https://github.com/m-weigand/mw_pinenote_misc/blob/main/compile_mesa.sh compile_mesa.sh]. {{info|If you frequently update your system with something `pacman -Syu`, you will end up updating these packages and losing the patches. Add this line to your <code>/etc/pacman.conf</code> to prevent them from being updated: <pre>IgnorePkg = libva-mesa-driver mesa mesa-debug mesa-vdpau opencl-mesa vulkan-mesa-layers vulkan-broadcom vulkan-panfrost vulkan-radeon vulkan-swrast</pre>}}</li>
<li> To ensure the GPU stays on, we need to use Maximilian's [https://github.com/m-weigand/mw_pinenote_misc/blob/main/systemd/mweigand_eglinfo.service mweigand_eglinfo.service]. The Readme.md in that same directory has instructions for how to install this, but basically we need to copy it to <code>/etc/systemd/system/</code>, run <code>sudo systemctl daemon-reload</code> to make sure systemd knows it exists, then execute <code>sudo systemctl enable mweigand_eglinfo.service</code></li>.
</ol>
</ol>


That should be it! Now are equipped with the freshest kernel + patches
That should be it! Now are equipped with the freshest kernel + patches.
 
However, to keep parity with Maximilian and enable the GPU, I completed a few other steps as well which involve generating a new . I'm not sure if these are necessary -- if someone wants to update this to indicate what is necessary, what is not, and maybe even why that is the case, that would be helpful :)</li>
 
 
 
WIP!!!
 
What I'm Doing
## compile mesa
### get mesa from here: https://github.com/0cc4m/pinenote-misc/releases (I can't install since I am deving on debian, not arch).
### Try to run dpkg-buildpackage gives me an error saying it can't open debian/changelog. This is because I don't have the debian package, which can be obtained here (I think) : https://salsa.debian.org/xorg-team/lib/mesa/-/tree/mesa-22.1.3-1.
### Install devscripts, run `mk-build-deps --install --root-cmd sudo --remove` to install build dependencies, then run dpkg-buildpackage.
### This spat out a ton of files into ../ (but not libmutter-9-0_41.4-1_arm64.deb as indicated in the install script. Worse, I didn't cross compile, it's all amd64 deb!
### I'm so dumb because it comes prebuilt in 0cc4m's stuff: https://github.com/0cc4m/pinenote-misc/releases lol
### Send that stuff over to the pinenote!!
### Untar it and install the packages like this: https://wiki.archlinux.org/title/offline_installation_of_packages
# At this point everything should be installed. Let's restart and see what happens.
## Kernel panic: https://pastebin.com/4Z0aJgHz
## Looking back to see if I missed anything. Mutter? Similar to mesa, but I actually have to build it. Build script has commands needed. Ah shit but I'm on debian, meaning I can only build for debian. I could do a chroot thing...but it's probably not mutter.
# But now networking is busted. Looking trhough `journalctl` for hints.
## https://matrix.to/#/!QtTzSRYMuozjbOQkzJ:matrix.org/$HdLaPUKxQr3F690EFNa0Qk0tm_k-72p8cX6ngObk_XQ?via=matrix.org&via=kde.org&via=tchncs.de
## Just rename those files and we'll boot, but still not display -- do I need modified mutter? It's X that's failing to start
# Display doesn't work either
## Need to change lib/firmware/waveform.bin to lib/firmware/rockchip/ebc.wbf. This whole conversation is a lot of the same stuff i ran into: https://matrix.to/#/!QtTzSRYMuozjbOQkzJ:matrix.org/$hnt-F-5YkDfb5I4Ky_ENI7s2jqq4O5Aeo-y4dFCsp_0?via=matrix.org&via=kde.org&via=tchncs.de
https://pastebin.com/VqXyHg6m
Aug 24 17:36:06 manjaro-arm sddm[693]: Display server starting...
Aug 24 17:36:06 manjaro-arm sddm[693]: Adding cookie to "/var/run/sddm/{e87f9555-bfb2-4d27-899d-1adea4cedbf1}"
Aug 24 17:36:06 manjaro-arm sddm[693]: Running: /usr/bin/X -nolisten tcp -background none -seat seat0 vt1 -auth /var/run/sddm/{e87f9555-bfb2-4d27-899d-1adea4cedbf1} -noreset -displayfd 18
Aug 24 17:36:06 manjaro-arm NetworkManager[682]: <info>  [1661387766.6634] dhcp4 (wlan0): state changed new lease, address=192.168.50.184
Aug 24 17:36:06 manjaro-arm sddm[693]: Failed to read display number from pipe
Aug 24 17:36:06 manjaro-arm sddm[693]: Display server stopping...
Aug 24 17:36:06 manjaro-arm systemd-timesyncd[658]: Network configuration changed, trying to establish connection.
Aug 24 17:36:06 manjaro-arm sddm[693]: Attempt 3 starting the Display server on vt 1 failed
Aug 24 17:36:06 manjaro-arm sddm[693]: Could not start Display server on vt 1
## yea looks like display server isn't starting. I tried running the x command from tty: https://pastebin.com/yP3A9cde "no screens found"
 
 
 
# Going to try switching to gnome?
https://wiki.ubuntu.com/LightDM#Changing_the_Default_Session
 
# Try switching to wayland? Idk the other guy was getting this error with wayland and sway, I'm getting with X and kde. Maybe something else.
 
# Look for sddm logs
 
Occam rescued me again!


Aug 21 12:53:07 manjaro-arm audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=upower comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
= Next Steps =
Aug 21 12:53:07 manjaro-arm kernel: audit: type=1130 audit(1661111587.904:73): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=upower comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
== Configuring the driver ==
Aug 21 12:53:08 manjaro-arm kwin_wayland_wrapper[436]: MESA-LOADER: failed to open rockchip_ebc: /usr/lib/dri/rockchip_ebc_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/dri, suffix _dri)
The driver has several options that can improve performance. These can be read about [https://github.com/m-weigand/mw_pinenote_misc/tree/main/rockchip_ebc/patches#new-features-as-of-2022august08 here]. Personally, I use <code>rockchip_ebc.bw_mode=1 rockchip_ebc.default_waveform=1 rockchip_ebc.refresh_threshold=30 rockchip_ebc.auto_refresh=1</code> to make the image lower quality, but much faster to update. The auto_refresh setting is also essential to clear ghosting which will otherwise accrue on screen. I added the above settings the <code>APPEND</code> line in my <code>extlinux.conf</code> to make sure they are applied on boot.
Aug 21 12:53:08 manjaro-arm kwin_wayland_wrapper[436]: failed to load driver: rockchip_ebc


from journal
== Fixing Suspend ==
If you're using a logind system, edit your <code>/etc/systemd/logind.conf</code> config. More information on what to do [https://wiki.archlinux.org/title/Power_management#ACPI_event in Arch's documentation].


DEBUGGING NETWORK NOT WORKINg
== Configuring your apps ==
Hints:
See [https://wiki.pine64.org/wiki/PineNote_Development/Apps this page].
cfg80211: Process '/usr/bin/set-wireless-regdom' failed with exit code


brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.pine64,pinenote-v1.2.bin
== Booting Linux instead of Android ==
brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.bin failed with error -2
[[PineNote Development/Booting Linux]]


Yep, this whole conversation:
== Fixing Bluetooth ==
Some users have noticed instability with their wireless driver. Upgrading the driver to the version provided by LibreELEC may help! To do this, download the BCM4345C0.hcd, brcmfmac43455-sdio.bin, and brcmfmac43455-sdio.txt from the [https://github.com/LibreELEC/brcmfmac_sdio-firmware/tree/master libreELEC repositories] and place them in the same location as your previous firmware (`/lib/firmware/brmc/`). Then rename brcmfmac43455-sdio.{txt,bin} as `brcmfmac43455-sdio.pine64,pinenote-v1.2.{txt,bin}`. If this doesn't help, ask about it in the matrix chat!


Debug display not working
=== Autoconnect to your Bluetooth devices ===
[   4.532267] rockchip-ebc fdec0000.ebc: Direct firmware load for rockchip/ebc.wbf failed with error -2
This [https://github.com/jrouleau/bluetooth-autoconnect bluetooth-autoconnect project] may help.
[    4.533249] rockchip-ebc: probe of fdec0000.ebc failed with error -2

Revision as of 20:53, 4 December 2022

Building the Kernel

After followed Dorian's directions to get Arch installed you've seen someone playing DOOM and you want to learn how to get the features that enable that kind of performance. To get your PN running this smoothly, we'll need to build our own kernel. There are two kernel efforts underway right now:

  1. pgwipeout: https://gitlab.com/pgwipeout/linux-next
  2. smaeul: https://github.com/smaeul/linux/tree/rk35/pinenote-next

We'll be using smaeul's kernel + some additional patches provided by DorianRudolph, pgwipeout, Maximilian Weigand, occam_razor, and hrdl. Thanks so much to them, and all the other users who have worked on piecing together drivers, twiddling configs, answering questions, and sharing their work in other ways. Brava!

Perhaps the main component of the kernel is the DRM driver. You can read more about the driver by reading Smaeul's RFC.

A small warning

This guide is completely based off of the scripts provided by Maximilian. We'll be cloning and running them, but he owns them and he -- or others -- might change them. It's smart to have a look at what's going on, check when this page was last updated vs when his scripts were last updated, etc. Be nimble!

Additionally, as Maximilian warns here, these changes are all experimental and may damage your panel.

Note: If anyone reading this has recommended reading for how we can understand what may damage our panels (IE is the risk in fast updates? The types of updates? something more complicated?), please add it here!

What you should have already done

I assume you've already got an operating system installed on your Pinenote other than the stock Android. Doing this isn't trivial, but it is well understood -- you will be following the footsteps of many others. Dorian Rudolph made a guide for doing this, available here.

What do you need to know?

If you followed Dorian's guide to get here and felt semi-comfortable, you'll be fine. This is no more complicated than that. If you are intimidated, that's okay! I'll still encourage you to try :) you will learn a lot, just be patient and don't put any data on your PineNote that you wouldn't be okay losing. If you run into trouble, ask for help in the Discord/Matrix. Please try to solve problems on your own first, and then ask for help -- if nobody replies, please be patient and ask again soon.

Steps to build

  1. Clone Maximilian's scripts:
  2.  $ git clone https://github.com/m-weigand/mw_pinenote_misc.git 
  3. Make a separate directory for patching the kernel. Then run Maximilian's clone_and_prepare_git.sh. This will clone smaeul's kernel and a number of patches. Read the script to see which patches it is using. Feel free to open the patches too -- it's helpful to get a slim idea of what's going on, if only looking at the commit messages in them:
  4.  $ cd ../
     $ sh mw_pinenote_misc/custom_kernel/clone_and_prepare_git.sh
    
  5. Compile the kernel:
  6.  $ sh ./mw_pinenote_misc/custom_kernel/compile.sh 
  7. Next we want to perform the work captured in install_to_pn.sh, but the work may vary slightly from person to person. For example, I believe Maximilian is running Debian Sid, and I am running Manjaro -- because of this, and personal preference, some of our files live at different places. As long as you put them somewhere and configure your extlinux.conf to point at it, things will be okay. Looking at install_to_pn.sh, we can see that there are three pieces to installing the kernel: the kernel image (called Image), the device tree (rk3566-pinenote-v1.2.dtb), and the modules. All of these files have been compiled and placed into the linux/pack folder. The easiest way to send these over is by using scp or rsync -- read the script and decide how you would like to get your files in the correct location. You may need to install rsync on your PineNote if it doesn't already have it.
    1. If it helps, I installed my dtb like this: $ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/
    2. After installing the dtb as above, I updated my /boot/extlinux/extlinux.conf to point to this new file (previously, my dtb did not have the -v1.2 on the end).
    3. (Perhaps not necessary?) The last step is to generate a new initrd image. (If you're like me and don't know what initrd is, the wiki is very enlightening.) This is done on the PineNote itself. Send Maximilian's installation script over and run it. Then place the generated image (from the last step of the shell script) into your boot partition and update extlinux.conf if needed to point at this new file.
       $ scp initrd/gen_uboot_image.sh root@pinenote:/root # Do this part on local to put script on PN
       $ ssh root@pinenote # Or use UART, the dongle + picocom, and change to root
       $ cd /root
       $ ./gen_uboot_image.sh
       $ mv initrd.img /boot/initrd.img
       $ vim /boot/extlinux/extlinux.conf # Update this to reference this new initrd image
      
    4. At this point your kernel is in place! However, there are a few more steps you may need to complete to ensure the display and networking continue to work:
      1. For display, you may need to change /lib/firmware/waveform.bin to /lib/firmware/rockchip/ebc.wbf (TODO is this a difference between PG and smaeul's kernel? or a patch?)
      2. For networking (and I imagine more as well), you may need to change /lib/firmware/pinenote.bin to /lib/firmware/pinenote-v1.2.bin
    5. This part technically isn't kernel specific, but we need to install a patched version of Mesa. If you are running an Arch based system, you're in luck! occam_razor provides prebuilt patched packages (say that 5 times fast) here. Simply extract these files, send them to PN, and install them using the package manager. You can also patch it yourself by looking at Maximilian's compile_mesa.sh.
      Note: If you frequently update your system with something `pacman -Syu`, you will end up updating these packages and losing the patches. Add this line to your /etc/pacman.conf to prevent them from being updated:
      IgnorePkg = libva-mesa-driver mesa mesa-debug mesa-vdpau opencl-mesa vulkan-mesa-layers vulkan-broadcom vulkan-panfrost vulkan-radeon vulkan-swrast
    6. To ensure the GPU stays on, we need to use Maximilian's mweigand_eglinfo.service. The Readme.md in that same directory has instructions for how to install this, but basically we need to copy it to /etc/systemd/system/, run sudo systemctl daemon-reload to make sure systemd knows it exists, then execute sudo systemctl enable mweigand_eglinfo.service
    7. .

    That should be it! Now are equipped with the freshest kernel + patches.

    Next Steps

    Configuring the driver

    The driver has several options that can improve performance. These can be read about here. Personally, I use rockchip_ebc.bw_mode=1 rockchip_ebc.default_waveform=1 rockchip_ebc.refresh_threshold=30 rockchip_ebc.auto_refresh=1 to make the image lower quality, but much faster to update. The auto_refresh setting is also essential to clear ghosting which will otherwise accrue on screen. I added the above settings the APPEND line in my extlinux.conf to make sure they are applied on boot.

    Fixing Suspend

    If you're using a logind system, edit your /etc/systemd/logind.conf config. More information on what to do in Arch's documentation.

    Configuring your apps

    See this page.

    Booting Linux instead of Android

    PineNote Development/Booting Linux

    Fixing Bluetooth

    Some users have noticed instability with their wireless driver. Upgrading the driver to the version provided by LibreELEC may help! To do this, download the BCM4345C0.hcd, brcmfmac43455-sdio.bin, and brcmfmac43455-sdio.txt from the libreELEC repositories and place them in the same location as your previous firmware (`/lib/firmware/brmc/`). Then rename brcmfmac43455-sdio.{txt,bin} as `brcmfmac43455-sdio.pine64,pinenote-v1.2.{txt,bin}`. If this doesn't help, ask about it in the matrix chat!

    Autoconnect to your Bluetooth devices

    This bluetooth-autoconnect project may help.