# How to building a Minimal system for BPI-M2

**1， Format microSD card**

Prepare one Class 10 SD card,and cut into two parts; the first partition is FAT32、the second partition is EXT4;but SD card’s front end should be reserve space more than 100MB which as Bootloader，Kernel storage area.we use Ubuntu provided by GParted tool to help us cut SD card.

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-gyKc93v5Pg7na%2Fmini%201.png?generation=1584080212298075\&alt=media)

Front end reserve 100MB，first part file system is FAT32，space is 50MB

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-i1xOez8jSVMvq%2Fmini%202.png?generation=1584080211640651\&alt=media)

Second partition file system is EXT4；size is remaining space from SD card

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-kUQeuqJc6wZOl%2Fmini%203.png?generation=1584080211962349\&alt=media)

**2,Install tool-chain**

```
udo apt-get install build-essential libncurses5-dev u-boot-tools qemu-user-static\ debootstrap git binfmt-support libusb-1.0-0-dev pkg-config
```

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-mbhiWo5yqLGEi%2Fmini%2016.png?generation=1584080211760432\&alt=media)

```
sudo apt-get install gcc-arm-linux-gnueabihf
```

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-oCC3JOFkrjihu%2Fmini%2017.png?generation=1584080210837183\&alt=media)

**3,To BPI-GitHub** <https://github.com/BPI-SINOVOIP/BPI-M2-bsp>

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-qyp5-FdjrkhfQ%2Fmini%204.png?generation=1584080210970635\&alt=media)

`git clone https://github.com/BPI-SINOVOIP/BPI-M2-bsp.git` ![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-sLLMdLqXn_cbs%2Fmini%2018.png?generation=1584080211194799\&alt=media)

After running，please switch to BPI-M2-bsp directory，run ./build.sh order to know support what development board currently：

```
./build
```

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-ueMzg3gBarl_T%2Fmini%2019.png?generation=1584080211253788\&alt=media)

can see BPI-M2 re-configuration profile; select the resolution what you want to compile the BPI-M2,it is assumed that BPI\_M2\_720P

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-wi1iEqR2msGPK%2Fmini%205.png?generation=1584080212755834\&alt=media)

Select model what you need compile(Here suggest choose (1) option when you compile first time)

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO-ynQaQP_fHOlPa%2Fmini%206.png?generation=1584080211622805\&alt=media)

**4,After compilation，can see produce new download folder under /BPI-M2-bsp**

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO0-JwumdgBBaJpZ%2Fmini%207.png?generation=1584080212332301\&alt=media)

**5,Go to ArmHf official website**

<http://www.armhf.com/download/download> Root File Systems-Debian Wheezy 7.5

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO01SZVMhGAuyHgs%2Fmini%208.png?generation=1584080212575729\&alt=media)

**6,Install Root File Systems**&#x20;

extract the files which was download compressed to SD second partition EXT4; please note that the decompressed instructions

`sudo tar --strip-components=1 -pJxvf< file source > -C < Extract storage location >`

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO03oVXo93ZOdcEr%2Fmini%2015.png?generation=1584080211439202\&alt=media)

**7,Install BootLoader;please use order to see current SD card position**

`sudo fdisk -l`

After run order，can see the example SD card’s position in /dev/sdb

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO057jwNG53Kxln9%2Fmini%209.png?generation=1584080212322681\&alt=media)

Please refer to fourth tips，after compilation will have Bananapi folder;then youwill see bootload/ Kernel these file from download/BPI\_M2\_720P folder。Please write in former 100MB of SD card Individually。

```
sudo dd if=boot0_sdcard.fex       of=${card} bs=1k seek=8
sudo dd if=u-boot.fex           of=${card} bs=1kseek=19096
sudo dd if=sunxi_mbr.fex         of=${card} bs=1k seek=20480
sudo dd if=bootloader.fex           of=${card} bs=1k seek=36864
sudo dd if=env.fex               of=${card}bs=1k seek=69632
sudo dd if=boot.fex               of=${card} bs=1k seek=86016
```

Step 1: BPI-M2 we will use first partition FAT32 don’t need to copy any file，for compatible with Kernel4.1.X in the near future

Step 2: Copy modules to Second partition EXT4 of lib catalog from /BPI-M2-bsp/download/BPI\_M2\_720P/lib directory

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO07K90J1uyT3ZzC%2Fmini%2010.png?generation=1584080212418988\&alt=media)

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO09bKM7UtWpijPe%2Fmini%2011.png?generation=1584080211484680\&alt=media)

Step 3:Please building wifi-firmware read’s directory (/system/vendor)and building Link from Second partition，because BPI-M2 loading bcmdhd.ko will go to relative path searching WiFi-firmware，so we need building one link：

`$sudo mkdir system`

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO0BP788rCX-jcOV%2Fmini%2012.png?generation=1584080212852496\&alt=media)

```
$cd system
$sudo mkdir vendor
```

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO0DgZDfGwDJq5FJ%2Fmini%2013.png?generation=1584080211040530\&alt=media)

Go to system/vendor directory building relative link

`$ sudo ln -s /lib/modules/3.11.0-15-generic/ modules`

![](https://1265032173-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2HWtRAeSna97-WL0mR%2F-M2HWvGmXE4MI8VrC8lC%2F-M2HXO0FWBzzUihkPgpw%2Fmini%2014.png?generation=1584080211963706\&alt=media)

**8.Finished above steps**

please insert maked-SD card into Banana Pi，please try to Boot。
