Difference between revisions of "Getting Started with M5/M2Pro"
(→Wifi/BT support) |
(→Wifi/BT support) |
||
Line 462: | Line 462: | ||
:USB type: Plug-in the usb dongle to usb host port and reboot the system, After bootup, you can enable or disable wifi and bluetooth in Settings app. | :USB type: Plug-in the usb dongle to usb host port and reboot the system, After bootup, you can enable or disable wifi and bluetooth in Settings app. | ||
− | :SDIO/UART type: Connect the hardware module to 40pin header correctly and [http://wiki.banana-pi.org/Getting_Started_with_BPI-M5#Android_DTB.2FDTBO_overlay | + | :SDIO/UART type: Connect the hardware module to 40pin header correctly and [http://wiki.banana-pi.org/Getting_Started_with_BPI-M5#Android_DTB.2FDTBO_overlay configure the Android DTB overlay] to enable it. |
:2. Linux test and support. | :2. Linux test and support. |
Revision as of 01:21, 21 January 2021
Contents
Introduction
Banana Pi M5 is a new generation single board computer design , use Amlogic S905X3 Quad-Core Cortex-A55 (2.0xxGHz) Processor. Mali-G31 MP2 GPU with 4 x Execution Engines (650Mhz). support 4GB LPDDR4 and 16G eMMC flash. it have 4 USB 3.0 port,1GbE LAN port.
specifications
- SoC – Amlogic S905X3 quad-core Cortex-A55 processor @ up to 2.0 GHz with
- Mali-G31 MP2 GPU @ 650Mhz
- System Memory – 4GB LPDDR4
- Storage – 16GB eMMC flash (option up to 64GB), MicroSD slot up to 2TB
- Video Output – HDMI 2.1 up to 4Kp60 with HDR, CEC, EDID
- Audio – 3.5mm audio jack, digital HDMI audio
- Connectivity – Gigabit Ethernet
- USB – 4x USB 3.0 ports via VL817 hub controller, 1x USB-C port (for power only?)
- Expansion – 40-pin Raspberry Pi header with 28x GPIO, UART, I2C, SPI, PWM, and power signal (+5V, +3.3V, GND).
- Debugging – 3-pin debug header
- Misc – Reset, Power, and U-boot button; power and activity LED’s; IR receiver
- Power Supply – 5V @3A via USB Type-C port
- Dimensions – 92x60mm (Not the same as Raspberry Pi PCB size, but they probably included the connectors during measurement)
- Weight – 48grams
development
Prepare
- 1. Prepare a usb-serial cable, a 5V/2A adaptor with type-c power supply. The serial cable is used for console debug and type-c cable is used for android image download and ADB debug.
- 2. Prepare a SDcard at least 8GB for linux development, android only support emmc boot.
- 3. The SOC rom first boot media is emmc, so board can't bootup from SDcard if the emmc is bootable with any image flashed, more info please refer to board boot sequence.
- 4. In Android SDcard is mmc0, emmc is mmc1, but in Linux SDcard is mmc1, emmc is mmc0.
Android
Prepare
- 1. Download and install the AML Usb Burning Tool for android image download via type-c, only support windows.
- 2. Download the latest android image.
Install Image with Usb Burning Tool
- 1. Open USB_Burning_Tool.exe, select menu File->Import image, choose the android image file aml_upgrade_package.img.
- 2. M5 board disconnect power, press and hold SW4 button beside 40pin header, plugin type-c usb cable to PC
- 3. Click the Start button and wait for upgrade complete.
- 4. After Burning successfull, Unplug the type-c usb and connect to power supply adaptor to startup.
- 5. Click the Stop button to cancel the upgrade process and close the USB Buring Tool.
Build Android Source Code
- 1. Get Android 9.0 source code
$ git clone https://github.com/BPI-SINOVOIP/BPI-S905X3-Android9
- 2. Build the Android 9.0 Source code
- Please read the source code README.md
Android DTB/DTBO overlay
- Bananapi M5 DTBO idx value table, default idx value is 0 in release image.
Bananapi M5 DTBO idx value table idx value device tree overlay description 0 android_p_overlay default dtbo, no use 1 wifi_bt_rtl8822cs enable bpi rtl8822cs wifi/bt module
- How to apply a new dtbo
- 1. ADB command via sysfs
root@dangku-desktop:/tmp# adb root restarting adbd as root root@dangku-desktop:/tmp# adb remount remount succeeded root@dangku-desktop:/tmp# adb shell bananapi_m5:/ # echo dtbo > /sys/class/unifykeys/name bananapi_m5:/ # echo "1" > /sys/class/unifykeys/write bananapi_m5:/ # reboot
- 2. Uart console command via sysfs
console:/ $ console:/ $ su console:/ # echo dtbo > /sys/class/unifykeys/name [ 115.702781@0] unifykey: name_store() 1302, name dtbo, 4 [ 115.702856@0] unifykey: name_store() 1311 console:/ # console:/ # echo "1" > /sys/class/unifykeys/write [ 129.262659@0] unifykey: write_store() is a string [ 129.262733@0] unifykey: dtbo, 1, 1 [ 129.265312@0] unifykey: amlkey_write 393 [ 129.292347@1] emmc_key_write:149, write ok console:/ # console:/ # reboot
- 3. Settings App(To-Do)
- Check the bootup uart debug message and confirm which dtbo is loaded actually, here "1" means idx=1 dtbo loaded.
load dtb from 0x1000000 ...... Amlogic multi-dtb tool Single dtb detected find 2 dtbos dtbos to be applied: 1 Apply dtbo 1
- Unifykeys is stored in a specific emmc part, "Normal erase" selected in USB_Burning_Tool will not erase this data for next update, you must select "Erase all" if you want the default dtbo idx to be applied.
- Build Android image with a specific DTBO default.
- 1. Default build-in overlays are defined in device/amlogic/bananapi_m5/Kernel.mk, you can add a new overlay dtbo here.
DTBO_DEVICETREE := android_p_overlay wifi_bt_rtl8822cs
- 2. Default apply DTBO idx is defined in device/amlogic/bananapi_m5/BoardConfig.mk, you can change the idx value to set which overlay dtbo will be applied default.
BOARD_KERNEL_CMDLINE += androidboot.dtbo_idx=0
- 3. DTS files are in common/arch/arm/boot/dts/amlogic/overlay/bananapi_m5/
- More info about android device tree overlays, please refer to google android offical site
Linux
Prepare
- 1. Linux image support SDcard or EMMC bootup, but you should read the boot sequence at first.
- 2. Make sure bootable EMMC is formatted from sector 0 if you want bootup from SDcard, and make sure bootable SDcard is formatted if you want bootup from EMMC(because uboot read bootscript file from mmc:1 first, which is SDcard dev, This is used for quickly SDcard bootup debug or flash image to EMMC while EMMC is bootable).
- 3. Install bpi-tools on your Linux PC. If you can't access this URL or any other install problem, please go to bpi-tools source repo, download 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
- 4. Download Linux latest Linux Image.
- 5. Default login: pi/bananapi or root/bananapi
Install Image to SDcard
- 1. Install image with bpi-tools on Linux, plug SDcard to Linux PC and run
$ sudo bpi-copy xxx-bpi-m5-xxx.img.zip /dev/sdX
- 2. Install bpi image with Etcher on Windows, Linux and MacOS.
- Balena Etcher is an opensource project by Balena, Flash OS images to SDcard and USB drive
Install Image to EMMC
- 1. Prepare a SDcard with Linux image flashed and bootup board with this SDcard.
- 2. Copy Linux image to udisk, plug the udisk to board and mount it.
- 3. Install with bpi-tools command
$ sudo bpi-copy xxx-bpi-m5-xxx.img.zip /dev/mmcblk0
- 4. Install with dd command, umount mmcblk0p1 and mmcblk0p2 partition if mounted automatically.
$ sudo apt-get install pv $ sudo unzip -p xxx-bpi-m5-xxx.img.zip | pv | dd of=/dev/mmcblk1 bs=10M status=noxfer
- 5. After download complete, power off safely and eject the SDcard.
Build Linux Source Code
- 1. Get the Linux bsp source code
$ git clone https://github.com/BPI-SINOVOIP/BPI-M5-bsp
- 2. Build the bsp source code
- Please read the source code README.md
- 3. If you want build uboot and kernel separately, please download the u-boot the kernel only, get the toolchains, boot script and other configuration files from BPI-M5-bsp
DTB overlay
- 1. DTB overlay is used for 40pin gpios multi-function configuration and install in vfat BPI-BOOT/overlays
root@bananapi:~# ls /media/pi/BPI-BOOT/overlays/ custom_ir.dtbo pwm_b-backlight.dtbo spi0.dtbo ds3231.dtbo pwm_c-beeper.dtbo uart1_cts_rts.dtbo hifi_pcm5102a.dtbo pwm_cd-c.dtbo uart1.dtbo hifi_pcm5122.dtbo pwm_cd.dtbo uart2.dtbo i2c0.dtbo pwm_ef.dtbo waveshare_tft24_lcd.dtbo i2c1.dtbo pwm_ef-f.dtbo waveshare_tft35c_lcd.dtbo pwm_ab.dtbo sdio.dtbo waveshare_tft35c_rtp.dtbo
- 2. Update the overlays env in vfat BPI-BOOT/boot.ini to enable what you want. Default i2c0, spi0 and uart1 enabled.
# Overlays to load # Example combinations: # spi0 i2c0 i2c1 uart0 # hktft32 # hktft35 setenv overlays "i2c0 spi0 uart1"
- 3. Must be restart the board for overlay dtb loaded.
WiringPi
- Note: This WiringPi only support set 40pin gpio to output, input or software pwm, for io functions as i2c, spi, pwm..., you must enable dtb overlay in boot.ini
- 1. Build and install wiringPi
$ git clone https://github.com/BPI-SINOVOIP/amlogic-wiringPi $ cd amlogic-wiringPi $ chmod a+x build $ sudo ./build
- 2. Run gpio readall to show all 40pins status.
- 3. BPI GPIO Extend board and examples in amlogic-wiringPi/examples
- blinkall, blink all pin header gpios, no extend board.
- lcd-bpi, BPI LCD 1602 display module example.
- 52pi-bpi, BPI OLED Display Module example.
- matrixled-bpi, BPI RGB LED Matrix Expansion Module example.
- berryclip-bpi, BPI BerryClip Module
Other Development
Custom Linux Boot Logo
- Linux uboot limit boot logo fb size to 1080p60hz/1920x1080 default, so oversize resolution will not be supported by default image, but you can modify uboot source code to support it.
- 1. Prepare a 24bit bmp file and named boot-logo.bmp
- 2. Compress the bmp file to boot-logo.bmp.gz
$ gzip boot-logo.bmp
- 3. copy the target file to BPI-BOOT partition of linux image
$ cp boot-logo.bmp.gz /media/xxx/BPI-BOOT/
Custom Android Boot Logo
- Android bootloader limit boot logo fb display size is 1080p60hz/1920x1080 default, and android kernel dtb partition table limit boot logo partition size to 16MB default .
- 1. Prepare a 24bit bmp file and named boot-logo.bmp
- 2. Compress the bmp file to boot-logo.bmp.gz
$ gzip boot-logo.bmp
- 3. Download m5_android_bootlogo_tool.zip
- 4. Extract this tool
$ unzip m5_android_bootlogo_tool.zip $ cd m5_android_bootlogo_tool/ $ cp -a logo_img_files logo //logo_img_files is the origin bootlogo resource in android source and copy from <android-source-dir>/devices/amlogic/bananapi_m5/log_img_files $ ls -l logo/ -rwxr--r-- 1 dangku dangku 525054 Sep 25 16:54 bootup.bmp -rwxr--r-- 1 dangku dangku 525054 Sep 25 16:54 bootup_X3.bmp -rwxr--r-- 1 dangku dangku 184 May 19 2020 upgrade_bar.bmp -rwxr--r-- 1 dangku dangku 180072 May 19 2020 upgrade_error.bmp -rwxr--r-- 1 dangku dangku 180072 May 19 2020 upgrade_fail.bmp -rwxr--r-- 1 dangku dangku 180072 May 19 2020 upgrade_logo.bmp -rwxr--r-- 1 dangku dangku 180072 May 19 2020 upgrade_success.bmp -rwxr--r-- 1 dangku dangku 184 May 19 2020 upgrade_unfocus.bmp -rwxr--r-- 1 dangku dangku 180072 May 19 2020 upgrade_upgrading.bmp
- 5. Copy the boot-logo.bmp.gz
$ cp boot-logo.bmp.gz logo/bootup.bmp $ cp boot-logo.bmp.gz logo/bootup_X3.bmp
- 6. Create target logo.img with img pack tool, the binary and related libs of m5_android_bootlogo_tool are copy from <android-source-dir>/out/host/linux-x86
$ ./logo_img_packer -r logo logo.img
- 7. Flash boot logo with fastboot
$ adb root $ adb remount $ adb reboot fastboot
- Wait few seconds and check whether fastboot connected
$ fastboot device 1234567890 fastboot $ fastboot flashing unlock_critical $ fastboot flashing unlock $ fastboot flash logo logo.img $ fastboot reboot
Boot Sequence
- Check bootloader loaded from SDcard or EMMC at the beginning of the console debug messages
- 1. Rom load bootloader from SDcard (Linux log example)
... BL2 Built : 15:21:42, Mar 26 2020. g12a g486bc38 - gongwei.chen@droid11-sz Board ID = 1 Set cpu clk to 24M Set clk81 to 24M Use GP1_pll as DSU clk. DSU clk: 1200 Mhz CPU clk: 1200 MHz Set clk81 to 166.6M board id: 1 Load FIP HDR DDR from SD, src: 0x00010200, des: 0xfffd0000, size: 0x00004000, part: 0 fw parse done PIEI prepare done fastboot data verify result: 255 Cfg max: 12, cur: 1. Board id: 255. Force loop cfg DDR4 probe ...
- 2. Rom load bootloader from EMMC(Android Log example)
... Board ID = 1 Set cpu clk to 24M Set clk81 to 24M Use GP1_pll as DSU clk. DSU clk: 1200 Mhz CPU clk: 1200 MHz Set clk81 to 166.6M eMMC boot @ 0 sw8 s board id: 1 Load FIP HDR DDR from eMMC, src: 0x00010200, des: 0xfffd0000, size: 0x00004000, part: 0 fw parse done PIEI prepare done 00000000 emmc switch 1 ok ddr saved addr:00016000 Load ddr parameter from eMMC, src: 0x02c00000, des: 0xfffd0000, size: 0x00001000, part: 0 00000000 ...
Erase EMMC for SDcard Bootup
- There are four possible scenarios should be pay attention to, EMMC already flashed Android image, EMMC already flashed Linux image, boot process hangup in BL2 and EMMC empty.
- 1. Bootable EMMC with Android image flashed
- a). Using usb burning tool, unplug the type-c usb cable while the download process at 7% formatting
- b). Using Android Fastboot tool, make sure the adb/fastboot tools is work on your PC before doing this.
root@dangku-desktop:/tmp# adb root adbd is already running as root root@dangku-desktop:/tmp# adb remount remount succeeded root@dangku-desktop:/tmp# adb shell bananapi_m5:/ # reboot fastboot
- Wait a few seconds for board reboot to fastboot mode
root@dangku-desktop:/tmp# fastboot devices 1234567890 fastboot root@dangku-desktop:/tmp# fastboot flashing unlock_critical ... OKAY [ 0.044s] finished. total time: 0.044s root@dangku-desktop:/tmp# fastboot flashing unlock ... OKAY [ 0.047s] finished. total time: 0.047s root@dangku-desktop:/tmp# fastboot erase bootloader erasing 'bootloader'... OKAY [ 0.059s] finished. total time: 0.059s root@dangku-desktop:/tmp# fastboot erase bootloader-boot0 erasing 'bootloader-boot0'... OKAY [ 0.036s] finished. total time: 0.036s root@dangku-desktop:/tmp# fastboot erase bootloader-boot1 erasing 'bootloader-boot1'... OKAY [ 0.035s] finished. total time: 0.035s
- c). Using uboot command, connect a debug console cable and press ESC while power on to enter uboot command line
bananapi_m5_v1#amlmmc erase 1 emmckey_is_protected(): protect start = 0,end = 57343 start = 221184,end = 30535679 Erasing blocks 0 to 8192 @ boot0 start = 0,end = 8191 Erasing blocks 0 to 8192 @ boot1 start = 0,end = 8191 bananapi_m5_v1#reset resetting ... SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:F;RCY:0;EMMC:0;READ:0;CHK:1F;READ:0;CHK:1F;READ:0;CHK;
- These two ways actually erase the bootloader part of EMMC android, After bootup from SDcard Linux, You'd better format the whole EMMC by dd command.
- d). Using uboot reboot command to restart from SDcard once time, but Android in EMMC still exist completely. Connect a debug console cable and press ESC while power on to enter uboot command line, type "reboot sdboot" command, After reboot from SDcard Linux, you can format the whole EMMC by dd command and then flash the Linux image to EMMC.
bananapi_m5_v1#
- Insert the SDcard with Linux image flashed now.
bananapi_m5_v1#reboot sdboot reboot mode: sdboot reboot dev: sd BPI: set rom boot from sdcard after reset before value = 0! after value = 4f5244c0! resetting ... SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:F;RCY:0;OVD:2;SD?:0;SD:0;READ:0;0.0;CHK:0; bl2_stage_init 0x01 ... board id: 1 Load FIP HDR DDR from SD, src: 0x00010200, des: 0xfffd0000, size: 0x00004000, part: 0 ...
- e). The simplest way is insert the SDcard with Linux image flashed before power on, the Android bootloader will check boot.ini file whether exist in SDcard vfat partition, so that the SDcard Linux will bootup. After bootup, you can format the whole EMMC by dd command and then flash the Linux image to EMMC.
... BPI: try boot from sdcard reading boot.ini 5699 bytes read in 3 ms (1.8 MiB/s) ## Executing script at 01b00000 ... reading Image.gz 9143358 bytes read in 510 ms (17.1 MiB/s) reading meson64_bananapi_m5.dtb 70850 bytes read in 8 ms (8.4 MiB/s) reading uInitrd 11704481 bytes read in 655 ms (17 MiB/s) reading overlays/i2c0.dtbo 223 bytes read in 6 ms (36.1 KiB/s) reading overlays/spi0.dtbo 516 bytes read in 6 ms (84 KiB/s) reading overlays/uart1.dtbo 225 bytes read in 5 ms (43.9 KiB/s)
- 2. Bootable EMMC with Linux image flashed
- a). Using uboot command, connect a debug console cable and press ESC while power on to enter uboot command line
bananapi_m5# mmc erase 0 1000
- b). Linux u-boot also check boot.ini file whether exist in SDcard vfat partition so that the SDcard Linux will bootup. After bootup, you can format the whole EMMC by dd command or flash the Linux image directly to EMMC.
- 3. A extreme situation is bootloader or uboot corrupted, Rom load it from EMMC but hangup in u-boot or BL2, for example the boot process will hangup in BL2 of EMMC if dram init failed, The only way is format the EMMC with usb burning tool, or download the Android image completely and then try other ways to erase EMMC or flash Linux image to EMMC.
- 4. Rom will try to load bootloader from SDcard directly if EMMC is empty.
Erase Emmc Android by dd command
- If the board is flashed android before, and now bootup with Linux image to erase the whole emmc by dd command.
$ sudo dd if=/dev/zero of=/dev/mmcblk0boot0 bs=1M status=noxfer $ sudo dd if=/dev/zero of=/dev/mmcblk0boot1 bs=1M status=noxfer $ sudo dd if=/dev/zero of=/dev/mmcblk0 bs=1M status=noxfer $ sync
Wifi/BT support
- 1. Android test and support.
rtl8723bu wifi/bt(usb) rtl8188eu wifi(usb) rtl8822cs wifi/bt(sdio/uart)
- How to enable Android Wifi/BT
- USB type: Plug-in the usb dongle to usb host port and reboot the system, After bootup, you can enable or disable wifi and bluetooth in Settings app.
- SDIO/UART type: Connect the hardware module to 40pin header correctly and configure the Android DTB overlay to enable it.
- 2. Linux test and support.
rtl8188eu wifi(usb) rtl8192eu wifi(usb) rtl8723bu wifi/bt(usb) rtl8811au wifi(usb) rtl8812au wifi(usb) rtl8812bu wifi(usb) rtl8822cs wifi/bt(sdio/uart)
- How to enable Linux Wifi
- Wifi module drivers are already prebuild in the release images.
- USB type: Plug-in the usb dongle to usb host port and driver will be loaded automatically.
- SDIO/UART type:
- 1). Connect the hardware module to 40pin header correctly.
- 2). Configure the dtb overlay
# Overlays to load # Example combinations: # spi0 i2c0 i2c1 uart0 # hktft32 # hktft35 setenv overlays "wifi_bt_rtl8822cs"
- 3). Add the wifi module name to /etc/modules for loaded automatically next boot.
- How to enable Linux Bluetooth
- 1). Please download rtk-linux-bt-driver source code, build and install usb or uart rtk linux bluetooth drivers/firmwares to your image.
- 2). For USB type, plug-in the usb dongle to usb host port and driver will be loaded automatically.
- 3). For UART type, Configure the dtb overlay as the same as wifi before install the bluetooth drivers/firmwares. hci_uart driver will be loaded when rtk-hciuart.service start.
Coreelec
- 1. Get the source code.
$ git clone https://github.com/Dangku/CoreELEC
- 2. Get the docker containner for source code build
- More info refer to Coreelec official website and github