Running native OpenWrt with 4.14.20 Kernel on BPI-R2

Finlay after spending some time i got natively OpenWrt with 4.14.20 Kernel running on my R2. :smiley:

wrt-boot

I will try to sum up all thinks here to get a little walk thru:

What you need:

  • USB-to-UART adapter -> connected to ā€œDebug UARTā€ on board and on other side to your computer
  • a running TFTP-Server
  • a ĀµSD card + reader
  • of course cabling for networking, power supply etc.
  1. Get the ā€œmtk-bpi-r2-SD.imgā€ Image from FrankWā€™s google drive:

    https://drive.google.com/open?id=1rtsqj3otRo41lQkjZLm1-oj7SyAjkuL6

  2. Put it on a ĀµSD card

    sudo dd if=mtk-bpi-r2-SD.img of=/dev/mmcblk0
    

    Pleas note! I use here my build-in card reader on my notebook. So i got the ĀµSD card mapped to mmcblk0. If you have a external card reader they maybe appear as /der/sdx! Check Kernel ring buffer for right device name before you overwrite your own sys-partiton :roll_eyes:!

    Donā€™t panic! This image contains not partitions so many tools will you show an empty ĀµSD card. This is not true! If you realy want to look if the image file is writen to ĀµSD then try tools like diff, hexdump or binwalk

    grafik You can do it same way on the .img file to get the same outputā€¦

  3. Wire up the R2 with the USB to UART adapter. I use the buspirate with minicom but there are so many other solutions out there that may also work.

  4. Put the ĀµSD into the R2 and press power button for about 6-8 seconds to boot up your board. You will see lines like thisā€¦

    boot-u-bot-from-sd

    ā€¦and at this point press any key! So you will get into U-Boot enter-u-boot-on-sd-image

  5. Now checkout the OpenWrt source code from github on your local computer

    git clone https://github.com/openwrt/openwrt.git
    
  6. Step into the openwrt folder and execute following commands to update and install feeds first:

     cd openwrt
     ./scripts/feed update -a 
     ./scripts/feed install -a
    
  7. Get config for the R2 target

    make menuconfig
    

    set following:

    • Target system -> MediaTek Ralink ARM
    • Target images -> ramdisk

    Let other thinks as there are for first time. Then exit and save all changes to .config file

  8. Build the images:

    make 
    
  9. After successful build step into

    cd build_dir/target-arm_cortex-a7_musl_eabi/linux-mediatek_32/
    

    Here you will find following files:

    • uImage-mt7623a-rfb-emmc-initramfs
    • root.squashfs

    copy both files to your tftp-server. Check Permissions on files and that your tftp-server is running now and serving these files.

  10. Connect your R2 borad (WAN Port) with the tftp server via Ethernet cable.

  11. Now you need to configure the R2-WAN-Network device in U-Boot

    setenv ipaddr <set your temporary ip address for B2 board>
    setenv netmask 255.255.255.0
    setenv serverip <set the ip adress of the tftp server>
    
  12. check if thetftp-server is reachable by the R2

    ping <ip address of the tftp server>
    

    if you get a message ā€˜is aliveā€™ then you can proceed with next step other wise you must check your cabling, tftp server and network configuration.

  13. Getting the kernel with init into emmc:

    tftp 84000000 uImage-mt7623a-rfb-emmc-initramfs
    mmc dev 0
    mmc write 84000000 1000 6000
    
  14. Now get the rootfs into emmc:

    tftp 84000000 root.squashfs
    mmc dev 0
    mmc write 84000000 20A00 6000
    
  15. Remove your ĀµSD card from board

  16. Reboot your board via ā€˜resetā€™ command and you are done!

Known issue:

  • After first boot all my network devices are populated and accessable via ping except the wifi. After second boot i get only eth0 and eth1 but not functional. I can bring the device up but link did not appear. I find out that if i enter the U-Boot again and bring up the WAN device via ping command and then boot to OS all devices again ready until reboot without U-Boot step. Maybe an initialization problem :thinking:

Currently i did not have time to look deeper into this and check other thinks like wifi. Will do so maybe in next daysā€¦

If you have questions so feel free to ask :smiley:

3 Likes

Nice tutorial.

I saw the patches for second gmac in 4.14,but got only eth1(wan) to work. Can you confirm that in this lede lan-ports (eth0) are not working?

wifi-driver is not included,but you can create a path from my repository an copy it to your lede-source. See lede-support-thread BPI-R2 OpenWRT(LEDE) Support

Good morning Frank,

yes i saw the patches for the second gmac too. But currently iā€™m not sure if i have include them. I check this later on with the funktionality of both eth devices again and report then.

You see if they are included if you have 2 eth-devices (native 4.14 have only eth0) where lan-ports mapped to eth0 and wan is mapped to eth1 (@-sign).

Ok waiting for your tests

you can check these eth not directly but over the lan/wan-Ports

do you know if it is possible to use additional space on the SD/EMMC. i ask because the image (~70MB for R2) itself has no partitiontable and so the SD-Card is (Free-space of >7GB) not visible to openwrt/lede.

Hi Frank,

after normal boot i get this output

grafik

here i can not bring up the net devices (wan/lan0/1/2/3/eth0/eth1). The ledā€™s on the ports did not appear and no ping will go out or in. Butā€¦

If i reboot an go direct to the U-Boot, ping a host, wherever it exist or not and boot then with ā€˜bootā€™ command from U-Boot to OpenWRT then i get this

grafik

At this point i can ping and send data to/from other hosts but only from following physical ports (WAN, LAN1, LAN2, LAN3). On LAN4 the lights goes on and they are blinking but the state is furthermore down.

It seams to me that the mapping is wrong. So i did the following simple test.

I put the lan cable into WAN port and ip shows me following (look on the nic states) grafik eth0 and lan0@eth0 are up

cable on port LAN1 (right next to WAN) grafik eth0 and lan1@eth0 are up

cable on port LAN2 grafik eth0 and lan2@eth0 are up

cable on port LAN3 grafik eth0 and lan3@eth0 are up

cable on port LAN4 grafik eth0 only up!

i would have expected following:

cable on WAN => eth1 up
cable on LAN1 => eth0 / lan0@eth0 up
cable on LAN2 => eth0 / lan1@eth0 up
cable on LAN3 => eth0 / lan2@eth0 up
cable on LAN4 => eth0 / lan3@eth0 up

Regarding SD / EMMC iā€™m pretty sure that itā€™s possible to use the rest of the EMMC. I will try to get some additional space and come back laterā€¦

Hi, thank you for the tests. These are differ completly from my. Also i miss wan-interface. eth0 an eth1 representing the ethernet-lanes between mt7623 and mt7530. These 2 are always up and routed via dts to the ports (wan,lan0-lan3). Per default wan to eth1 and lan-ports to eth0 in my tests wan(eth1) works,but i did not get traffic on all lan-ports, routed lan0 to eth1 then lan0 is working.