What´s the best Practice to Build own Kernel

CONFIG_DEBUG_FS is enabled…

14.4.boot.log (29,7 KB)

my.config (100,8 KB)

of course i removed my entries in pinctrl/mediatek/Makefile and Kconfig and made a “make clean”

maybe you can post your .config for compare

please mount debugfs before you cat something from it

just by

mount -t debugfs none /sys/kernel/debug

1 Like

OK, i didn’t work with debugfs before, sorry for the dumb question…of course it must be mounted :smiley:

as for my example in my wiki, i use pin 14(-)/16 (+) = GPIO 25

# echo $((232+25)) > /sys/class/gpio/export                                                                                                                                                                                            
# echo out > /sys/class/gpio/gpio$((232+25))/direction                                                                               
# echo 1 > /sys/class/gpio/gpio$((232+25))/value       

LED is ON!! :slight_smile:

i can confirm that memory-Hack is not needed (Pin12=GPIO24):

# GPIO_NO=$((232+24))
# echo $GPIO_NO > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio${GPIO_NO}/direction
# echo 1 > /sys/class/gpio/gpio${GPIO_NO}/value

short question regarding mmc…how can i mount it? it does not create a device in /dev…i can see it in /proc/partitons and /sys/devices/platform/11240000.mmc/, but found no block-device for mounting. searched a bit around…

CONFIG_MMC_BLOCK=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

are set…or must the device created by udev (maybe not included in my ramdisk)

i tried to create them manually, but failed

# cat /proc/partitions                                                                                                               
major minor  #blocks  name                                                                                                           
                                                                                                                                     
 179        0    7634944 mmcblk0                                                                                                     
 179       24        512 mmcblk0rpmb                                                                                                 
 179       16       4096 mmcblk0boot1                                                                                                
 179        8       4096 mmcblk0boot0                                                                                                
 179       32    7974912 mmcblk1                                                                                                     
 179       33     262144 mmcblk1p1                                                                                                   
 179       34    7270400 mmcblk1p2                                                                                                   
# mknod /dev/mmcblk1 b 179 32                                                                                                        
# mknod /dev/mmcblk1p1 b 179 33                                                                                                      
# mknod /dev/mmcblk1p2 b 179 34                                                                                                      
#                                                                                                                                    
# mount /dev/mmcblk1p1 /mnt                                                                                                          
mount: mounting /dev/mmcblk1p1 on /mnt failed: Invalid argument

seems, that FS must be set, too (works for p2 not for p1,tried with vfat,fat,fat16,fat32)

# mount -t ext4 /dev/mmcblk1p2 /mnt                                                                                                  
[ 6254.297674] EXT4-fs (mmcblk1p2): warning: mounting unchecked fs, running e2fsck is recommended                                    
[ 6254.318748] EXT4-fs (mmcblk1p2): mounted filesystem without journal. Opts: (null)                                                 
# ls /mnt                                                                                                                            
bin         etc         lost+found  opt         run         srv         tmp                                                          
boot        home        media       proc        sbin        sys         usr                                                          
dev         lib         mnt         root        selinux     system      var

ok, that should be the reason (because i’m still using ramfs as root, there are no modules):

frank@Frank-Laptop:/media/data_ext/kernel_4.14/linux$ grep 'VFAT' .config
CONFIG_VFAT_FS=m
frank@Frank-Laptop:/media/data_ext/kernel_4.14/linux$ grep 'EXT4' .config
CONFIG_EXT4_FS=y

after making vfat fixed in kernel i’ve got this:

# mount -t vfat /dev/mmcblk1p1 /mnt                                                                                                  
[   87.055989] FAT-fs (mmcblk1p1): codepage cp437 not found                                                                          
mount: mounting /dev/mmcblk1p1 on /mnt failed: Invalid argument

i think this is because the config

CONFIG_FAT_DEFAULT_CODEPAGE=437
CONFIG_NLS_CODEPAGE_437=m
CONFIG_NLS_ISO8859_1=m

setting these m to y i can successful mount BPI-BOOT

# mknod /dev/mmcblk1p1 b 179 33                                                                                                      
# mount /dev/mmcblk1p1 /mnt                                                                                                          
[   99.768645] FAT-fs (mmcblk1p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.                     
# ls /mnt                                                                                                                            
bananapi  uEnv.txt

now i try to disable ramdisk and use bootloder cmdline:

goodman48 login: root                                                                                                                
# cat /proc/cmdline                                                                                                                  
board=bpi-r2 console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 root=/dev/mmcblk1p2 rootfstype=ext4 rootwait service=0
# 

cmdline looks correct, but it was booted to ramdisk

frank@Frank-Laptop:/media/data_ext/kernel_4.14/linux$ grep 'RAMFS\|CMDLINE' .config
CONFIG_INITRAMFS_SOURCE="../rootfs_ttys0_rng.cpio.gz"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_INITRAMFS_COMPRESSION=".gz"
CONFIG_BLK_CMDLINE_PARSER=y
CONFIG_CMDLINE_PARTITION=y
CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y
# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set
CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 vmalloc=496M debug=7 loglevel=8 no_console_suspend"
CONFIG_CMDLINE_FROM_BOOTLOADER=y
# CONFIG_CMDLINE_EXTEND is not set
# CONFIG_CMDLINE_FORCE is not set
# CONFIG_MTD_CMDLINE_PARTS is not set
# CONFIG_CRAMFS is not set

removed the CONFIG_INITRAMFS_SOURCE and now it tries to boot from SD-Card, but fails loading init

[    1.758553] Freeing unused kernel memory: 1024K                                                                                                  
[    1.805009] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-464c, throttling...                        
[    6.872446] request_module: modprobe binfmt-464c cannot be processed, kmod busy with 50 threads for more than 5 seconds now                      
[    6.886616] Starting init: /sbin/init exists but couldn't execute it (error -8)                                                                  
[    6.910835] Starting init: /etc/init exists but couldn't execute it (error -13)                                                                  
[    6.926854] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-464c, throttling...                        
[   11.992432] request_module: modprobe binfmt-464c cannot be processed, kmod busy with 50 threads for more than 5 seconds now                      
[   12.006612] Starting init: /bin/sh exists but couldn't execute it (error -8)                                                                     
[   12.024728] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst.

it’s a debian jessie where /sbin/init is a symlink to /lib/systemd/systemd…is a additional kernel-module needed for that?

file /media/frank/BPI-ROOT/lib/systemd/systemd
/media/frank/BPI-ROOT/lib/systemd/systemd: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=e8dd34610703fa7966ae24f424ccb4e6eb464a8c, stripped

ELF-Support is included in kernel

Symbol: BINFMT_ELF [=y]
Type  : boolean
Prompt: Kernel support for ELF binaries

Filesystem boots well with 4.4.70…so nothing is corrupt…something is missing in 4.14 kernel

4.14.sd-boot.log (42,6 KB)

googled around but found nothing specific, only that the errorcode stands for ENOEXEC

#define ENOEXEC 8 /* Exec format error */

maybe this is a solution:

https://groups.google.com/forum/#!topic/linux.kernel/NibC_s8YpdQ (patch not included in 4.14 fs/exec.c:1655 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/exec.c?h=v4.14 )

same error after patch (only without the 2 Line begin with request_module)…any idea?

You got any repo with this patches?

What do you mean? I patch kernel manually and using official debian jessi lite-image

debian runs with 4.4.70,but there sd+emmc are swapped (SD=mmcblk0) maybe this causes the Problem…

mhm, swapping mmc1 and mmc0-position (mmc1-block before mmc0-block) is not enough to swap devices in system…i had to swap it in dts also…now sd is mmc0 and emmc is mmc1, but this solves not the Problem with loading init ;(

4.14.log (27,1 KB)

“Starting init:”-String is in init.main.c where debug is enabled, enabled debug also for fs/exec.c, but no more messages ;(

google answers are mostly 32bit vs 64 bit…and little endian vs. big endian

kernel should be little endian (ARCH_SUPPORTS_BIG_ENDIAN [=n]) and 32bit (all 64-Bit Options i’ve found are off)…systemd is also 32bit as posted above…don’t know byte-order of systemd…but i think little endian should be default here Can be “(uses shared libs)” the problem (missing option for it)?

any idea?

bpi-iot-ros-ai login: root                                                                                                                 
Password:                                                                                                                                  
Last login: Thu Mar  9 19:09:50 CST 2017 on ttyS0                                                                                          
Linux bpi-iot-ros-ai 4.14.0-BPI-R2-Kernel-dirty #59 SMP Sat Nov 25 19:44:42 CET 2017 armv7l 

:grinning:

using defconfig from 4.4.70 :wink: (still swapped mmc0&1)

mt7623n_evb_bpi_defconfig.txt (132,7 KB) defconfig_fwu_vs_4.4.70.diff (142,6 KB)

Stripped commented options,sorted and making diff again…any idea which option is the problem? 4.14_vs_4.4.conf (42,1 KB)

with this added to my config the init-error does not come up:

needed_defconfig (10,5 KB)

it seems to be block “Processor Features”, removing now the other additional options

it’s this option:

CONFIG_ARM_THUMB=y

with enabled debian is starting

now i’m trying to enable network-interfaces

root@bpi-iot-ros-ai:~# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 3e:3a:36:55:76:4c brd ff:ff:ff:ff:ff:ff
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
4: wan@eth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 3e:3a:36:55:76:4c brd ff:ff:ff:ff:ff:ff
5: lan0@eth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 3e:3a:36:55:76:4c brd ff:ff:ff:ff:ff:ff
6: lan1@eth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 3e:3a:36:55:76:4c brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 3e:3a:36:55:76:4c brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 3e:3a:36:55:76:4c brd ff:ff:ff:ff:ff:ff

how can i assign an ip-adress to it (never seen iface@iface before)?

root@bpi-iot-ros-ai:~# ifconfig lan0 192.168.0.10
SIOCSIFFLAGS: Network is down
root@bpi-iot-ros-ai:~# ifconfig lan3 192.168.0.10
SIOCSIFFLAGS: Network is down
root@bpi-iot-ros-ai:~# ifconfig lan0@eth0 192.168.0.10
SIOCSIFADDR: No such device
lan0@eth0: ERROR while getting interface flags: No such device
root@bpi-iot-ros-ai:~# ifconfig lan3@eth0 192.168.0.10
SIOCSIFADDR: No such device
lan3@eth0: ERROR while getting interface flags: No such device

i have Ethernet-cable plugged in the Lan-Port next to Wan…is this 0 or 3? maybe eth0 must be set to up first, but this does not work

root@bpi-iot-ros-ai:~# ifup eth0
Missing required variable: address
Missing required configuration variables for interface eth0/inet.
Failed to bring up eth0.

got it running like that:

root@bpi-iot-ros-ai:~# ifconfig eth0 up
root@bpi-iot-ros-ai:~# ifconfig lan0 192.168.0.10/24
root@bpi-iot-ros-ai:~# ping 192.168.0.5
PING 192.168.0.5 (192.168.0.5) 56(84) bytes of data.
^C
--- 192.168.0.5 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2115ms

root@bpi-iot-ros-ai:~# ifconfig lan0 up
root@bpi-iot-ros-ai:~# ping 192.168.0.5
PING 192.168.0.5 (192.168.0.5) 56(84) bytes of data.
64 bytes from 192.168.0.5: icmp_seq=1 ttl=64 time=0.878 ms
64 bytes from 192.168.0.5: icmp_seq=2 ttl=64 time=0.441 ms
^C
--- 192.168.0.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.441/0.659/0.878/0.220 ms

#additional IP-configuration (gateway+DNS-server)
route add default gw 192.168.0.5
echo "nameserver 192.168.0.5" > /etc/resolv.conf

not getting it via /etc/network/interfaces to work :frowning:

auto eth0
        iface eth0 inet manual

auto lan0
        iface eth0 inet static
        hwaddress ether 08:00:00:00:00:00 # if you want to set MAC manually
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.5

eth0 gets hwaddress and ip from lan0 but both not visible for ifconfig

if i add this to eth0:

    pre-up ifconfig $IFACE up
    post-down ifconfig $IFACE down

i see eth0 with lan0-config, enabling lan0 manually does not work since eth0 got the config from lan0 ;( any idea how to fix this?

strange, that wan is also @eth0…isn’t it on the 2nd NIC?

also my mt7612 does not show up in lspci…seems that pcie-slot is not enabled…

enabled CONFIG_PCIEPORTBUS=y and CONFIG_PCIE_MEDIATEK=y and added the devicenodes for pcie in dtsi and dts (bpidts.patch (5,4 KB) ,patch including mmc-swap) but also no output on lspci…any idea? maybe this is needed…

take this patch https://patchwork.kernel.org/patch/9980063/

enable CONFIG_PHY_MTK_TPHY=y

1 Like

Good progress on getting the mainline kernel to work on the board!

I quickly tried copying the defconfig from 4.4.70 to 4.14 and did “make oldconfig” to upgrade it to 4.14, mostly accepting the default settings. Sadly no output on the serial console after u-boot (why would it work the first time :expressionless:…). I noticed you added some links to config files, and i diffed some of them but there are quite some changes. Could you please share or point me to the latest config file that is working for you with 4.14? Then I can take a look with you to hopefully get more up and running, instead of wasting my time finding the issue with my config :yum:

http://fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:kernel#using_own_newer_kernel

there is a script to build…maybe you’ve forgotten to append the dtb :slight_smile:

4.14-mmc.patch
with this Patch SD-Card will be detected…
changed defconfig <<<< is my config

if you using the uenv.txt from 4.4.70, you have to swap mmcs to…

Yeah well… MMC is a problem to solve when the kernel at least boots. I will certainly take a look at your patch.

I just did “make uImage”, with a cross compiler configured, exactly the same setup as I use for 4.4.70. With “make uImage” it automatically runs mkimage. But you’re right… i didn’t do anything with the dtb, while it is a separate build target :thinking:. Maybe it worked for 4.4.70 because the dts didn’t change.

Thanks for the feedback, will investigate and come back with the results later.

root@bpi-r2:~# lspci
00:00.0 PCI bridge: MEDIATEK Corp. Device 0801 (rev 01)
00:01.0 PCI bridge: MEDIATEK Corp. Device 0801 (rev 01)
01:00.0 Network controller: MEDIATEK Corp. Device 7612
02:00.0 IDE interface: ASMedia Technology Inc. ASM1061 SATA IDE Controller (rev 02)

wlan1     Link encap:Ethernet  HWaddr f8:62:aa:50:12:1d  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

nice :wink: the internal wifi is not so easy…tried to copy the drivers from 4.4.70 (drivers/misc/mediatek/connectivity/…),changed Makefile/Kconfig and activated the modules (MTK_COMBO_CHIP_CONSYS_7623)

now try to fix the errors :wink:

came till the point where port_ipc.h is missing (included from drivers/misc/mediatek/conn_md/include/conn_md_exp.h)…not found the file in 4.4.70.

found the file in a android-repo (https://android.googlesource.com/kernel/mediatek/+/android-mediatek-pike-3.10-marshmallow-mr1-wear-release/drivers/misc/mediatek/eccci/), but when i use these files i got many redefinitions…

also tried to get lm-sensors to working, but there is no module i2c_dev…maybe i need MTK_SENSOR_SUPPORT which is also in drivers/misc/mediatek (which i copied from 4.4.70 and is not working yet)

regards Frank

do you mean i2c is not working on newest kernel?

I mean sensors-detect shows me “module i2c_dev not found” may i have a missing option…

for internal wifi…wonder how 4.4.70 gets compiled without the eccci-folder in drivers/misc/mediatek

for network-config i got /etc/network/interfaces working with lan-interfaces: http://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/software#network-configuration

For internal wifi i have no idea,why the missing files ignored in 4.4.70…sam code,same makefile-integration…

i’ve now tried to enable the other uart (mt7623n-bananapi*.dts) set status=okay in uart0

in mt7623.dtsi there must be uart2 the first one and then uart0,uart1…else there is no output after kernel is loaded to memory (message from uboot “Starting Kernel” is the last you see on debug-uart)

are there Problems if that is done in mainline (global for all mt7623)?

i see now ttyS0 and ttyS1 in /dev… :wink: nice so far…i see that the 2 gpio-uart has now pin-defines, that are not existing when i try to enable that for 4.4.70…maybe tx-problem is fixed with it…have to try it

@sinovoip is it possible to release a new Ubuntu 16.04 minimal Image with 4.14 Kernel ?

Why not using existing image and replacing kernel? I have precompiled kernels on my gdrive…

Since internal wifi does not work,you can use it only with external card or without wifi

The Images includes the Mate Desktop and it is huge work to remove all unneeded Packages.

my hope is, sinovoip can create this very easy :slight_smile: and upgrade also to the new Kernel … i follow the thread :slight_smile: and you have make a lot of work for the new Kernel … for this thanks a lot