Help on nanopi-k2

This forum is for topics dealing with problems with software specifically in the AArch64 repo.

Help on nanopi-k2

Postby plokko » Mon Sep 04, 2017 9:45 am

Hi,
i need some help building an image for the Nanopi-k2 ( Amlogic s905, 64bit armv8, a perfect copy of odroid-c2 :lol: ) but i'm not yet familiar with arm u-boot so i'm struggling making it boot correctly.

Do i start from an odroid-c2 or generic image?
What u-boot do i use?

Friendlyarm did release kernel and u-boot sources here with a build guide:
http://wiki.friendlyarm.com/wiki/index. ... n_OS_Image
but i'm not sure if i must use their u-boot, kernel, both or none.

Friendlyarm's ubuntu image is far from perfect: i'm having problems with monitor resolutions, hdmi and gpu;
will be archlinux a little better or it's just the board that lacks support?
plokko
 
Posts: 6
Joined: Mon Sep 04, 2017 6:36 am

Re: Help on nanopi-k2

Postby plokko » Mon Sep 04, 2017 11:40 am

the progress so far:
i have successfully cross-compiled u-boot and kernel provided for the nanopi-k2.
  1. I followed the initial part of odroid-c2 guide for preparing the sd card (a single ext4 primary partition)
  2. extracted the ArchLinuxARM-aarch64-latest.tar.gz to the sd with bztar without errors (bsdtar 3.3+)
  3. i ran from the nanopi-k2 uboot ./fusing.sh
  4. copied nanopi-k2.dtb (compiled nanopi-k2 kernel) in /boot and / (in the sd card) renaming it nanopi-k2.dtb or dtb.img
but i still get a blank screen from the board.

What i'm doing wrong? :(
plokko
 
Posts: 6
Joined: Mon Sep 04, 2017 6:36 am

Re: Help on nanopi-k2

Postby plokko » Mon Sep 04, 2017 12:05 pm

indirect success! :D
i found an archlinux image for s905 here:
https://github.com/150balbes/Amlogic_s905/wiki
with the provided u-boot patch it starts correctly!
The problem may have been in the boot partition type: the k2 seems to accept only fat16, no ext4 like the c2.
plokko
 
Posts: 6
Joined: Mon Sep 04, 2017 6:36 am

Re: Help on nanopi-k2

Postby summers » Mon Sep 04, 2017 4:05 pm

Boot partition file type is usually a uboot issue. uboot needs to be compiled so it understands the partition type of your boot partition. Though recent uboot versions were automatically set up to do ext4 - but maybe its a configuration parameter.

You should be able to debug, by attaching a UART cable to any serial interface, then uboot will show what it is doing across the serial interface ...

Probably worth checking the uboot configs:

https://github.com/u-boot/u-boot/tree/m ... de/configs
https://github.com/u-boot/u-boot/tree/master/configs

See if one is appropriate
summers
 
Posts: 173
Joined: Sat Sep 06, 2014 12:56 pm

Re: Help on nanopi-k2

Postby plokko » Mon Sep 04, 2017 5:35 pm

I tried to read serial output with putty but i could only get unreadable characters, something like this: :?
Code: Select all
▒b▒▒▒▒▒▒▒▒▒||▒▒衢΅[▒▒F▒!▒(▒▒▒((▒▒▒▒()▒4-▒▒▒▒F▒▒▒▒|▒▒"▒▒Tx@j▒▒,▒[▒▒▒▒▒▒▒x▒▒▒"]▒ᡵ<`zP▒顿▒▒▒▒▒:,d▒RG▒▒<c▒▒D▒v▒▒▒▒͘▒▒D▒B▒▒▒ݫ▒z▒▒▒▒>▒▒x▒ո▒х
                                                     ~d▒ֶ▒▒▒▒Tn▒▒
                                                                ▒1▒:▒H▒▒▒�▒j X
                                                                              ▒(▒▒Zn▒?▒▒.▒

I saw the u-boot configurations available: they're a little too many to try one by one, is there one appropriate way to find one compatible for my board? (maybe comparing with the default u-boot sources?)
is this file of any help?
https://github.com/friendlyarm/u-boot/b ... _defconfig
plokko
 
Posts: 6
Joined: Mon Sep 04, 2017 6:36 am

Re: Help on nanopi-k2

Postby summers » Tue Sep 05, 2017 9:37 am

You have the serial parameters wrong, so its worth checking what uboot has them set to. I'd expect you need 115200/8N1 so a command something like
Code: Select all
screen /dev/ttyS0 115200
on the machine with the serial connection on it ...

Hopefully looking through the uboot defconf you'll find one that is set up for your CPU ...
summers
 
Posts: 173
Joined: Sat Sep 06, 2014 12:56 pm

Re: Help on nanopi-k2

Postby plokko » Tue Sep 05, 2017 7:50 pm

You were right: setting putty to 115200 speed fixed the issue! :D

Nanopi-k2 u-boot gave me a nice boot sequence and shell; i don't know what command you need, hope this helps :roll:
Code: Select all
GXBB:BL1:08dafd:0a8993;FEAT:EDFC318C;POC:3;RCY:0;EMMC:800;NAND:81;SD:0;READ:0;CHK:0;
no sdio debug board detected
TE: 224894

BL2 Built : 12:06:06, Jun 13 2016.
gxb g176ecdb - laiyin.mo@droid12-sz

set vcck to 1100 mv
set vddee to 1000 mv
Board ID = 8
CPU clk: 1536MHz
DDR chl: Rank0+1 same @ 792MHz
DDR0: 2048MB(auto)-2T-11
DataBus test pass!
AddrBus test pass!
Load fip header from SD, src: 0x0000c200, des: 0x01400000, size: 0x00004000
New fip structure!
Load bl30 from SD, src: 0x00010200, des: 0x01000000, size: 0x0000d460
Sending bl30......................................................OK.
Run bl30...
Load bl31 from SD, src: 0x00020200, des: 0x101000[0, size: 0x00013140
Image: gxb_v1.1.3134-b387442 2016-06-16 14:48:44 yun.cai@droid06]
OPS=0x13
67 89 db 86 3d d9 aa 71 4c d6 8b fe [0.322092 Inits done]
secure task start!
high task start!
low task start!
Load bl33 from SD, src: 0x00034200, des: 0x01000000, size: 0x0006ae70
NOTICE:  BL3-1: v1.0(debug):c813a61
NOTICE:  BL3-1: Built : 14:47:05, Jun 16 2016
INFO:    BL3-1: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address = 0x1000000
INFO:    BL3-1: Next image spsr = 0x3c9


U-Boot 2015.01-00014-g4ef665ff6c (Sep 04 2017 - 09:45:00)

DRAM:  2 GiB
Relocation Offset is: 76f3b000
register usb cfg[1][0] = 0000000077f96a30
register usb cfg[0][1] = 0000000077f96a50
register usb cfg[2][0] = 0000000077f96a70
vpu: error: vpu: check dts: FDT_ERR_BADMAGIC, load default parameters
vpu: clk_level = 7
vpu: set clk: 666667000Hz, readback: 666660000Hz(0x300)
MMC:   SDIO Port B: 0, SDIO Port C: 1
[mmc_init] mmc init success
In:    serial
Out:   serial
Err:   serial
reboot_mode=cold_boot
hpd_state=0
cvbs performance type = 4, table = 0
Net:   Meson_Ethernet
** File not found nanopi-k2.dtb **
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
[OSD]check dts: FDT_ERR_BADMAGIC, load default fb_addr parameters
[OSD]fb_addr for logo: 0x3d800000
[OSD]check dts: FDT_ERR_BADMAGIC, load default fb_addr parameters
[OSD]fb_addr for logo: 0x3d800000
[CANVAS]addr=0x3d800000 width=5760, height=2160

270054 bytes read in 25 ms (10.3 MiB/s)
Hit Enter or space or Ctrl+C key to stop autoboot -- :  0
** File not found Image **
** File not found ramdisk.img **
Bad Linux ARM64 Image magic!
nanopi-k2#
nanopi-k2#printenv
baudrate=115200
bloader=ext4load mmc 0:1
bootargs=console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 androidboot.console=ttyS0 androidboot.hardware=nanopi-k2 hdmimode=1080p60hz hdmitx=cecf logo=osd1,loaded,0x3d800000,1080p60hz initrd=0x39000000,0x
bootcmd=run loadkernel; run loadinitrd; run init_bootargs; booti ${loadaddr} - ${dtb_mem_addr}
bootdelay=3
consoleargs=console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0
cvbs_drv=0
cvbsmode=576cvbs
display_bpp=24
display_color_bg=0
display_color_fg=0xffff
display_color_index=24
display_height=576
display_layer=osd0
display_width=720
droidargs=androidboot.console=ttyS0 androidboot.hardware=nanopi-k2
dtb_mem_addr=0x1000000
dtb_name=nanopi-k2.dtb
ethact=Meson_Ethernet
ethaddr=00:16:0F:A0:10:22
fb_addr=0x3d800000
fb_height=1080
fb_width=1920
fdt_high=0x20000000
firstboot=1
gatewayip=192.168.102.1
hdmimode=1080p60hz
hostname=nanopi-k2-u1
init_bootargs=setenv bootargs ${consoleargs} ${droidargs} hdmimode=${hdmimode} hdmitx=cecf logo=osd1,loaded,${fb_addr},${hdmimode} initrd=${initrd_start},${initrd_size}
init_display=osd open; osd clear; ${bloader} 0x20000000 logo.bmp; bmp display 0x20000000
initrd_high=0x40000000
initrd_name=ramdisk.img
initrd_size=0x
initrd_start=0x39000000
ipaddr=192.168.102.39
loadaddr=0x1080000
loadbootimg=${bloader} 0x20000000 boot.img
loaddtb=${bloader} ${dtb_mem_addr} ${dtb_name}; fdt addr ${dtb_mem_addr}
loadinitrd=${bloader} ${initrd_start} ${initrd_name}; setenv initrd_size 0x${filesize}
loadkernel=${bloader} ${loadaddr} Image
netmask=255.255.255.0
outputmode=576cvbs
preboot=run loaddtb; run init_display
reboot_mode=cold_boot
serial#=fe2017a905b20003
serverip=192.168.102.30
stderr=serial
stdin=serial
stdout=serial
upgrade_step=0

Environment size: 1866/65532 bytes



PS: nanopi-k2's HDMI is giving me hell, it only sets at 1080p cropping on lower resolution and detaching the cable after boot will give you a permanent black scren; i need it for a multimedia project so it's basicalli useless as it is! :evil:
plokko
 
Posts: 6
Joined: Mon Sep 04, 2017 6:36 am

Re: Help on nanopi-k2

Postby summers » Wed Sep 06, 2017 3:37 pm

OK, the machine isn't booting, but is going into the boot loader.

It is going through a two stage boot, the first one bring up the board to begin with, its an unknown blob (seems to be https://github.com/ARM-software/arm-trusted-firmware). But seem quite extensive, given how verbose it is being. Half way down it boots up uboot - and an unusual version number - more later.

Now printing the environment variables and you can see how its trying to boot. Unwrap the commands, so "loadkernel" expands as:

Code: Select all
ext4load mmc 0:1 0x1080000 Image


This means load from and ext4 formatted partition, that is located on the mmc chip, in position 0:1 to the memory location 0x1080000, the file Image.

Now mmc 0:1 is looking like the boot partition. Four files are mentioned there "Image" "boot.img" "ramdisk.img" "nanopi-k2.dtb" - whats interesting is these are all in the same top directory - usually /boot has more directory structure than that. Also the names of files are quite generic.

Clue though is the device tree nanopi-k2.dtb, its not in the main kernel:

https://github.com/torvalds/linux/tree/master/arch/arm64/boot/dts/amlogic

Turns out its from:

https://github.com/friendlyarm/

and that seems to be where the uboot originates from as well. There is a mainstream version:

https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts

Having a device tree though, and a hope you can boot a plain vanilla Armv8 kernel.

Now during set up, booting from the mmc is a hassle, easier to boot from a usb or sd card - as that you can pop from the device, and populate with a file system. Once its working you can then transfer to the mmc if it has enough room. So try running the commands by hand in uboot, seeing where they fail - and what you need to change.

There are a couple of similar threads recently about booting amlogic cpu so worth reading.

ANyway may sound like you still have much to do, but at least you have a way in now.
summers
 
Posts: 173
Joined: Sat Sep 06, 2014 12:56 pm

Re: Help on nanopi-k2

Postby summers » Wed Sep 06, 2017 8:07 pm

On the way home, thought about what would the simplest way to boot arch.

Now you have a way to get into uboot, and changing uboot is a step too far at the moment. How about extracting the generic arch armv8:
https://archlinuxarm.org/platforms/armv8/generic
to an USB or sd card - which ever best for you.

Then find on the file system the kernel, initrd, and device tree called *nanopi-k2.dtb. Now the latter may not be in the generic arch; and if so download the latest kernel, and compile the nanopi-k2 device tree and copy int probably /boot/dtbs.

Then move to the k2, boot into the mmc uboot - and then load the kernel and device tree from the sd/usb to some area of memory - probably what the current uboot says. Set the kernel to point to the usb/sd mount point, and boot.

Then see what happens.

Alas I can't try any of this - I don't have any armv8 devices ...
summers
 
Posts: 173
Joined: Sat Sep 06, 2014 12:56 pm

Re: Help on nanopi-k2

Postby summers » Thu Sep 07, 2017 3:45 pm

PS: nanopi-k2's HDMI is giving me hell, it only sets at 1080p cropping on lower resolution and detaching the cable after boot will give you a permanent black scren; i need it for a multimedia project so it's basicalli useless as it is!


Oh yes - not that init_bootargs has hdmimode=1080p60hz - so looks like that is passed to the kernel on boot. That would explain why you can only get 1080p ...
summers
 
Posts: 173
Joined: Sat Sep 06, 2014 12:56 pm

Next

Return to ARMv8

Who is online

Users browsing this forum: No registered users and 2 guests

cron