TuryRx / Banana-pi-m2-zero-GPIO

gpio pin configuration and use project on Bananapi m2 zero board
38 stars 8 forks source link

Build doesn't work with latest Armbian #2

Open oaquique opened 1 year ago

oaquique commented 1 year ago

Hola! Let me start with saying a big Thanks for the work you've done in enabling the BPi M2Zero and making it more usable (way closer to the RPi), especially filling the gap within the RPi and BPi ways they handle GPIO.

I'm currently working on porting some projects I had working on RPiZero and RPi3B with screen hats into the BPi (due chip shortage) and, while until a week or so ago I was able to build your libraries, after all the updates released this week (117 packages) for Debian (they pushed it from 11 to 11.5), I cannot longer build your libraries. Here is the /etc/os-release of my Armbian OS:

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Uname -a output: Linux bpim2z 5.15.48-sunxi #22.05.3 SMP Wed Jun 22 07:35:10 UTC 2022 armv7l GNU/Linux

Neofetch:

                                 xxxxxxxx@bpim2z
                                 ---------------
      █ █ █ █ █ █ █ █ █ █ █      OS: Armbian bullseye (21.08.1) armv7l
     ███████████████████████     Host: Banana Pi BPI-M2-Zero
   ▄▄██                   ██▄▄   Kernel: 5.15.48-sunxi
   ▄▄██    ███████████    ██▄▄   Uptime: 27 mins
   ▄▄██   ██         ██   ██▄▄   Packages: 527 (dpkg)
   ▄▄██   ██         ██   ██▄▄   Shell: bash 5.1.4
   ▄▄██   ██         ██   ██▄▄   Resolution: 1280x720
   ▄▄██   █████████████   ██▄▄   Terminal: /dev/pts/0
   ▄▄██   ██         ██   ██▄▄   CPU: Allwinner sun8i Family (4) @ 1.008GHz
   ▄▄██   ██         ██   ██▄▄   Memory: 86MiB / 491MiB
   ▄▄██   ██         ██   ██▄▄
   ▄▄██                   ██▄▄
     ███████████████████████
      █ █ █ █ █ █ █ █ █ █ █

When running the automated build script, I get that apt repositories universe, multiverse and restricted are invalid (also verified this manually in two ways:

  1. By running sudo add-apt-repository universe, which responds with Error: 'universe' invalid
  2. By adding 'universe multiverse restricted' at the end of each line on /etc/apt/sources.list, which makes sudo apt update to indicate those repositories don't exist.

I imagine that, with the high number of new packages, there are quite a number of things that broke up, and I was wondering if you could take a look once you have some time.

Please let me know if you need any additional information.

Thanks in advance, Wilferik

TuryRx commented 1 year ago

Hi friend I am glad that my work has been useful to you and thank you for letting me know about the problem. I have not had much time but I will try to review it these days to be able to give a solution, just as anything you can tell me I hope you have a good day friend 😁

TuryRx commented 1 year ago

one more little thing friend the script only works for ubuntu base images

oaquique commented 1 year ago

Thanks for letting me know. I normally use Fedora or Debian but will try it in Ubuntu. I'll spin a VM and try it to see how it goes and report back.

Bests, Oswaldo

TuryRx commented 1 year ago

ok friend anyway I think a virtual machine will not work for you I think it would be better if you run it on the same board with some of the ubuntu images you can still find them in my repo

Cheers

oaquique commented 1 year ago

Definitely! I was thinking about a different project I'm working on. Your work can only be tested live on the device :) I'll get a microSD card prepared with Ubuntu and give it a try.

Me estoy volviendo loco! ;)

TuryRx commented 1 year ago

ok friend but try to relax really don't get overwhelmed just try calmly and if you need something I can help you with I'm here alone that then it takes me a while to answer

evandene commented 1 year ago

Thanks for the great job so far. Question: would it be possible to make it available for the Armbian Bullseye version? Thanks for letting me know

electroscat commented 1 year ago

Good time ! Thanks a lot for the great work! This area is in high demand!

uname -a: Linux bananapim2zero 3.4.113-sun8i #32 SMP PREEMPT Fri Nov 10 14:42:00 CST 2017 armv7l GNU/Linux

My system version: ARMBIAN 5.34 user-built Debian GNU/Linux 8 (jessie) 3.4.113-sun8i Distributor ID: Debian Description: Debian GNU/Linux 8.9 (jessie) Release: 8.9 codename: jessie And during installation, what happens is described above, the repositories "universe", "multiverse" and "restricted" are not added.

typing in console:

sudo add-apt-repository -y universe sudo add-apt-repository -y multiverse sudo add-apt-repository -y restricted

ends with the message:

Error: 'universe' invalid Error: 'multiverse' invalid Error: 'restricted' invalid

If you are doing this, please let me know when some solution to the problem is found. Thank you very much in advance!

electroscat commented 1 year ago

I tried to use your system image. But, nothing happened to me. I don't have a monitor and a keyboard, all my communication with the banana takes place via SSH. But your distribution does not have network support. I already put all the necessary configuration files in there and it should have given me the option to login via ssh, but it didn't, i.e. either ssh is not supported or the network is disabled. Unfortunately, I can't carry a monitor and keyboard with me, I'm traveling and it's not convenient for me to carry a lot of things with me. If you add network support to your image so that it responds to any address on the 192.168.0.X subnet, it will be very good. Or post a link to an installation image of a system that will fully meet the requirements of your work. That would be great too, I'll configure a new system and install your libraries on it. Thank you very much in advance! Hello from India ;)

TuryRx commented 1 year ago

hi, friend in advance an apology for the delay in responding, look at my images they are compatible with ssh but the problem you have with the repositories is that they are only for ubuntu those of universe, multiverse and restricted for debian they are useless and as for ssh in ubuntu as in It should work well, the problem is that I haven't updated the images due to lack of time, but I hope to be able to do it.

At the moment the solution would be to run a full-upgrade as well as to enable ssh use the following commands as administrator

sudo sed -i 's/#write_enable=YES/write_enable=YES/g' /etc/vsftpd.conf sudo sed -i 's/#local_umask=022/local_umask=022/g' /etc/vsftpd.conf sudo sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd.conf sudo echo 'allow_writeable_chroot=YES' | sudo tee -a /etc/vsftpd.conf sudo echo 'pasv_enable=Yes' | sudo tee -a /etc/vsftpd.conf sudo echo 'pasv_min_port=40000' | sudo tee -a /etc/vsftpd.conf sudo echo 'pasv_max_port=40100' | sudo tee -a /etc/vsftpd.conf

You will only have to remember that for ssh communication to work you must be within the same network.

Any questions you can comment and I will try to answer as soon as possible friend for the moment have a good day.

electroscat commented 1 year ago

Good time! Thanks for the answer !!! I ran your image and updated it, everything is fine now. The problem was that I use an external USB hub with an Ethernet network card, and I access the network using this card. Ubuntu associates the ETH0 device with the built-in card and assigns the external device enx00e04c534458. I just wrote enx00e04c534458 instead of ETH0 and the network worked. I continue to understand. So far, I can not run more than one example in python. But this is already my ignorance of python))) Thank you for your extensive and serious work!

By the way, sudo gpioread and sudo i2cdetect do not work, as in the screenshots. Do I need to install something else to run these commands?

TuryRx commented 1 year ago

You do not have to thank that my work is useful to you, it is more than enough, as for i2cdetect and gpioread, they should work for you, but only in ubuntu. In any case, for gpioread you can also use sudo gpio readall, but i2cdetect's you would have to check the configuration that I explain below in the repository where I explain how to activate it

https://github.com/TuryRx/Banana-pi-m2-zero-GPIO#habilitar-gpio-

electroscat commented 1 year ago

Hi, friend! I use your distro, updated it to the latest version, did everything as you described, all hardware devices are included in the configuration utility. I try to manage from the console as it is written: sudo gpio -1 mode 29 in(out). I don't get any error warnings, but the logic analyzer doesn't see any change on the corresponding pin. I tried several different pins, the result is the same. Next, I compiled the C + code using the bcm2835 library, the standard program from the example, I slightly changed it to understand that the code works, but I got the same thing, the code is executed, there are no errors, but there is no reaction on the corresponding pins. Please tell me what could be the problem? Faulty device or somewhere else could there be a problem?

And the python code does not run, it does not see the libraries that control the gpio. My understanding of python is less than minimal, so I first decided to deal with C ++ which I know a little better.

TuryRx commented 1 year ago

Hello friend, good afternoon. Let me tell you, I think I did not understand your problem very well, but I think that as far as I can tell, it is an execution of a code in c++ because you could not make it work in python.

if that is your problem it is due to the fact that compiling and running c++ on this board is already something old and also because it is easier to run things in python and I think that another problem you have is related to how you declared the pin out .

from what you tell me, you put it like this but it would only be with one statement, not with both. I'll give you some examples: sudo gpio -1 mode 29 in(out)

examples:

Change pin mode:

gpio-1 mode 29in gpio -1 mode 29 out

Write pin state:

gpio -1 write 29 1 gpio -1 write 29 0

Read pin status:

gpio -1 read 29

Activate or Deactivate pull-up resistance:

gpio -1 mode 29 up gpio -1 mode 29 down

I think the problem would be that or maybe you need to review python a little more because I don't think your board is damaged or something like that. I think it's more due to that.

But if you like, I could help you review your code and see how I can help you.

electroscat commented 1 year ago

Thanks for the help ! I managed to manage the GPIO from the console, the problem was that the default ports are in IN mode. By putting the port in OUT mode, I was able to control the port pins and see the result on the logic analyzer.

Now I know that there is no problem in my device. I will study in more detail the C ++ libraries that I use.

I am not interested in writing programs in python, because I want to write a kernel module for specific purposes, and a universal library. And for this I need a compiled language, and C ++ is suitable for this, but Python is not. I would love to write this in assembler so I can optimize the code and make it really small and very fast. Perhaps at the last stage of the implementation of my project, I will implement it. But for starters, C++ is fine.