What´s the best Practice to Build own Kernel

hdmi on mt7623 seems already in upstream one moment ago

http://lists.infradead.org/pipermail/linux-mediatek/2018-May/013176.html

I assume this patchset is for 4.17 and needs additional to these 7 patches

There is a patchset with 10 patches and an incomplete one with 24parts

Are there additional patches needed? Can this patchset used for 4.14?

I try to replace just because I don’t know how to just replace kernel. I tryed, but I failed. The kernel was build from config.gz.

But essentially, I just need modules, so I think I will build modules from config.gz then add it to /lib/modules/…

First get your sd-card bootable again…

I guess config.gz is backup from .config…i don’t know if adding modules work…maybe they need options in kernel-binary. So better replace both.

The config.gz is the current kernel config found on /proc. Kernel must be build to provide config.gz. Fortunately, image contain it. So I hope to be able to just add modules. Otherwise I don’t know if the kernel (make zImage) could be write over current kernel on image. u-Boot should know some address to load kernel. This info is unclear.

You have nothing to do with uboot when replace kernel…uboot loads simply the uImage from boot-partition. You have to simply replace that file (or change kernel-var in uEnv.txt to new Filename).

Ok, so, should I build kernel with make uBoot or make zImage ?

Both repo. (4.4 and my 4.14) have a build.sh which creating a compatible binary. imho a single make does not work because compiled devicetree has to be appended to binary and aligned with mkimage

It is actually not that hard to build everything from a vanilla kernel. The only thing that is missing in the vanilla kernel repository is a good default config for the banana pi r2. That’s why we need to pull this one from frank’s repository.

Here are the commands for building the linux kernel without the build.sh script:

$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ cd linux/
$ git checkout tags/4.16.8  # or whichever kernel version you want
$ curl -o arch/arm/configs/mt7623n_evb_fwu_defconfig https://raw.githubusercontent.com/frank-w/BPI-R2-4.14/4.16-main/arch/arm/configs/mt7623n_evb_fwu_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 2 zImage  # replace -j 2 with your CPU count
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 2 dtbs
$ cat arch/arm/boot/zImage arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dtb > arch/arm/boot/zImage_dtb
$ mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n "Linux Kernel 4.16.8" -d arch/arm/boot/zImage_dtb arch/arm/boot/uImage

Copy then the now created uImage to your SD card.

$ sudo mount /dev/sdX1 /mnt
$ sudo cp arch/arm/boot/uImage /mnt
$ sudo umount /mnt

For the kernel modules make sure you mounted your / (root partition) first (e.g. under /tmp).

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf -j 2 modules
$ sudo mount /dev/sdX2 /mnt 
$ sudo ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf INSTALL_MOD_PATH=/mnt -j 2 modules_install
1 Like

why not using my full repo? there are also some bugfixes and the wifi-driver (4.14) for internal card

@Ryder.Lee @linkerosa can you write me patches i need for hdmi?

These are done for 4.16 right? Then i can start new branch for 4.16-hdmi

Some dts-nodes already in 4.14-main for drm/hdmi (larb,hdmi,…) are these complete?

Some others seem related like https://patchwork.kernel.org/patch/10377773/,but i did not found the other parts

can i include a git-tree to merge these patches so that the original author will be listed?

Started a new branch, applied the 7-part patchset added some config-options…dts-nodes still missing (see https://github.com/frank-w/BPI-R2-4.14/commit/e62269eb06944c088f04c0e34031598c4863f580)

Hello, Frank.

I’ve tried to run your 4.16-hdmi kernel, but without success. It builds successfully, with your build.sh script (./build.sh importconfig, ./build.sh config, and ./build.sh), but it hangs on boot:

Boot from SD
reading bananapi/bpi-r2/linux/uEnv.txt
776 bytes read in 9 ms (84 KiB/s)
Loaded environment from uEnv.txt
Banana Pi bpi-r2 chip: mt7623n Service: linux
reading bananapi/bpi-r2/linux/uImage.4.16
5461199 bytes read in 705 ms (7.4 MiB/s)
reading bananapi/berryboot.img
** Unable to read file bananapi/berryboot.img **
bootm flag=0, states=70f
## Booting kernel from Legacy Image at 84000000 ...
   Image Name:   Linux Kernel 4.16.10-hdmi
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5461135 Bytes = 5.2 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

Probably, i’ve missed something, but 4.14-main branch, built with same steps boots and works correct, and I didn’t find any scpecial instruction.

I only applid patches to it…i have not tried it yet…4.14 crashed invisible an need a patch for iommu…

https://patchwork.kernel.org/patch/10185161/

More details here: https://github.com/frank-w/BPI-R2-4.14/issues/10

Thank You Frank! The iommu patch had helped.

but hdmi does not work,right? I guess there is something needed in drm-stack.

Yes, it doesn’t dorks, but there are some messages about HDMI, witch were absent in 4.14.

I got theese messages:

[    1.034468] ERROR: could not get clock /hdmi-phy@10209100:pll_ref(0)
[    1.043906] mediatek-hdmi-phy 10209100.hdmi-phy: Failed to get PLL reference clock: -2
[    1.051809] mediatek-hdmi-phy: probe of 10209100.hdmi-phy failed with error -2

Usb doesn’t work too:

[    1.612494] xhci-mtk 1a1c0000.usb: fail to get vbus
[    1.617572] xhci-mtk 1a240000.usb: fail to get vbus  

I’ll attach full dmesg

dmesg.out (20.8 КБ)

for usb: https://patchwork.kernel.org/patch/10237289/

for hdmi: mhm…CLK_APMIXED_HDMI_REF should be set…maybe it is missing in driver…

this looks related to your error: https://patchwork.kernel.org/patch/10341979/

i think we need this 10-part patchset:

  1. https://patchwork.kernel.org/patch/10367857/
  2. https://patchwork.kernel.org/patch/10367861/
  3. https://patchwork.kernel.org/patch/10367877/
  4. https://patchwork.kernel.org/patch/10367875/
  5. https://patchwork.kernel.org/patch/10367885/
  6. https://patchwork.kernel.org/patch/10367883/
  7. https://patchwork.kernel.org/patch/10367889/
  8. https://patchwork.kernel.org/patch/10367907/
  9. https://patchwork.kernel.org/patch/10367909/
  10. https://patchwork.kernel.org/patch/10367905/

It’s alredy applied

patching file arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.

I’we trided to apply theese patches: 2, 4, and 7 was applied with errors

patches_fail.txt (1.2 КБ)

I’ll try to find it out as soon as i can.