mirror of
https://github.com/easytarget/MQ-Pro-IO.git
synced 2025-10-13 17:25:52 +01:00
Update README.md
This commit is contained in:
parent
637eb088dd
commit
b1f80fc589
284
README.md
284
README.md
@ -2,12 +2,9 @@
|
||||
### The MQ pro is a single core RISC-V allwinner D1 64bit 1Ghz, 1Gb SBC, in a Pi-Zero form factor.
|
||||
## This is a guide for enabling bluetooth and using the MangoPi MQ pro's IO capabilities when running Ubuntu 24.04.1
|
||||
|
||||
-----------------------------
|
||||
The `24.04.1` is a LTS+ release from Ubuntu and should provide 5+ years of updates.
|
||||
|
||||
# (STILL) A WORK IN PROGRESS
|
||||
- Currently being re-written for the 24.04.1 release.
|
||||
|
||||
`24.04.1` is a LTS+ release from Ubuntu, and should provide 5+ years of updates. As such it makes a good choice for an unattended headless device.
|
||||
As such it makes a good choice for an unattended headless device.
|
||||
|
||||
Unfortunately there is no Official Ubuntu image for the MQ Pro, but you can use the image for the Lichee RV dock. This has the same SOC as the MQ-Pro, and boots properly.
|
||||
|
||||
@ -27,24 +24,189 @@ There is *no* specific image provided by Ubuntu for the MQ PRO, but they *do* pr
|
||||
- I had issues getting a successful first boot with a cheap SD card, using a brand-name (Kingston) high speed card solved all the issues.
|
||||
- I am also using a high wear resistance card since I want this to run for years in a hard-to-reach location.
|
||||
|
||||
- EXPAND!!!,
|
||||
notes about hdmi console, usb ethernet adapters, presetup wifi etc.
|
||||
`
|
||||
The HDMI console with a USB kbd and mouse works well, install `gpm` to get a working mouse in it. Once i had bluetooth working I was able to attach and use a bluetooth kbd+mouse.
|
||||
You can boot the licheerv image directly on the MQ Pro, the HDMI console is available:
|
||||
- Unfortunately it only starts very late in the boot process and is not usable until the boot is complete.
|
||||
- You can use a USB keyboard, and install `gpm` to get a working mouse.
|
||||
- Once I had bluetooth working I was able to attach and use a bluetooth kbd+mouse.
|
||||
- If you have a USB serial adapter available you can follow the entire boot process
|
||||
- This is the only way to access the GRUB prompt and select recovery options etc!
|
||||
- Make sure your adapter is set to 3.3v and *not* 5v. This is important.
|
||||
- Attach `gnd`, `tx` and `rx` to pins 6,8 and 10 on th eGPIO header.
|
||||
- See Jeff Geerlings excellent '[https://www.jeffgeerling.com/blog/2021/attaching-raspberry-pis-serial-console-uart-debugging](https://www.jeffgeerling.com/blog/2021/attaching-raspberry-pis-serial-console-uart-debugging) article for a good description. His example is for a Raspberry PI, but MQ Pro is *identical* to a Pi for this.
|
||||
|
||||
### steps:
|
||||
- AT PRESENT: See the raw log at the end of this doc.
|
||||
<EDITED LOG HERE>
|
||||
The WiFi module will be detected, but will not connect to any networks unless preconfigured on the SD card before first boot.
|
||||
- The instructions below show how to do this. (Requires a linux machine to mount+modify the SD card.)
|
||||
- Alternatively, wait for the console boot to finish and configure the network on that using netplan or NetworkManager.
|
||||
- If you have a Linux compatible USB Ethernet adapter you can attach that to the spare USB-C port.
|
||||
- It will be detected and connected (using DHCP) during boot.
|
||||
- You will need to find the assigned IP from router logs, netscan, or looking on the console.
|
||||
|
||||
### Creating SD card & first boot.
|
||||
You will need a suitable machine to download the image file to, with a SD card writer so the image can be written.
|
||||
- The instructions below are for a generic Linux system with a sd card writer.
|
||||
- As ever with this sort of operation make *absolutely* sure you are using the correct disk device when writing.
|
||||
- The example here assumes `/dev/mmcblk0`, which is the inbuilt SD card slot om my system.
|
||||
- Windows users need to ignore the linux steps and use a tool such as Belena Etcher, or similar, before skipping to the console network config section.
|
||||
|
||||
Get the image file; (as of 2-Sep-2024 the url below works).
|
||||
```console
|
||||
$ wget https://cdimage.ubuntu.com/releases/noble/release/ubuntu-24.04.1-preinstalled-server-riscv64+licheerv.img.xz
|
||||
```
|
||||
|
||||
Unpack and copy the deownloaded image to the SD card:
|
||||
```console
|
||||
$ xzcat ubuntu-24.04.1-preinstalled-server-riscv64+licheerv.img.xz | sudo dd bs=8M conv=fsync status=progress of=/dev/mmcblk0
|
||||
```
|
||||
|
||||
If you are going to configure Wifi/Network via the console, or using a USB Ethernet adapter you can skip to `First Boot`, below.
|
||||
|
||||
#### Preconfiguring WiFi networks
|
||||
|
||||
Mount the SD card you just created:
|
||||
```console
|
||||
$ sudo mount /dev/mmcblk1p1 /mnt
|
||||
```
|
||||
|
||||
Create a new network config file that will be applied at first init:
|
||||
```console
|
||||
$ sudo vi /mnt/etc/cloud/cloud.cfg.d/55_net.cfg
|
||||
```
|
||||
|
||||
It should have the following contents:
|
||||
```yaml
|
||||
network:
|
||||
version: 2
|
||||
wifis:
|
||||
wlan0:
|
||||
optional: true
|
||||
access-points:
|
||||
"SSID":
|
||||
password: "PASSWORD"
|
||||
dhcp4: true
|
||||
```
|
||||
- Replace 'SSID' and 'PASSWORD' with your details, multiple ssid/password line pairs are allowed.
|
||||
- This is for a very simple 'connect to accesspoint' scenario.
|
||||
- The Netplan syntax allows almost any possible Network setup to be preconfigured!
|
||||
- See the (Netplan Documentation)[https://netplan.readthedocs.io/en/stable/examples/] for lots of examples and the full syntax.
|
||||
- After first boot this file will be copied, directly, to `/etc/netplan/50-cloud-init.yaml`.
|
||||
- If you made a mistake in the config, or need to change details, edit it in `/etc/netplan/` and use `netplan try` to test the new configuration.
|
||||
|
||||
Unmount the filesystem so that it is synced properly.
|
||||
```console
|
||||
$ sudo umount /mnt
|
||||
```
|
||||
|
||||
#### First Boot
|
||||
Insert the SD card into the MQ Pro and BOOT.
|
||||
- First boot is SLOW. It will take 5+ minutes before anything appears on HDMI.
|
||||
- This is where, if you have a serial adapter, it is useful for following progress.
|
||||
- The HDMI console first appears after several minutes, appears to freeze soon after, but recovers after a while when the login prompt appears.
|
||||
|
||||
Once the maching has booted you can login on console, or via ssh, as `ubuntu:ubuntu` and follow the mandatory instructions to change password.
|
||||
|
||||
#### WiFi config after boot
|
||||
If you are setting up WiFI after first boot you can use `netplan` to config the WiFi.
|
||||
|
||||
Create and edit a file in the netplan config:
|
||||
```console
|
||||
$ sudo vi /etc/netplan/55-wifi.yaml
|
||||
```
|
||||
The contents of this are **identical** to the (precofigured WiFi)[#preconfiguring-wifi-networks] setup given above.
|
||||
- Copy the `yaml` definition given there to this file and edit with your details.
|
||||
- The comments for the file there also apply here.
|
||||
|
||||
### Reconfigure to use MangoPI Device Tree
|
||||
|
||||
You should now have bootable machine you can access via the console or SSH. We can now reconfigure this to use the MQ Pro device tree via `(flash-kernel)[https://manpages.debian.org/testing/flash-kernel/flash-kernel.8.en.html)`.
|
||||
|
||||
```console
|
||||
ubuntu@ubuntu:~$ sudo vi /etc/flash-kernel/db
|
||||
```
|
||||
|
||||
Append the following after the comments:
|
||||
```text
|
||||
Machine: MangoPI MQ pro
|
||||
Kernel-Flavors: any
|
||||
DTB-Id: allwinner/sun20i-d1-mangopi-mq-pro.dtb
|
||||
Boot-Script-Path: /boot/boot.scr
|
||||
U-Boot-Script-Name: bootscr.uboot-generic
|
||||
Required-Packages: u-boot-tools
|
||||
```
|
||||
|
||||
This adds new entry for the MQ Pro based on the default Lichhee image in `/usr/share/flash-kernel/db/all.db` but with the correct name and device tree.
|
||||
|
||||
Make this the default with:
|
||||
```console
|
||||
ubuntu@ubuntu:~$ sudo echo 'MangoPI MQ pro' > /etc/flash-kernel/machine
|
||||
``
|
||||
|
||||
We now apply this by running `flash-kernel` manually (it runs automatically whenever kernel images are (re)installed).
|
||||
```console
|
||||
ubuntu@ubuntu:~$ sudo flash-kernel
|
||||
Using DTB: allwinner/sun20i-d1-mangopi-mq-pro.dtb
|
||||
Installing /lib/firmware/6.8.0-41-generic/device-tree/allwinner/sun20i-d1-mangopi-mq-pro.dtb into /boot/dtbs/6.8.0-41-generic/allwinner/sun20i-d1-mangopi-mq-pro.dtb
|
||||
Taking backup of sun20i-d1-mangopi-mq-pro.dtb.
|
||||
Installing new sun20i-d1-mangopi-mq-pro.dtb.
|
||||
System running in EFI mode, skipping.
|
||||
```
|
||||
Reboot the system and you will be using the default (vanilla) device tree.
|
||||
|
||||
```console
|
||||
ubuntu@ubuntu:~$ sudo reboot
|
||||
# wait!
|
||||
ssh into the machine as ubuntu:<new passwd>
|
||||
$ sudo cat /proc/device-tree/model
|
||||
```
|
||||
- Should return 'MangoPi MQ Pro'
|
||||
|
||||
#### You can now update as normal
|
||||
```console
|
||||
$ apt update
|
||||
# let this run, slow on this machine, especially the first run
|
||||
# will eventually tell you that a lot of packages need updating
|
||||
apt update
|
||||
# You may see packages 'deferred due to phasing', this is quite normal, an artifact of Ubuntu's build system, and can safely be ignored.
|
||||
# This may be a good time to have lunch.
|
||||
```
|
||||
|
||||
When this completes reboot again, or finish the BT setup below first, since it also needs a reboot.
|
||||
|
||||
#### Setup Bluetooth adapter and status LED
|
||||
Get the Bluetooth firmware files, they can be found online, but thee is a copy in my repo for convenience.
|
||||
|
||||
```console
|
||||
$git clone https://github.com/easytarget/MQ-Pro-IO.git
|
||||
```
|
||||
|
||||
Copy Bluetooth firmware to the system firmware tree.
|
||||
```console
|
||||
$ sudo cp MQ-Pro-IO/files/rtl_bt/* /usr/lib/firmware/rtl_bt/
|
||||
```
|
||||
|
||||
Before you reboot to apply these you shpule also install `bluez`, which allows uou to use `bluetoothctl` to connect and pair,etc
|
||||
```console
|
||||
$ sudo apt install bluez
|
||||
$ sudo reboot
|
||||
```
|
||||
In my expreience you need to reboot after installing bluez before the BT devie will be detected.
|
||||
|
||||
# set up a service for the activity light
|
||||
```console
|
||||
$ sudo cp MQ-Pro-IO/files/mqpro-status-led.service /etc/systemd/system/
|
||||
$ sudo systemctl daemon-reload
|
||||
$ sudo systemctl enable --now mqpro-status-led.service
|
||||
```
|
||||
The Status LED should now be continually flashing with Network activity
|
||||
|
||||
# My Motivation:
|
||||
My MQ PRO is connected to a Waveshare LORA hat, I want to make it work but the default Nezha device tree conflicts with some of the pins my HAT uses. So I decided to 'fix' this be putting a better device tree on it.
|
||||
My MQ PRO is connected to a Waveshare LORA hat, I want to make it work but the default device tree conflicts with some of the pins my HAT uses. So I decided to 'fix' this by putting a better device tree on my board.
|
||||
|
||||

|
||||
|
||||
# Device Trees
|
||||
In the install steps above we reconfigure the system to use the correct MangoPI MQ pro device tree instead of the Sipeed Lichee RV one.
|
||||
|
||||
A device tree is a file that defines the structure of the peripherals attached to, and provided by, the GPIO and internal busses on a SBC.
|
||||
A device tree is a file in the `/boot` area file that defines the structure of the hardware provided by the chipset on a SBC.
|
||||
|
||||
It is used in several places during initial boot to discover storage, console and other devices as needed. Once the linux kernel starts it is used to provision devices such as UART, network, gpu and other hardware. The device tree itself is a source file that is compiled into a binary to be loaded during boot.
|
||||
|
||||
@ -59,11 +221,6 @@ But if not; my somewhat limited notes on compiling the tree, plus a script that
|
||||
|
||||
# Using the trees
|
||||
|
||||
## Enabling Bluetooth
|
||||
After changing to the correct device tree you also need the correct firmware for the bluetooth adapter, a copy of this is in the [files/rtl_bt/](./files/rtl_bt) folder.
|
||||
* Copy the two firmware (`.bin`) files to `/usr/lib/firmware/rtl_bt/` on the MQ PRO.
|
||||
* Install *Bluez* (`sudo apt install bluez`) and reboot, you can then use `bluetoothctl` to configure and connect
|
||||
|
||||
## Status LED
|
||||
The onboard (blue) status LED can be controlled via the sys tree:
|
||||
|
||||
@ -155,92 +312,3 @@ Online:
|
||||
* https://mangopi.org/mangopi_mqpro
|
||||
* https://linux-sunxi.org/MangoPi_MQ-Pro
|
||||
* https://github.com/boosterl/awesome-mango-pi-mq-pro
|
||||
|
||||
|
||||
|
||||
# RAW INSTALL LOG
|
||||
## THIS WILL BE FOLDED INTO THE "STEPS" SECTION ABOVE.
|
||||
|
||||
```console
|
||||
wget https://cdimage.ubuntu.com/releases/noble/release/ubuntu-24.04.1-preinstalled-server-riscv64+licheerv.img.xz
|
||||
|
||||
xzcat ubuntu-24.04.1-preinstalled-server-riscv64+licheerv.img.xz | sudo dd bs=8M conv=fsync status=progress of=/dev/mmcblk0
|
||||
|
||||
sudo mount /dev/mmcblk1p1 /mnt
|
||||
|
||||
sudo vi /mnt/etc/cloud/cloud.cfg.d/55_net.cfg
|
||||
------ new file comments, contents -------
|
||||
network:
|
||||
version: 2
|
||||
wifis:
|
||||
wlan0:
|
||||
optional: true
|
||||
access-points:
|
||||
"SSID":
|
||||
password: "PASSWORD"
|
||||
dhcp4: true
|
||||
-----------------
|
||||
sudo umount /mnt
|
||||
|
||||
Insert card to MQ Pro and BOOT
|
||||
- serial adapter useful to follow progress
|
||||
- hdmi console after several minutes, appears to freeze but recovers when prompt reached
|
||||
- should come up on network if wifi configured or using a usb ethernet adapter
|
||||
- login on console or via ssh as ubuntu:ubuntu and follow instructions to change password
|
||||
|
||||
swap to mqpro dtb:
|
||||
|
||||
ubuntu@ubuntu:~$ sudo vi /etc/flash-kernel/db
|
||||
---- Append this after the comments -----
|
||||
Machine: MangoPI MQ pro
|
||||
Kernel-Flavors: any
|
||||
DTB-Id: allwinner/sun20i-d1-mangopi-mq-pro.dtb
|
||||
Boot-Script-Path: /boot/boot.scr
|
||||
U-Boot-Script-Name: bootscr.uboot-generic
|
||||
Required-Packages: u-boot-tools
|
||||
----------------
|
||||
ubuntu@ubuntu:~$ sudo vi /etc/flash-kernel/machine
|
||||
--- change to read (one line) ---
|
||||
MangoPI MQ pro
|
||||
---
|
||||
ubuntu@ubuntu:~$ sudo flash-kernel
|
||||
Using DTB: allwinner/sun20i-d1-mangopi-mq-pro.dtb
|
||||
Installing /lib/firmware/6.8.0-41-generic/device-tree/allwinner/sun20i-d1-mangopi-mq-pro.dtb into /boot/dtbs/6.8.0-41-generic/allwinner/sun20i-d1-mangopi-mq-pro.dtb
|
||||
Taking backup of sun20i-d1-mangopi-mq-pro.dtb.
|
||||
Installing new sun20i-d1-mangopi-mq-pro.dtb.
|
||||
System running in EFI mode, skipping.
|
||||
|
||||
Reboot again to check the dt is correct before going further..
|
||||
... rebooting takes some time on this board
|
||||
ubuntu@ubuntu:~$ sudo reboot
|
||||
wait..
|
||||
ssh into the machine as ubuntu:<new passwd>
|
||||
sudo cat /proc/device-tree/model
|
||||
- should return 'MangoPi MQ Pro'
|
||||
|
||||
-- now update
|
||||
sudo su -
|
||||
screen
|
||||
apt update
|
||||
.. let this run, slow on this machine, especially the first run
|
||||
.. will eventually tell you that a lot of packages (149 as of this guide) need updating
|
||||
apt update
|
||||
.. You may see packages 'deferred due to phasing', this is quite normal, an artifact of Ubuntu's build system, and can safely be ignored.
|
||||
.. This may be a good time to have lunch.
|
||||
|
||||
When this completes reboot again, or finish the BT setup below first, since it also needs a reboot.
|
||||
|
||||
# BT and Status LED
|
||||
git clone https://github.com/easytarget/MQ-Pro-IO.git
|
||||
# copy Bluetooth firmware to correct folder
|
||||
sudo cp MQ-Pro-IO/files/rtl_bt/* /usr/lib/firmware/rtl_bt/
|
||||
- install bluez, use bluetoothctl to connect and pair,etc
|
||||
apt install bluez
|
||||
- this will be applied at next reboot
|
||||
|
||||
|
||||
# set up a service for the activity light
|
||||
sudo cp MQ-Pro-IO/files/mqpro-status-led.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now mqpro-status-led.service
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user