# Getting Started with M1P - Banana Pi Wiki

## Introduction

### BPI-M1P

Overview: BPI-M1P ubuntu linux

```
  The Banana Pi M1+ features onboard WiFi g/b/n. The board supports all classic projects and even more because of the onboard WIFi chip. Like its sibling, it can run operating systems including Android, Lubuntu, Ubuntu, Debian, and Raspbian.
  The Banana Pi M1+ is our upgraded M1 board. We feel like the onboard WiFi adds a lot more features to the board and makes it more convient for users to set up their linx desktop or router projects. 
```

* Read more about : [Banana Pi BPI-M1+](http://wiki.banana-pi.org/Banana_Pi_BPI-M1%2B)

#### Key Features

* &#x20;Dual-core 1.0GHz CPU
* &#x20;1 GB DDR3 memeory
* &#x20;Mali-400 MP2 with Open GL ES 2.0/1.1
* &#x20;WiFi onbaord

## Development

Let's get start to develop on BPI-M1P, see amazing things happen.

### Basic Development

#### Prepare to develop

```
 * Prepare 8G/above TF card, USB-Serial interface, PC with Ubuntu System
 * Using your USB-Serial Connect debug console on M1P
```

#### Load your first image on M1P

```
 1.You could download latest image from our forum
 
 2.Install bpi-tools on your system. If you can't access this URL or any other problems, please go to bpi-tools repo and install this tools manually.
 * apt-get install pv
 * curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
 
 3.After you download the image, insert your TF card into your Ubuntu
 * Execute "bpi-copy xxx.img /dev/sdx" to install image on your TF card.
 
 4.After step 3, then you can insert your TF card into M1P, and press power button setup M1P
```

### Advanced Development

#### SATA

1\. Mount SATA on M1P

* &#x20;After insert sata interface, execute "fdisk -l"
* &#x20;Then "mount /dev/sdx /mnt/xxx"

```
 
```

2\. If you meet some errors when you mount SATA, try these following commands:

* &#x20;"fdisk /dev/sdx" to create new partition , set your partition numbers and size, after created partitions, input "wq" to save and quit.
* &#x20;"mkfs.ext2 /dev/sdx" to format the SATA
* &#x20;"mount /dev/sdx /mnt/xxx"

3\. After you success to insert SATA, we could input following commands to test SATA interface:

* &#x20;"time dd if=/dev/xxx of=/dev/null bs=1M count=1000" to test read speed
* &#x20;"time dd if=/dev/zero of=/dev/sdx bs=1M count=1000" to test write speed

```
 
```

#### Touch screen

#### GMAC

Use iperf3 to test gmac

1\. On PC Terminal:

* &#x20;Execute "iperf3 -s"

2\. On M1P console:

* &#x20;TCP test: "iperf3 -c serverIP"
* &#x20;UDP test: "iperf3 -u -c serverIP"

#### WiFi on M1P

**WiFi Client**

**You have two ways to setup WiFi Client**

1\. Use commands to setup WiFi client

* &#x20;ip link set wlan0 up
* &#x20;iw dev wlan0 scan | grep SSID
* &#x20;vim /etc/wpasupplicant/wpa\_supplicant.conf

```
 network={    
 ssid="ssid"    
 psk="password"    
 priority=1 
 }
```

* &#x20;wpa\_supplicant -iwlan0 -c /etc/wpa\_supplicant/wpa\_supplicant.conf
* &#x20;dhclient wlan0

2\. Use UI interface to setup WiFi Client

#### Clear boot

* &#x20;git clone <https://github.com/BPI-SINOVOIP/BPI-files/tree/master/SD/100MB>
* &#x20;bpi-bootsel BPI-cleanboot-8k.img.gz /dev/sdX

#### IR function

* &#x20;Execute "getevent"
* &#x20;Use your IR device to send information to M1P

#### RPi.GPIO

**Install RPi.GPIO**

* &#x20;Execute "git clone <https://github.com/BPI-SINOVOIP/RPi.GPIO>"
* &#x20;after clone the repo, cd RPi,GPIO
* &#x20;Execute "sudo apt-get update"
* &#x20;Execute "sudo apt-get install python-dev python3-dev"
* &#x20;Execute "sudo python setup.py install" or "sudo python3 setup.py install" to install the module

**Using RPi.GPIO**

* &#x20;cd /usr/local/bin
* &#x20;Execute "./bpi\_test\_g40.py" to test RPi.GPIO

#### WringPi

* &#x20;GitHub: <https://github.com/BPI-SINOVOIP/BPI-WiringPi2.git>
* &#x20;We also have built-in test command in "/usr/local/bin"

**RGB 1602 LCD**

* &#x20;Execute "/usr/local/bin/bpi\_test\_lcd1602.sh"

**8x8 RGB LED Martix**

* &#x20;Firstly you need a GPIO Extend Board for 8x8 LED Martix
* &#x20;Execute "/usr/local/bin/bpi\_test\_gpio40.sh"

#### File System

* &#x20;read only system change to read & write mode: "mount -o remount,rw /"

#### Install QT

* &#x20;sudo apt-get install build-essential
* &#x20;sudo apt-get install libgl1-mesa-dev
* &#x20;sudo apt-get install libglu1-mesa-dev
* &#x20;sudo apt-get install freeglut3-dev
* &#x20;sudo apt-get install cmake
* &#x20;sudo apt-get install qt5-default qtcreator

#### A20 CAN Bus

In order to port [can4linux](https://sourceforge.net/projects/can4linux/) to the BananaPi, the CAN module description is needed from the A20 hardware manual. can4linux is a character-driver-based Linux driver used already on desktop PCs and embedded platforms like Freescale FlexCAN (the i.MX series of micro controllers) or Xiliny Zynq.

There is a more detailed document about CAN on the A20 at: <https://dl.linux-sunxi.org/A20/CAN%20Bus1.pdf>

This is a tutorial for using CAN BUS on bananapi with bananian 15-01

Thank selqcir share this example:

* Download and install "bananian-1501.img" into 8 GB SDCard.
* Expand the root file system using "bananian-config"
* Install missing package:

```
apt-get install git
apt-get update
apt-get upgrade
reboot
```

* Get last bananian available, and continu to install missing package:

```
git clone https://github.com/Bananian/linux-bananapi
apt-get install build-essential u-boot-tools uboot-mkimage 
apt-get install libusb-1.0-0 libusb-1.0-0-dev git wget fakeroot kernel-package zlib1g-dev libncurses5-dev
apt-get install subversion
```

* Build kernel:

```
cd linux-bananapi
make menuconfig
```

* Exit without saving when menu appears

```
zcat /proc/config.gz > /root/linux-bananapi/.config
make uImage modules
make INSTALL_MOD_PATH=output modules_install
```

* At this step, kernel should be compiled and "Module.symvers" should be available
* Then rename modules and firmware provide by Bananian, and replace by the new one.

```
mv /lib/modules /lib/modules.old
mv /lib/firmware /lib/firmware.old
mv /root/linux-bananapi/output/lib/modules /lib/modules
mv /root/linux-bananapi/output/lib/firmware /lib/firmware
```

* Same for uImage:

```
mount /dev/mmcblk0p1 /mnt
cd /mnt
mv uImage uImage.old
mv /root/linux-bananapi/arch/arm/boot/uImage /mnt
reboot
```

* Create link for further build:

```
cd /lib/modules/3.4.104/
ln -s /root/linux-bananapi build
cd ~
```

* Get Can4Linux and build it:

```
svn checkout https://svn.code.sf.net/p/can4linux/code/trunk can4linux-code
cd /root/can4linux-code/can4linux/
make TARGET=BANANAPI
```

* Install module for each startup of the board:

```
insmod can4linux.ko
cp can4linux.ko /lib/modules/3.4.104/kernel/net/can/
depmod -A -v
modprobe -v can4linux
echo "" >> /etc/modules ; echo "can4linux" >> /etc/modules
reboot
```

* Build CAN example

```
apt-get install swig
apt-get install python-dev
cd can4linux-code/can4linux-examples/
```

* Update CAN speed and device in file "pyCan-example.py"

```
# setting the device number
device = 0
defaultBaudrate = '250'
```

* Connect CAN transceiver and CAN bus, and check with for example:

```
  python pyCan-example.py
```

That's all

With this method, kernel version is "Linux bananapi 3.4.104" instead of "Linux bananapi 3.4.104+", because i was unable to find same sources than Bananian 15-01 , but CAN bus work !

### FAQ


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bananapi.gitbook.io/bpi-m2-ultra-open-source-single-board-computer/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
