Add support for NanoPi 4M

Hello,

Is there a guide on where to begin to create a new install target or profile for a new device?

Not a guide as such, but there are a few things you can do to implement support for a device.

  1. Check that the device is supported in upstream linux kernel.
  2. Check that the device is supported in the upstream u-boot project or has Board Firmware able to load mainline DTS for the device.
  3. Change the kernel config to enable what is needed for the device, build and test the kernel.
  4. Create a u-boot package for the device if needed, based on a PKGBUILD of an existing u-boot package in our gitlab.
  5. If the device has working Board Firmware on SPI, check of the Generic image with your kernel works.
  6. If it has no SPI or Board Firmware, create a new device profile in our arm-profiles repository, where you add the packages needed for this device to function, like u-boot package name, kernel wifi drivers and such.
  7. When device is added to arm-profiles you make the needed changes in the manjaro-arm-tools to get u-boot flashed correctly.
1 Like

The device is based on RK3399 (Nanopi M4v2).

  1. There’s support in mainline.
  2. There’s firmware available, it already boots other distros (eg. Armbian, R-Cade)
  3. This I can do.
  4. Any guide or wiki entry on how to do this?

I used to build my own kernels and desktop environment back in the day, install from scratch, etc. but that was a long time ago and it was x86 and tinkered with ppc too. Arm is a very different. beast.

The device already runs Armbian, but my preferred OS is Manjaro, so I would like to get this working with Manjaro and contribute a bit.

1 Like
  1. Great. What DTS does it use? this one?
  2. Awesome. What defconfig file does it use? this one?
  3. Shouldn’t be much needed, so great.
  4. I would probably take a similar devices PKGBUILD, like the NanoPi T4, and simply change it’s pkgname and change the defconfig it uses to the correct one.
  5. I can do this when you have tested that a test image works on the device, as we don’t have this device.
  6. Same as 6.
  1. I’m not sure what DTS the other distros use, I have the DTB. Can it be decompiled? They probably use this one as base:
    kernel-rockchip/rk3399-nanopi4-rev22.dts at nanopi4-v4.19.y · friendlyarm/kernel-rockchip · GitHub

  2. Yes, there are other distros available. So far I could boot the following:

  • Armbian (this has a specific image for M4v2)
  • R-Cade (I used the one for RockPro64)
  • LibreElec (I used the one for Nanopi M4)
  1. This is what I’ll like to learn how to do. No RK3399 Manjaro image boots with this board.

5&6. I can do the testing.

I would be very interested in a HowTo as I’m an ARM architecture dummy and just by chance have one of these nanopi boards around.

Thanks in advance!

So the board does not have mainline linux support. Only BSP. It needs to be upstreamed first then.

1 Like

So in theory, if the DTS was in mainline it should work? Let’s suppose this device uses the DTS you mentioned, would something need to be adjusted for it to boot?

I connected the debug terminal and it doesn’t show any useful information, it just gets stuck loading system.

Again, it depends on the board firmware you use.

If the board firmware you have on SPI flash can boot mainline distribution, you can see in the u-boot SPL or TPL sequence when it boots, which DTS it’s loading.

If you don’t have the board firmware on the SPI flash and it’s part of the OS images instead, then you would need a proper uboot package to handle that part too.

So what is the output from UART?

hello, I install the Manjaro-arm-t4.image to M4V2, it can start and use, but it usually reports some errors like can’t use plasma, Is there some support for the M4’s image?

DDR Version 1.25 20210517
In
channel 0
CS = 0
MR0=0x98
MR4=0x3
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
CS = 1
MR0=0x18
MR4=0x3
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 1
CS = 0
MR0=0x98
MR4=0x3
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
CS = 1
MR0=0x18
MR4=0x3
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 0 training pass!
channel 1 training pass!
change freq to 416MHz 0,1
Channel 0: LPDDR4,416MHz
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
Channel 1: LPDDR4,416MHz
Bus Width=32 Col=10 Bank=8 Row=15/15 CS=2 Die Bus-Width=16 Size=2048MB
256B stride
channel 0
CS = 0
MR0=0x98
MR4=0x81
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
CS = 1
MR0=0x18
MR4=0x3
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 1
CS = 0
MR0=0x98
MR4=0x81
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
CS = 1
MR0=0x18
MR4=0x81
MR5=0xFF
MR8=0x8
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 0 training pass!
channel 1 training pass!
channel 0, cs 0, advanced training done
channel 0, cs 1, advanced training done
channel 1, cs 0, advanced training done
channel 1, cs 1, advanced training done
change freq to 856MHz 1,0
ch 0 ddrconfig = 0x101, ddrsize = 0x2020
ch 1 ddrconfig = 0x101, ddrsize = 0x2020
pmugrf_os_reg[2] = 0x3AA1FAA1, stride = 0xD
ddr_set_rate to 328MHZ
ddr_set_rate to 666MHZ
ddr_set_rate to 928MHZ
channel 0, cs 0, advanced training done
channel 0, cs 1, advanced training done
channel 1, cs 0, advanced training done
channel 1, cs 1, advanced training done
ddr_set_rate to 416MHZ, ctl_index 0
ddr_set_rate to 856MHZ, ctl_index 1
support 416 856 328 666 928 MHz, current 856MHz
OUT
Boot1 Release Time: May 29 2020 17:36:36, version: 1.26
CPUId = 0x0
ChipType = 0x10, 346
SdmmcInit=2 0
BootCapSize=100000
UserCapSize=7456MB
FwPartOffset=2000 , 100000
mmc0:cmd5,20
SdmmcInit=0 0
BootCapSize=0
UserCapSize=119276MB
FwPartOffset=2000 , 0
StorageInit ok = 68273
SecureMode = 0
SecureInit read PBA: 0x4
SecureInit read PBA: 0x404
SecureInit read PBA: 0x804
SecureInit read PBA: 0xc04
SecureInit read PBA: 0x1004
SecureInit read PBA: 0x1404
SecureInit read PBA: 0x1804
SecureInit read PBA: 0x1c04
SecureInit ret = 0, SecureMode = 0
atags_set_bootdev: ret:(0)
GPT part:  0, name:          primary, start:0xf424, size:0xe4e1d
GPT part:  1, name:          primary, start:0xf4241, size:0xe801d9e
no find partition:uboot.
Trust Addr:0x4000, 0x0
Trust Addr:0x4400, 0x0
Trust Addr:0x4800, 0x0
Trust Addr:0x4c00, 0x0
Trust Addr:0x5000, 0x0
Trust Addr:0x5400, 0x0
Trust Addr:0x5800, 0x0
Trust Addr:0x5c00, 0x0
Addr:0x4000 No find trust.img!
LoadTrustBL error:-3
SecureMode = 0
SecureInit read PBA: 0x4
SecureInit read PBA: 0x404
SecureInit read PBA: 0x804
SecureInit read PBA: 0xc04
SecureInit read PBA: 0x1004
SecureInit read PBA: 0x1404
SecureInit read PBA: 0x1804
SecureInit read PBA: 0x1c04
SecureInit ret = 0, SecureMode = 0
atags_set_bootdev: ret:(0)
GPT 0x3335db8 signature is wrong
recovery gpt...
GPT 0x3335db8 signature is wrong
recovery gpt fail!
Trust Addr:0x4000, 0x58334c42
No find bl30.bin
No find bl32.bin
Load uboot, ReadLba = 2000
Load OK, addr=0x200000, size=0xda010
RunBL31 0x40000 @ 132122 us
NOTICE:  BL31: v1.3(release):845ee93
NOTICE:  BL31: Built : 15:51:11, Jul 22 2020
NOTICE:  BL31: Rockchip release version: v1.1
INFO:    GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 0
INFO:    plat_rockchip_pmu_init(1196): pd status 3e
INFO:    BL31: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2022.04-armbian (Jun 22 2022 - 07:16:34 +0000)

SoC: Rockchip rk3399
Reset cause: POR
Model: FriendlyElec NanoPi M4V2
DRAM:  3.9 GiB
PMIC:  RK808
Core:  279 devices, 26 uclasses, devicetree: separate
MMC:   mmc@fe320000: 1, mmc@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Model: FriendlyElec NanoPi M4V2
Net:   eth0: ethernet@fe300000
Hit any key to stop autoboot:  0
starting USB...
Bus usb@fe380000: USB EHCI 1.00
Bus usb@fe3c0000: USB EHCI 1.00
Bus usb@fe900000: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe380000 for devices... 1 USB Device(s) found
scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found
scanning bus usb@fe900000 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found

Device 0: Vendor: WD       Rev: 1026 Prod: Elements SE 25FE
            Type: Hard Disk
            Capacity: 953837.0 MB = 931.4 GB (1953458176 x 512)
... is now current device
Scanning usb 0:2...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disk mmc@fe320000.blk...
Scanning disk mmc@fe330000.blk...
Scanning disk usb_mass_storage.lun0...
Found 9 disks
** Unable to read file ubootefi.var **
Failed to load EFI variables
BootOrder not defined
EFI boot manager: Cannot load any image
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
1:      Manjaro ARM
Retrieving file: /initramfs-linux.img
Retrieving file: /Image
append: initrd=/initramfs-linux.img console=ttyS2,1500000 root=PARTUUID=4893db83-afc8-42b2-8c4e-dcdbdedd2965 rw rootwait audit=0 splash plymouth.ignore-serial-consoles
Retrieving file: /dtbs/rockchip/rk3399-nanopi-m4v2.dtb
Moving Image from 0x2080000 to 0x2200000, end=3a90000
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Ramdisk to f17f3000, end f1f0b7b4 ... OK
   Loading Device Tree to 00000000f17dd000, end 00000000f17f2cd8 ... OK

Starting kernel ...

That’s all code when the M4V2 start, the error code maybe need some time to wait

[  434.187168] Unhandled 64-bit el1h sync exception on CPU1, ESR 0x0000000056000006 -- SVC (AArch64)
[  434.187190] CPU: 1 PID: 655 Comm: journal-offline Tainted: G         C         6.0.7-1-MANJARO-ARM #1
[  434.187199] Hardware name: FriendlyElec NanoPi M4 Ver2.0 (DT)
[  434.187204] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  434.187212] pc : __filemap_fdatawrite_range+0x78/0x90
[  434.187231] lr : __filemap_fdatawrite_range+0x60/0x90
[  434.187239] sp : ffff80000c643b50
[  434.187242] x29: ffff80000c643b50 x28: ffff000000728000 x27: 0000000000000000
[  434.187256] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
[  434.187266] x23: ffff000005e443d0 x22: ffff000005e443d0 x21: 0000000000000000
[  434.187275] x20: 7fffffffffffffff x19: 0000000000000001 x18: 0000000000000000
[  434.187285] x17: 0000000000000000 x16: 0000000000000000 x15: fffffc0000300800
[  434.187295] x14: 000000000000003e x13: 0000000000000000 x12: 0000000000000000
[  434.187304] x11: ffff800009589a48 x10: 0000000000000af0 x9 : ffff80000c643790
[  434.187314] x8 : ffff000000728b50 x7 : ffff0000f77612c0 x6 : 00000000103eb040
[  434.187324] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
[  434.187333] x2 : 0000000000000000 x1 : ffff000000728000 x0 : 0000000000000000
[  434.187344] Kernel panic - not syncing: Unhandled exception
[  434.187349] CPU: 1 PID: 655 Comm: journal-offline Tainted: G         C         6.0.7-1-MANJARO-ARM #1
[  434.187356] Hardware name: FriendlyElec NanoPi M4 Ver2.0 (DT)
[  434.187360] Call trace:
[  434.187362]  dump_backtrace+0xdc/0x120
[  434.187372]  show_stack+0x18/0x50
[  434.187378]  dump_stack_lvl+0x64/0x80
[  434.187387]  dump_stack+0x18/0x34
[  434.187393]  panic+0x140/0x308
[  434.187401]  arm64_exit_nmi.isra.0+0x0/0x7c
[  434.187410]  el1h_64_sync_handler+0x64/0xd0
[  434.187417]  el1h_64_sync+0x64/0x68
[  434.187424]  __filemap_fdatawrite_range+0x78/0x90
[  434.187433]  file_write_and_wait_range+0x5c/0xcc
[  434.187441]  ext4_sync_file+0x90/0x330
[  434.187450]  vfs_fsync_range+0x34/0x80
[  434.187457]  do_fsync+0x40/0x90
[  434.187462]  __arm64_sys_fsync+0x18/0x30
[  434.187469]  invoke_syscall+0x70/0xf4
[  434.187478]  el0_svc_common.constprop.0+0xcc/0xec
[  434.187487]  do_el0_svc+0x28/0x34
[  434.187495]  el0_svc+0x2c/0x84
[  434.187502]  el0t_64_sync_handler+0xf4/0x120
[  434.187510]  el0t_64_sync+0x18c/0x190
[  434.187519] SMP: stopping secondary CPUs
[  434.187640] Kernel Offset: disabled
[  434.187642] CPU features: 0x4000,0820d021,00001086
[  434.187648] Memory Limit: none
[  434.207636] ---[ end Kernel panic - not syncing: Unhandled exception ]---

it’s the error, if there any method to fix it ? when i use hdmi ,it report gpu error

Good to know. I tried every RK3399 image in two occations with different Manjaro releases but none booted, I’ll give it a try again.

Cause both devices are different and does not have same power management connections and other connections.

I don’t think many have worked on this model and friendlyarm is not great with upstream support.