Page 1 of 1

SAFE disabling unused modules

Posted: 2024-07-29 18:05
by alex9x
Hello!

Need only linux on pico boards with:
- working ethernet/ipv4,
- working serial ports,
- working usb host for flash drive.

No imaging/cameras/rgb screens/npu/android and etc.
Need to disable/remove unused libraries and modules, like tests, vcodec, mpp and others.

What modules in congif files can be safely disable/delete?

1. default kernel config

Code: Select all

CONFIG_WL_ROCKCHIP=m
CONFIG_WIFI_BUILD_MODULE=y
CONFIG_INPUT_EVDEV=y
CONFIG_KEYBOARD_ADC=y
CONFIG_KEYBOARD_GPIO=y
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_GOODIX=y
CONFIG_TOUCHSCREEN_EDT_FT5X06=y
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_VIDEOBUF2_CMA_SG=y
CONFIG_V4L_PLATFORM_DRIVERS=y
CONFIG_VIDEO_ROCKCHIP_CIF=m
CONFIG_VIDEO_ROCKCHIP_ISP=m
CONFIG_VIDEO_RK_IRCUT=y
CONFIG_VIDEO_OS04A10=m
CONFIG_VIDEO_SC3336=m
CONFIG_VIDEO_SC4336=m
CONFIG_VIDEO_SC530AI=m
CONFIG_DRM=y
CONFIG_DRM_EDID=y
CONFIG_DRM_ROCKCHIP=y
CONFIG_ROCKCHIP_VOP=y
CONFIG_ROCKCHIP_RGB=y
CONFIG_DRM_PANEL_SIMPLE=y
CONFIG_DRM_SII902X=y
CONFIG_BACKLIGHT_PWM=y
CONFIG_ROCKCHIP_MULTI_RGA=m
CONFIG_ROCKCHIP_RGA_PROC_FS=y
CONFIG_ROCKCHIP_RVE=m
CONFIG_ROCKCHIP_RVE_PROC_FS=y
CONFIG_ROCKCHIP_DVBM=m
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_LOGO=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_SOC=y
CONFIG_SND_SOC_ROCKCHIP=y
CONFIG_SND_SOC_ROCKCHIP_I2S_TDM=y
CONFIG_SND_SOC_RV1106=y
CONFIG_SND_SIMPLE_CARD=y
CONFIG_USB_DWC3=y
CONFIG_USB_GADGET=y
CONFIG_USB_CONFIGFS=y
CONFIG_USB_CONFIGFS_UEVENT=y
CONFIG_USB_CONFIGFS_RNDIS=y
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
CONFIG_USB_CONFIGFS_F_FS=y
CONFIG_USB_CONFIGFS_F_UAC1=y
CONFIG_USB_CONFIGFS_F_UAC2=y
CONFIG_USB_CONFIGFS_F_HID=y
CONFIG_USB_CONFIGFS_F_UVC=y
CONFIG_USB_GADGETFS=y
CONFIG_STAGING=y
CONFIG_FB_TFT=y
CONFIG_FB_TFT_ST7735R=y
CONFIG_FB_TFT_ST7789V=y
CONFIG_COMMON_CLK_PROCFS=y
CONFIG_ROCKCHIP_SARADC=y
CONFIG_ANDROID=y
CONFIG_ROCKCHIP_OTP=y
CONFIG_ROCKCHIP_RKNPU=m
CONFIG_ROCKCHIP_RKNPU_PROC_FS=y
CONFIG_ROCKCHIP_RKNPU_DMA_HEAP=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ISO8859_1=y
CONFIG_CRYPTO_ZSTD=y
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=0
CONFIG_PRINTK_TIME=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_FS=y

2. /luckfox-pico/sysdrv/cfg/package.mk

Code: Select all

# Enable build eudev
CONFIG_SYSDRV_ENABLE_EUDEV=y

# Enable build adbd debug tool
CONFIG_SYSDRV_ENABLE_ADBD=y

# Enable build gdb and gdbserver debug tool
CONFIG_SYSDRV_ENABLE_GDB=y

# Enable build wifi
CONFIG_SYSDRV_ENABLE_WIFI=n

# Enable rockchip test
CONFIG_SYSDRV_ENABLE_ROCKCHIP_TEST=n

# Enable build motor
CONFIG_SYSDRV_ENABLE_MOTOR=n

# Enable build rndis
CONFIG_SYSDRV_ENABLE_RNDIS=n

# Enable build rk_ota
CONFIG_SYSDRV_ENABLE_OTA=n

# Enable build strace
CONFIG_SYSDRV_ENABLE_STRACE=n
3. /luckfox-pico/luckfox-pico/sysdrv/drv_ko

kmpp
motor
rockit
wifi

How to disable/remove them correctly?

4. Maybe other config files can be checked, please, point path.

5. It is possible don`t download source archives after each 'clean'? Cache them or disable deleting "dl" folder with clean.

Thanks!

Re: SAFE disabling unused modules

Posted: 2024-07-30 2:24
by Crocodile
Hello, if you need to disable the Rockchip multimedia-related drivers, you can simply delete the insmod_ko.sh file under /oem/usr/ko. This is the easiest way to prevent these drivers from being loaded. If you want to disable them permanently, you need to disable the corresponding modules in the kernel. You can do this by using ./build.sh kernelconfig. After making the changes, they will be automatically saved as defconfig to prevent temporary settings from not taking effect.

Re: SAFE disabling unused modules

Posted: 2024-07-30 16:03
by alex9x
Hello!

There are some features that can't remove safely, like samba and others.
Their links are in some configure files that don`t change with menuconfig. And need to comment them in Makefiles in different folders.
Some changes need to make in RkLunch.sh that placed in app folder, without it net interface don`t become "up" and don`t fix MAC for interface, seems it random each system boot (SoC does not have it?).

Still working on "clean unix" build for this system.

By now there a result:

Code: Select all

[root@luckfox root]# df -h
Filesystem                Size      Used Available Use% Mounted on
ubi0:rootfs              67.1M     21.2M     45.8M  32% /
devtmpfs                 28.0M         0     28.0M   0% /dev
tmpfs                    28.1M         0     28.1M   0% /dev/shm
tmpfs                    28.1M     44.0K     28.0M   0% /tmp
tmpfs                    28.1M     76.0K     28.0M   0% /run
/dev/ubi4_0              22.4M      1.0M     21.4M   4% /oem
/dev/ubi5_0               4.5M     20.0K      4.5M   0% /userdata
[root@luckfox root]#

Code: Select all

Mem: 17876K used, 39584K free, 120K shrd, 0K buff, 4132K cached
CPU:   0% usr   2% sys   0% nic  97% idle   0% io   0% irq   0% sirq
Load average: 0.00 0.00 0.00 1/47 219


[root@luckfox root]# lsmod
Module                  Size  Used by    Not tainted
[root@luckfox root]#

Code: Select all

[root@luckfox root]# ps
PID   USER     COMMAND
    1 root     init
    2 root     [kthreadd]
    3 root     [kworker/0:0-eve]
    4 root     [kworker/0:0H]
    5 root     [kworker/u2:0-ev]
    6 root     [mm_percpu_wq]
    7 root     [ksoftirqd/0]
    8 root     [kdevtmpfs]
    9 root     [oom_reaper]
   10 root     [writeback]
   11 root     [kcompactd0]
   12 root     [ksmd]
   28 root     [kblockd]
   29 root     [kconsole]
   30 root     [devfreq_wq]
   31 root     [watchdogd]
   32 root     [kworker/0:1-eve]
   33 root     [rpciod]
   34 root     [kworker/u3:0]
   35 root     [xprtiod]
   36 root     [kswapd0]
   37 root     [nfsiod]
   38 root     [irq/52-rockchip]
   39 root     [irq/53-rockchip]
   40 root     [kworker/u2:1-fl]
   41 root     [hwrng]
   49 root     [stmmac_wq]
   51 root     [kworker/0:2-eve]
   52 root     [irq/22-rockchip]
   53 root     [ubi_bgt0d]
   56 root     [ubifs_bgt0_0]
   72 root     /sbin/syslogd -n
   76 root     /sbin/klogd -n
   87 root     /sbin/udevd -d
  105 root     [kworker/u2:2-ev]
  125 root     [ubi_bgt4d]
  130 root     [ubifs_bgt4_0]
  139 root     [ubi_bgt5d]
  144 root     [ubifs_bgt5_0]
  179 root     /usr/sbin/ntpd -g -p /var/run/ntpd.pid
  190 root     sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups
  196 root     /usr/sbin/telnetd -F
  202 root     -sh
  214 root     udhcpc -i eth0
  218 root     ps
  

Another question - have SDK ability to copy files from one folder to rootfs after build before packing?
I mean if I need to add some folders/files to firmware, can I place their structure in one place to auto copy/overwrite each build after CLEAN build before making firmware folder in IMAGE path. This is realized in openwrt and some other SDK for MTK family SoCs, but don`t find for Luckfox SDK. Maybe you can point me where to add own scripts or give an other solution.

Thanks!

Re: SAFE disabling unused modules

Posted: 2024-07-31 1:29
by Crocodile
You can use ./build.sh buildrootconfig to disable Samba. Afterwards, you can rebuild the image and flash it by running ./build.sh rootfs and ./build.sh firmware. If you need to add custom scripts after executing ./build.sh rootfs (or after building the system with ./build.sh), simply copy the files to <Luckfox_SDK>/output/out/rootfs_uclibc_rv1106. Finally, use ./build.sh firmware to package everything into the firmware.

Re: SAFE disabling unused modules

Posted: 2024-10-18 19:58
by cem
Hi @alex9x!
I'm looking for small footprint image as well (net, serial, i2c/spi, usb).
Could you please share your final scripts ?
Thank you!

btw which startup time you was able to achieve with your minimal config ?