ludiazv / octocitrico

OctoPrint for other fruits
149 stars 18 forks source link

Different BPi M2 Zero Options #13

Open Cjkeenan opened 3 years ago

Cjkeenan commented 3 years ago

So I am searching around to find the best way to get OctoPrint running on my m2 zero, and I was wondering if you could help me narrow down my options. These are the options I have come up with so far but not exactly sure what the pros and cons are between them so I would appreciate any insight you can provide:

The main questions I have are if any of these OSes are better than any other for security reasons, performance reasons, or just basic compatibility reasons. I plan on plugging my m2 zero into the back of my Prusa's Einsy board via GPIO pins if that makes any difference.

I have heard that the m2 zero gets very hot along with certain installs on the board running hotter than others so that will likely be a concern of mine if that is relevant to any of the above options.

Also if I missed an option, please let me know.

ludiazv commented 3 years ago

Hi @Cjkeenan , Although I have not performed any test on all the distributions you mention, in my opinion all options should have similar performance( or compatibility) as they are debian-like distributions.

In general I would avoid to use Strech distributions as this is "old-stable" and LTS finish in 15months. Also is quite possible that the kernel is based on 3.x or 4.x versions. Armbian (and typically) has good support for Allwiner boards and uses very kernels that provide better hardware support.

Then only difference btw manual armbian install and octocitrico is that the later is easy. Just flash your SD and configure the wifi network.

At the end, however, doing tests is the best way to check what's best for your specific setup.

If you use the prebuild version of octocitrico and find any problem let me know.

Best,

Cjkeenan commented 3 years ago

Thank you so much for your reply. I think I will try out your image first and if I run into issues try the dietpi route.

Do I have to do anything special to communicate over the GPIO pins like when plugged directly into an Einsy board?

Also is it possible to configure the WiFi without a mouse and keyboard? Possibly via a wpa_supplicant file like on normal pi's? For instance, does this work with your images? https://github.com/armbian/build/blob/master/packages/bsp/armbian_first_run.txt.template

ludiazv commented 3 years ago

Hi, Octoprint communicates with the printer via serial. Typically using a USB->Serial chip installed in the printer board. For the Einsy board I think is possible to connect RPI via GPIOs. In principle it should be no problem to use this BPI M2 Zero as a similar pinout to the RPI. In this case the UART of the BPI will connect with the UART of the MCU in the printer controller therefore there is no need to USB cable. Have in mind , however , that you need to activate the overaly to enable the UART in armbian and check to which /dev/tty* is the serial port mapped and configure octoprint to use it.

By this account http://wiki.banana-pi.org/Banana_Pi_BPI-M2_ZERO. I thinke the uart3 is the one you need.

As regards, configuring WiFi without a console any valid procedure described in armbian should work. I've have not tested it though.

Cjkeenan commented 3 years ago

Thank you so much for your help. I ran into one issue with the image so far. It seems, at least with the M2 Zero image, that the OctoPrint service does not have no password sudo rights and as a result cannot turn off/reboot the board or restart its own process. Is this intended or do you know how to fix this?

I found this post, but I was not sure if it applies to this board/image: https://community.octoprint.org/t/failed-to-restart-octoprint-service-unit-octoprint-service-not-found/19258

Also OctoPrint is not detecting my printer via USB cable into the OTG port out of the box, is there any additional configuration that I have to follow?

/dev/ttyS1 is missing from the dropdown FYI which I believe is the port being used based on this but I could be wrong:

pi@Prusa-OctoPi-M2Zero:~$ dmesg | grep tty
[    0.000000] Kernel command line: root=UUID=f56ddcd5-c95f-4e94-81fc-ed92bfc474a9 rootwait rootfstype=ext4 console=ttyS0,115200 console=tty1 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 consoleblank=0 loglevel=1 ubootpart=55704041-01 ubootsource=mmc usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u   sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16 cgroup_enable=memory swapaccount=1
[    0.000347] printk: console [tty1] enabled
[    2.123689] printk: console [ttyS0] disabled
[    2.123786] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 50, base_baud = 1500000) is a 16550A
[    2.124044] printk: console [ttyS0] enabled
[    2.125325] 1c28400.serial: ttyS1 at MMIO 0x1c28400 (irq = 51, base_baud = 1500000) is a 16550A
[    2.125512] serial serial0: tty port ttyS1 registered
[    2.126267] 1c28c00.serial: ttyS3 at MMIO 0x1c28c00 (irq = 52, base_baud = 1500000) is a 16550A
[    5.381845] systemd[1]: multi-user.target: Found ordering cycle on getty.target/start
[    5.381880] systemd[1]: multi-user.target: Found dependency on getty@tty1.service/start
[    5.381938] systemd[1]: multi-user.target: Job getty.target/start deleted to break ordering cycle starting with multi-user.target/start
Cjkeenan commented 3 years ago

Update: I enabled UART 3 and soldered the pins like the ZeroW and it is working well now in the back of the Einsy board. Only issue now is it is running a bit hot, about 30C over ambient with a copper heatsink on the SoC and memory. I really wish the Einsy boards had a flipped GPIO pinout that way the SoC could get better airflow from the outside.

ludiazv commented 3 years ago

Hi, Thanks for the feedback. Regarding the sudo problem,could you check the file /home/pi/.octoprint/config.yml and /etc/sudoers.d/*? These files define the rules so pi user can run shutdown and reboot.

For temperature control there are no easy fixes from software. Try to set the cpu governor to powersave mode, this will reduce the cpu clock.

Cjkeenan commented 3 years ago

This is in the config.yaml:

server:
    commands:
        serverRestartCommand: sudo service octoprint restart
        systemRestartCommand: sudo shutdown -r now
        systemShutdownCommand: sudo shutdown -h now

And for the sudoers.d:

root@Prusa-OctoPi-M2Zero:/# ls /etc/sudoers.d/
octoprint-service  octoprint-shutdown  README
GNU nano 3.2                              /etc/sudoers.d/octoprint-shutdown                                         

pi ALL=(ALL) NOPASSWD: /sbin/shutdown *
GNU nano 3.2                               /etc/sudoers.d/octoprint-service                                         

pi ALL= NOPASSWD: /bin/systemctl restart octoprint.service

All of those files seem fine to me based on what I have seen online. I am running a print right now so I unfortunately cannot do live troubleshooting for the next 12 hours, but once that is done I will do some more extensive testing and see which commands are specifically breaking and what errors they give.

I wanted to thank you again, this has been relatively painless and coming from a ZeroW this M2 Zero is leaps and bounds faster and I appreciate the work you have put in to make this happen. As a side note, do you have any idea what the safe operating temperature for the Allwinner H2+ SoC is? I found the datasheet online but that is the one spec I could not find.

ludiazv commented 3 years ago

Yes sudo files seem ok. Have you check /etc/sudoers? This file should include the files in the .d directory.

On the other hand, I do't have a specific reference of this chips. My experience is that they get hot but they support high temperatures well. If you have space for 5V fan on the side you could try if it cool down.

I normally do not use fans but oversized heatsinks.

Cjkeenan commented 3 years ago
  GNU nano 3.2                                           sudoers                                                      

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

I am guessing the commented out includedir is the issue?

ludiazv commented 3 years ago

No. I think the leading "#" is ok. could you show the file permissions?

Cjkeenan commented 3 years ago
root@Prusa-OctoPi-M2Zero:~# ls -l /etc/sudoers
-r--r----- 1 root root 669 Apr 12 23:11 /etc/sudoers
pi@Prusa-OctoPi-M2Zero:~$ ls -l /etc/sudoers.d
total 12
-rw-rw-r-- 1 root root  59 Dec 27 10:26 octoprint-service
-rw-rw-r-- 1 root root  40 Dec 27 10:26 octoprint-shutdown
-r--r----- 1 root root 958 Feb  1  2020 README
ludiazv commented 3 years ago

I think this is the problem. I just checked and all files in this directory should be mode 0440.

Cjkeenan commented 3 years ago

Okay, so what can I do to fix? Also sorry I just started another print, 24hr this time 🤣. I forgot we still had to troubleshoot this.

ludiazv commented 3 years ago

No problem. to fix it run chmod with 0440 mask.

Cjkeenan commented 3 years ago

On which files? The octoprint-service and octoprint-shutdown?

ludiazv commented 3 years ago

yes, and reboot to test it.

Cjkeenan commented 3 years ago

OK it is working now with one minor modification. Inside OctoPrint the command has to be sudo systemctl restart octoprint.service instead of sudo service octoprint restart since you gave permissions for systemctl in the /etc/sudoers.d/octoprint-service file.

Does this really matter in any way? Should the permissions be modified to stay consistent with default OctoPrint or does OctoPrint by default use systemctl?

ludiazv commented 3 years ago

Init system of armbian is systemd so systemctl should be more correct. I will check this.

Thanks for testing this board.

ludiazv commented 3 years ago

New version for bpi m2 zero is available in releases. It should fix the this issue.

Faceless3D commented 2 years ago

I have the feeling that I have overlooked something. I want to run the Bananapi image on a Bananapi Zero M2 and can't get it to work.

Image downloaded and unzipped -> Written to SD card with Balena Etcher -> SD card inserted in another Pi -> Image mounted and the Wifi data inserted in the interface file -> SD card inserted in the Bananpi and started.

I see the Bananapi in the wifi network but can not access it. Have tried it via SSH and the Ip address. No Connection. I think the OS is not booting.

What have I forgotten or done wrong? I have no way to connect a network cable to the bananapi.

jezzaaa commented 2 years ago

Image downloaded and unzipped -> Written to SD card with Balena Etcher -> SD card inserted in another Pi -> Image mounted and the Wifi data inserted in the interface file -> SD card inserted in the Bananpi and started.

Seems right to me.

I see the Bananapi in the wifi network

Can you explain what this means? Do you know it's IP address? Did you try to ping it?

but can not access it. Have tried it via SSH and the Ip address. No Connection. I think the OS is not booting.

Did you try to connect on port 5000 with your browser?

What have I forgotten or done wrong? I have no way to connect a network cable to the bananapi.

The BPi has pins to connect a serial console, possibly via a level shifter. You might be able to use that for diagnostics.

HugoCLSC commented 2 years ago

I seem to have a similiar problem as @Faceless3D, i can identify my banana pi on the network and see the ip for the device. I can access it with ssh. I also checked if the octoprint service was running and it was. The only thing i can not do is access octoprint. I tried to connect on port 5000 with the browser and nothing appears.

jezzaaa commented 2 years ago

I seem to have a similiar problem as @Faceless3D

But not exactly the same.

I can access it with ssh.

whereas @Faceless3D said: "Have tried it via SSH and the Ip address. No Connection."

I also checked if the octoprint service was running and it was. The only thing i can not do is access octoprint. I tried to connect on port 5000 with the browser and nothing appears.

From your ssh session, check to see what ports the octoprint process has opened for listening:

pi@citrico-bpim2z:~$ sudo lsof -itcp -a -p `pgrep octoprint`
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
octoprint 1211   pi    4u  IPv4  14734      0t0  TCP *:5000 (LISTEN)
octoprint 1211   pi   17u  IPv6  15474      0t0  TCP *:5000 (LISTEN)

And/or, do a port scan of the IP address to see what ports are listening. I use the Fing app on Android for this, but you can use nmap on Linux/UNIX or Windows.

Also, I've had problems with a browser seemingly caching a failed connection attempt. Perhaps restart your browser. But first, check that you can connect using "telnet 5000" and see if you get a connection.

If you're on Windows, you might need to add the telnet client, then you can run it from a CMD prompt. If you connect, the CMD prompt window will switch to a blank screen, which means it was a success. If it doesn't connect, the telnet program will give you an error like "Could not open a connection".

HugoCLSC commented 2 years ago

Worked perfectly thanks!

jezzaaa commented 2 years ago

Worked perfectly thanks!

Great that you have it working. What was the problem? What did you need to do to connect with a browser?

HugoCLSC commented 2 years ago

I activated telnet on windows and checked the connection just how you recommended it , after that i still could not access octoprint using the :5000 on the browser. Instead of using the ip with the port i tried accessing it on the browser with the http://bpi-m2z.home:5000/ and it worked. I could not figure out what the problem was exactly but it is working now.

JesterIsDead commented 1 year ago

CJKeenan, did you follow the guide on Prusa's site to get the GPIO header working? I got octoprint installed and running fine, but not on the Einsy. I know I have to enable the UART and disable usb, but I'm not sure how to do so. I can get into the Armbian Config and see where I can toggle hardware for UART 3 to on but I'm lost after that as I don't have anything in the config files Prusa says to edit (as in no lines of code).

Cjkeenan commented 1 year ago

I did this so long ago, I don't remember all of the specifics, but yes, I still have it working to this day plugged into the back of my Einsy board on a MK3S+.

I believe I followed this guide: https://help.prusa3d.com/article/prusaprint-rpi-zero-and-octoprint_2180

Unfortunately, I am on vacation right now, so I will not be able to troubleshoot easily, but if you want me to check some things on my M2 Zero setup, let me know and I can try to VPN to my house and check the settings you want.

P.S. I also found a section in the normal guide talking about the Zero, but it is pretty unhelpful. I think you are right though, you need to change both a printer setting and a serial setting on the "pi" itself, now again if you have a guess as to what that setting is, let me know and I can try to help you confirm. https://help.prusa3d.com/article/octoprint-configuration-and-install_2182#configure-rpi-zero-w-gpio

JesterIsDead commented 1 year ago

CJKeenan, thanks a bunch for respondiing. I followed the most up to date guide but it seems some of my files are blank and I'm expecting command lines from the guides. I am 100% able to see Octopring and the Pi when powered via USB but the second it starts talking via GPIO (or I'm trying once installed on the Einsy) I lose the IP address.

I'm following this guide and thinking my issues are with disabling the serial console and enabling UART. If you follow the link below I run into issues (I think, I'm linux dumb) on the "sudo nano /boot/config.txt and /boot/cmdline.txt. When these files open in nano they are blank for me. I'm guessing I'm chasing the wrong filepath and creating a blank config. ^^ Again linux/unix dumb.

https://help.prusa3d.com/article/octoprint-configuration-and-install_2182

Cjkeenan commented 1 year ago

Actually, I just realized, I cannot help at all, my printer is offline currently, and since the m2 zero gets power from the printer, there is no way for me to check anything. Did you try enabling serial via armbian-config?

JesterIsDead commented 1 year ago

Edit: I'm not sure why the config files were empty, but I was able to get it working.

CJKeenan, no need to worry about helping on your vacation. I understand you're not a magician.

I thought I enabled it by turning UART on, I'm trying to break some stuff now (not on purpose). I'll see where I get.

jezzaaa commented 1 year ago

I'm not sure if it's because the OctoCitrico images have been updated recently, but I was having trouble getting the GPIO pins enabled for UART3, because the guides say to edit a file called /boot/config.txt and add "dtoverlay=pi3-miniuart-bt". But that file doesn't exist on the latest image.

I had this going last year, but my SD card failed so I setup the device again with a new image on a new SD card. And I couldn't find config.txt.

It turns out the file to edit is (now) called armbianEnv.txt. However, the official way to modify the settings in there is to use the "armbian-config" text-UI command (System > Bootenv).

And the line to add is "overlays=uart3".

ludiazv commented 1 year ago

One comment on this: Have in mind that /boot/config.txt is RPI specific as is part of the Raspi OS. As this distribution is not for RPI boards it does not support this configuration method. This distribution is based on Armbian that has some differences with RPI OS:

The boot configuration file is: /boot/armbianEnv.txt and it has a different syntax and features. Armbian does not create a FAT boot partition that can be mounted on a windows system all boot files are in a root partition in ext4 format. I you have a linux box you will be able to mount the SD and edit the file but windows does not support this Filesystem out of the box.

as @jezzaaa explains the best way to configure your box is to ssh and run armbian-config to tweak the configuration.

i will add to the default overaly of bpi m2 zero the overlay for uart3 as I see it required by most users.