Raspberry Pi Camera Error: `Failed to create component ‘vc.ril.camera’`

Hardware & Software Info:

  • 5MP Camera Board
  • Raspbian 10 (Buster)
  • Python 3

When using a Python library PiCamera and this error below occured:

mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera
    self._camera = mo.MMALCamera()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in __init__
    super(MMALCamera, self).__init__()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 633, in __init__
    prefix="Failed to create MMAL component %s" % self.component_type)
  File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
    raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "cam.py", line 4, in <module>
    camera = PiCamera()
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in __init__
    self._init_camera(camera_num, stereo_mode, stereo_decimate)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 460, in _init_camera
    "Camera is not enabled. Try running 'sudo raspi-config' "
picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.

There are two possible issue that which can cause this error to appear.

  1. Your FFC (Flexible Flat Cable) connection to your camera or your board is loose.
  2. You haven’t enabled your camera yet.

Solution: Tighten your loose FFC on your camera and board

Yes, as it says. It won’t be that hard to follow right. 😀

Solution: Enable camera access

Step 1

Open your terminal and execute:

sudo raspi-config

Once executed and you have provided your password, you’ll be greeted by this screen:

┌──────────────────────────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├───────────────────────────────┐
│                                                                                                                        │
│                  1 Change User Password Change password for the 'pi' user                                              │
│                  2 Network Options      Configure network settings                                                     │
│                  3 Boot Options         Configure options for start-up                                                 │
│                  4 Localisation Options Set up language and regional settings to match your location                   │
│                  5 Interfacing Options  Configure connections to peripherals                                           │
│                  6 Overclock            Configure overclocking for your Pi                                             │
│                  7 Advanced Options     Configure advanced settings                                                    │
│                  8 Update               Update this tool to the latest version                                         │
│                  9 About raspi-config   Information about this configuration tool                                      │
│                                                                                                                        │
│                                                                                                                        │
│                                                                                                                        │
│                                                                                                                        │
│                                   <Select>                                   <Finish>                                  │
│                                                                                                                        │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Select 5 Interfacing Options

Step 2

Once you have selected 5 Interfacing Options, this screen will show:

┌──────────────────────────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├───────────────────────────────┐
│                                                                                                                        │
│                    P1 Camera      Enable/Disable connection to the Raspberry Pi Camera                                 │
│                    P2 SSH         Enable/Disable remote command line access to your Pi using SSH                       │
│                    P3 VNC         Enable/Disable graphical remote access to your Pi using RealVNC                      │
│                    P4 SPI         Enable/Disable automatic loading of SPI kernel module                                │
│                    P5 I2C         Enable/Disable automatic loading of I2C kernel module                                │
│                    P6 Serial      Enable/Disable shell and kernel messages on the serial connection                    │
│                    P7 1-Wire      Enable/Disable one-wire interface                                                    │
│                    P8 Remote GPIO Enable/Disable remote access to GPIO pins                                            │
│                                                                                                                        │
│                                                                                                                        │
│                                                                                                                        │
│                                                                                                                        │
│                                                                                                                        │
│                                   <Select>                                   <Back>                                    │
│                                                                                                                        │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Select P1 Camera and proceed with the instructions of enabling your camera. After it, go back on the main menu and select <Finish>. You’ll be prompted to restart your board. Go on and restart, then proceed to the next step to test your camera.

Step 3

Execute the command below and see if your board can detect your camera:

vcgencmd get_camera

You should get this output supported=1 detected=1 if not, tighten your FFC on your cam and board.

To test if the camera is working, execute the command below:

raspistill -v -o test.jpg

Once executed, on the same directory you’re in, you should see a file named test.jpg open it and you should see the captured image from your cam.

References

  1. Raspbian Docs:vcgencmd
  2. Raspbian Docs: Camera

Written with StackEdit.

Use Raspberry PI 4 model B as Local Network Private DNS server on Ubuntu

Tested on the following Ubuntu Version

  • Ubuntu 19.10 (eoan)

There’s not much configuration change when configuring Bind 9 on an ARM architecture over an x86 or x64 this steps can be interchangeable except for different Linux distro which places default configuration files on a different folder (e.g CentOS uses /etc/named while Ubuntu uses /etc/bind) or some preset configurations has already been set and default config locations.

Step 1

Install Bind 9 DNS Server, Bind 9 Utilities and Bind 9 Docs

sudo apt install bind9 bind9utils dnsutils bind9-doc

Step 2

Make sure Bind 9 uses only IPv4, add named arguments for IPv4:

sudo vi /etc/default/bind9

Then add -4 on OPTIONS

# run resolvconf?
RESOLVCONF=no

# startup options for the server
OPTIONS="-4 -u bind"

Step 3

After installation we’re gonna remove some preset. First, open /etc/bind/named.conf.options

sudo vi /etc/bind/named.conf.options

Then remove the following line:

listen-on-v6 { any; };

Then add the following inside options { ... };

// Allow dns query on localhost and all host within the subnet
allow-query     { localhost;192.168.1.0/24; };
// Listen on port 53 with any IP or host (This is the default). 
// In case you're using DHCP for your IP 
// or there are not any statically assigned IP for you NS. 
// You can also use your subnet's CIDR.
listen-on port 53 {any;}

Step 4

Now, we’re gonna add Zone configuration and configure each zone files.

sudo vi /etc/bind/named.conf.default-zones

For CentOS/Fedora, the default file can be at /etc/named.conf.local Then add the following line:

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.1.168.192";
    allow-update { none; };
};

zone "sample.net" {
    type master;
    file "/etc/bind/db.sample.net";
    allow-update { none; };
};

Step 5

After setting up the zone info, we’ll now proceed at configuring each zone. First create /etc/bind/db.sample.net and add the following:

TTL    604800
@    IN    SOA   ns1.sample.net.    admin.sample.net. (
     6        ; Serial
     604800   ; Refresh
     86400    ; Retry
     2419200  ; Expire
     604800 ) ; Negative Cache TTL
; name servers - NS records
    IN    NS    ns1.sample.net.
; name servers - A records
ns1      IN    A    192.168.1.10
desktop  IN    A    192.168.1.20

Next, create the reverse lookup record, /etc/bind/db.1.168.192

$TTL 604800
@ IN SOA ns1.sample.net. root.sample.net. (
          5     ; Serial
    6048000     ; Refresh
      86400     ; Retry
    2419200     ; Expire
     604800 )   ; Negative Cache TTL
;
@  IN NS ns1.sample.net.
; PTR Records
101    IN    PTR    ns1.sample.net.     ; 192.168.1.10
200    IN    PTR    desktop.sample.net. ; 192.168.1.20

Step 6

After creating DNS record, we’ll have to test the configuration. To check the configuration files for error run named-checkconfig

sudo named-checkconfig

This will output the error and on which specific line the error occurred on your config file. It won’t output any if there are no error on your configurations. For your zone file, we’ll use named-checkzone. This requires you to input the zone name and zone file. In our case, we’ll do the following:

sudo named-checkzone sample.net db.sample.net
sudo named-checkzone 1.192.168.in-addr.arpa db.1.168.192

It will output OK if no issues are found in your zone file/s.

Step 7

When all configurations are set we’ll have to start/restart the bind9 service.

sudo server bind9 start

Step 8

Make sure you have set your new server as the default or primary DNS on you client/s. To check if your client can now query from your DNS, do the following:

# use `@` to query on the specific DNS
# We're using `localhost` since we're inside the DNS
#   if you're on your client, you have to provide the DNS IP
dig ns1.sample.net @localhost
# For reverse lookup
dig -x 192.168.1.200 @localhost

# Don't point to the DNS if you already have configured your
#   client's network interface's DNS, 
#   pointing at your new server
dig ns1.sample.net
dig desktop.sample.net
# For reverse lookup
dig -x 192.168.1.200

References

  1. MIT Bind Config
  2. ISC: Bind 9 Documentation
  3. ISC: Bind 9.14 named.conf Docs

Written with StackEdit.

Enable Wifi on Raspbian Using WPA Supplicant

Step 1

Edit your wpa_supplication config file.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf 

Step 2

Then copy and paste the configurations below and edit the SSID and WIFI PASSWORD.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=PH

network={
    ssid="[SSID]"
    psk="[WIFI PASSWORD]"
    scan_ssid=1
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    auth_alg=OPEN
}

Note: Double check your own Wifi settings and change the network configuration as you see fit. See WPA Supplicant Config Documentation for details. Also use iwlist [NET INTERFACE] scan to get more infor on your Wifi settings

Note on Hidden SSID: If you’re using hidden SSID for your Wifi hotspot, make sure to use scan_ssid=1 This uses probe request specific to your hidden SSID, and has a high latency.

Step 3

After setting the WPA Supplicant configurations. Restart your network manager with:

sudo service networking restart

Note: If restarting your network manager doesn’t connect you to wifi. Restart your board.

References

  1. WPA Supplicant Configuration Documentation

Written with StackEdit.

Enable SSH on Raspbian OS without Desktop UI (Headless)

Step 1

Whichever storage you’re using for your Raspbian OS either SD Card, SSD, or HDD; remove it from your board and mount the storage to your computer. Look for the boot partition and push an empty file with a filename ssh

Step 2

Put your storage back in the board and start your Raspberry Pi.

Step 3

Connect to your Raspberry Pi with SSH ssh [USERNAME]@[YOUR PI IP OR DOMAIN HERE]

Note: The default username and password for Raspbian is pi for username and raspberry as password, in case you didn’t add a new user or you didn’t change it.

REFERENCES

  1. Raspberry Pi Documentation: SSH Remote Access
  2. Raspberry Pi Documentation: Linux User Management

Written with StackEdit.