您现在的位置是:首页 >技术杂谈 >20230511干掉CV1826的buildroot系统的串口用户名和密码root网站首页技术杂谈

20230511干掉CV1826的buildroot系统的串口用户名和密码root

南棱笑笑生 2024-06-17 10:13:33
简介20230511干掉CV1826的buildroot系统的串口用户名和密码root

20230511干掉CV1826的buildroot系统的串口用户名和密码root
2023/5/11 11:56

https://blog.csdn.net/u011342132/article/details/126116391
buildroot跳过密码登录

 

 


1、全新原始编译:
rootroot@rootroot-X99-Turbo:~$ 
rootroot@rootroot-X99-Turbo:~$ cd smartpen/
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ ll
total 116
drwxrwxr-x 18 rootroot rootroot  4096 4月  28 10:20 ./
drwxr-xr-x 32 rootroot rootroot  4096 5月  10 17:23 ../
drwxrwxr-x  2 rootroot rootroot  4096 4月  28 10:19 aw_cali/
drwxrwxr-x  5 rootroot rootroot  4096 4月  28 10:19 bluetooth/
drwxrwxr-x  7 rootroot rootroot  4096 4月  28 10:19 build/
drwxrwxr-x 14 rootroot rootroot  4096 4月  28 10:19 buildroot/
-rwxrwxr-x  1 rootroot rootroot 18139 4月  28 10:19 CHANGELIST.md*
drwxrwxr-x  8 rootroot rootroot  4096 4月  28 10:20 .git/
-rw-rw-r--  1 rootroot rootroot  3820 4月  28 10:19 .gitignore
-rwxrwxr-x  1 rootroot rootroot  4015 4月  28 10:19 GSENSOR.md*
drwxrwxr-x  3 rootroot rootroot  4096 4月  28 10:19 host-tools/
drwxrwxr-x 10 rootroot rootroot  4096 4月  28 10:19 install/
drwxrwxr-x  3 rootroot rootroot  4096 4月  28 10:19 isp_tuning/
drwxrwxr-x 26 rootroot rootroot  4096 4月  28 10:19 linux/
drwxrwxr-x  7 rootroot rootroot  4096 4月  28 10:19 middleware/
drwxrwxr-x  3 rootroot rootroot  4096 4月  28 10:19 osdrv/
drwxrwxr-x  3 rootroot rootroot  4096 4月  28 10:19 package/
drwxrwxr-x  9 rootroot rootroot  4096 4月  28 10:20 ramdisk/
-rw-rw-r--  1 rootroot rootroot   952 4月  28 10:19 README.md
drwxrwxr-x  3 rootroot rootroot  4096 4月  28 10:20 sample_bt/
drwxrwxr-x  5 rootroot rootroot  4096 4月  28 10:20 sample-demo/
drwxrwxr-x 23 rootroot rootroot  4096 4月  28 10:20 u-boot/
-rwxrwxr-x  1 rootroot rootroot  9377 4月  28 10:19 ZTFunctionsTestInfo.md*
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ find . -name inittab
./ramdisk/rootfs/common_arm64/etc/inittab
./ramdisk/rootfs/common_uclibc/etc/inittab
./ramdisk/rootfs/common_arm/etc/inittab
./ramdisk/initramfs/glibc_arm/etc/inittab
./ramdisk/initramfs/glibc_arm64/etc/inittab
./ramdisk/initramfs/uclibc_arm/etc/inittab
./buildroot/package/sysvinit/inittab
./buildroot/package/busybox/inittab
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 

INFO: size:6400000, offset:9c900,crc:90f1d346
INFO: size:6400000, offset:ce900,crc:4b282398
INFO: Packing rootfs_ext4.emmc done!
 Run pack_system_emmc() function 
mkdir -p /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/system
  [TARGET] /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/system.emmc 
/home/rootroot/smartpen/build/tools/common/prebuild/make_ext4fs -l 38M  -L SYSTEM /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/system.emmc /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/system
Creating filesystem with parameters:
    Size: 39845888
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 2432
    Inode size: 256
    Journal blocks: 1024
    Label: SYSTEM
    Blocks: 9728
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/2432 inodes and 1190/9728 blocks
resize2fs -M /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/system.emmc
resize2fs 1.44.1 (24-Mar-2018)
Resizing the filesystem on /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/system.emmc to 1201 (4k) blocks.
The filesystem on /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/system.emmc is now 1201 (4k) blocks long.

  [TARGET] system 
python3 /home/rootroot/smartpen/build/tools/common/image_tool/raw2cimg.py /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/system.emmc /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a /home/rootroot/smartpen/build/tools/common/image_tool/partition_cv1826_wevb_0005a.xml
 Run pack_gpt() function 
~/smartpen/build/tools/common/emmc_tool ~/smartpen
gcc mk_gpt.c crc.c -luuid -lxml2 -L ./ -lm -I ./ -o mk_gpt
./mk_gpt -p /home/rootroot/smartpen/build/tools/common/image_tool/partition_cv1826_wevb_0005a.xml -d /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/gpt.img
xml_file : /home/rootroot/smartpen/build/tools/common/image_tool/partition_cv1826_wevb_0005a.xml
update_dev     : /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/rawimages/gpt.img
[hq] total size:3727392768
INFO: size:4400, offset:0,crc:7c166466
INFO: Packing gpt.img done!
~/smartpen
INFO: size:7ef3, offset:6000,crc:b9b2bd53
INFO: Packing logo.jpg done!
-bash: [: : integer expression expected
INFO: Packing /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a/upgrade.zip done!
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 


rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ source build/cvisetup.sh
===========================================================
  Usage:
  (1) menuconfig - Use menu to configure your board.
      ex: $ menuconfig
  (2) defconfig $CHIP_$BOARD - Choose EVB board settings.
      ex: $ defconfig cv1835_wevb_0002a
===========================================================

- The avaliable cvitek EVB boards
  cv1835 - cv1835_wevb_0001a [EMMC 8GB + LPDDR4 1GB]
  cv1838 - cv1838_wevb_0001a [EMMC 8GB + LPDDR4 32bit 1GB]
  cv1821 - cv1821_wevb_0005b_spinand [SPINAND 256MB + QFN SIP 128MB]
  cv1822 - cv1822_wevb_0005b_spinand [SPINAND 256MB + QFN SIP 256MB]
  cv1823 - cv1823_wevb_0005a [SPINAND 256MB + BGA SIP 128MB]
  cv1825 - cv1825_wevb_0005a [EMMC + BGA SIP 256MB]
           cv1825_wevb_0005a_spinand [SPINAND 256MB + BGA SIP 256MB]
  cv1826 - cv1826_dictpen_wm108_v00a [EMMC 256MB + BGA SIP 512MB]
           cv1826_wevb_0005a [EMMC 256MB + BGA SIP 512MB YD-X5]
           cv1826_wevb_0005a_1 [YD-X5S]
           cv1826_wevb_0005a_2 [YD-X6]
           cv1826_wevb_0005a_3 [YD-S6]
           cv1826_wevb_0005a_spinand [SPINAND 256MB + BGA SIP 512MB]

rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ defconfig cv1826_wevb_0005a
 Run defconfig function 
Loaded configuration '/home/rootroot/smartpen/build/boards/cv1826_wevb_0005a/.config'
Configuration saved to '.config'

====== Environment Variables ======= 
  PROJECT: cv1826_wevb_0005a, DDR_CFG=ddr3_1866_x16_auto
  CHIP_ARCH: CV182X, DEBUG=0 BOARD=wevb_0005a
  SDK VERSION: 32bit, RPC=0
  ATF options: ATF_KEY_SEL=default, BL32=1
  UBOOT options: UBOOT_VBOOT=0 ENABLE_BOOTLOGO=1
                 ENABLE_CHARGELOGO=
  CROSS_COMPILE_PREFIX: /home/rootroot/smartpen/host-tools/gcc/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
  CROSS_COMPILE_PREFIX_PATH: /home/rootroot/smartpen/host-tools/gcc/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf
  USE_CCACHE: n
  Flash layout xml: /home/rootroot/smartpen/build/tools/common/image_tool/partition_cv1826_wevb_0005a.xml
  output path: /home/rootroot/smartpen/install/soc_cv1826_wevb_0005a
  sensor: sms_sc035gs
  Sensor tuning param: sony_imx307_sony_imx307

rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ build_all


rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ find . -name inittab
./ramdisk/rootfs/common_arm64/etc/inittab
./ramdisk/rootfs/common_uclibc/etc/inittab
./ramdisk/rootfs/common_arm/etc/inittab
./ramdisk/build/cv1826_wevb_0005a/target/etc/inittab
./ramdisk/initramfs/glibc_arm/etc/inittab
./ramdisk/initramfs/glibc_arm64/etc/inittab
./ramdisk/initramfs/uclibc_arm/etc/inittab
./buildroot/output/cvitek_cv182x/build/busybox-1.33.0/examples/inittab
./buildroot/output/cvitek_cv182x/build/busybox-1.33.0/examples/bootfloppy/etc/inittab
./buildroot/output/cvitek_cv182x/target/etc/inittab
./buildroot/package/sysvinit/inittab
./buildroot/package/busybox/inittab
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 
rootroot@rootroot-X99-Turbo:~/smartpen$ 

 

 


2、编译后生成的文件:
./ramdisk/build/cv1826_wevb_0005a/target/etc/inittab

 

./buildroot/output/cvitek_cv182x/target/etc/inittab

 

很容易知道(根据经验在全部的inittab中加打印,看哪个inittab起作用!):
Z:smartpen amdiskinitramfsglibc_armetcinittab
# Put a getty on the serial port
console::respawn:/sbin/getty -L  console 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:33 wenyuanbo"

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

 


Z:smartpen amdiskinitramfsglibc_arm64etcinittab
# Put a getty on the serial port
#ttyS0::sysinit:/bin/sh
#ttyS0::respawn:/sbin/getty -L  ttyS0 115200 vt100
console::respawn:/sbin/getty -L  console 115200 vt100 -n -l /usr/local/bin/autologin

echo "2023/4/28 18:34 wenyuanbo"

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

 


Z:smartpen amdiskinitramfsuclibc_armetcinittab
# Put a getty on the serial port
console::respawn:/sbin/getty -L  console 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:35 wenyuanbo"

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

 


Z:smartpen amdisk ootfscommon_armetcinittab
# Put a getty on the serial port
#ttyS0::sysinit:/bin/sh
#ttyS0::respawn:/sbin/getty -L  ttyS0 115200 vt100
console::respawn:/sbin/getty -L  console 115200 vt100 -n -l /usr/local/bin/autologin

echo "2023/4/28 18:41 wenyuanbo"

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

 


Z:smartpen amdisk ootfscommon_arm64etcinittab
# Put a getty on the serial port
#ttyS0::sysinit:/bin/sh
#ttyS0::respawn:/sbin/getty -L  ttyS0 115200 vt100
console::respawn:/sbin/getty -L  console 115200 vt100 -n -l /usr/local/bin/autologin

echo "2023/4/28 18:42 wenyuanbo"

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

 


Z:smartpen amdisk ootfscommon_uclibcetcinittab
# Put a getty on the serial port
#ttyS0::sysinit:/bin/sh
#ttyS0::respawn:/sbin/getty -L  ttyS0 115200 vt100
console::respawn:/sbin/getty -L  console 115200 vt100 -n -l /usr/local/bin/autologin

echo "2023/4/28 18:43 wenyuanbo"

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

 


Z:smartpenuildrootpackageusyboxinittab
# Put a getty on the serial port
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
修改为:
# Put a getty on the serial port
#ttyS0::respawn:-/bin/sh # GENERIC_SERIAL

echo "2023/4/28 18:51 wenyuanbo"

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

 


Z:smartpenuildrootpackagesysvinitinittab
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:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:52 wenyuanbo"

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

rootroot@rootroot-X99-Turbo:~/smartpen$ clean_buildroot_fs 

rootroot@rootroot-X99-Turbo:~/smartpen$ build_all

 

Z:smartpen amdiskuildcv1826_wevb_0005a argetetcinittab
Z:comcom1 amdiskinitramfsglibc_armetcinittab
# Put a getty on the serial port
console::respawn:/sbin/getty -L  console 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:33 wenyuanbo"

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

 



Z:smartpenuildrootoutputcvitek_cv182x argetetcinittab
Z:comcom1uildrootpackageusyboxinittab

# Put a getty on the serial port
console::respawn:/sbin/getty -L  console 0 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:51 wenyuanbo"

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

echo "2023/4/28 18:51 wenyuanbo"

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


3、终章:
rootroot@rootroot-X99-Turbo:~/smartpen$ clean_buildroot_fs 
rootroot@rootroot-X99-Turbo:~/smartpen$ build_all

 


./ramdisk/build/cv1826_wevb_0005a/target/etc/inittab
./buildroot/output/cvitek_cv182x/target/etc/inittab

Z:smartpen amdiskuildcv1826_wevb_0005a argetetcinittab
Z:comcom1 amdiskinitramfsglibc_armetcinittab


修正1:
Z:smartpenuildrootpackageusyboxusybox.mk
ifeq ($(BR2_INIT_BUSYBOX),y)

define BUSYBOX_SET_INIT
    $(call KCONFIG_ENABLE_OPT,CONFIG_INIT)
endef

ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
define BUSYBOX_SET_GETTY
    $(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(SYSTEM_GETTY_PORT)::respawn:/sbin/getty -L $(SYSTEM_GETTY_OPTIONS) $(SYSTEM_GETTY_PORT) $(SYSTEM_GETTY_BAUDRATE) $(SYSTEM_GETTY_TERM) #~'
        $(TARGET_DIR)/etc/inittab
endef
else
define BUSYBOX_SET_GETTY
    $(SED) '/# GENERIC_SERIAL$$/s~^.*#~#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 #~' $(TARGET_DIR)/etc/inittab
endef

endif # BR2_TARGET_GENERIC_GETTY
BUSYBOX_TARGET_FINALIZE_HOOKS += BUSYBOX_SET_GETTY

BUSYBOX_TARGET_FINALIZE_HOOKS += SYSTEM_REMOUNT_ROOT_INITTAB
修改为:
ifeq ($(BR2_INIT_BUSYBOX),y)

define BUSYBOX_SET_INIT
    $(call KCONFIG_ENABLE_OPT,CONFIG_INIT)
endef

echo "2023/4/28 12:32 wenyuanbo *****"

#ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
define BUSYBOX_SET_GETTY
    $(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(SYSTEM_GETTY_PORT)::respawn:-/bin/sh #~'
        $(TARGET_DIR)/etc/inittab
endef
#else
#define BUSYBOX_SET_GETTY
#    $(SED) '/# GENERIC_SERIAL$$/s~^.*#~#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 #~' $(TARGET_DIR)/etc/inittab
#endef
#endif # BR2_TARGET_GENERIC_GETTY

BUSYBOX_TARGET_FINALIZE_HOOKS += BUSYBOX_SET_GETTY

echo "2023/4/28 12:56 wenyuanbo *****"


BUSYBOX_TARGET_FINALIZE_HOOKS += SYSTEM_REMOUNT_ROOT_INITTAB

 


# Add /bin/{a,hu}sh to /etc/shells otherwise some login tools like dropbear
# can reject the user connection. See man shells.
define BUSYBOX_INSTALL_ADD_TO_SHELLS
    if grep -q CONFIG_ASH=y $(BUSYBOX_DIR)/.config; then
        grep -qsE '^/bin/ash$$' $(TARGET_DIR)/etc/shells
        || echo "/bin/ash" >> $(TARGET_DIR)/etc/shells;
    fi
    if grep -q CONFIG_HUSH=y $(BUSYBOX_DIR)/.config; then
        grep -qsE '^/bin/hush$$' $(TARGET_DIR)/etc/shells
        || echo "/bin/hush" >> $(TARGET_DIR)/etc/shells;
    fi
    
    echo "2023/4/28 11:06 wenyuanbo *****"
    echo $(SYSTEM_GETTY_PORT)
    echo $(SYSTEM_GETTY_OPTIONS) 
    echo $(SYSTEM_GETTY_PORT) 
    echo $(SYSTEM_GETTY_BAUDRATE) 
    echo $(SYSTEM_GETTY_TERM)
    echo $(TARGET_DIR)
    echo "2023/4/28 11:07 wenyuanbo *****"
    
    echo $(BR2_TARGET_GENERIC_GETTY)
    echo "2023/4/28 12:32 wenyuanbo *****"

endef
BUSYBOX_TARGET_FINALIZE_HOOKS += BUSYBOX_INSTALL_ADD_TO_SHELLS

 


Z:smartpenuildrootpackageusyboxinittab
# 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:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:51 wenyuanbo"

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
修改为:
# 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

echo "2023/4/28 18:51 wenyuanbo"

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

 


Z:smartpen amdiskinitramfsglibc_armetcinittab

# Put a getty on the serial port
console::respawn:/sbin/getty -L  console 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:33 wenyuanbo"

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
修改为:
# Put a getty on the serial port
#console::respawn:/sbin/getty -L  console 115200 vt100 # GENERIC_SERIAL

echo "2023/4/28 18:33 wenyuanbo"
console::respawn:-/bin/sh

echo "2023/4/29 11:35 wenyuanbo"


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


 

 

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。