Power & Source of Big Ideas

M4 : update kernel and dtb files

Moderators: chensy, FATechsupport

Hi,

I'm user of this very good board which is NanoPi M4.
I would like to add CAN-BUS support to the friendlyCore image by updating kernel, dtb and modules files of my current SDcard.

Problem that I have : I don't understand how I can replace current files of my SDcard, without reflasing all the SDcard (eflasher) ? I saw "linux upgrade tool" too, but I can't see information about dtb file.

I checked uboot, but I only saw address without clear location. I suspect files are stored into the raw partition of the SDcard.

If you have solution to replace kernel and dtb file I'm interested.

Thank you.
Nobody know where are stored and how we can do to update kernel and dtb files of the rk3399-sd-friendlycore-bionic-4.4-arm64 image ?
GoblE wrote:
Nobody know where are stored and how we can do to update kernel and dtb files of the rk3399-sd-friendlycore-bionic-4.4-arm64 image ?


With Armbian playing with this its easier.

https://forum.armbian.com/topic/13347-n ... ment-97310
https://forum.armbian.com/topic/13389-s ... ment-97352
igorp wrote:
GoblE wrote:
Nobody know where are stored and how we can do to update kernel and dtb files of the rk3399-sd-friendlycore-bionic-4.4-arm64 image ?


With Armbian playing with this its easier.

https://forum.armbian.com/topic/13347-n ... ment-97310
https://forum.armbian.com/topic/13389-s ... ment-97352



Thank you for your help igorp!
Nice mechanism, unfortunately is not the same with friendlycore image :cry:
Kernel and dtb files seem to be stored in the sdcard, but where....
GoblE wrote:
Thank you for your help igorp!
Nice mechanism, unfortunately is not the same with friendlycore image :cry:


Armbian support is much better and there are more people which can help you.

https://docs.armbian.com/#what-is-armbian

GoblE wrote:
Kernel and dtb files seem to be stored in the sdcard, but where....


I only tried this once, probably on separate partition.
igorp wrote:
Armbian support is much better and there are more people which can help you.
https://docs.armbian.com/#what-is-armbian

Ok, I did lot of things on my current image so I'll try to find a solution but it's good thing to know for the future, before to start an embedded development. thanks for your feedback igorp.

igorp wrote:
I only tried this once, probably on separate partition.

Yes, I think too. I suspect that the first "unused" memory area contains raw data :
sd_friendlycore.png
sd_friendlycore.png (47.75 KiB) Viewed 9407 times
GoblE wrote:
I did lot of things on my current image


Currently you are not receiving any updates. Not functional nor security for the most important part. That doesn't bothers you?
igorp wrote:
GoblE wrote:
I did lot of things on my current image


Currently you are not receiving any updates. Not functional nor security for the most important part. That doesn't bothers you?

For my current use case no, it's a POC, not connected to the web. If this kernel information was not missing, my POC would be finished :|
Ok I found the solution! Based on provided scripts from FriendlyARM (sd-fuse_rk3399), I made this script to flash parameters, kernel and dtb files only into the first raw partition.

I copied usefull files next to my script :
- kernel.img (kernel binary)
- resource.img (dtb, logo, etc)
- param4sd.txt (from sd-fuse_rk3399 repo)
- parameter.txt (from sd-fuse_rk3399 repo)
- partmap.txt (from sd-fuse_rk3399 repo)
- sd_update (from sd-fuse_rk3399 repo)

Code: Select all

#!/bin/bash
# flash=mmc,1:kern:raw:0x2000000,0x2000000:kernel.img;
# flash=mmc,1:boot:raw:0x4000000,0x2000000:boot.img;

# Checking device for fusing
if [ $# -eq 0 ]; then
   echo "Usage: $0 DEVICE"
   exit 0
fi

case $1 in
/dev/sd[a-z] | /dev/loop[0-9]* | /dev/mmcblk[0-9]*)
   if [ ! -e $1 ]; then
      echo "Error: $1 does not exist."
      exit 1
   fi
   DEV_NAME=`basename $1`
   BLOCK_CNT=`cat /sys/block/${DEV_NAME}/size` ;;&
/dev/sd[a-z])
   DEV_PART=${DEV_NAME}1
   REMOVABLE=`cat /sys/block/${DEV_NAME}/removable` ;;
/dev/mmcblk[0-9]* | /dev/loop[0-9]*)
   DEV_PART=${DEV_NAME}p1
   REMOVABLE=1 ;;
*)
   echo "Error: Unsupported SD reader"
   exit 0
esac

if [ ${REMOVABLE} -le 0 ]; then
   echo "Error: $1 is a non-removable device. Stop."
   exit 1
fi

if [ -z ${BLOCK_CNT} -o ${BLOCK_CNT} -le 0 ]; then
   echo "Error: $1 is inaccessible. Stop fusing now!"
   exit 1
fi

let DEV_SIZE=${BLOCK_CNT}/2
if [ ${DEV_SIZE} -gt 64000000 ]; then
   echo "Error: $1 size (${DEV_SIZE} KB) is too large"
   exit 1
fi

true ${MIN_SIZE:=600000}
if [ ${DEV_SIZE} -le ${MIN_SIZE} ]; then
    echo "Error: $1 size (${DEV_SIZE} KB) is too small"
    echo "       please try another SD card."
    exit 1
fi

# ----------------------------------------------------------
cp ../kernel-rockchip/*.img $(dirname $0)

# ----------------------------------------------------------
RKPARAM=$(dirname $0)/parameter.txt
RKPARAM2=$(dirname $0)/param4sd.txt

# Automatically re-run script under sudo if not root
if [ $(id -u) -ne 0 ]; then
   echo "Need sudo..."
   sudo "$0" "$@"
fi

# ----------------------------------------------------------
# Get host machine
ARCH=
if uname -mpi | grep aarch64 >/dev/null; then
   ARCH=aarch64/
fi

# ----------------------------------------------------------
# umount all at first
umount /dev/${DEV_NAME}* > /dev/null 2>&1
sync

# ----------------------------------------------------------
# partition card & fusing filesystem
true ${SD_UPDATE:=$(dirname $0)/sd_update}

[[ ! -f "${RKPARAM}" ]] && exit 0

PARTMAP=$(dirname $0)/partmap.txt
PARAM4SD=$(dirname $0)/param4sd.txt

# ----------------------------------------------------------
# Prepare image for sd raw img
#     emmc boot: need parameter.txt, do not need partmap.txt
#     sdraw: all need parameter.txt and partmap.txt
if [ ! -f "${PARTMAP}" ]; then
      echo "File not found: ${PARTMAP}, please download the latest version of the image files from http://dl.friendlyarm.com/nanopct4"
      exit 1
fi

if [ ! -f "${PARAM4SD}" ]; then
      echo "File not found: ${PARAM4SD}, please download the latest version of the image files from http://dl.friendlyarm.com/nanopct4"
      exit 1
fi

# write ext4 image
${SD_UPDATE} -d /dev/${DEV_NAME} -p ${PARTMAP}
if [ $? -ne 0 ]; then
   echo "Error: filesystem fusing failed, Stop."
   exit 1
fi

if [ -z ${ARCH} ]; then
   partprobe /dev/${DEV_NAME} -s 2>/dev/null
fi
if [ $? -ne 0 ]; then
   echo "Warning: Re-reading the partition table failed"

else
  sleep 1
  resize2fs -f /dev/${DEV_PART}
fi

sync
echo "---------------------------------"
echo "All done."

Who is online

In total there are 39 users online :: 0 registered, 0 hidden and 39 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 39 guests