Vim3 kernel mainline can not run with kasan and gcov

Dear khadas,

I enable kasan and gcov with vim3 mianline kernel in defconfig

project/fenix/build/linux-mainline-5.14-rc5/defconfig
+CONFIG_KASAN=y
+CONFIG_KASAN_OUTLINE=y
+CONFIG_STACKTRACE=y
+
+CONFIG_GCOV_KERNEL=y
+CONFIG_GCOV_FORMAT_AUTODETECT=y
+CONFIG_GCOV_PROFILE_ALL=y

but it seems not work, @numbqq @Frank can you help me do some check? thanks.

xxxxx@ubuntu:~/project/fenix/build/linux-mainline-5.14-rc5/lib$ ls test_kasan*
test_kasan.c         test_kasan_module.gcno  test_kasan_module.mod    test_kasan_module.mod.gcno  test_kasan_module.o
test_kasan_module.c  test_kasan_module.ko    test_kasan_module.mod.c  test_kasan_module.mod.o

are u using insmod try to use modprobe

modprobe test_kasan_module.ko

but before u must sure kernel was updated

zgrep CONFIG_KASAN /proc/config.gz

@hyphop Thank you for your reply, it looks like the configuration is not working.

root@Khadas:/home/khadas# uname -r
5.14.0-rc5
root@Khadas:/home/khadas#


heimac@ubuntu:~/project/fenix/build/images$ ls -all
total 13900444
drwxrwxr-x  6 yyy yyy 4096 Aug 27 20:51 .
drwxrwxr-x 30 yyy yyy 4096 Aug 27 17:28 ..
drwxr-xr-x  3 yyy yyy 4096 Aug 27 05:45 cache
drwxrwxr-x  3 yyy yyy 4096 Aug 27 05:39 debs
-rw-r--r--  1 yyy yyy 908608 Aug 27 20:48 logo.img
drwxr-xr-x  2 yyy yyy 4096 Aug 27 20:48 rootfs
-rw-r--r--  1 yyy yyy 4798283776 Aug 27 06:36 rootfs.img
drwxrwxr-x  3 yyy yyy 4096 Aug 27 07:30 u-boot-mainline
-rw-r--r--  1 yyy yyy 5251268608 Aug 27 20:48 VIM3_Ubuntu-gnome-focal_Linux-5.14-rc5_arm64_SD-USB_V1.0.7-210827-develop.img
-rw-r--r--  1 yyy yyy 842797056 Aug 27 20:51 VIM3_Ubuntu-gnome-focal_Linux-5.14-rc5_arm64_SD-USB_V1.0.7-210827-develop.img.xz

I used balenaEtcher to flash the system to the U disk after compiling, the kernel should be updated,
But it looks like it is not updated through the command.

So what should be the correct way?
By the way, how can I flash the U disk system to EMMC?

Thanks in advance.

do sudo emmc-install, the image will be installed on your eMMC

  1. change kernel config
  2. rebuild full image with new kernel make
  3. write image

@heimac Use make debs && make to rebuild a full image

I have done these steps, maybe like Frank said, it is the lack of compile command make debs, I will try the compile command Frank said today.

I will try this method today. I have used the make -j8 command to build a full image before. It may be that the kernel update is not packaged into the system image.

@heimac You must use make debs to rebuild all debs . Or you can follow this to update kernel only.

Hi @Frank, After enabled these two functions, the boot partition does not seem to be large enough. How can I adjust the size of this partition? Have you ever encountered this kind of problem?In addition, this is not my host space is not enough,Can you help me do some checks?

...
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xac67d84a.

Command (m for help): Created a new DOS disklabel with disk identifier 0xd2979a5a.

Command (m for help): Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): Partition number (1-4, default 1): First sector (2048-10756095, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (32768-10756095, default 10756095): 
Created a new partition 1 of type 'Linux' and of size 240 MiB.

Command (m for help): Selected partition 1
The bootable flag on partition 1 is enabled now.

Command (m for help): Selected partition 1
Hex code (type L to list all codes): Changed type of partition 'Linux' to 'W95 FAT32'.

Command (m for help): Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): Partition number (2-4, default 2): First sector (2048-10756095, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (524288-10756095, default 10756095): 
Created a new partition 2 of type 'Linux' and of size 4.9 GiB.

Command (m for help): Disk ~/project/fenix/build/images/VIM3_Ubuntu-gnome-focal_Linux-5.14-rc5_arm64_SD-USB_V1.0.7-210830-develop.img: 5.13 GiB, 5507121152 bytes, 10756096 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd2979a5a

Device                                                                                                                 Boot  Start      End  Sectors  Size Id Type
~/project/fenix/build/images/VIM3_Ubuntu-gnome-focal_Linux-5.14-rc5_arm64_SD-USB_V1.0.7-210830-develop.img1 *     32768   524287   491520  240M  b W95 FAT32
~/project/fenix/build/images/VIM3_Ubuntu-gnome-focal_Linux-5.14-rc5_arm64_SD-USB_V1.0.7-210830-develop.img2      524288 10756095 10231808  4.9G 83 Linux

Command (m for help): The partition table has been altered.
Syncing disks.

mkfs.fat 4.1 (2017-01-24)
Info: Copying files to root directory...
          3.52G  82%  135.47MB/s    0:00:24 (xfr#99943, to-chk=0/137773)   

sent 3.53G bytes  received 2.05M bytes  138.64M bytes/sec
total size is 4.28G  speedup is 1.21
Info: Copying files to /boot directory...
        299.98M 100%  280.72MB/s    0:00:01 (xfr#64, to-chk=0/79) 
rsync: write failed on "~/project/fenix/build/images/rootfs/boot/zImage": No space left on device (28)
rsync error: error in file IO (code 11) at receiver.c(374) [receiver=3.1.3]
Cleanup...
make: *** [Makefile:5: all] Error 11
...

Hi @Frank ,If only the kasan function is enabled, the build can pass, but the kernel can not boot up from sd card,it also seems to be related to the partition,Can you help me do some checks? Maybe you can also try to compile with enable kasan and gcov.

15766307 bytes read in 674 ms (22.3 MiB/s)
57706504 bytes read in 2459 ms (22.4 MiB/s)
77922 bytes read in 5 ms (14.9 MiB/s)
Failed to load '/boot/env.txt'
4195 bytes read in 2 ms (2 MiB/s)
Import env.txt
Set default mac address to ethaddr: c8:63:14:70:44:fd!
Booting mainline kernel...
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
Setting bus to 0
port mode is usb3.0
Apply dtbo uart3
345 bytes read in 3 ms (112.3 KiB/s)
Apply dtbo pwm_f
Failed to load '/dtb/amlogic/overlays/kvim3/pwm_f.dtbo'
Apply dtbo i2c3
415 bytes read in 4 ms (100.6 KiB/s)
Apply dtbo i2s
520 bytes read in 4 ms (127 KiB/s)
Apply dtbo os08a10
Failed to load '/dtb/amlogic/overlays/kvim3/os08a10.dtbo'
Apply dtbo watchdog
Failed to load '/dtb/amlogic/overlays/kvim3/watchdog.dtbo'
Moving Image from 0x11000000 to 0x11080000, end=14890000
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
Scanning mmc 1:5...
** Invalid partition 5 **
Can't set block device
Scanning mmc 2:1...
11940624 bytes read in 262 ms (43.5 MiB/s)
22734856 bytes read in 496 ms (43.7 MiB/s)
77922 bytes read in 3 ms (24.8 MiB/s)
Failed to load '/boot/env.txt'
4243 bytes read in 1 ms (4 MiB/s)
Import env.txt
Found custom ethmac: c8:63:14:70:44:fd, overwrite eth_mac!
Booting mainline kernel...
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
Setting bus to 0
port mode is usb3.0
Apply dtbo uart3
345 bytes read in 1 ms (336.9 KiB/s)
Apply dtbo pwm_f
Failed to load '/dtb/amlogic/overlays/kvim3/pwm_f.dtbo'
Apply dtbo i2c3
415 bytes read in 1 ms (405.3 KiB/s)
Apply dtbo i2s
520 bytes read in 2 ms (253.9 KiB/s)
Apply dtbo os08a10
Failed to load '/dtb/amlogic/overlays/kvim3/os08a10.dtbo'
Apply dtbo watchdog
Failed to load '/dtb/amlogic/overlays/kvim3/watchdog.dtbo'
Remove eMMC vendor partitions...
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
Moving Image from 0x11000000 to 0x11080000, end=12700000
## Loading init Ramdisk from Legacy Image at 13000000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:    11940560 Bytes = 11.4 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 04080000
   Booting using the fdt blob at 0x4080000
   Loading Ramdisk to 7b3b4000, end 7bf172d0 ... OK
   Loading Device Tree to 000000007b338000, end 000000007b3b3fff ... OK

@heimac The configure file in /boot is missing . Did you do any change with /boot dir ?

@Frank This is it not the reason, even if there is this log, it can be started normally, i only change the kernel config file.
The following is the log of the mainline that can be started normally without enable kasan and gcov.

uboot type: mainline
Scanning mmc 0:1...
Card did not respond to voltage select! : -110
Can't set block device
Scanning mmc 0:5...
Card did not respond to voltage select! : -110
Can't set block device
Scanning mmc 1:1...
Card did not respond to voltage select! : -110
Can't set block device
Scanning mmc 1:5...
Card did not respond to voltage select! : -110
Can't set block device
Scanning mmc 2:1...
11940624 bytes read in 260 ms (43.8 MiB/s)
22734856 bytes read in 495 ms (43.8 MiB/s)
77922 bytes read in 2 ms (37.2 MiB/s)
Failed to load '/boot/env.txt'
4243 bytes read in 1 ms (4 MiB/s)
Import env.txt
Found custom ethmac: c8:63:14:70:44:fd, overwrite eth_mac!
Booting mainline kernel...
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
Setting bus to 0
port mode is usb3.0
Apply dtbo uart3
345 bytes read in 2 ms (168 KiB/s)
Apply dtbo pwm_f
Failed to load '/dtb/amlogic/overlays/kvim3/pwm_f.dtbo'
Apply dtbo i2c3
415 bytes read in 1 ms (405.3 KiB/s)
Apply dtbo i2s
520 bytes read in 2 ms (253.9 KiB/s)
Apply dtbo os08a10
Failed to load '/dtb/amlogic/overlays/kvim3/os08a10.dtbo'
Apply dtbo watchdog
Failed to load '/dtb/amlogic/overlays/kvim3/watchdog.dtbo'
Remove eMMC vendor partitions...
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
Moving Image from 0x11000000 to 0x11080000, end=12700000
## Loading init Ramdisk from Legacy Image at 13000000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:    11940560 Bytes = 11.4 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 04080000
   Booting using the fdt blob at 0x4080000
   Loading Ramdisk to 7b3b4000, end 7bf172d0 ... OK
   Loading Device Tree to 000000007b338000, end 000000007b3b3fff ... OK

Starting kernel ...

[    0.119318] kvm: pmu event creation failed -2
[    0.576558] rtc-hym8563 4-0051: hctosys: unable to read the hardware clock
[    1.671622] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4359-sdio for chip BCM4359/9
[    1.984793] panfrost ffe40000.gpu: dev_pm_opp_set_regulators: no regulator (mali) found: -19
[    4.176389] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4359-sdio for chip BCM4359/9
[    4.179344] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[    4.192418] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4359/9 wl0: Sep 20 2019 20:22:36 version 9.87.51.11.34 (edb7293@shgit) (r711217) FWID 01-c7feb1ee
[    4.692387] ieee80211 phy0: brcmf_dongle_roam: WLC_SET_ROAM_TRIGGER error (-52)

Ubuntu 20.04.3 LTS Khadas ttyAML0

Khadas login: khadas
Password:

Welcome to Fenix 1.0.7 Ubuntu 20.04.3 LTS Linux 5.14.0-rc5
 _  ___               _            __     _____ __  __ _____
| |/ / |__   __ _  __| | __ _ ___  \ \   / /_ _|  \/  |___ /
| ' /| '_ \ / _` |/ _` |/ _` / __|  \ \ / / | || |\/| | |_ \
| . \| | | | (_| | (_| | (_| \__ \   \ V /  | || |  | |___) |
|_|\_\_| |_|\__,_|\__,_|\__,_|___/    \_/  |___|_|  |_|____/


 * Website:        https://www.khadas.com
 * Documentation:  https://docs.khadas.com
 * Forum:          https://forum.khadas.com

Last login: Mon Aug 30 15:22:36 PDT 2021 on ttyAML0
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

khadas@Khadas:~$

@heimac Did you compile the complete firmware or just replace the kernel deb package ?

@Frank I build the complete firmware use make debs -j8 && make -j8.
and then flash complete firmware to sd card by balenaEtcher.
enable kasan as follow:


Maybe you can also try to compile with enable kasan and gcov? :rofl:
My hardware verison is: VIM3 V12, 19073119.

@Frank Can you compile after enabling these two functions?