NanoPi M1 - ArchWiki

# NanoPi M1

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This article or section needs expansion.

Reason: Graphics is still to be documented. (Discuss in Talk:NanoPi M1#)
Note: The device is not officially supported by the ALARM project, i.e. please refrain from submitting patches, feature requests or bug reports for it.

The NanoPi M1 is a small, arm-based computer. It contains an Allwinner H3 processor and either 512 or 1024 MB of RAM. This article is strongly based on Orange Pi.

## Create the base system

This NanoPi M1 boots from a single ext4 partition, imaged with Das U-Boot. An ArchLinuxArm RootFS can then be downloaded to the card.

### Create development environment

Create a directory system to store the development files:

    $ mkdir -p nanopi_arch/mnt

### Partition, format and mount SD card

Use fdisk to partition the SD card, and use `mkfs.ext4 -O ^metadata_csum,^64bit /dev/sdX1` to format it. The mount the card with:

    # mount /dev/sdX1 mnt

### Install ArchLinuxArm RootFS

Download the RootFS from ArchLinuxArm's website:

    $ wget https://archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz

Extract the RootFS to the SD card:

    # bsdtar -xpf ArchLinuxARM-armv7-latest.tar.gz -C mnt/
    # sync

### Configure U-Boot

Create a file with the following boot script:

    boot.cmd

    part uuid ${devtype} ${devnum}:${bootpart} uuid
    setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait

    if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/zImage; then
      if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
        if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
          bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
        else
          bootz ${kernel_addr_r} - ${fdt_addr_r};
        fi;
      fi;
    fi

    if load ${devtype} ${devnum}:${bootpart} 0x48000000 /boot/uImage; then
      if load ${devtype} ${devnum}:${bootpart} 0x43000000 /boot/script.bin; then
        setenv bootm_boot_mode sec;
        bootm 0x48000000;
      fi;
    fi

Compile it and write it to the SD-card using the package uboot-tools:

    # mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "NanoPi M1 Boot Script" -d boot.cmd mnt/boot/boot.scr

### Unmount the SD Card

    # umount mnt

### Install U-Boot

Install swig package. Clone U-Boot from the offical git repository:

    $ git clone https://git.denx.de/u-boot.git

Checkout to latest stable tag e.g.: v2019.04

    $ git checkout tags/v2019.04

The NanoPi shares many similarities with the OrangePi PC, so use this as the target until better support is available. Build U-Boot:

    $ cd u-boot
    $ make -j4 ARCH=arm CROSS_COMPILE=arm-none-eabi- nanopi_m1_defconfig
    $ make -j4 ARCH=arm CROSS_COMPILE=arm-none-eabi-

This process should have generated an image called `u-boot-sunxi-with-spl.bin`. Write this to your SD card:

    # dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
    $ cd ..

## Configure the base system

### Boot the NanoPi

Apply 5V power to the NanoPi. It should boot successfully. If not, then attach the UART serial debugger as shown here and here.

Login over SSH with `alarm/alarm`.

Root password: `root`.

### Configure Linux

First, SSH into the machine and change the root password.

    # passwd

You must install the base-devel group as well as Git in order to continue. Do this and update the Linux system using:

    # pacman -Syu base-devel git

### Open Source Mali driver (lima)

Since linux 5.2 lima drm driver was merged in the mainline kernel.

    # pacman -Syu linux-armv7-rc

### Mali Binary driver

Now you should download and install the drivers for the Mali graphics card inside the SoC.

    # git clone https://github.com/mripard/sunxi-mali.git
    # cd sunxi-mali
    # export CROSS_COMPILE=$TOOLCHAIN_PREFIX
    # export KDIR=$KERNEL_BUILD_DIR
    # export INSTALL_MOD_PATH=$TARGET_DIR
    # ./build.sh -r r6p2 -b
    # ./build.sh -r r6p2 -i

Finally, install the UserSpace blobs from arm using these commands:

    # git clone https://github.com/free-electrons/mali-blobs.git
    # cd mali-blobs
    # cp -a r6p2/fbdev/lib/lib_fb_dev/lib* $TARGET_DIR/usr/lib

Category:

- ARM architecture

Hidden category:

- Pages or sections flagged with Template:Expansion