Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
networking issue on a banana pi [SOLVED]
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Tue Oct 25, 2022 4:47 pm    Post subject: networking issue on a banana pi [SOLVED] Reply with quote

I'm setting up gentoo on a banana pi, and it's not able to connect to the network. During boot, eth0 produces a large number of messages, but I think the most important are

eth0: soliciting a DHCP lease
dhcp_openbpf: eth0: Protocol not available
eth0: carrier lost

and then later
dhcp_openbpf: eth0: Protocol not available
eth0: probing for an IPv4LL address
arp_new: Protocol not available

I've search for the string "dhcp_openbpf: eth0: Protocol not available", and there is one forum thread

http://github.com/kobolabs/Kobo-Reader/issues/105

However, the thread ends with the folks basically giving up on the bug and switching from dhcpc to udhcpc. Interestingly, in both our cases ifconfig shows that the network interface is detected, although it's not assign an IP.

For my setup, I've used the stage3 arm v7 tarball to get me started, and then configured the kernel by hand. It seems like there might be something related to the kernel, however I've checked my kernel against this individual's kernel
http://wiki.gentoo.org/wiki/Banana_Pi_the_Gentoo_Way#Compile_the_Kernel

Grepping for BPF in their kernel shows only one item enabled, CONFIG_HAVE_BPF_JIT=y, which is also enabled in my kernel. dmesg doesn't show anything that looks like an error message related to "net" or "eth0". lscpi is also isn't much help in this specific case. It turns out that on the banana pi the "network card" is more integrated with the other systems, and doesn't go through a PCI interface.

I'd be grateful for any help on this mystery!


Last edited by jyoung on Sun Jan 01, 2023 6:39 pm; edited 1 time in total
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Tue Oct 25, 2022 5:25 pm    Post subject: Reply with quote

I should add that I'm using openrc, and that net.eth0 is in default, but dhcpcd is not. My desktop (that I'm writing from now) is configured this way too.

When I add dhcpcd to default on the banana pi, the error messages I reported in my previous post are not present at boot. However, it's still not able to connect to the network. ifconfig still detects the device, but doesn't assign it an IP, and there are no apparent error messages relating to "net" or "eth0" in dmesg.

Also, the problem is almost certainly with the banana pi's configuration, and not with the network, since it's able to connect when I boot it from an ubuntu SD card instead of the gentoo SD card it's working from now.
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1921

PostPosted: Tue Oct 25, 2022 5:37 pm    Post subject: Reply with quote

CONFIG_BPF should be set when CONFIG_NET is set.

CONFIG_NET is required to get any useful networking in the kernel flowing.

Code:
menuconfig NET
        bool "Networking support"
        select NLATTR
        select GENERIC_NET_UTILS
        select BPF
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Tue Oct 25, 2022 5:46 pm    Post subject: Reply with quote

In my current kernel, CONFIG_BPF and CONFIG_NET are both set.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54578
Location: 56N 3W

PostPosted: Tue Oct 25, 2022 8:25 pm    Post subject: Reply with quote

Moved from Kernel & Hardware to Gentoo on ARM.

Its one of these.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5115
Location: Bavaria

PostPosted: Tue Oct 25, 2022 8:45 pm    Post subject: Re: networking issue on a banana pi Reply with quote

jyoung wrote:
[...] and then configured the kernel by hand. [...]

Have you used "make menuconfig" for this ? If you have edited your .config please read this:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration#Never_edit_.config

I have a minimal kernel configuration (only IPv4) and I can tell you, it is very difficult to make networking not to work. I assume you have enabled your needed network driver.

Then you need only in networking section:

Code:
[*] Networking support  --->

If you look into the help of this item, you will find:
Quote:
Selects: NLATTR [=y] && GENERIC_NET_UTILS [=y] && BPF [=y]

So, these options will be enabled automatically.
The only options you need in this menu are:
Code:
      Networking options  --->
[*] Packet socket
-*- Unix domain sockets
[*] TCP/IP networking

And none of them enables more options.
Of course for IPv6 you will need:
Code:
[ ]   The IPv6 protocol  ----

and for netfilter (firewall or NAT) you need:
Code:
[*] Network packet filtering framework (Netfilter)  --->


Thats all :D
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Tue Oct 25, 2022 10:35 pm    Post subject: Reply with quote

pietinger, I just checked, and those options are enabled in the kernel, aside from Netfilter. The BPI is connected to my home router, so I don't think that's the issue. I have not enabled all of the suboptions, for example IPv6 has quite a lot, although most seem related to router functionality, and this isn't a router.

And, yes, I'm configuring through menuconfig, so not totally "by hand".
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5115
Location: Bavaria

PostPosted: Tue Oct 25, 2022 11:44 pm    Post subject: Reply with quote

I would like to see the complete "dmesg" after you would set a static IP address (simply use "netifrc" as described in our AMD64 handbook) an do a reboot (so we see also kernel boot messages). This is to see if its a kernel problem or "only" dhcpcd.

(Please use wgetpaste for this)
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Wed Oct 26, 2022 12:19 am    Post subject: Reply with quote

Okay, I've setup netirfc to request a static IP, rebooted, and here's the dmesg output

http://pastebin.com/PhhJ4V4P

Also, when I run ifconfig the inet field is now populated with the IP I requested
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Wed Oct 26, 2022 3:28 am    Post subject: Reply with quote

With a static IP set and dhcpcd in the default runlevel, I'm able to ping other machines on the network, and the router. With a dynamic IP, I can't. I'm not able to ping an outside URL in either case.

This is the configuration I used in /etc/conf.d/net for the static IP

Code:
config_eth0="10.0.0.30 netmask 255.255.255.0 brd 10.0.0.255"
routes_eth0="default via 10.0.0.1"
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5115
Location: Bavaria

PostPosted: Wed Oct 26, 2022 8:21 am    Post subject: Reply with quote

jyoung, thanks for your dmesg. Now I am sure that it is not a problem with your kernel. As far as I understand the problem in the thread you already have found was ALSO a problem with: dhcpcd AND old kernel version.

This looks good:
Code:
[   22.773587] eth0: device MAC address 02:17:05:00:a0:c8
[   22.804514] sunxi_gmac: probed
[   22.809950] eth0: PHY ID 001cc915 at 0 IRQ 0 (sunxi_gmac-0:00) active
[   22.819098] eth0: PHY ID 001cc915 at 1 IRQ 0 (sunxi_gmac-0:01)
[   27.256488] PHY: sunxi_gmac-0:00 - Link is Up - 100/Full

... and here I cannot help (because I have all forgotten from that time)
Code:
[    0.000000] Linux version 3.4.103+ (root@bananagen) (gcc version 4.8.3 (Gentoo 4.8.3 p1.1, pie-0.5.9) ) #4 SMP PREEMPT Fri Mar 6 04:58:06 MST 2015

Maybe you have only three choices:
1. Remove dhcpcd from runlevel and work with this static configuration, or
2. Try it with a newer kernel and/or with a newer gcc.
3. Use another dhcp client.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Wed Oct 26, 2022 8:37 am    Post subject: Reply with quote

That's really strange. I've been compiling and installing kernel 5.15.74, which is the only option in grub.cfg. But, uname -a confirms that the current kernel is 3.4.103. How is this possible? During the install, I followed the handbook on installing grub, although I think a next step might be to repeat it, just be be sure. But where did 3.4.103 come from? Interestingly, I've never been prompted with a grub bootup screen.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Wed Oct 26, 2022 6:31 pm    Post subject: Reply with quote

Okay, I see that I did something very silly. For a banana pi, there's a specialized bootloader called u-boot. It's spelled out pretty clearly in the how-to that I linked, but in a section that I skipped because I didn't do cross compiling. So, I think what I did with grub was totally ignored. Okay, let me mess with u-boot and report back.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Thu Oct 27, 2022 3:11 pm    Post subject: Reply with quote

Okay, I'm a little perplexed regarding uBoot. Based on what I've been able to find, the procedure is to compile uImage

Code:
make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage


And then copy the uImage to the boot folder
Code:
cp arch/amd/boot/uImage /boot/uImage


After this operation, the BPI won't boot at all (no messages of any kind). One interesting question is the UIMAGE_LOADADDR= argument, which is the address where the kernel will be loaded into memory. This tutorial,

http://wiki.gentoo.org/wiki/Banana_Pi_the_Gentoo_Way#Compile_the_Kernel

which provided the working example that allowed me to boot in the first place, also provided this uEnv.txt file

Code:
bootargs=console=ttyS0,115200 console=tty0 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
aload_script=fatload mmc 0 0x43000000 script.bin;
aload_kernel=fatload mmc 0 0x48000000 uImage; bootm 0x48000000;
uenvcmd=run aload_script aload_kernel


That seems to imply 0x48000000 as the correct value for UIMAGE_LOADADDR. Or, maybe it's not such much "correct" but more a case where they just need to match? Or maybe that's the kernel size (which is reported by make), and 0x43000000 is the entry point? I tried that too. I also found 0x8000 in this example

http://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842481/Build+kernel

But that wouldn't boot either. Any thoughts?
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Thu Oct 27, 2022 7:23 pm    Post subject: Reply with quote

I've enabled the grub_platforms_uboot flag for grub, and I'm going to give grub another try.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Thu Oct 27, 2022 9:00 pm    Post subject: Reply with quote

Okay, I'm running

Code:
emerge --newuse grub


with grub_platforms_uboot added to /etc/portage/package.use, and the emerge process seems to be running over and over again. I think I've seen it rebuild grub four times now. Any ideas?
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Thu Oct 27, 2022 9:42 pm    Post subject: Reply with quote

Actually, I think I figured that one out. The BPI doesn't have an internal clock, and since it can't sync it's time with a network clock, it defaults back to 2010 at each reboot (why 2010?). Anyhow, this created a bunch of warnings during the build which I was ignoring (they were warnings, not errors). However, when I manually reset the time to the correct value, I was able to emerge grub.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Thu Oct 27, 2022 10:05 pm    Post subject: Reply with quote

Okay, the new grub is compiled and installed, but this experiment didn't work. Here's the usage:

Code:
grub-install /dev/<device>


At this step, grub reports that it's installing for arm-uboot. Then

Code:
grub-mkconfig -o /boot/grub/grub.cfg


Here, grub reports that it detected the kernel that I compiled. When I rebooted, it booted back into the old 3.4.103 kernel. I thought perhaps that there was still something left from the old bootloader on the card, so I flattened the first segement:

Code:
dd if=/dev/zero of=/dev/sdX bs=1k count=1023 seek=1


Then, I ran the grub-install and grub-mkconfig commands again, which reported the same success. Now, it won't boot. I can go back to the tutorial and burn the u-boot bootloader to the disk again, so I think the disk is recoverable. But I'm not sure how to get this system booting off the new kernel.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Fri Oct 28, 2022 2:32 am    Post subject: Reply with quote

There's a note at the top of the tutorial about u-boot, which sends me here
http://linux-sunxi.org/U-Boot#Compile_U-Boot

Following the directions there, I created a boot.cmd file
Code:
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10
load mmc 0:1 0x43000000 sun7i-a20-bananapi-m1-plus.dtb || load mmc 0:1 0x43000000 boot/sun7i-a20-bananapi-m1-plus.dtb
load mmc 0:1 0x42000000 uImage-5.15.74 || load mmc 0:1 0x42000000 boot/uImage-5.15.74
bootm 0x42000000 - 0x42000000


used that to generate a boot.src file

Code:
mkimage -C none -A arm -T script -d boot.cmd boot.scr


And then installed the bootloader (the tutorial had me do this too, so it's redundant)

Code:
 dd if=u-boot-sunxi-with-spl.bin of=/dev/<device> bs=1024 seek=8


Note that in the boot.cmd file I've specified uImage-5.15.74 instead of just uImage, which would just be the old 3.4.103 kernel. uImage-5.15.74 I created from the kernel I configured with menuconfig. When I rebooted, the BPI rebooted successfully, but still on the 3.4.103 kernel. It really seems like those steps from the u-boot page didn't do anything, since the system just ignored uImage-5.15.74. What did I miss?
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Wed Nov 02, 2022 2:47 pm    Post subject: Reply with quote

I've tried several variations on compiling a new uImage kernel and then copying it over to the location where the bootloader is expecting uImage. This looks like

Code:
make
make LOADADDR=0x48000000 uImage
cp -v arch/arm/boot/uImage/boot


The above commands would be executed from /usr/src/linux with /boot mounted. In all cases the BPI fails to boot, displaying no messages at all. I even wondered if it was booting but not displaying anything (like, the video driver didn't work or something), but I checked my routers and no machine connected.

I've tried several values for LOADADDR, and also specifying UIMAGE_LOADADDR instead. I admit that I don't fully understand how this is determined but 0x48000000 is explicitly referenced in the bootloader's uEnv.txt file. I've also recompiled using config files from BPI forms, after running make oldconfig.

I've also tried following this tutorial

http://wiki.lemaker.org/BananaPro/Pi:Building_u-boot,_script.bin_and_linux-kernel

Which is actually very thorough, although I can't get past installing the toolchain. Specifically, "make" requires arm-linux-gnueabihf-gcc. It seems like that's a part of the crossdev package, but after installing crossdev I'm kind of stuck on what to feed to crossdev. Ironically, I'm not cross compiling, so I don't think I really need it. Maybe I could just switch it to gcc in the Makefile?

I actually think that the setup as is is mostly there, since I can boot into gentoo, but there's some bit missing that's preventing a kernel update. I'm really lost.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54578
Location: 56N 3W

PostPosted: Wed Nov 02, 2022 6:02 pm    Post subject: Reply with quote

jyoung.

crossdev builds cross toolchains for you.
There is an arm64 worked example of building a cross toolchain for a Raspberry Pi.
It goes on into building a kernel.

The tuple you need is the CHOST in the stage3 talball, which comes from your profile.
You need
Code:
crossdev -t  <CHOST>


If you are not cross compiling none of this matters.
make should find the native gcc on the Banana pi, as provided by the stage3 tarball.

After you have built one kernel on the Banana pi, I'm pretty sure you will be cross compiling. :)

-- edit --

Your link says
Quote:
Note: all of the following instructions (and also in the sections 2, 3 and 4
following on from this page) have to be carried out on a Linux computer, not the Bananan Pro/Pi itself!!

That means you are expected to cross compile.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.


Last edited by NeddySeagoon on Fri Nov 04, 2022 11:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1248
Location: Richmond Hill, Canada

PostPosted: Wed Nov 02, 2022 6:21 pm    Post subject: Reply with quote

jyoung,

I don't have banana pi, I am raspberry pi 4b owner. I am no expert for u-boot, but I have a nanopi r4s which boot with uboot which can give me a little bit of reference.

I think may be a second pair of eyes can help catch something missing 8O

If you don't mind, I like to reset to beginning,
  • what is your current plan?
    • Using mainline uboot?
    • Using sunxi uboot?
    • Using sunxi kernel? (seems only at linux v3.x)
    • Using mainline kernel?
  • What did you plan for init?
    • openrc?
    • systemd?


From most of your post in this thread it seems to be you are able to boot in to a working system except the working system is not to your like, so you want to change it?

if I am right about you can boot into working system, lets collect some parameters of current system so we can later reference them.
  • list of SD partitions
    Code:
    fdisk -x /dev/mmcblk0

  • current kernel command line
    Code:
    dmesg|grep "Kernel command line:"


I am still trying to figure out how to see uboot environment variables from linux.
Back to top
View user's profile Send private message
jyoung
Guru
Guru


Joined: 20 Mar 2007
Posts: 467

PostPosted: Wed Nov 02, 2022 7:06 pm    Post subject: Reply with quote

NeddySeagoon, thanks for confirming that those instructions were for cross compiling. It does indeed take ~6 hours to compile a new kernel on the BPI! I've been letting it run overnight. Luckily, building the uImage is pretty fast if the kernel is otherwise compiled.

pingtoo, I'm currently booting off the uboot binary and uImage that came in a tarball from this tutorial

http://wiki.gentoo.org/wiki/Banana_Pi_the_Gentoo_Way#Compile_the_Kernel

under the link "Banana Pi Boot Files". That setup works in the sense that I can boot the BPI, although it's been impossible to update. As you pointed out, the sunxi kernel is quite old, and seems to be the source of the networking issue that started this thread. I'd really like to switch over to the mainline kernel so that I could update as needed.

The system that's currently installed is using openrc, which I'd like to use.

Here are the partitions. Note that it reads as /dev/sda because (at the moment) I'm booting the BPI off ubuntu and then chrooting into the gentoo SD through a USB port. This gives the BPI network access so I can use emerge, but most of the experiments I've done have had the BPI booted off the gentoo SD, which then appears as /dev/mmcblk0

Code:
Disk /dev/sda: 29.72 GiB, 31914983424 bytes, 62333952 sectors
Disk model: Storage Device 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x08e2b47e

Device     Boot    Start      End  Sectors Id Type      Start-C/H/S  End-C/H/S Attrs
/dev/sda1           2048   309247   307200  b W95 FAT32       1/0/1  150/63/32
/dev/sda2         309248 25475071 25165824 83 Linux         151/0/1 1023/63/32
/dev/sda3       25475072 27572223  2097152 83 Linux      1023/63/32 1023/63/32
/dev/sda4       27572224 62333951 34761728 83 Linux      1023/63/32 1023/63/32


And the kernel command line:

Code:
[    0.000000] Kernel command line: console=ttyS0,115200 console=tty1 board=bpi-m1p root=/dev/mmcblk0p2 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 enforcing=0 loglevel=8
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1248
Location: Richmond Hill, Canada

PostPosted: Wed Nov 02, 2022 8:42 pm    Post subject: Reply with quote

jyoung,

if /dev/sda1 is not already mounted somewhere please mount it read-only for example mount -r /dev/sda1 /mnt/boot

Do you have the uImage from Banana Pi the Gentoo Way/Downloads Banana Pi Boot Files?
if you do and you can examine it by
Code:
mkimage -l <uImage>
Do the same for your custom build kernel uImage. This may give you idea on how the Load address setup.

What is in /mnt/boot/uEnv.txt?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54578
Location: 56N 3W

PostPosted: Wed Nov 02, 2022 8:59 pm    Post subject: Reply with quote

jyoung,

Its been a while since I used uboot. Since the very early days of Pi 3 in 64 bit mode, when getting a serial console. was doing well. The USB chip driver didn't work yet, so that's all there was :)

The key line here
Code:
bootargs=console=ttyS0,115200 console=tty0 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_no_mali_mem_reserve console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
aload_script=fatload mmc 0 0x43000000 script.bin;
aload_kernel=fatload mmc 0 0x48000000 uImage; bootm 0x48000000;
uenvcmd=run aload_script aload_kernel

Is
Code:
aload_kernel=fatload mmc 0 0x48000000 uImage; bootm 0x48000000;
Thats load the kernel called uImage from a FAT partition on mmc0.
Call you kernel binary uImage or rewrite that file

There are a couple of buts here too.
Take care with the compression system used if any. Whatever in in use now, use that.
I don't see any mention of loading an initrd. That suggests that there is no initrd or its built into the kernel.

Booting without an initrd requires careful configuration of the kernel, since all the modules needed to read root must be built into the kernel.
If you haven't don that before, you need to practice on something faster than the BPI.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum