> For the complete documentation index, see [llms.txt](https://bananapi.gitbook.io/bpi-m2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bananapi.gitbook.io/bpi-m2/zh/howtobuildingaminimalsystem.md).

# 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.

![](/files/-M2HXO-gyKc93v5Pg7na)

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

![](/files/-M2HXO-i1xOez8jSVMvq)

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

![](/files/-M2HXO-kUQeuqJc6wZOl)

**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
```

![](/files/-M2HXO-mbhiWo5yqLGEi)

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

![](/files/-M2HXO-oCC3JOFkrjihu)

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

![](/files/-M2HXO-qyp5-FdjrkhfQ)

`git clone https://github.com/BPI-SINOVOIP/BPI-M2-bsp.git` ![](/files/-M2HXO-sLLMdLqXn_cbs)

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

```
./build
```

![](/files/-M2HXO-ueMzg3gBarl_T)

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

![](/files/-M2HXO-wi1iEqR2msGPK)

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

![](/files/-M2HXO-ynQaQP_fHOlPa)

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

![](/files/-M2HXO0-JwumdgBBaJpZ)

**5,Go to ArmHf official website**

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

![](/files/-M2HXO01SZVMhGAuyHgs)

**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 >`

![](/files/-M2HXO03oVXo93ZOdcEr)

**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

![](/files/-M2HXO057jwNG53Kxln9)

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

![](/files/-M2HXO07K90J1uyT3ZzC)

![](/files/-M2HXO09bKM7UtWpijPe)

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`

![](/files/-M2HXO0BP788rCX-jcOV)

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

![](/files/-M2HXO0DgZDfGwDJq5FJ)

Go to system/vendor directory building relative link

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

![](/files/-M2HXO0FWBzzUihkPgpw)

**8.Finished above steps**

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