# bpi-r64 openwrt installation guide (from raw device)
==Since the eMMC on the raw bpi-r64 device is empty.
You can't boot at all.
So you need a sd card equiped with an OS, and a USB stored boot loader binary and openwrt image file. (I used ubuntu 18.04 especially for bpi-r64 for sd card. I will show the links of all the required files down below.)==
## Requirements
1. Empty USB drive and a Micro SD card (and of course the Micro SD to USB adapter).
2. Uart to USB connector.
3. A linux computer as the output monitor for bpi-r64. *(Windows is also fine, but I use linux for example.)*
## Steps
1. Making materials for the installation
1. Install OS on SD card.
1. Download the [image file][1].
2. Insert you SD card to a linux computer.
3. Download the live USB tool [balenaEtcher][2]. (After the download, you need to unzip the file and get the binary file. Before you execute it, you need ==chmod +x==)
4. Choose the downloaded image file(step 1) as the source and SD card as the destination. And wait for a moment for completion.

2. USB Drive material
1. Format you USB drive as fat32.
2. Mount it on your linux computer. (You may need to use ==sudo mount -t vfat /dev/sdXX /mnt==)
3. Download the [bootloader binary][4] and the [openwrt image][3], and store them into the USB drive.
2. Setting up the connection between linux computer and the bpi-r64.
1. Use Uart to USB connector to connect the bpi-r64 to the linux computer.
1. Plug the wires like the photo, and connect the usb end to the linux computer. ==Green -> rx White -> tx Black -> GND==
2. In your linux computer, install minicom. ==sudo apt install minicom==
3. ==sudo minicom -s==
4. Configure as follow.


4. Save setup as dfl.
5. Press ESC to get the screen like this. ==(This will be the screen to capture all the output from the bpi-r64)==

3. Start the installation on bpi-r64
1. Insert SD card onto bpi-r64.
2. Plug in the power. (Once you plug the power, bpi-r64 will start booting)
3. Your minicom screen will start to pop some infomation, wait for login message. ==username:root passwd:bananpi==
4. Insert USB drive onto bpi-r64.
5.
```shell=
mount -t vfat /dev/sdXX /mnt
cd /mnt
echo 0 > /sys/block/mmcblk0boot0/force_ro
dd if=emmc_singleimage.img of=/dev/mmcblk0
dd if=preloader_emmc.bin of=/dev/mmcblk0boot0
mmc bootpart enable 1 1 /dev/mmcblk0
shutdown
```
6. Unplug USB Drive and SD card, replug the power. bpi-r64 will boot into openwrt.
[1]: https://download.banana-pi.dev/d/3ebbfa04265d4dddb81b/?p=%2FImages%2FBPI-R64%2FUbuntu18.04&mode=list "For SD card Ubuntu 18.04 image"
[2]: https://www.balena.io/etcher/ "live USB tool"
[3]: https://drive.google.com/open?id=1w8kO3klbPfdHK6lTI8Ub8sR_7ViISORM "openwrt image"
[4]: https://drive.google.com/open?id=1Fy__GpNSWRcITEmzH4Z_jxnjrCS3BpQJ
"boot loader binary"
## Reference
1. [Getting Started with R64][1]
2. [Build and Install OpenWRT on Banana Pi R64][2]
[1]: http://wiki.banana-pi.org/Getting_Started_with_R64?fbclid=IwAR090ZFWCtsKBEhZSYtKfyTdEI6lwMvROr1w91178hVOdhe6DMMUpwlPeqg "Getting Started with R64"
[2]: https://ntsd.me/install-openwrt-on-banana-pi-r64/ "Build and Install OpenWRT on Banana Pi R64"