20230427配置cv1826的buildroot在串口免登录的方法二

20230427配置cv1826的buildroot在串口免登录的方法二
2023/4/27 16:46


进度:可以拿掉密码,但是无法拿掉用户名!


1、
Z:\buildroot1\buildroot\configs\cvitek_cv182x_defconfig
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y                     
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y               
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y              
# BR2_TOOLCHAIN_EXTERNAL_HAS_SSP_STRONG is not set 
BR2_TOOLCHAIN_EXTERNAL_CXX=y                       
BR2_TARGET_GENERIC_HOSTNAME="yd-dictpen"           
BR2_TARGET_GENERIC_ISSUE="Welcome to YD Buildroot" 
# BR2_INIT_NONE is not set                         
BR2_TARGET_GENERIC_ROOT_PASSWD="root"  
           
BR2_ROOTFS_OVERLAY="board/cvitek/cv1826/overlay-32"
BR2_INIT_BUSYBOX=y                                 
BR2_PACKAGE_BUSYBOX=y                              
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y         
BR2_PACKAGE_INITSCRIPTS=y                          
修改为:
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y                     
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y               
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y              
# BR2_TOOLCHAIN_EXTERNAL_HAS_SSP_STRONG is not set 
BR2_TOOLCHAIN_EXTERNAL_CXX=y                       
BR2_TARGET_GENERIC_HOSTNAME="yd-dictpen"           
BR2_TARGET_GENERIC_ISSUE="Welcome to YD Buildroot" 
# BR2_INIT_NONE is not set                         
BR2_TARGET_GENERIC_ROOT_PASSWD=""                  
BR2_ROOTFS_OVERLAY="board/cvitek/cv1826/overlay-32"
BR2_INIT_BUSYBOX=y                                 
BR2_PACKAGE_BUSYBOX=y                              
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y         
BR2_PACKAGE_INITSCRIPTS=y                          

                                                                               
LOG信息:
Number  Start   End     Size    File system  Name    Flags                     
 1      4194kB  12.6MB  8389kB               BOOT    msftdata                  
 2      12.6MB  13.1MB  524kB                MISC    msftdata                  
 3      13.1MB  13.6MB  524kB                PIC     msftdata                  
 4      13.6MB  13.8MB  131kB                ENV     msftdata                  
 5      13.8MB  559MB   545MB   ext4         ROOTFS  msftdata                  
 6      559MB   601MB   41.9MB               SYSTEM  msftdata                  
 7      601MB   3673MB  3072MB  ext4         DATA    msftdata                  
                                                                               
e2fsck 1.46.2 (28-Feb-2021)                                                    
CFG: clean, 15/960 files, 2549/2551 blocks                                     
resize2fs 1.46.2 (28-Feb-2021)                                                 
Filesystem at /dev/mmcblk0p7 is mounted on /mnt; on-line resizing required     
old_desc_blocks = 1, new_desc_blocks = 2                                       
The filesystem on /dev/mmcblk0p7 is now 7488219 (4k) blocks long.              
                                                                               
Populating /dev using udev: done                                               
Saving random seed: OK                                                         
Starting system message bus: done                                              
Starting bluetoothd: OK                                                        
Starting network: OK                                                           
Starting wlan0: ifconfig: SIOCGIFFLAGS: No such device                         
Successfully initialized wpa_supplicant                                        
Could not read interface wlan0 flags: No such device                           
nl80211: Driver does not support authentication/association or connect commands
nl80211: deinit ifname=wlan0 disabled_11b_rates=0                              
Could not read interface wlan0 flags: No such device                           
wlan0: Failed to initialize driver interface                                   
Starting adbd: udhcpc: SIOCGIFINDEX: No such device                            
0 file(s)                                                                      
2 in ep                                                                        
1 out ep                                                                       
1 file(s)                                                                      
3 in ep                                                                        
2 out ep                                                                       
2 file(s)                                                                      
OK                                                                             
install_listener('tcp:5037','*smartsocket*')                                   
Starting MCU: load mcu fw: /lib/firmware/mercury_mcu_fw.bin                    
size = 7066                                                                    
WARNING: Logging before InitGoogleLogging() is written to STDERR               
I0101 00:00:05.430665   339 server.cpp:442] MTP server starting...             
done                                                                           
                                                                               
Welcome to YD Buildroot                                                        
yd-dictpen login: root                                                         
#                                                                              
#                                                                              
#                                                                              


如果输入密码不是root就会被要求输入密码:
Welcome to YD Buildroot
yd-dictpen login:      
Welcome to YD Buildroot
yd-dictpen login: 1    
Password:              
Login incorrect        
yd-dictpen login: root 

#                      
#                      
#      

               


2、在menuconfig中确认root的密码被拿掉了!
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/buildroot1$ cd buildroot/
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/buildroot1/buildroot$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/buildroot1/buildroot$ make menuconfig


  x x        Root FS skeleton (default target skeleton)  --->                       x x  
  x x    (yd-dictpen) System hostname                                               x x  
  x x    (Welcome to YD Buildroot) System banner                                    x x  
  x x        Passwords encoding (sha-256)  --->                                     x x  
  x x        Init system (BusyBox)  --->                                            x x  
  x x        /dev management (Dynamic using devtmpfs + eudev)  --->                 x x  
  x x    (system/device_table.txt) Path to the permission tables                    x x  
  x x    [ ] support extended attributes in device tables                           x x  
  x x    [ ] Use symlinks to /usr for /bin, /sbin and /lib                          x x  
  x x    [*] Enable root login with password                                        x x  
  x x    (root) Root password                                                       x x  
  x x        /bin/sh (busybox' default shell)  --->                                 x x  

  x x    [*] Run a getty (login prompt) after boot  --->                            x x  
  x x    [*] remount root filesystem read-write during boot                         x x  
  x x    ()  Network interface to configure through DHCP                            x x  
  x x    (/bin:/sbin:/usr/bin:/usr/sbin) Set the system's default PATH              x x  
  x x    [*] Purge unwanted locales                                                 x x  
  x x    (C en_US) Locales to keep                                                  x x  
  x x    ()  Generate locale data                                                   x x  
  x x    [ ] Enable Native Language Support (NLS)                                   x x  
  x x    -*- Install timezone info                                                  x x  
  x x    (default) timezone list                                                    x x  
  x x    (Etc/UTC) default local time                                               x x  
  x x    ()  Path to the users tables                                               x x  
  x x    (board/cvitek/cv1826/overlay-32) Root filesystem overlay directories       x x  
  x x    ()  Custom scripts to run before creating filesystem images                x x  
  x x    ()  Custom scripts to run inside the fakeroot environment                  x x  
  x x    ()  Custom scripts to run after creating filesystem images                 x x  


修改为:
  x x        Root FS skeleton (default target skeleton)  --->                       x x  
  x x    (yd-dictpen) System hostname                                               x x  
  x x    (Welcome to YD Buildroot) System banner                                    x x  
  x x        Passwords encoding (sha-256)  --->                                     x x  
  x x        Init system (BusyBox)  --->                                            x x  
  x x        /dev management (Dynamic using devtmpfs + eudev)  --->                 x x  
  x x    (system/device_table.txt) Path to the permission tables                    x x  
  x x    [ ] support extended attributes in device tables                           x x  
  x x    [ ] Use symlinks to /usr for /bin, /sbin and /lib                          x x  
  x x    [*] Enable root login with password                                        x x  
  x x    ()    Root password                                                        x x  
  x x        /bin/sh (busybox' default shell)  --->                                 x x  

  x x    [*] Run a getty (login prompt) after boot  --->                            x x  
  x x    [*] remount root filesystem read-write during boot                         x x  
  x x    ()  Network interface to configure through DHCP                            x x  
  x x    (/bin:/sbin:/usr/bin:/usr/sbin) Set the system's default PATH              x x  
  x x    [*] Purge unwanted locales                                                 x x  
  x x    (C en_US) Locales to keep                                                  x x  
  x x    ()  Generate locale data                                                   x x  
  x x    [ ] Enable Native Language Support (NLS)                                   x x  
  x x    -*- Install timezone info                                                  x x  
  x x    (default) timezone list                                                    x x  
  x x    (Etc/UTC) default local time                                               x x  
  x x    ()  Path to the users tables                                               x x  
  x x    (board/cvitek/cv1826/overlay-32) Root filesystem overlay directories       x x  
  x x    ()  Custom scripts to run before creating filesystem images                x x  
  x x    ()  Custom scripts to run inside the fakeroot environment                  x x  
  x x    ()  Custom scripts to run after creating filesystem images                 x x  
  x x                                                                               x x  
  x x                                                                               x x  


http://e.betheme.net/article/show-999739.aspx?action=onClick
参考博客:                                                                              
Buildroot根文件系统权限表、用户表、设备管理                                             
参考手册:buildroot手册                                                                 
在 buildroot 中,默认的 root 用户,可以使用 make menuconfig 来配置;密码在下面菜单设置;
System configuration  --->()    Root password                                           


3、继续修改:
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y                     
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y               
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y              
# BR2_TOOLCHAIN_EXTERNAL_HAS_SSP_STRONG is not set 
BR2_TOOLCHAIN_EXTERNAL_CXX=y                       
#BR2_TARGET_GENERIC_HOSTNAME="yd-dictpen"          
#BR2_TARGET_GENERIC_ISSUE="Welcome to YD Buildroot"
# BR2_INIT_NONE is not set                         
BR2_TARGET_GENERIC_ROOT_PASSWD=""        
         
BR2_ROOTFS_OVERLAY="board/cvitek/cv1826/overlay-32"
BR2_INIT_BUSYBOX=y                                 
BR2_PACKAGE_BUSYBOX=y                              
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y         
BR2_PACKAGE_INITSCRIPTS=y                          


LOG发现还是有用户名,密码已经被拿掉了!
Welcome to Buildroot 
buildroot login: root

#                    
#                    


可能会用到的文件:
Z:\buildroot1\buildroot\package\sysvinit\inittab
# /etc/inittab
#
# This inittab is a basic inittab sample for sysvinit, which mimics
# Buildroot's default inittab for BusyBox.
id:3:initdefault:

si0::sysinit:/bin/mount -t proc proc /proc
si1::sysinit:/bin/mount -o remount,rw /
si2::sysinit:/bin/mkdir -p /dev/pts /dev/shm
si3::sysinit:/bin/mount -a
si4::sysinit:/sbin/swapon -a
si5::sysinit:/bin/ln -sf /proc/self/fd /dev/fd 2>/dev/null
si6::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin 2>/dev/null
si7::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout 2>/dev/null
si8::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr 2>/dev/null
si9::sysinit:/bin/hostname -F /etc/hostname
rcS:12345:wait:/etc/init.d/rcS

# S0:1:respawn:-/bin/sh # GENERIC_SERIAL

# Stuff to do for the 3-finger salute
#ca::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
shd0:06:wait:/etc/init.d/rcK
shd1:06:wait:/sbin/swapoff -a
shd2:06:wait:/bin/umount -a -r

# The usual halt or reboot actions
hlt0:0:wait:/sbin/halt -dhp
reb0:6:wait:/sbin/reboot


Z:\buildroot1\buildroot\package\busybox\inittab 
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <[email protected]>
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
::sysinit:/bin/mount -a
::sysinit:/sbin/swapon -a
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
#ttyS0::respawn:-/bin/sh # GENERIC_SERIAL

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r


Z:\buildroot1\buildroot\package\sysvinit\sysvinit.mk
################################################################################
#
# sysvinit
#
################################################################################

SYSVINIT_VERSION = 2.99
SYSVINIT_SOURCE = sysvinit-$(SYSVINIT_VERSION).tar.xz
SYSVINIT_SITE = http://download.savannah.nongnu.org/releases/sysvinit
SYSVINIT_LICENSE = GPL-2.0+
SYSVINIT_LICENSE_FILES = COPYING
SYSVINIT_CPE_ID_VENDOR = sysvinit_project

SYSVINIT_MAKE_OPTS = SYSROOT=$(STAGING_DIR)

ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
SYSVINIT_DEPENDENCIES += libselinux
SYSVINIT_MAKE_OPTS += WITH_SELINUX="yes"
endif

define SYSVINIT_BUILD_CMDS
    $(TARGET_CONFIGURE_OPTS) $(MAKE) $(SYSVINIT_MAKE_OPTS) -C $(@D)/src
endef

define SYSVINIT_INSTALL_TARGET_CMDS
    for x in halt init shutdown killall5; do \
        $(INSTALL) -D -m 0755 $(@D)/src/$$x $(TARGET_DIR)/sbin/$$x || exit 1; \
    done
    $(INSTALL) -D -m 0644 package/sysvinit/inittab $(TARGET_DIR)/etc/inittab
    ln -sf /sbin/halt $(TARGET_DIR)/sbin/reboot
    ln -sf /sbin/halt $(TARGET_DIR)/sbin/poweroff
    ln -sf killall5 $(TARGET_DIR)/sbin/pidof
endef

ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
define SYSVINIT_SET_GETTY
    $(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(SYSTEM_GETTY_PORT) | tail -c+4)::respawn:-/bin/sh #~' \
        $(TARGET_DIR)/etc/inittab
endef
else
define SYSVINIT_SET_GETTY
    $(SED) '/# GENERIC_SERIAL$$/s~^.*#~# S0:1:respawn:-/bin/sh #~' \
        $(TARGET_DIR)/etc/inittab
endef
endif # BR2_TARGET_GENERIC_GETTY
SYSVINIT_TARGET_FINALIZE_HOOKS += SYSVINIT_SET_GETTY

SYSVINIT_TARGET_FINALIZE_HOOKS += SYSTEM_REMOUNT_ROOT_INITTAB

$(eval $(generic-package))

猜你喜欢

转载自blog.csdn.net/wb4916/article/details/130410748