Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFTP/NFS booted Pi 3 Model B+ locks up when using official V4L2 driver #2963

Open
jorisvervuurt opened this issue May 11, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@jorisvervuurt
Copy link

commented May 11, 2019

When booting a Raspberry Pi 3 Model B+ via TFTP/NFS (no SD card), there seems to be an issue with the official V4L2 driver. When trying to access /dev/video0, the entire Pi locks up.

I have the following setup:

  • Ubiquiti EdgeRouter X
  • Synology DiskStation DS715
  • Raspberry Pi 3 Model B+ (clean install of the latest Raspbian Stretch Lite image)

I have configured a number of VLANs on the EdgeRouter X:

  • Synology DiskStation DS715 is on the 192.168.10.x subnet (IP 192.168.10.6)
  • Raspberry Pi 3 Model B+ is on the 192.168.40.x subnet (IP 192.168.40.2)

The Synology NAS acts as a TFTP server for the boot files and NFS server for the root filesystem; bootcode.bin is in the TFTP root directory, the rest of the boot files are in the <serial>/ directory. I have configured the Ubiquiti router’s DHCP server to add option 43 and provide the correct IP to the TFTP server. Booting the Pi from the NAS works perfectly fine without any errors. I’ve edited /etc/fstab to mount the <serial>/ boot file directory as /boot (this allows me to edit the boot files from the network-booted Pi).

I have added bcm2835-v4l2 to the /etc/modules file.
After a reboot, /dev/video0 is available so it appears the V4L2 driver has loaded correctly.

I use v4l2rtspserver to serve an RTSP stream of /dev/video0, which works perfectly fine when the Pi is booted from an SD card (both the boot files and the root filesystem). As soon as I switch to full TFTP/NFS boot without an SD card, executing v4l2rtspserver completely locks up the Pi.

I've compiled and installed v4l2rtspserver as follows:

sudo apt-get install git cmake
git clone https://github.com/mpromonet/v4l2rtspserver.git
cd v4l2rtspserver && cmake . && make
sudo cp v4l2rtspserver /usr/local/bin/
cd .. && rm -rf v4l2rtspserver

This is where things become weird, because raspivid seems to work just fine. After running raspivid, the v4l2rtspserver command works just fine as well... I’ve tried running sudo rpi-update (and of course replaced the bootcode.bin file in the TFTP root directory) but unfortunately that didn't fix the issue either.

I then came across these two issues on GitHub:
#2335
#2528

So, I created bcmhi.c with the following content:

#include "bcm_host.h"

int main(int argc, char* argv)
{
  bcm_host_init();
  return 0;
}

I then compiled it using sudo gcc bcmhi.c -I/opt/vc/include -L/opt/vc/lib -lbcm_host -o /usr/local/bin/bcmhi. When I executed bcmhi && v4l2rtspserver, the Pi no longer locked up and everything worked as it should (even after a reboot without running raspivid first).

So, in short, the issue is that bcm_host_init() needs to be called before /dev/video0 is usable. However, the weird thing is that this is only needed when the Pi is booted from TFTP/NFS without an SD card.

@jorisvervuurt jorisvervuurt changed the title TFTP/NFS booted Pi 3 Model B+ freezes when using official V4L2 driver TFTP/NFS booted Pi 3 Model B+ locks up when using official V4L2 driver May 11, 2019

@6by9

This comment has been minimized.

Copy link
Contributor

commented May 11, 2019

As requested in the template for issues, please provide your kernel and firmware version.

System
Copy and paste the results of the raspinfo command in to this section. Alternatively, copy and paste a pastebin link, or add answers to the following questions:

  • Which model of Raspberry Pi? e.g. Pi3B+, PiZeroW
  • Which OS and version (cat /etc/rpi-issue)?
  • Which firmware version (vcgencmd version)?
  • Which kernel version (uname -a)?

The fix for #2335 and #2528 was merged May 2018 so I was believing the issue was resolved.

@jorisvervuurt

This comment has been minimized.

Copy link
Author

commented May 11, 2019

Thanks for your reply.
Here’s the info you requested:

  • Which model of Raspberry Pi?
    Pi3B+

  • Which OS and version (cat /etc/rpi-issue)?
    Raspberry Pi reference 2019-04-08
    Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, e910bf55ac92e27c6e77043e8995bcb5e0a2d742, stage2

  • Which firmware version (vcgencmd version)?
    Mar 27 2019 15:48:59
    Copyright (c) 2012 Broadcom
    version 2e98b31d18547962e564bdf88e57b3df7085c29b (clean) (release) (start_x)

  • Which kernel version (uname -a)?
    Linux rpi-at 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

The issue as mentioned in the other threads indeed seems to be fixed, as loading the module (either via modprobe or via /etc/modules) no longer locks up the Pi. This issue however, seems to be somewhat related to the other two issues (same bcm_host_init() workaround)...

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.