# Problem launching balenaCam

**URL:** <https://forums.balena.io/t/problem-launching-balenacam/134078>\
**Category:** Product support\
**Created:** [June 16, 2020, 11:59pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078 "2020-06-16T23:59:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 16, 2020, 11:59pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/1 "2020-06-16T23:59:18Z")

</div>

Hi, so I successfully pushed the code for balenaCam to my Rpi4. I followed all the instructions on the GitHub page and It seems that my Rpi4 is stuck in a loop of trying and ultimately failing to initiate the bcm2835-v4l2 driver. It ultimately exits the service and tries to boot it again but to no avail. I looked on the forums and I edited the source code at line 168 to say “if not os.path.exists(’/dev/video1’)” instead of “if not os.path.exists(’/dev/video0’)” as per instructions in a previous forum post about a person that encountered the same issue. I pushed that updated code to my device and im still having the same issue. When I click the public link, it says that “tunneling socket could not be established: 500”. Can anyone help me out with this issue?

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [June 17, 2020, 9:49am UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/2 "2020-06-17T09:49:25Z")

</div>

Hi

- About the public link: If the service isn’t online, and the device is restarting, it’s expected that the tunneling part won’t work. So that’s just an effect of the first problem.
- Can you share the device logs that you see?

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 17, 2020, 6:31pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/4 "2020-06-17T18:31:24Z")

</div>

Here is a screenshot of the log for the device.

 ![Screen Shot 2020-06-17 at 2.30.53 PM](https://global.discourse-cdn.com/balena/original/2X/e/eaa998d9f02c659420ce233b27a43c0762f5b759.png)

---

<div class="post-metadata">

**Author:** ![jtonello](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jtonello/32/3246_2.png) [@jtonello](https://forums.balena.io/u/jtonello)\
**Post date:** [June 17, 2020, 6:49pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/6 "2020-06-17T18:49:37Z")

</div>

Hi @thomas.cullen,

Have you enabled the various `gpu_mem` variables per the balenaCam [README](https://github.com/balenalabs/balena-cam)? Also, in the HostOS, are you seeing your /dev/video1 (or similar)? I noticed, too, that the balenaCam repo has line 31 (`#RUN printf "bcm2835-v4l2\n" >> /etc/modules`) commented out. If that’s true in your version, the module likely isn’t getting loaded. Can you confirm that line is uncommented in your Dockerfile.template?

John

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 17, 2020, 7:11pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/9 "2020-06-17T19:11:45Z")

</div>

1.) So I uncommented line 31 in the Dockerfile.template and I reuploaded it to my device…nothing changed and the logs are still saying that there is an issue.  
2.) How do I go about checking in the hostOS terminal session that I am seeing /dev/video1?  
3.) I have attached what i set as the gpu\_mem variables for the device.

 ![Screen Shot 2020-06-17 at 3.02.11 PM](https://global.discourse-cdn.com/balena/original/2X/4/422d4fd0a01092b79ce1ffbf22fe545c31b994e6.png)

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [June 18, 2020, 10:47am UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/10 "2020-06-18T10:47:54Z")

</div>

Hey, to check if `/dev/video1` exists, you can do `ls /dev | grep video` and please paste the output here, it should give us more information to diagnose this.

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 18, 2020, 7:50pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/12 "2020-06-18T19:50:52Z")

</div>

> [@CameronDiver](#):
>
> ls /dev | grep video

root@7499973:~# ls /dev | grep video  
video10  
video11  
video12

This is what I see as a result of running that command in terminal of the Host OS.

---

<div class="post-metadata">

**Author:** ![dtischler](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dtischler/32/2483_2.png) [@dtischler](https://forums.balena.io/u/dtischler)\
**Post date:** [June 18, 2020, 9:25pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/13 "2020-06-18T21:25:08Z")

</div>

Hi Thomas, well, that seems strange that they are being enumerated as video10 through 12, but I suppose it is now worth trying to go back to the information in your first post, where you mention line 168 needing to be updated, and giving it a try with these values instead. Out of curiosity, this Pi 4 that you are using, how much memory does it have? Is it a 2gb RAM model?

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 18, 2020, 11:33pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/15 "2020-06-18T23:33:39Z")

</div>

These values are after editing line 168 and reuploading the image to the Rpi. And yes, my Rpi 4 has 2gb of RAM.

---

<div class="post-metadata">

**Author:** ![vipulgupta2048](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@vipulgupta2048](https://forums.balena.io/u/vipulgupta2048)\
**Post date:** [June 19, 2020, 9:57am UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/16 "2020-06-19T09:57:08Z")

</div>

Hi, can you mention the link to the forum post that you used to make the edit to the source code. Thanks!

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 19, 2020, 8:55pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/18 "2020-06-19T20:55:31Z")

</div>

> [@Problem launching balenaCam](https://forums.balena.io/t/problem-launching-balenacam/134078/6):
>
> Hi @thomas.cullen, Have you enabled the various gpu\_mem variables per the balenaCam [README](https://github.com/balenalabs/balena-cam)? Also, in the HostOS, are you seeing your /dev/video1 (or similar)? I noticed, too, that the balenaCam repo has line 31 (#RUN printf "bcm2835-v4l2\n" \>\> /etc/modules) commented out. If that’s true in your version, the module likely isn’t getting loaded. Can you confirm that line is uncommented in your Dockerfile.template? John

It was a post previously made in this thread.

---

<div class="post-metadata">

**Author:** ![saintaardvark](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/saintaardvark/32/3390_2.png) [@saintaardvark](https://forums.balena.io/u/saintaardvark)\
**Post date:** [June 19, 2020, 9:29pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/20 "2020-06-19T21:29:11Z")

</div>

Hi @thomas.cullen – thanks for the additional details. Just to make sure we’re on the same page, let me see if I understand correctly:

- Your Pi4 has video devices /dev/video10, /dev/video11 and /dev/video12
- You’ve made a couple changes to your local copy of the balenaCam source code:
- You’ve changed line 168 of app/server.py to look for /dev/video10
- You’ve uncommented this line of Dockerfile.template, so that the kernel module for the camera will be loaded when the containe starts
- After pushing all of that to your device, you are still having the same problem where the container restarts in a loop, and the logs say `Video device is not ready` / `Trying to load bcm2835-vl42` over and over again

Can you confirm that I’ve got that right?

Assuming for the moment that I do:

- As we mentioned before, it looks as though the device is coming up with a different name than the balenaCam source code expects (video10 instead of video0). This expectation is built into the software right now, but [there is an issue to address this](https://github.com/balenalabs/balena-cam/issues/69). You can log into Github to watch that issue, and you’ll get notified when it’s addressed.
- Are you able to run the `ls /dev | grep video` command from within the balena-cam container, and at the same time do it in the Host OS as well? It would be good to confirm that both have the same view of things – if the container, for some reason, can’t see the devices that the Host OS can, then it would definitely cause problems.
- Can you run `vcgencmd get_camera` in the Host OS and post the output, to see if the camera is being detected?

All the best,

Hugh

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 19, 2020, 10:16pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/22 "2020-06-19T22:16:06Z")

</div>

You’ve got that all right, except for the fact that I changed line 168 of the app/server.py to look for /dev/video1 but not /dev/video10.

Thank you for the suggestions, ill give them a try and get back to you.

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 21, 2020, 3:43pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/24 "2020-06-21T15:43:06Z")

</div>

When I try to run `ls /dev | grep video` in the balenacam container, I get a repeating error that says…

> Error response from daemon: Container 857d2710264fc5ab51957866596291c39ebb23bcba8f21c3e590831b85334dad is restarting, wait until the container is running  
> Error response from daemon: Container 857d2710264fc5ab51957866596291c39ebb23bcba8f21c3e590831b85334dad is restarting, wait until the container is running  
> SSH session disconnected  
> SSH reconnecting…  
> Spawning shell…

In terms of what I get when I run `vcgencmd get_camera` in the host os, I get this response…

> ```
> root@7499973:~# vcgencmd get_camera
> supported=1 detected=0
> 
> ```

---

<div class="post-metadata">

**Author:** ![jtonello](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jtonello/32/3246_2.png) [@jtonello](https://forums.balena.io/u/jtonello)\
**Post date:** [June 22, 2020, 3:53pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/25 "2020-06-22T15:53:46Z")

</div>

Hi @thomas.cullen,

The error shows that the container is not able to restart. Perhaps a change you made is preventing a start. Can you share the device service logs?

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![thomas.cullen](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thomas.cullen/32/3985_2.png) [@thomas.cullen](https://forums.balena.io/u/thomas.cullen)\
**Post date:** [June 22, 2020, 4:45pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/27 "2020-06-22T16:45:41Z")

</div>

![Screen Shot 2020-06-22 at 12.44.58 PM](https://global.discourse-cdn.com/balena/original/2X/7/709de6fc1b92654d9a6800636cdb6afc752a7ae9.png)  
this is a snapshot of the log that is repeating.

---

<div class="post-metadata">

**Author:** ![jtonello](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jtonello/32/3246_2.png) [@jtonello](https://forums.balena.io/u/jtonello)\
**Post date:** [June 22, 2020, 6:19pm UTC](https://forums.balena.io/t/problem-launching-balenacam/134078/30 "2020-06-22T18:19:35Z")

</div>

Hi,

Have you tried running a `modprobe bcm2835-v4l2` in a Dockerfile.template CMD? You could try this from the command line, too, and then rerun your `vcgencmd get_camera`. If the result is good, then you can add the modprobe _before_ the server.py script.

John
