[BPI-R4] Test to extract OpenWRT MTK MP4.1 kernel

I try to understand the BSP and OpenWRT MP provided by SINOVOIP and MTK.
The first step starts with unpacking the Kernel.

  1. Download & Flashing OpenWRT MTK MP4.1 wifi SDK wifi driver for BE14000 Wifi Card to SD

  2. Download(git clone) BPI-R4-bsp-5.4

  3. Fdisk to see SD Partition and dump(dd) to files

# dd if=/dev/sda1 of=/tmp/sda1_bl2
# dd if=/dev/sda2 of=/tmp/sda2_u-boot-env
# dd if=/dev/sda3 of=/tmp/sda3_factory
# dd if=/dev/sda4 of=/tmp/sda4_fip
# dd if=/dev/sda5 of=/tmp/sda5_kernel
# dd if=/dev/sda6 of=/tmp/sda6_rootfs

4. Insert SD into BPI-R4 and Upload kernel config, cmdline
Boot to OpenWRT MP4.1
# scp /proc/config.gz
# scp /proc/cmdline

5. Build u-boot-mt in BPI-R4-bsp-5.4

./build.sh
Press 2

The fiptool tool will be compiled and placed in the u-boot-mt directory.



6. Try using fiptool to look at the kernel and fip dump files.

fip Partition is a fip format file, and the information is as shown in the figure.
Kernel Partition is not a fip format file.

7. Try using dumpimage to look at the kernel dump file.



8. Extract kernel


9. Look at the config.gz file & find initrd/initramfs

zcat config.gz
  1. Look at the cmdline file


  1. Summary
    a. Kernel no built-in initramfs
    b. MTK BE14 driver not in Kernel (as modules in /lib/modules/ )
    c. bootargv has pci=pcie_bus_perf
    d. Extract the unpacked Linux Kernel
    e. Got Kernel config

Additional description:

When we use the dumpimage command to view the kernel file, because its format is itb format, it shows that itb contains multiple blocks of data.

This itb kernel includes three areas and two data.

Image 0 name is kernel-1:
Type is Kernel Image
Compression is LZMA

Image 1 name is fdt-1:
Type is Flat Device Tree(FDT)

Configuration 0 name is config-1:
This definition describes that the itb file includes the above two data.

We extracted the Linux Kernel before, here we extract the FDT.

Extract fdt-1 to fdt-1 file.

dumpimage -T flat_dt -p 1 -o fdt-1 ../sda5_kernel

Dump fdt-1 file to fdt-1.txt.

fdtdump -sd fdt-1 > fdt-1.txt

The content of fdt-1.txt is as follows: