Power & Source of Big Ideas

nano pi m4v2 rootfs crash problem

Moderators: chensy, FATechsupport

Buildroot image from Google Drive
https://drive.google.com/file/d/1zPgtH- ... sp=sharing

works.

But syncing buildroot from,
http://wiki.friendlyarm.com/wiki/index. ... for_RK3399

Doesn't work and have compilation issues.

So I git cloned uboot and kernel from

kernel:

git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip

export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-bootimg
built boot.img


uboot:

git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi4-v2014.10_oreo
cd uboot-rockchip
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
make CROSS_COMPILE=aarch64-linux- rk3399_defconfig
make CROSS_COMPILE=aarch64-linux-

and then copied boot.img, uboot.img, miniloader.bin to extracted buildroot images and replaced. Created buildroot image
./mk-sd-image.sh buildroot

Then flashed
sudo dd if=out/rk3399-sd-buildroot-linux-4.4-arm64-20210706.img of=/dev/sdd bs=1M

But rootfs doesn't mount and it crashes.

What I am missing here,
1. initrd
2. root parameter, tried many parameters such as /dev/mmcblk0p1,p2, 1p7, 1p2 rootfs never mounts.
3. synced armbian image and that build system boots correctly.

param4sd.txt

FIRMWARE_VER: 6.0.1
MACHINE_MODEL: RK3399
MACHINE_ID: 007
MANUFACTURER: RK3399
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 3399
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
#KERNEL_IMG: 0x00280000
#FDT_NAME: rk-kernel.dtb
#RECOVER_KEY: 1,1,0,20,0
#in section; per section 512(0x200) bytes
CMDLINE: root=/dev/mmcblk0p7 rw rootfstype=ext3 data=/dev/mmcblk1p8 consoleblank=0 earlyprintk init=/sbin/init mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),0x00006000@0x00008000(resource),0x00010000@0x0000e000(kernel),0x00010000@0x0001e000(boot),0x12E000@0x00030000(rootfs),-@0x15E000(userdata)

bootlog with debug prints enabled in uboot : https://pastebin.com/raw/A00jfNc2
Looks like these guys who made it are sleeping, anyways,

After some digging for buildroot I will suggest below method,
1. Don't sync with repo,
2. Download from google drive,

https://drive.google.com/file/d/1B4kl9h ... sp=sharing

this file, linuxsdk-friendlyelec-20190903.tar

Mind it its 8 GB file,

3. Solve compilation issues,
4. Issues are with

While building we will get many syntax errors, version errors, I changed like below and was able to build buildroot
./build.sh buildroot

Patches and issues. Copy these patches and apply with,

patch -p1 -i <patch> or make a patch file then put in respective package dir for automatically applied by buildroot,

A. qemu ( Path: linuxsdk-friendlyelec/buildroot/package/qemu)
delete the pre supplied patches, disable sha mismath error, then use 4.2.0 qemu version, upgrading qemu will give python errors =>3.6

deleted: 0001-user-exec-fix-usage-of-mcontext-structure-on-ARM-uCl.patch
deleted: 0002-memfd-fix-configure-test.patch
modified: qemu.mk
modified: ../../support/download/check-hash

diff --git a/package/qemu/qemu.mk b/package/qemu/qemu.mk
index 345ef52668..6a85916415 100644
--- a/package/qemu/qemu.mk
+++ b/package/qemu/qemu.mk
@@ -4,7 +4,7 @@
#
################################################################################

-QEMU_VERSION = 2.10.2
+QEMU_VERSION = 4.2.0
QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.xz
QEMU_SITE = http://download.qemu.org
QEMU_LICENSE = GPL-2.0, LGPL-2.1, MIT, BSD-3-Clause, BSD-2-Clause, Others/BSD-1c
diff --git a/support/download/check-hash b/support/download/check-hash
index fe9c10570e..b8a7add85e 100755
--- a/support/download/check-hash
+++ b/support/download/check-hash
@@ -106,6 +106,6 @@ if [ ${nb_checks} -eq 0 ]; then
exit 0
;;
esac
- printf "ERROR: No hash found for %s\n" "${base}" >&2
- exit 3
+ printf "Warning: No hash found for %s, continue\n" "${base}" >&2
+ #exit 3
fi



B. QTlauncher app (PATH: linuxsdk-friendlyelec/app/QLauncher)
patch for this error,

diff --git a/src/appi18n.cpp b/src/appi18n.cpp
index cd8da96..3347860 100644
--- a/src/appi18n.cpp
+++ b/src/appi18n.cpp
@@ -28,7 +28,7 @@ QString AppI18n::getName(Application* app){
QVariant defaultLang(QLocale::system().name()/*"zh_CN.UTF-8"*/);
if(setting!=NULL){
QSettings* tmp= getSettings();
- QString lang= tmp->value("LANG",defaultLang).toString().leftRef(langTokenLength)+"/appName";
+ QString lang= tmp->value("LANG",defaultLang).toString().leftRef(langTokenLength).toString()+QString(QLatin1String("/appName"));
delete tmp;
return setting->value(lang).toString();
}
@@ -43,7 +43,7 @@ void AppI18n::reflush(){
{
iter.next();
QSettings* tmp= getSettings();
- QString lang= tmp->value("LANG",defaultLang).toString().leftRef(langTokenLength)+"/appName";
+ QString lang= tmp->value("LANG",defaultLang).toString().leftRef(langTokenLength).toString()+QString(QLatin1String("/appName"));
QString name= iter.value()->value(lang).toString();
iter.key()->setUiName(name);
delete tmp;
diff --git a/src/applicationManager.cpp b/src/applicationManager.cpp
index 9382334..c9f5f50 100644
--- a/src/applicationManager.cpp
+++ b/src/applicationManager.cpp
@@ -2,6 +2,7 @@
#include "application.h"

#include <QDebug>
+#include <QFile>
#include <QSettings>
#include <QApplication>
#include "appscanner.h"


C. settings app (PATH: buildroot_friendlyarm/app/settings)
patch for this error,

diff --git a/wlan/wlanlisttable.cpp b/wlan/wlanlisttable.cpp
index cad2ae9..313d411 100644
--- a/wlan/wlanlisttable.cpp
+++ b/wlan/wlanlisttable.cpp
@@ -31,7 +31,7 @@ bool WifiStateItem::operator <(const QTableWidgetItem &other) const

if (state == WIFI_STATE_CONNECTED || state == WIFI_STATE_CONNECTING) {
return false;
- } else if (state == WIFI_STATE_SAVED || this->text() == WIFI_STATE_AUTH_FAILED) {
+ } else if (state == WIFI_STATE_SAVED || this->text() .toInt() == WIFI_STATE_AUTH_FAILED) {
if (otherState == WIFI_STATE_CONNECTED || otherState == WIFI_STATE_CONNECTING)
return true;
else


D. squashfs-tools
patch for this error,

--- a/squashfs-tools/mksquashfs.c 2018-02-15 14:11:24.661930637 +0100
+++ b/squashfs-tools/mksquashfs.c 2018-02-15 14:12:28.218412025 +0100
@@ -44,6 +44,7 @@
#include <setjmp.h>
#include <sys/types.h>
#include <sys/mman.h>
+#include <sys/sysmacros.h>
#include <pthread.h>
#include <regex.h>
#include <fnmatch.h>
--- a/squashfs-tools/unsquashfs.c 2018-02-15 14:25:34.608263881 +0100
+++ b/squashfs-tools/unsquashfs.c 2018-02-15 14:26:01.376410327 +0100
@@ -35,6 +35,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
+#include <sys/sysmacros.h>
#include <limits.h>
#include <ctype.h>


E. libglib2.54 issue (buildroot_friendlyarm/buildroot/package/libglib2) or directly apply in
(buildroot_friendlyarmbuildroot/output/rockchip_rk3399/build/libglib2-2.54.2/gio)
0003-Avoid-printing-null-strings.patch

From 566e1d61a500267c7849ad0b2552feec9c9a29a6 Mon Sep 17 00:00:00 2001
From: Ernestas Kulik <ekulik@redhat.com>
Date: Tue, 29 Jan 2019 09:50:46 +0100
Subject: [PATCH] gdbus: Avoid printing null strings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This mostly affects the 2.56 branch, but, given that GCC 9 is being
stricter about passing null string pointers to printf-like functions, it
might make sense to proactively fix such calls.

gdbusauth.c: In function '_g_dbus_auth_run_server':
gdbusauth.c:1302:11: error: '%s' directive argument is null
[-Werror=format-overflow=]
1302 | debug_print ("SERVER: WaitingForBegin, read '%s'",
line);
|

gdbusmessage.c: In function ‘g_dbus_message_to_blob’:
gdbusmessage.c:2730:30: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
2730 | tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
|
---
gio/gdbusauth.c | 2 +-
gio/gdbusmessage.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
index 1f8ea8057..752ec23fc 100644
--- a/gio/gdbusauth.c
+++ b/gio/gdbusauth.c
@@ -1272,9 +1272,9 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
&line_length,
cancellable,
error);
- debug_print ("SERVER: WaitingForBegin, read '%s'", line);
if (line == NULL)
goto out;
+ debug_print ("SERVER: WaitingForBegin, read '%s'", line);
if (g_strcmp0 (line, "BEGIN") == 0)
{
/* YAY, done! */
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index 3221b925d..3a1a1f9e9 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -2731,7 +2731,6 @@ g_dbus_message_to_blob (GDBusMessage *message,
if (message->body != NULL)
{
gchar *tupled_signature_str;
- tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
if (signature == NULL)
{
g_set_error (error,
@@ -2739,10 +2738,10 @@ g_dbus_message_to_blob (GDBusMessage *message,
G_IO_ERROR_INVALID_ARGUMENT,
_("Message body has signature “%s” but there is no signature header"),
signature_str);
- g_free (tupled_signature_str);
goto out;
}
- else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
+ tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
+ if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
{
g_set_error (error,
G_IO_ERROR,
--
2.22.0


Then do some more changes as below.
After above fixes we get the final image. That image may not boot, so just to boot fully,(These are hacks not, use them if it doesn't boot with the provided uboot)

clone u-boot from this repo,

git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi4-v2014.10_oreo
and rename it u-boot. Keep the original u-boot as backup.

In this uboot apply below changes,

Disable ramdisk failure and sha failure patch,


diff --git a/nanopi4-uboot-v4.4.y/common/cmd_bootrk.c b/nanopi4-uboot-v4.4.y/common/cmd_bootrk.c
index 93c40a6df..ca80b33ba 100755
--- a/nanopi4-uboot-v4.4.y/common/cmd_bootrk.c
+++ b/nanopi4-uboot-v4.4.y/common/cmd_bootrk.c
@@ -278,7 +278,7 @@ static rk_boot_img_hdr * rk_load_image_from_storage(const disk_partition_t* ptn,
if (StorageReadLba(sector, (void *)(unsigned long) hdr->ramdisk_addr, \
blocks) != 0) {
FBTERR("bootrk: failed to read ramdisk\n");
- goto fail;
+ //goto fail;
}
#ifdef CONFIG_SECUREBOOT_CRYPTO
if (hdr->second_size != 0) {
diff --git a/nanopi4-uboot-v4.4.y/include/configs/rk33plat.h b/nanopi4-uboot-v4.4.y/include/configs/rk33plat.h
index ee0858c3c..b142a7672 100644
--- a/nanopi4-uboot-v4.4.y/include/configs/rk33plat.h
+++ b/nanopi4-uboot-v4.4.y/include/configs/rk33plat.h
@@ -123,8 +123,6 @@


#if defined(CONFIG_RKCHIP_RK3399)
- #define CONFIG_SECUREBOOT_CRYPTO
- #define CONFIG_SECUREBOOT_SHA256
#define CONFIG_RKTIMER_INCREMENTER
#define CONFIG_RK_SDHCI_BOOT_EN
#undef CONFIG_RK_SDMMC_BOOT_EN



Now build wit

./build.sh all

Make flashable sd image,

sudo ./build.sh sd-img

Then flash

sudo dcfldd if=r<IMAGEPATH> of=/dev/sdX bs=1M sizeprobe=if

Once done,

sync & watch -d grep -e Dirty: -e Writeback: /proc/meminfo

Now SD card image should boot fully to GUI.

Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 13 guests