[SOLVED] Support for NanoPC-T3 (very similar to NanoPi-M2)

Suggestions for features and software you would like to see in DietPi, goes here.
awl29

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by awl29 »

Oh, and I nearly forgot about the following (another small issue):

In my setup, I have no USB mass storage device connected (yet) to my NanoPC-T3 (only SD/mmc). The current default fstab is set up to have /mnt/usb_1 enabled as type autofs, and this causes all attempts to access this directory to completely hang (I noticed this when running "du -k /") the shell/tty, because autofs seems to think it can mount "something" (even though there is no mass storage connected to my USB ports) while it indeed must not - and hangs on accessing the mount path... :(

So for my image, I have patched /etc/fstab to comment out the line for /mnt/usb1 (as default).

Best
awl
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by Fourdee »

awl29 wrote: So for my image, I have patched /etc/fstab to comment out the line for /mnt/usb1 (as default).

Best
awl
Yes, this can happen.

We use the x-systemd.automount feature to allow the user to have 1 USB drive automatically mounted, without any need for configuration changes.
Its also used for automatic mounting when using the dietpi-drive_manager. All those usb_x entries are enabled when the script is run, then disables any unactive drive mounts at exit.

The downside is, if usb_1 is not attached, systemD will hang all commands that involve the target /mnt/usb_1. so ls -lha /mnt/usb_1 will hang in a endless loop.
I've been unable to find a timeout option or any workarounds, without disabling the mount entirely.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by Fourdee »

Hi Awl,
Please note that I think I have found a small bug: During disable, you'll also need to stop and disable the systemd bluetooth service first, and not only/simply force unload "modprobe -rf" the modules...
Good find, great job :)

Great work on adding that code in! I've sent to GitHub and your changes are available on the testing branch: https://github.com/Fourdee/DietPi/commi ... 5d6c7d058e

Notes:
Diff (left = current): https://www.diffchecker.com/LqBaadPQ
I need to remove the dependency of the systemd "brcm_patchram_plus.service" to "syslog.service", because a systemd service for logging does not seem to exist with DietPi - am I correct?
Only remove it if it causes "brcm_patchram_plus.service" to fail, if "syslog.service" is not started/available.
DietPi-Ramlog has an option to have full logging which installs rsyslog. So our users can add/remove syslog to their system at any time.
If you find some time, can you please also check whether (with an updated service file as stated above) my brcm_patchram_plus service does indeed also make Bluetooth work for NanoPi-M2/NanoPC-T2 (and possibly, BPi M2+ as you mentioned)?
Yep, I've made a note ;), will test when I can.





Notes:

Code: Select all

root@DietPi:~# cat /lib/systemd/system/brcm_patchram_plus.service
[Unit]
Description=brcm_patchram_plus
Before=bluetooth.service hwservice.service hwservice_monitor.service

[Service]
Type=oneshot
ExecStart=/etc/init.d/brcm_patchram_plus start
ExecStop=/etc/init.d/brcm_patchram_plus stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Alias=brcm_patchram_plus.service




root@DietPi:~# cat /etc/init.d/brcm_patchram_plus
#!/bin/bash

### BEGIN INIT INFO
# Provides:             brcm_patchram_plus
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    brcm_patchram_plus
### END INIT INFO


case "$1" in
    start|"")
      if [ -d /sys/class/rfkill/rfkill0 ]; then
        rfkill block 0
        rfkill unblock 0
        chmod 0660 /sys/class/rfkill/rfkill0/state
        chmod 0660 /sys/class/rfkill/rfkill0/type
        chgrp dialout /sys/class/rfkill/rfkill0/state
        chgrp dialout /sys/class/rfkill/rfkill0/type
        MACADDRESS=`md5sum /sys/devices/platform/cpu/uuid | cut -b 1-12 | sed -r ':1;s/(.*[^:])([^:]{2})/\1:\2/;t1'`
        echo $MACADDRESS > /tmp/brcm_mac.txt
        /bin/brcm_patchram_plus -d --patchram /lib/firmware/ap6212/bcm43438a0.hcd --enable_hci --bd_addr $MACADDRESS --no2bytes --tosleep 5000 /dev/ttyAMA1
      fi
        ;;

    stop)
        kill `ps --no-headers -C brcm_patchram_plus -o pid`
        ;;
    *)
        echo "Usage: brcm_patchram_plus start|stop" >&2
        exit 3
        ;;
esac

If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
awl29

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by awl29 »

Hello again,
Fourdee wrote:Great work on adding that code in! I've sent to GitHub and your changes are available on the testing branch: https://github.com/Fourdee/DietPi/commi ... 5d6c7d058e
thank you, the patch is working fine for me.

But please be warned that on NanoPi-M2/NanoPC-T2 and NanoPi-M3/NanoPC-T3 (and probably also on the BananaPi using AP6212), you will also need to add the files from my Bluetooth patch tarball (i.e. /bin/bumpRTSCTS, /bin/brcm_patchram_plus, /etc/init.d/brcm_patchram_plus, /lib/systemd/system/brcm_patchram_plus.service) to the respective image.

I will do so for my NanoPi-M3/NanoPC-T3 image, but I will wait for the official release of v134 (including the above change) before I rebuild my image based on the final v134 release. Otherwise, my image would be "mostly" v133 with one file from v134 and not be based on an officially released DietPi version, which could create confusion about the exact versions of files included in the image and cause trouble on subsequent DietPi updates.
Fourdee wrote:
awl wrote:I need to remove the dependency of the systemd "brcm_patchram_plus.service" to "syslog.service", because a systemd service for logging does not seem to exist with DietPi - am I correct?
Only remove it if it causes "brcm_patchram_plus.service" to fail, if "syslog.service" is not started/available.
DietPi-Ramlog has an option to have full logging which installs rsyslog. So our users can add/remove syslog to their system at any time.
It is indeed necessary to remove the references (After, Requires) to the syslog service - changing "Requires" to "Wants" does not help, as even "Wants" causes brcm_patchram_plus service not to be started even though enabled, as no syslog service is running...
Fourdee wrote:

Code: Select all

root@DietPi:~# cat /lib/systemd/system/brcm_patchram_plus.service
[Unit]
Description=brcm_patchram_plus
Before=bluetooth.service hwservice.service hwservice_monitor.service

[Service]
Type=oneshot
ExecStart=/etc/init.d/brcm_patchram_plus start
ExecStop=/etc/init.d/brcm_patchram_plus stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Alias=brcm_patchram_plus.service




root@DietPi:~# cat /etc/init.d/brcm_patchram_plus
#!/bin/bash

### BEGIN INIT INFO
# Provides:             brcm_patchram_plus
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    brcm_patchram_plus
### END INIT INFO


case "$1" in
    start|"")
      if [ -d /sys/class/rfkill/rfkill0 ]; then
        rfkill block 0
        rfkill unblock 0
        chmod 0660 /sys/class/rfkill/rfkill0/state
        chmod 0660 /sys/class/rfkill/rfkill0/type
        chgrp dialout /sys/class/rfkill/rfkill0/state
        chgrp dialout /sys/class/rfkill/rfkill0/type
        MACADDRESS=`md5sum /sys/devices/platform/cpu/uuid | cut -b 1-12 | sed -r ':1;s/(.*[^:])([^:]{2})/\1:\2/;t1'`
        echo $MACADDRESS > /tmp/brcm_mac.txt
        /bin/brcm_patchram_plus -d --patchram /lib/firmware/ap6212/bcm43438a0.hcd --enable_hci --bd_addr $MACADDRESS --no2bytes --tosleep 5000 /dev/ttyAMA1
      fi
        ;;

    stop)
        kill `ps --no-headers -C brcm_patchram_plus -o pid`
        ;;
    *)
        echo "Usage: brcm_patchram_plus start|stop" >&2
        exit 3
        ;;
esac

Please be warned that the code as listed above is outdated (IIRC, this is the original defunct code that FriendlyARM included with their image) and will not work. When looking into fixing the Bluetooth issue, please use the code from my updated tarball at the FriendlyARM forum:
http://www.friendlyarm.com/Forum/viewto ... t=312#p958
and edit the systemd service description "brcm_patchram_plus.service" to remove all dependencies to the syslog service (After and Requires) - note that this change is only needed for DietPi, where no syslog service exists by default. The tarball is correct for Debian and Ubuntu.

Looking forward to the release of v134 (do you already have a target date?)...

Best,
awl
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by Fourdee »

Looking forward to the release of v134 (do you already have a target date?)...
No date set at the moment. Been working alot on RPi Stretch support. You can track milestone progress here https://github.com/Fourdee/DietPi/milestone/35

I'll probably release v134 as soon as your image is ready. Could be a few days delay, depends if any bug reports are sent in the mean time that need investigating. Either way, I can shuffle tickets around if needed to release v134.

Ran out of time today (apologies), so, I've made a note, will go through your post in detail tomorrow and get back to you with a full response.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
awl29

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by awl29 »

Fourdee wrote:I'll probably release v134 as soon as your image is ready. Could be a few days delay, depends if any bug reports are sent in the mean time that need investigating. Either way, I can shuffle tickets around if needed to release v134.
No worries - there is no real need to hurry! ;)

I have a working DietPi installation on my SD card (that I used for testing) for the meantime, and the new final NanoPC-T3 v134 image (which is "ready" except that I need the DietPi v134 files from the master branch) can perfectly wait until you're finished with the release...

Best regards
awl
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by Fourdee »

Ok uploaded your BT patch with syslog removed, to http://dietpi.com/downloads/binaries/al ... t_patch.7z. It will be applied to T2 image (and M2, shared) during v134 update (under patch_file):
https://github.com/Fourdee/DietPi/commi ... 81af2101d5

NanoPi M2 doesn't have any wifi/bt chip, so i'll test on BPi M2+ ap6212.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
awl29

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by awl29 »

Fourdee wrote:Ok uploaded your BT patch with syslog removed, to http://dietpi.com/downloads/binaries/al ... t_patch.7z. It will be applied to T2 image (and M2, shared) during v134 update (under patch_file):
https://github.com/Fourdee/DietPi/commi ... 81af2101d5
Thank you - that's good news :D
Fourdee wrote:NanoPi M2 doesn't have any wifi/bt chip, so i'll test on BPi M2+ ap6212.
When testing on BPi M2+, please be warned that you most probably need to change the BT UART device port to something different from /dev/ttySAC1 (on the NanoPC-T series, the second UART port is used for Bluetooth).

Have a nice weekend!
awl
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by Fourdee »

awl29 wrote:When testing on BPi M2+, please be warned that you most probably need to change the BT UART device port to something different from /dev/ttySAC1 (on the NanoPC-T series, the second UART port is used for Bluetooth).
Legend, thanks :)

Ok so, I'll aim to get v134 wrapped up and released over the weekend. I'll let you know when its done and ready for you to create the final image.
Have a nice weekend!
You too :)
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Fourdee
Site Admin
Posts: 2787
Joined: Tue Feb 06, 2007 1:36 pm

Re: Request: Support for NanoPC-T3 (very similar to NanoPi-M

Post by Fourdee »

awl:

v134 is released. Good to go for creating your image on master branch :)

EDIT: I've made various changes to the system prep file since we started this, so if your using your own script, you may need to update it: https://github.com/Fourdee/DietPi/blob/ ... _DIETPI.sh
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Post Reply