Brainy Pi

Available to select audience (currently beta)

Raspberry Pi Compatiblity

Description

Raspberry Pi is an inspirational product which disrupted the prototyping market. It added support to many thousands of sensors, peripherals, packages and software. Any replacement which doesn’t support this ecosystem will spoil customer experience.
So though we are an enterprise focussed board, we understand a bulk of our users would want something that works fast and would love to using existing Raspberry Pi code. Brainy Pi through Rbian is an effort to bring 1:1 software compatibility with Raspbian and all codes that run on Raspbian should ideally directly run on Brainy Pi.
Brainy Pi is designed to be pin to pin compatible with Raspberry Pi but because of different hardware some programmes using GPU (eg: camera) might have issues. Brainy Pi has an ISP for processing camera input and also has dedicated VPU for encoding/decoding media. These changes lead to some issues. Though compatibility might not work, if we are asked to make it work in an independent way we might be able to offer a more optimized code for the same function. Some of these are released as alternate code in documentation below.
ADDITIONAL NOTE:
Most of the open source codes and packages have scope for more optimisation and if written for enterprise we would have used more secure and optimized versions of same. Compatibility helps enterprise users prototype fast and then migrate out of Rbian to Shunya OS or build any custom solution which is more customized for the application. Though Rbian being based on Debian is a fully stable OS already just that it has further scope for optimisation which might be necessary only in large scale or precision projects.

INFO
This documentation is for Rbian OS version: 0.7.2-beta
To check the version of Rbian run the command in terminal
				
					os-version
				
			
Note: If the command fails or gives error then Rbian version is < 0.7.2-beta.

Software Compatibility

Approach: All software running on Raspbian should not just work exactly same but also install with same commands on Brainy Pi.
Following components define software compatibility.

32-bit v/s 64-bit

Currently we only support 64-bit OS for Brainy Pi.

Package Support

Status: Beta
Rbian is a distro based on Debian 11 (Bullseye), Hence most packages on Raspberry Pi OS are directly compatible. Some libraries developed specifically for Raspberry Pi OS for camera and GPIO functions have been rewritten for Brainy Pi so exactly same code can run on Brainy Pi.

Kernel Compatibility

Being enterprise focussed we take a ship with LTS Kernel only approach. This creates some scope for bugs and compatibility with application software written for different kernel version. Though most of it should work if users face any issues kindly report them on the BrainyPi forum here

GPIO Compatibility

Status: Beta
Brainy Pi GPIO vs Raspberry Pi GPIO
All differences compiled into a table
Pin NoRaspberry piBrainy PiType of change
26GPIO7ADCHardware not same
3/dev/i2c-1/dev/i2c-7Software configurable change
8 & 10/dev/ttyS0/dev/ttyS2Software configurable change
19,21,23,24,26*/dev/spidev0.0//dev/spidev0.1/dev/spidev0.0/Software configurable change
Unmodified GPIO code works directly on Brainy Pi.
Working examples of Sample Raspberry Pi GPIO codes directly running on Brainy PI without any modifications.
Example 1: Blinking LED on pin 37
  1. Connect LED and 220 Ohm resistor to pin 37 as per the image below. 
  2. Program to Blink LED on pin 37, Save it as gpio-example1.py
    #import the GPIO and time package
    import RPi.GPIO as GPIO
    import time
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(37, GPIO.OUT)
    # loop through 50 times, on/off for 1 second
    for i in range(50):
    GPIO.output(37,True)
    time.sleep(1)
    GPIO.output(37,False)
    time.sleep(1)
    GPIO.cleanup()
    
  3. Run the program by running command
    sudo python3 gpio-example1.py
    
Example 2: Blinking 2 LED’s on button press
Example does a little input little output and even does a little PWM.
  1. Connect LED’s and buttons according to the diagram below. 
  2. Program to Blink LED on pin 37, Save it as gpio-example2.py
    # External module imports
    import RPi.GPIO as GPIO
    import time
    # Pin Definitons:
    pwmPin = 18 # Broadcom pin 18 (P1 pin 12)
    ledPin = 23 # Broadcom pin 23 (P1 pin 16)
    butPin = 17 # Broadcom pin 17 (P1 pin 11)
    dc = 95 # duty cycle (0-100) for PWM pin
    # Pin Setup:
    GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
    GPIO.setup(ledPin, GPIO.OUT) # LED pin set as output
    GPIO.setup(pwmPin, GPIO.OUT) # PWM pin set as output
    pwm = GPIO.PWM(pwmPin, 50)  # Initialize PWM on pwmPin 100Hz frequency
    GPIO.setup(butPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Button pin set as input w/ pull-up
    # Initial state for LEDs:
    GPIO.output(ledPin, GPIO.LOW)
    pwm.start(dc)
    print("Here we go! Press CTRL+C to exit")
    try:
       while 1:
           if GPIO.input(butPin): # button is released
               pwm.ChangeDutyCycle(dc)
               GPIO.output(ledPin, GPIO.LOW)
           else: # button is pressed:
           pwm.ChangeDutyCycle(100-dc)
           GPIO.output(ledPin, GPIO.HIGH)
           time.sleep(0.075)
           GPIO.output(ledPin, GPIO.LOW)
           time.sleep(0.075)
    except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
       pwm.stop() # stop PWM
       GPIO.cleanup() # cleanup all GPIO
    
  3. Run the program by running command
    sudo python3 gpio-example2.py
    
See More Examples

Raspi Config

raspi-config works directly on Brainy Pi
Status: Beta
Raspi config available Options are listed below.
  1. Main Menu options 
  2. System Options

3. Display Options

4. Interface Options

5. Performance Options

6. Localization Options
7. Advanced Options

PiCamera

Status: Alpha BrainyPi supports Picamera python library for capturing images from CSI camera.
NOTE
For now the library supports only capturing the images form CSI camera.
The following key functions work for Picamera.
Sr.no API Input Output
1 capture capture(output, format=None, use_video_port=False, resize=None, splitter_port=0, bayer=False, **options) captures image from video and store in output variable. Inputs: bayer: the raw bayer data from the camera’s sensor
2 start_preview No Inputs Displays the preview overlay.
3 stop_preview No Inputs No outputs
4 resolution Its a variable which can set using camera.resolution (Value: (width, height)) Returns the resolution of camera
5 rotation Its a variable which can set using camera.rotation (Valid values are 0, 90, 180, and 270) Returns the angle the image rotated at
6 vflip Its a variable can set with camera.vflip (Values: True or False) Returns the True or False value
7 hflip Its a variable can set with camera.hflip (Values: True or False) Returns the True or False value
INFO
Use OpenCV to for advanced Image processing functions supported by PiCamera.
Example 1: Capturing image from Raspi cam v1.3
  1. Connect the Raspi cam v1.3 to CSI port.Oops!, No Image to display.
  2. Enable the Raspi cam and Reboot BrainyPi.
    sudo sed -i 's/#intfc:dtoverlay=ov5647/intfc:dtoverlay=ov5647/g' /boot/hw_intfc.conf
    sudo reboot
    
  3. Program to capture the image from CSI camera
    # Import required packages
    import picamera
    import time
    # Create PiCamera Object
    cam = picamera.PiCamera()
    # Capture the image of resolution 1920x1080
    cam.resolution = (1920, 1080)
    # Flip image horizontally
    cam.hflip = True
    # Flip image vertically
    cam.vflip = True
    # Set the camera output rotation value which can be 0, 90,
    # 180 or 270.
    cam.rotation = 270
    # Capture image and store it in .jpeg file
    cam.capture('image.jpeg')
  4. Save the program in file picamera-capture.py
  5. Run the program by running command
sudo python3 picamera-capture.py
  1. The image form the camera is captured in the file image.jpeg

Hardware Compatibility

General Approach: Brainy Pi strives to keep full compatibility with hardware signals and voltages so you can tap into Raspberry Pi module/HAT’s ecosystem.

Why things may not work and what we plan to do ?

The main issues crop around GPU related functions since we use a different GPU with different capabilities. Also we use a different WiFi and Bluetooth chip which may cause some incompatibility issues. Bluetooth we use currently has 4.1 BLE stack support while Raspberry Pi uses 5.0 stack. BT5.0 though can be made available in custom order it is not currently used in the board due to supply chain issues. PWM may also have some issues.
GPIO dependent hardware: There should be no problem with GPIO related hardware.
If you face issues with any hardware module, please report at link in next section. We will solve them and post it to community.
If you are a module/HAT manufacturer and want us to add support to your modules/HATs please write to support@brainypi.com.
NEED SUPPORT?
First, Ensure version of OS installed and the version this document is intended for match. If they match and yet problem persists. Please use this Forum link for community help.
If you are an enterprise customer please use the ticketing system login provided to you for priority support.

Previous

<< Rbian OS

Next

AI on Rbian >>

Index