close

BB.PNG

BusyBox是一個遵循GPL協定, 以自由軟體形式發行的應用程式. Busybox在單一的可執行檔中提供了精簡的Unix工具集,可執行於多款POSIX環境的作業系統, 例如Linux (包括Android[6]) , Hurd[7], FreeBSD[8][9]等等. 由於BusyBox執行檔的檔案大小比較小, 並通常使用Linux內核, 這使得它非常適合使用於嵌入式系統。作者將BusyBox稱為 "嵌入式Linux的瑞士軍刀" . 

 

筆者曾經製作過 Embedded Linux 之 rootfs ; 但真正需要製作或 Customize 時, 卻往往左支右絀, 這都是以往沒有將一些經驗文件化的結果. 網路上一時找不到適合的. 想一想還是參考網路上的資料自己慢慢製作吧. 筆者這過程 post 至 blog 上, 等下次碰到同樣的狀況時, 就很快完成. 

 

 

安裝 Cross 編譯器

 

請使用下列 apt-get 指令 安裝 Armel Cross 編譯器. 注意: Armel 與 Armhf 不同. 

 

sudo apt-get install -y g++-5-arm-linux-gnueabi gcc-5-arm-linux-gnueabi libstdc++-5-dev-armel-cross linux-libc-dev-armel-cross libc6-dev-armel-cross gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libncurses5-dev

 

注意!! 如果您是使用 Ubuntu 14 (trusty)

1. 執行 `sudo apt-get update` ; `sudo apt-get auto remove`

2. 先備份 /etc/apt/sources.list
   cp /etc/apt/sources.list ~/sources.list

3. 編輯 /etc/apt/sources.list , 將所有 trusty 替換為 xenial

4. 執行 `sudo apt-get update`

5. 執行 `sudo apt-get install --reinstall -y g++-5-arm-linux-gnueabi gcc-5-arm-linux-gnueabi libstdc++-5-dev-armel-cross linux-libc-dev-armel-cross libc6-dev-armel-cross gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libncurses5-dev`

6. 將備份還原

   sudocp ~/sources.list /etc/apt/sources.list

7.  執行 `sudo apt-get update` ; `sudo apt-get auto remove`

 

 

產生我門所需要的 Busybox Defconfig

 

Busybox 之 defconfig (configs/arm9_defconfig) 我是使用 busybox 1.24.1 內 configs/cygwin_defconfig 修改而來的. 我已經盡可能地跟原始的 cygwin_defconfig 一致了, 然而 diff 出來仍有 300 餘行. 請準備這 patches/bb_arm9_defconfig.patch 檔案. 

 

export PROJDIR=`pwd`
export TARGET_SERIAL_CONSOL=ttyMK0

 

1. clone busybox

git clone https://git.busybox.net/busybox/
cd busybox/
git branch -a
git checkout remotes/origin/1_24_stable

 

2. 以 patches/arm9_defconfig.patch 產生這 defconfig (configs/arm9_defconfig) :  

Patch 指令是這樣的: 

patch -d busybox --verbose configs/cygwin_defconfig --ignore-whitespace -i ../patches/arm9_defconfig.patch -o configs/arm9_defconfig

 

patches/arm9_defconfig.patch
--- configs/cygwin_defconfig    2019-01-16 17:14:46.218653000 +0800
+++ configs/arm9_defconfig    2019-01-17 11:44:54.121906689 +0800
@@ -12,24 +12,24 @@
 #
 # General Configuration
 #
-CONFIG_DESKTOP=y
+# CONFIG_DESKTOP is not set
 # CONFIG_EXTRA_COMPAT is not set
-CONFIG_INCLUDE_SUSv2=y
+# CONFIG_INCLUDE_SUSv2 is not set
 # CONFIG_USE_PORTABLE_CODE is not set
 CONFIG_PLATFORM_LINUX=y
 CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
 # CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
 # CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
 CONFIG_SHOW_USAGE=y
-CONFIG_FEATURE_VERBOSE_USAGE=y
+# CONFIG_FEATURE_VERBOSE_USAGE is not set
 CONFIG_FEATURE_COMPRESS_USAGE=y
-CONFIG_FEATURE_INSTALLER=y
+# CONFIG_FEATURE_INSTALLER is not set
 # CONFIG_INSTALL_NO_USR is not set
 # CONFIG_LOCALE_SUPPORT is not set
-CONFIG_UNICODE_SUPPORT=y
+# CONFIG_UNICODE_SUPPORT is not set
 # CONFIG_UNICODE_USING_LOCALE is not set
 # CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
-CONFIG_SUBST_WCHAR=65533
+CONFIG_SUBST_WCHAR=0
 CONFIG_LAST_SUPPORTED_WCHAR=0
 # CONFIG_UNICODE_COMBINING_WCHARS is not set
 # CONFIG_UNICODE_WIDE_WCHARS is not set
@@ -39,17 +39,17 @@
 CONFIG_LONG_OPTS=y
 CONFIG_FEATURE_DEVPTS=y
 # CONFIG_FEATURE_CLEAN_UP is not set
-# CONFIG_FEATURE_UTMP is not set
+CONFIG_FEATURE_UTMP=y
 # CONFIG_FEATURE_WTMP is not set
 CONFIG_FEATURE_PIDFILE=y
 CONFIG_FEATURE_SUID=y
-# CONFIG_FEATURE_SUID_CONFIG is not set
-# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
+CONFIG_FEATURE_SUID_CONFIG=y
+CONFIG_FEATURE_SUID_CONFIG_QUIET=y
 # CONFIG_SELINUX is not set
 # CONFIG_FEATURE_PREFER_APPLETS is not set
 CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
 CONFIG_FEATURE_SYSLOG=y
-# CONFIG_FEATURE_HAVE_RPC is not set
+CONFIG_FEATURE_HAVE_RPC=y
 
 #
 # Build Options
@@ -62,7 +62,7 @@
 # CONFIG_FEATURE_SHARED_BUSYBOX is not set
 CONFIG_LFS=y
 CONFIG_CROSS_COMPILER_PREFIX=""
-CONFIG_EXTRA_CFLAGS=""
+CONFIG_EXTRA_CFLAGS=" -O2 -g -feliminate-unused-debug-types -marm -pipe -march=armv5t"
 
 #
 # Debugging Options
@@ -99,17 +99,17 @@
 CONFIG_FEATURE_EDITING=y
 CONFIG_FEATURE_EDITING_MAX_LEN=1024
 # CONFIG_FEATURE_EDITING_VI is not set
-CONFIG_FEATURE_EDITING_HISTORY=255
+CONFIG_FEATURE_EDITING_HISTORY=15
 CONFIG_FEATURE_EDITING_SAVEHISTORY=y
 CONFIG_FEATURE_TAB_COMPLETION=y
-# CONFIG_FEATURE_USERNAME_COMPLETION is not set
+CONFIG_FEATURE_USERNAME_COMPLETION=y
 CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
 # CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set
 CONFIG_FEATURE_NON_POSIX_CP=y
 # CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
 CONFIG_FEATURE_COPYBUF_KB=4
 CONFIG_FEATURE_SKIP_ROOTFS=y
-# CONFIG_MONOTONIC_SYSCALL is not set
+CONFIG_MONOTONIC_SYSCALL=y
 CONFIG_IOCTL_HEX2STR_ERROR=y
 CONFIG_FEATURE_HWIB=y
 
@@ -141,18 +141,18 @@
 CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
 CONFIG_LZOP=y
 # CONFIG_LZOP_COMPR_HIGH is not set
-CONFIG_RPM2CPIO=y
-CONFIG_RPM=y
+# CONFIG_RPM is not set
+# CONFIG_RPM2CPIO is not set
 CONFIG_TAR=y
 CONFIG_FEATURE_TAR_CREATE=y
 CONFIG_FEATURE_TAR_AUTODETECT=y
 CONFIG_FEATURE_TAR_FROM=y
 CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
-CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
+# CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY is not set
 CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
-CONFIG_FEATURE_TAR_LONG_OPTIONS=y
-CONFIG_FEATURE_TAR_TO_COMMAND=y
-CONFIG_FEATURE_TAR_UNAME_GNAME=y
+# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set
+# CONFIG_FEATURE_TAR_TO_COMMAND is not set
+# CONFIG_FEATURE_TAR_UNAME_GNAME is not set
 CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
 # CONFIG_FEATURE_TAR_SELINUX is not set
 # CONFIG_UNCOMPRESS is not set
@@ -179,17 +179,17 @@
 CONFIG_TOUCH=y
 CONFIG_TR=y
 CONFIG_FEATURE_TR_CLASSES=y
-CONFIG_FEATURE_TR_EQUIV=y
-CONFIG_BASE64=y
-CONFIG_CAL=y
-CONFIG_CATV=y
+# CONFIG_FEATURE_TR_EQUIV is not set
+# CONFIG_BASE64 is not set
+# CONFIG_CAL is not set
+# CONFIG_CATV is not set
 CONFIG_CHGRP=y
 CONFIG_CHMOD=y
 CONFIG_CHOWN=y
-CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y
+# CONFIG_FEATURE_CHOWN_LONG_OPTIONS is not set
 CONFIG_CHROOT=y
 CONFIG_CKSUM=y
-CONFIG_COMM=y
+# CONFIG_COMM is not set
 CONFIG_CP=y
 CONFIG_FEATURE_CP_LONG_OPTIONS=y
 CONFIG_CUT=y
@@ -200,26 +200,26 @@
 CONFIG_DF=y
 CONFIG_FEATURE_DF_FANCY=y
 CONFIG_DIRNAME=y
-CONFIG_DOS2UNIX=y
-CONFIG_UNIX2DOS=y
+# CONFIG_DOS2UNIX is not set
+# CONFIG_UNIX2DOS is not set
 CONFIG_DU=y
-# CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K is not set
+CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
 CONFIG_ECHO=y
 CONFIG_FEATURE_FANCY_ECHO=y
 CONFIG_ENV=y
 CONFIG_FEATURE_ENV_LONG_OPTIONS=y
-CONFIG_EXPAND=y
-CONFIG_FEATURE_EXPAND_LONG_OPTIONS=y
+# CONFIG_EXPAND is not set
+# CONFIG_FEATURE_EXPAND_LONG_OPTIONS is not set
 CONFIG_EXPR=y
 CONFIG_EXPR_MATH_SUPPORT_64=y
 CONFIG_FALSE=y
-CONFIG_FOLD=y
+# CONFIG_FOLD is not set
 CONFIG_FSYNC=y
 CONFIG_HEAD=y
-CONFIG_FEATURE_FANCY_HEAD=y
-CONFIG_HOSTID=y
-CONFIG_INSTALL=y
-CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y
+# CONFIG_FEATURE_FANCY_HEAD is not set
+# CONFIG_HOSTID is not set
+# CONFIG_INSTALL is not set
+# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set
 CONFIG_LN=y
 CONFIG_LOGNAME=y
 CONFIG_LS=y
@@ -229,15 +229,15 @@
 CONFIG_FEATURE_LS_SORTFILES=y
 CONFIG_FEATURE_LS_TIMESTAMPS=y
 CONFIG_FEATURE_LS_USERNAME=y
-CONFIG_FEATURE_LS_COLOR=y
-CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y
+# CONFIG_FEATURE_LS_COLOR is not set
+# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set
 CONFIG_MD5SUM=y
 CONFIG_MKDIR=y
 CONFIG_FEATURE_MKDIR_LONG_OPTIONS=y
 CONFIG_MKFIFO=y
 CONFIG_MKNOD=y
 CONFIG_MV=y
-CONFIG_FEATURE_MV_LONG_OPTIONS=y
+# CONFIG_FEATURE_MV_LONG_OPTIONS is not set
 CONFIG_NICE=y
 CONFIG_NOHUP=y
 CONFIG_OD=y
@@ -249,11 +249,11 @@
 CONFIG_REALPATH=y
 CONFIG_RM=y
 CONFIG_RMDIR=y
-CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y
+# CONFIG_FEATURE_RMDIR_LONG_OPTIONS is not set
 CONFIG_SEQ=y
 CONFIG_SHA1SUM=y
 CONFIG_SHA256SUM=y
-CONFIG_SHA512SUM=y
+# CONFIG_SHA512SUM is not set
 CONFIG_SLEEP=y
 CONFIG_FEATURE_FANCY_SLEEP=y
 CONFIG_FEATURE_FLOAT_SLEEP=y
@@ -278,8 +278,8 @@
 CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS=y
 CONFIG_UNIQ=y
 CONFIG_USLEEP=y
-CONFIG_UUDECODE=y
-CONFIG_UUENCODE=y
+# CONFIG_UUDECODE is not set
+# CONFIG_UUENCODE is not set
 CONFIG_WC=y
 CONFIG_FEATURE_WC_LARGE=y
 # CONFIG_WHO is not set
@@ -309,26 +309,26 @@
 #
 # Console Utilities
 #
-# CONFIG_CHVT is not set
-# CONFIG_FGCONSOLE is not set
+CONFIG_CHVT=y
+CONFIG_FGCONSOLE=y
 CONFIG_CLEAR=y
-# CONFIG_DEALLOCVT is not set
-# CONFIG_DUMPKMAP is not set
+CONFIG_DEALLOCVT=y
+CONFIG_DUMPKMAP=y
 # CONFIG_KBD_MODE is not set
-# CONFIG_LOADFONT is not set
-# CONFIG_LOADKMAP is not set
-# CONFIG_OPENVT is not set
+CONFIG_LOADFONT=y
+CONFIG_LOADKMAP=y
+CONFIG_OPENVT=y
 CONFIG_RESET=y
 CONFIG_RESIZE=y
 CONFIG_FEATURE_RESIZE_PRINT=y
-# CONFIG_SETCONSOLE is not set
+CONFIG_SETCONSOLE=y
 # CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set
 # CONFIG_SETFONT is not set
 # CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set
 CONFIG_DEFAULT_SETFONT_DIR=""
-# CONFIG_SETKEYCODES is not set
-# CONFIG_SETLOGCONS is not set
-# CONFIG_SHOWKEY is not set
+CONFIG_SETKEYCODES=y
+CONFIG_SETLOGCONS=y
+CONFIG_SHOWKEY=y
 # CONFIG_FEATURE_LOADFONT_PSF2 is not set
 # CONFIG_FEATURE_LOADFONT_RAW is not set
 
@@ -350,17 +350,17 @@
 #
 CONFIG_PATCH=y
 CONFIG_VI=y
-CONFIG_FEATURE_VI_MAX_LEN=4096
-# CONFIG_FEATURE_VI_8BIT is not set
+CONFIG_FEATURE_VI_MAX_LEN=1024
+CONFIG_FEATURE_VI_8BIT=y
 CONFIG_FEATURE_VI_COLON=y
 CONFIG_FEATURE_VI_YANKMARK=y
 CONFIG_FEATURE_VI_SEARCH=y
 # CONFIG_FEATURE_VI_REGEX_SEARCH is not set
 CONFIG_FEATURE_VI_USE_SIGNALS=y
-CONFIG_FEATURE_VI_DOT_CMD=y
-CONFIG_FEATURE_VI_READONLY=y
-CONFIG_FEATURE_VI_SETOPTS=y
-CONFIG_FEATURE_VI_SET=y
+# CONFIG_FEATURE_VI_DOT_CMD is not set
+# CONFIG_FEATURE_VI_READONLY is not set
+# CONFIG_FEATURE_VI_SETOPTS is not set
+# CONFIG_FEATURE_VI_SET is not set
 CONFIG_FEATURE_VI_WIN_RESIZE=y
 CONFIG_FEATURE_VI_ASK_TERMINAL=y
 CONFIG_AWK=y
@@ -369,7 +369,7 @@
 CONFIG_DIFF=y
 CONFIG_FEATURE_DIFF_LONG_OPTIONS=y
 CONFIG_FEATURE_DIFF_DIR=y
-CONFIG_ED=y
+# CONFIG_ED is not set
 CONFIG_SED=y
 CONFIG_FEATURE_ALLOW_EXEC=y
 
@@ -387,6 +387,7 @@
 CONFIG_FEATURE_FIND_NEWER=y
 CONFIG_FEATURE_FIND_INUM=y
 CONFIG_FEATURE_FIND_EXEC=y
+CONFIG_FEATURE_FIND_EXEC_PLUS=y
 CONFIG_FEATURE_FIND_USER=y
 CONFIG_FEATURE_FIND_GROUP=y
 CONFIG_FEATURE_FIND_NOT=y
@@ -394,7 +395,7 @@
 CONFIG_FEATURE_FIND_PAREN=y
 CONFIG_FEATURE_FIND_SIZE=y
 CONFIG_FEATURE_FIND_PRUNE=y
-CONFIG_FEATURE_FIND_DELETE=y
+# CONFIG_FEATURE_FIND_DELETE is not set
 CONFIG_FEATURE_FIND_PATH=y
 CONFIG_FEATURE_FIND_REGEX=y
 # CONFIG_FEATURE_FIND_CONTEXT is not set
@@ -404,10 +405,11 @@
 CONFIG_FEATURE_GREP_FGREP_ALIAS=y
 CONFIG_FEATURE_GREP_CONTEXT=y
 CONFIG_XARGS=y
-CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
-CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
-CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
-CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
+# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_QUOTES is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM is not set
+CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR=y
 
 #
 # Init Utilities
@@ -415,44 +417,45 @@
 # CONFIG_BOOTCHARTD is not set
 # CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
 # CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
-# CONFIG_HALT is not set
+CONFIG_HALT=y
 # CONFIG_FEATURE_CALL_TELINIT is not set
 CONFIG_TELINIT_PATH=""
-# CONFIG_INIT is not set
-# CONFIG_FEATURE_USE_INITTAB is not set
+CONFIG_INIT=y
+CONFIG_FEATURE_USE_INITTAB=y
 # CONFIG_FEATURE_KILL_REMOVED is not set
 CONFIG_FEATURE_KILL_DELAY=0
-# CONFIG_FEATURE_INIT_SCTTY is not set
-# CONFIG_FEATURE_INIT_SYSLOG is not set
-# CONFIG_FEATURE_EXTRA_QUIET is not set
-# CONFIG_FEATURE_INIT_COREDUMPS is not set
-# CONFIG_FEATURE_INITRD is not set
-CONFIG_INIT_TERMINAL_TYPE=""
+CONFIG_FEATURE_INIT_SCTTY=y
+CONFIG_FEATURE_INIT_SYSLOG=y
+CONFIG_FEATURE_EXTRA_QUIET=y
+CONFIG_FEATURE_INIT_COREDUMPS=y
+CONFIG_FEATURE_INITRD=y
+CONFIG_INIT_TERMINAL_TYPE="linux"
 CONFIG_MESG=y
-CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
+# CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP is not set
 
 #
 # Login/Password Management Utilities
 #
-CONFIG_ADD_SHELL=y
-CONFIG_REMOVE_SHELL=y
-CONFIG_FEATURE_SHADOWPASSWDS=y
-CONFIG_USE_BB_PWD_GRP=y
-CONFIG_USE_BB_SHADOW=y
+# CONFIG_ADD_SHELL is not set
+# CONFIG_REMOVE_SHELL is not set
+# CONFIG_FEATURE_SHADOWPASSWDS is not set
+# CONFIG_USE_BB_PWD_GRP is not set
+# CONFIG_USE_BB_SHADOW is not set
 CONFIG_USE_BB_CRYPT=y
-CONFIG_USE_BB_CRYPT_SHA=y
+# CONFIG_USE_BB_CRYPT_SHA is not set
 CONFIG_ADDUSER=y
 CONFIG_FEATURE_ADDUSER_LONG_OPTIONS=y
 # CONFIG_FEATURE_CHECK_NAMES is not set
+CONFIG_LAST_ID=60000
 CONFIG_FIRST_SYSTEM_ID=100
 CONFIG_LAST_SYSTEM_ID=999
 CONFIG_ADDGROUP=y
 CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS=y
-CONFIG_FEATURE_ADDUSER_TO_GROUP=y
+# CONFIG_FEATURE_ADDUSER_TO_GROUP is not set
 CONFIG_DELUSER=y
 CONFIG_DELGROUP=y
-CONFIG_FEATURE_DEL_USER_FROM_GROUP=y
-# CONFIG_GETTY is not set
+# CONFIG_FEATURE_DEL_USER_FROM_GROUP is not set
+CONFIG_GETTY=y
 CONFIG_LOGIN=y
 # CONFIG_PAM is not set
 CONFIG_LOGIN_SCRIPTS=y
@@ -463,8 +466,8 @@
 CONFIG_CRYPTPW=y
 CONFIG_CHPASSWD=y
 CONFIG_SU=y
-CONFIG_FEATURE_SU_SYSLOG=y
-CONFIG_FEATURE_SU_CHECKS_SHELLS=y
+# CONFIG_FEATURE_SU_SYSLOG is not set
+# CONFIG_FEATURE_SU_CHECKS_SHELLS is not set
 CONFIG_SULOGIN=y
 CONFIG_VLOCK=y
 
@@ -479,17 +482,17 @@
 #
 # Linux Module Utilities
 #
-# CONFIG_MODINFO is not set
-# CONFIG_MODPROBE_SMALL is not set
-# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
-# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+CONFIG_MODINFO=y
+CONFIG_MODPROBE_SMALL=y
+CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
+CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils
@@ -502,97 +505,98 @@
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
 # CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
-CONFIG_DEFAULT_MODULES_DIR=""
-CONFIG_DEFAULT_DEPMOD_FILE=""
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
+CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
+CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 
 #
 # Linux System Utilities
 #
-# CONFIG_BLOCKDEV is not set
+CONFIG_BLOCKDEV=y
 CONFIG_REV=y
 # CONFIG_ACPID is not set
 # CONFIG_FEATURE_ACPID_COMPAT is not set
-# CONFIG_BLKID is not set
-# CONFIG_FEATURE_BLKID_TYPE is not set
-# CONFIG_DMESG is not set
-# CONFIG_FEATURE_DMESG_PRETTY is not set
-# CONFIG_FBSET is not set
-# CONFIG_FEATURE_FBSET_FANCY is not set
-# CONFIG_FEATURE_FBSET_READMODE is not set
-# CONFIG_FDFLUSH is not set
-# CONFIG_FDFORMAT is not set
-# CONFIG_FDISK is not set
-# CONFIG_FDISK_SUPPORT_LARGE_DISKS is not set
-# CONFIG_FEATURE_FDISK_WRITABLE is not set
+CONFIG_BLKID=y
+CONFIG_FEATURE_BLKID_TYPE=y
+CONFIG_DMESG=y
+CONFIG_FEATURE_DMESG_PRETTY=y
+CONFIG_FBSET=y
+CONFIG_FEATURE_FBSET_FANCY=y
+CONFIG_FEATURE_FBSET_READMODE=y
+CONFIG_FDFLUSH=y
+CONFIG_FDFORMAT=y
+CONFIG_FDISK=y
+CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
+CONFIG_FEATURE_FDISK_WRITABLE=y
 # CONFIG_FEATURE_AIX_LABEL is not set
 # CONFIG_FEATURE_SGI_LABEL is not set
 # CONFIG_FEATURE_SUN_LABEL is not set
 # CONFIG_FEATURE_OSF_LABEL is not set
 # CONFIG_FEATURE_GPT_LABEL is not set
-# CONFIG_FEATURE_FDISK_ADVANCED is not set
-# CONFIG_FINDFS is not set
+CONFIG_FEATURE_FDISK_ADVANCED=y
+CONFIG_FINDFS=y
 CONFIG_FLOCK=y
-# CONFIG_FREERAMDISK is not set
+CONFIG_FREERAMDISK=y
 CONFIG_FSCK_MINIX=y
-# CONFIG_MKFS_EXT2 is not set
+CONFIG_MKFS_EXT2=y
 # CONFIG_MKFS_MINIX is not set
 CONFIG_FEATURE_MINIX2=y
 # CONFIG_MKFS_REISER is not set
-# CONFIG_MKFS_VFAT is not set
+CONFIG_MKFS_VFAT=y
 CONFIG_GETOPT=y
 CONFIG_FEATURE_GETOPT_LONG=y
 CONFIG_HEXDUMP=y
-CONFIG_FEATURE_HEXDUMP_REVERSE=y
-CONFIG_HD=y
+# CONFIG_FEATURE_HEXDUMP_REVERSE is not set
+# CONFIG_HD is not set
 # CONFIG_HWCLOCK is not set
 # CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS is not set
 # CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS is not set
-CONFIG_IPCRM=y
+# CONFIG_IPCRM is not set
 # CONFIG_IPCS is not set
 # CONFIG_LOSETUP is not set
 # CONFIG_LSPCI is not set
-# CONFIG_LSUSB is not set
-# CONFIG_MDEV is not set
-# CONFIG_FEATURE_MDEV_CONF is not set
-# CONFIG_FEATURE_MDEV_RENAME is not set
-# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set
-# CONFIG_FEATURE_MDEV_EXEC is not set
-# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set
+CONFIG_LSUSB=y
+CONFIG_MDEV=y
+CONFIG_FEATURE_MDEV_CONF=y
+CONFIG_FEATURE_MDEV_RENAME=y
+CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
+CONFIG_FEATURE_MDEV_EXEC=y
+CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
 CONFIG_MKSWAP=y
 CONFIG_FEATURE_MKSWAP_UUID=y
 CONFIG_MORE=y
-# CONFIG_MOUNT is not set
-# CONFIG_FEATURE_MOUNT_FAKE is not set
-# CONFIG_FEATURE_MOUNT_VERBOSE is not set
-# CONFIG_FEATURE_MOUNT_HELPERS is not set
-# CONFIG_FEATURE_MOUNT_LABEL is not set
-# CONFIG_FEATURE_MOUNT_NFS is not set
-# CONFIG_FEATURE_MOUNT_CIFS is not set
-# CONFIG_FEATURE_MOUNT_FLAGS is not set
-# CONFIG_FEATURE_MOUNT_FSTAB is not set
-# CONFIG_PIVOT_ROOT is not set
+CONFIG_MOUNT=y
+CONFIG_FEATURE_MOUNT_FAKE=y
+CONFIG_FEATURE_MOUNT_VERBOSE=y
+CONFIG_FEATURE_MOUNT_HELPERS=y
+CONFIG_FEATURE_MOUNT_LABEL=y
+CONFIG_FEATURE_MOUNT_NFS=y
+CONFIG_FEATURE_MOUNT_CIFS=y
+CONFIG_FEATURE_MOUNT_FLAGS=y
+CONFIG_FEATURE_MOUNT_FSTAB=y
+# CONFIG_FEATURE_MOUNT_OTHERTAB is not set
+CONFIG_PIVOT_ROOT=y
 # CONFIG_RDATE is not set
-CONFIG_RDEV=y
-CONFIG_READPROFILE=y
+# CONFIG_RDEV is not set
+# CONFIG_READPROFILE is not set
 # CONFIG_RTCWAKE is not set
-CONFIG_SCRIPT=y
-CONFIG_SCRIPTREPLAY=y
+# CONFIG_SCRIPT is not set
+# CONFIG_SCRIPTREPLAY is not set
 # CONFIG_SETARCH is not set
 # CONFIG_SWAPONOFF is not set
 # CONFIG_FEATURE_SWAPON_PRI is not set
-# CONFIG_SWITCH_ROOT is not set
-# CONFIG_UMOUNT is not set
-# CONFIG_FEATURE_UMOUNT_ALL is not set
-# CONFIG_FEATURE_MOUNT_LOOP is not set
-# CONFIG_FEATURE_MOUNT_LOOP_CREATE is not set
+CONFIG_SWITCH_ROOT=y
+CONFIG_UMOUNT=y
+CONFIG_FEATURE_UMOUNT_ALL=y
+CONFIG_FEATURE_MOUNT_LOOP=y
+CONFIG_FEATURE_MOUNT_LOOP_CREATE=y
 # CONFIG_FEATURE_MTAB_SUPPORT is not set
-# CONFIG_VOLUMEID is not set
-# CONFIG_FEATURE_VOLUMEID_EXT is not set
-# CONFIG_FEATURE_VOLUMEID_BTRFS is not set
+CONFIG_VOLUMEID=y
+CONFIG_FEATURE_VOLUMEID_EXT=y
+CONFIG_FEATURE_VOLUMEID_BTRFS=y
 # CONFIG_FEATURE_VOLUMEID_REISERFS is not set
-# CONFIG_FEATURE_VOLUMEID_FAT is not set
+CONFIG_FEATURE_VOLUMEID_FAT=y
 # CONFIG_FEATURE_VOLUMEID_HFS is not set
 # CONFIG_FEATURE_VOLUMEID_JFS is not set
 # CONFIG_FEATURE_VOLUMEID_XFS is not set
@@ -612,8 +616,8 @@
 #
 # CONFIG_CONSPY is not set
 # CONFIG_NANDWRITE is not set
-# CONFIG_NANDDUMP is not set
-# CONFIG_SETSERIAL is not set
+CONFIG_NANDDUMP=y
+CONFIG_SETSERIAL=y
 # CONFIG_UBIATTACH is not set
 # CONFIG_UBIDETACH is not set
 # CONFIG_UBIMKVOL is not set
@@ -626,22 +630,22 @@
 # CONFIG_BEEP is not set
 CONFIG_FEATURE_BEEP_FREQ=0
 CONFIG_FEATURE_BEEP_LENGTH_MS=0
-CONFIG_CHAT=y
-CONFIG_FEATURE_CHAT_NOFAIL=y
+# CONFIG_CHAT is not set
+# CONFIG_FEATURE_CHAT_NOFAIL is not set
 # CONFIG_FEATURE_CHAT_TTY_HIFI is not set
-CONFIG_FEATURE_CHAT_IMPLICIT_CR=y
-CONFIG_FEATURE_CHAT_SWALLOW_OPTS=y
-CONFIG_FEATURE_CHAT_SEND_ESCAPES=y
-CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
-CONFIG_FEATURE_CHAT_CLR_ABORT=y
-CONFIG_CHRT=y
+# CONFIG_FEATURE_CHAT_IMPLICIT_CR is not set
+# CONFIG_FEATURE_CHAT_SWALLOW_OPTS is not set
+# CONFIG_FEATURE_CHAT_SEND_ESCAPES is not set
+# CONFIG_FEATURE_CHAT_VAR_ABORT_LEN is not set
+# CONFIG_FEATURE_CHAT_CLR_ABORT is not set
+# CONFIG_CHRT is not set
 CONFIG_CROND=y
 CONFIG_FEATURE_CROND_D=y
-CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
+# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
 CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
 CONFIG_CRONTAB=y
 CONFIG_DC=y
-CONFIG_FEATURE_DC_LIBM=y
+# CONFIG_FEATURE_DC_LIBM is not set
 # CONFIG_DEVFSD is not set
 # CONFIG_DEVFSD_MODLOAD is not set
 # CONFIG_DEVFSD_FG_NP is not set
@@ -650,25 +654,17 @@
 CONFIG_DEVMEM=y
 # CONFIG_EJECT is not set
 # CONFIG_FEATURE_EJECT_SCSI is not set
-# CONFIG_FBSPLASH is not set
-# CONFIG_FLASHCP is not set
-# CONFIG_FLASH_LOCK is not set
-# CONFIG_FLASH_UNLOCK is not set
+CONFIG_FBSPLASH=y
+CONFIG_FLASHCP=y
+CONFIG_FLASH_LOCK=y
+CONFIG_FLASH_UNLOCK=y
 # CONFIG_FLASH_ERASEALL is not set
 # CONFIG_IONICE is not set
 # CONFIG_INOTIFYD is not set
 # CONFIG_LAST is not set
 # CONFIG_FEATURE_LAST_SMALL is not set
 # CONFIG_FEATURE_LAST_FANCY is not set
-CONFIG_LESS=y
-CONFIG_FEATURE_LESS_MAXLINES=9999999
-CONFIG_FEATURE_LESS_BRACKETS=y
-CONFIG_FEATURE_LESS_FLAGS=y
-CONFIG_FEATURE_LESS_MARKS=y
-CONFIG_FEATURE_LESS_REGEXP=y
-CONFIG_FEATURE_LESS_WINCH=y
-CONFIG_FEATURE_LESS_DASHCMD=y
-CONFIG_FEATURE_LESS_LINENUMS=y
+# CONFIG_LESS is not set
 # CONFIG_HDPARM is not set
 # CONFIG_FEATURE_HDPARM_GET_IDENTITY is not set
 # CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set
@@ -679,23 +675,23 @@
 # CONFIG_MAKEDEVS is not set
 # CONFIG_FEATURE_MAKEDEVS_LEAF is not set
 # CONFIG_FEATURE_MAKEDEVS_TABLE is not set
-CONFIG_MAN=y
-# CONFIG_MICROCOM is not set
+# CONFIG_MAN is not set
+CONFIG_MICROCOM=y
 # CONFIG_MOUNTPOINT is not set
-CONFIG_MT=y
+# CONFIG_MT is not set
 # CONFIG_RAIDAUTORUN is not set
 # CONFIG_READAHEAD is not set
 # CONFIG_RFKILL is not set
 # CONFIG_RUNLEVEL is not set
 # CONFIG_RX is not set
-CONFIG_SETSID=y
+# CONFIG_SETSID is not set
 CONFIG_STRINGS=y
 # CONFIG_TASKSET is not set
 # CONFIG_FEATURE_TASKSET_FANCY is not set
 CONFIG_TIME=y
-CONFIG_TIMEOUT=y
-CONFIG_TTYSIZE=y
-CONFIG_VOLNAME=y
+# CONFIG_TIMEOUT is not set
+# CONFIG_TTYSIZE is not set
+# CONFIG_VOLNAME is not set
 # CONFIG_WALL is not set
 # CONFIG_WATCHDOG is not set
 
@@ -706,23 +702,23 @@
 # CONFIG_FEATURE_NAMEIF_EXTENDED is not set
 # CONFIG_NBDCLIENT is not set
 CONFIG_NC=y
-CONFIG_NC_SERVER=y
-CONFIG_NC_EXTRA=y
+# CONFIG_NC_SERVER is not set
+# CONFIG_NC_EXTRA is not set
 # CONFIG_NC_110_COMPAT is not set
-# CONFIG_PING is not set
-# CONFIG_PING6 is not set
-# CONFIG_FEATURE_FANCY_PING is not set
+CONFIG_PING=y
+CONFIG_PING6=y
+CONFIG_FEATURE_FANCY_PING=y
 CONFIG_WHOIS=y
-CONFIG_FEATURE_IPV6=y
+# CONFIG_FEATURE_IPV6 is not set
 # CONFIG_FEATURE_UNIX_LOCAL is not set
-CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
+# CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set
 # CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
-# CONFIG_ARP is not set
+CONFIG_ARP=y
 # CONFIG_ARPING is not set
 # CONFIG_BRCTL is not set
 # CONFIG_FEATURE_BRCTL_FANCY is not set
 # CONFIG_FEATURE_BRCTL_SHOW is not set
-CONFIG_DNSD=y
+# CONFIG_DNSD is not set
 # CONFIG_ETHER_WAKE is not set
 CONFIG_FAKEIDENTD=y
 CONFIG_FTPD=y
@@ -732,46 +728,45 @@
 CONFIG_FTPPUT=y
 CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
 CONFIG_HOSTNAME=y
-CONFIG_HTTPD=y
-CONFIG_FEATURE_HTTPD_RANGES=y
-# CONFIG_FEATURE_HTTPD_USE_SENDFILE is not set
-CONFIG_FEATURE_HTTPD_SETUID=y
-CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
-CONFIG_FEATURE_HTTPD_AUTH_MD5=y
-CONFIG_FEATURE_HTTPD_CGI=y
-CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
-CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
-CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y
-CONFIG_FEATURE_HTTPD_ERROR_PAGES=y
-CONFIG_FEATURE_HTTPD_PROXY=y
-CONFIG_FEATURE_HTTPD_GZIP=y
-# CONFIG_IFCONFIG is not set
-# CONFIG_FEATURE_IFCONFIG_STATUS is not set
+# CONFIG_HTTPD is not set
+# CONFIG_FEATURE_HTTPD_RANGES is not set
+# CONFIG_FEATURE_HTTPD_SETUID is not set
+# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
+# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
+# CONFIG_FEATURE_HTTPD_CGI is not set
+# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
+# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
+# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
+# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set
+# CONFIG_FEATURE_HTTPD_PROXY is not set
+# CONFIG_FEATURE_HTTPD_GZIP is not set
+CONFIG_IFCONFIG=y
+CONFIG_FEATURE_IFCONFIG_STATUS=y
 # CONFIG_FEATURE_IFCONFIG_SLIP is not set
-# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
-# CONFIG_FEATURE_IFCONFIG_HW is not set
-# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
+CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
+CONFIG_FEATURE_IFCONFIG_HW=y
+CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
 # CONFIG_IFENSLAVE is not set
 # CONFIG_IFPLUGD is not set
-# CONFIG_IFUPDOWN is not set
-CONFIG_IFUPDOWN_IFSTATE_PATH=""
+CONFIG_IFUPDOWN=y
+CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
 # CONFIG_FEATURE_IFUPDOWN_IP is not set
 # CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
-# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
-# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
-# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
-# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
-# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
+CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN=y
+CONFIG_FEATURE_IFUPDOWN_IPV4=y
+CONFIG_FEATURE_IFUPDOWN_IPV6=y
+CONFIG_FEATURE_IFUPDOWN_MAPPING=y
+CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y
 CONFIG_INETD=y
 CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y
-CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y
-CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y
-CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y
-CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
 # CONFIG_FEATURE_INETD_RPC is not set
-# CONFIG_IP is not set
-# CONFIG_FEATURE_IP_ADDRESS is not set
-# CONFIG_FEATURE_IP_LINK is not set
+CONFIG_IP=y
+CONFIG_FEATURE_IP_ADDRESS=y
+CONFIG_FEATURE_IP_LINK=y
 # CONFIG_FEATURE_IP_ROUTE is not set
 # CONFIG_FEATURE_IP_TUNNEL is not set
 # CONFIG_FEATURE_IP_RULE is not set
@@ -782,17 +777,17 @@
 # CONFIG_IPROUTE is not set
 # CONFIG_IPTUNNEL is not set
 # CONFIG_IPRULE is not set
-CONFIG_IPCALC=y
-CONFIG_FEATURE_IPCALC_FANCY=y
-CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
-# CONFIG_NETSTAT is not set
+# CONFIG_IPCALC is not set
+# CONFIG_FEATURE_IPCALC_FANCY is not set
+# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set
+CONFIG_NETSTAT=y
 # CONFIG_FEATURE_NETSTAT_WIDE is not set
 # CONFIG_FEATURE_NETSTAT_PRG is not set
-# CONFIG_NSLOOKUP is not set
+CONFIG_NSLOOKUP=y
 # CONFIG_NTPD is not set
 # CONFIG_FEATURE_NTPD_SERVER is not set
-CONFIG_PSCAN=y
-# CONFIG_ROUTE is not set
+# CONFIG_PSCAN is not set
+CONFIG_ROUTE=y
 # CONFIG_SLATTACH is not set
 CONFIG_TCPSVD=y
 CONFIG_TELNET=y
@@ -812,9 +807,9 @@
 CONFIG_FEATURE_TFTP_BLOCKSIZE=y
 CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
 # CONFIG_TFTP_DEBUG is not set
-# CONFIG_TRACEROUTE is not set
+CONFIG_TRACEROUTE=y
 # CONFIG_TRACEROUTE6 is not set
-# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
+CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
 # CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
 # CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
 # CONFIG_TUNCTL is not set
@@ -825,16 +820,16 @@
 # CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set
 # CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set
 CONFIG_DHCPD_LEASES_FILE=""
-# CONFIG_UDHCPC is not set
-# CONFIG_FEATURE_UDHCPC_ARPING is not set
-# CONFIG_FEATURE_UDHCP_PORT is not set
-CONFIG_UDHCP_DEBUG=0
-# CONFIG_FEATURE_UDHCP_RFC3397 is not set
-# CONFIG_FEATURE_UDHCP_8021Q is not set
-CONFIG_UDHCPC_DEFAULT_SCRIPT=""
-CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=0
-CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS=""
-CONFIG_UDPSVD=y
+CONFIG_UDHCPC=y
+CONFIG_FEATURE_UDHCPC_ARPING=y
+CONFIG_FEATURE_UDHCP_PORT=y
+CONFIG_UDHCP_DEBUG=9
+CONFIG_FEATURE_UDHCP_RFC3397=y
+CONFIG_FEATURE_UDHCP_8021Q=y
+CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
+CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
+CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n"
+# CONFIG_UDPSVD is not set
 # CONFIG_VCONFIG is not set
 CONFIG_WGET=y
 CONFIG_FEATURE_WGET_STATUSBAR=y
@@ -846,44 +841,46 @@
 #
 # Print Utilities
 #
-CONFIG_LPD=y
-CONFIG_LPR=y
-CONFIG_LPQ=y
+# CONFIG_LPD is not set
+# CONFIG_LPR is not set
+# CONFIG_LPQ is not set
 
 #
 # Mail Utilities
 #
-CONFIG_MAKEMIME=y
-CONFIG_FEATURE_MIME_CHARSET="us-ascii"
-CONFIG_POPMAILDIR=y
-CONFIG_FEATURE_POPMAILDIR_DELIVERY=y
-CONFIG_REFORMIME=y
-CONFIG_FEATURE_REFORMIME_COMPAT=y
-CONFIG_SENDMAIL=y
+# CONFIG_MAKEMIME is not set
+CONFIG_FEATURE_MIME_CHARSET=""
+# CONFIG_POPMAILDIR is not set
+# CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set
+# CONFIG_REFORMIME is not set
+# CONFIG_FEATURE_REFORMIME_COMPAT is not set
+# CONFIG_SENDMAIL is not set
 
 #
 # Process Utilities
 #
-CONFIG_IOSTAT=y
-CONFIG_MPSTAT=y
-CONFIG_NMETER=y
+# CONFIG_IOSTAT is not set
+# CONFIG_LSOF is not set
+# CONFIG_MPSTAT is not set
+# CONFIG_NMETER is not set
 # CONFIG_PMAP is not set
 # CONFIG_POWERTOP is not set
-CONFIG_PSTREE=y
-CONFIG_PWDX=y
-CONFIG_SMEMCAP=y
+# CONFIG_PSTREE is not set
+# CONFIG_PWDX is not set
+# CONFIG_SMEMCAP is not set
 # CONFIG_FREE is not set
 CONFIG_FUSER=y
 CONFIG_KILL=y
 CONFIG_KILLALL=y
-CONFIG_KILLALL5=y
-CONFIG_PGREP=y
+# CONFIG_KILLALL5 is not set
+# CONFIG_PGREP is not set
 CONFIG_PIDOF=y
-CONFIG_FEATURE_PIDOF_SINGLE=y
-CONFIG_FEATURE_PIDOF_OMIT=y
-CONFIG_PKILL=y
+# CONFIG_FEATURE_PIDOF_SINGLE is not set
+# CONFIG_FEATURE_PIDOF_OMIT is not set
+# CONFIG_PKILL is not set
 CONFIG_PS=y
 CONFIG_FEATURE_PS_WIDE=y
+CONFIG_FEATURE_PS_LONG=y
 # CONFIG_FEATURE_PS_TIME is not set
 CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y
 # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
@@ -897,23 +894,23 @@
 CONFIG_FEATURE_TOP_SMP_PROCESS=y
 CONFIG_FEATURE_TOPMEM=y
 # CONFIG_FEATURE_SHOW_THREADS is not set
-# CONFIG_UPTIME is not set
-CONFIG_WATCH=y
+CONFIG_UPTIME=y
+# CONFIG_WATCH is not set
 
 #
 # Runit Utilities
 #
-CONFIG_RUNSV=y
-CONFIG_RUNSVDIR=y
+# CONFIG_RUNSV is not set
+# CONFIG_RUNSVDIR is not set
 # CONFIG_FEATURE_RUNSVDIR_LOG is not set
-CONFIG_SV=y
-CONFIG_SV_DEFAULT_SERVICE_DIR="/var/service"
-CONFIG_SVLOGD=y
-CONFIG_CHPST=y
-CONFIG_SETUIDGID=y
-CONFIG_ENVUIDGID=y
-CONFIG_ENVDIR=y
-CONFIG_SOFTLIMIT=y
+# CONFIG_SV is not set
+CONFIG_SV_DEFAULT_SERVICE_DIR=""
+# CONFIG_SVLOGD is not set
+# CONFIG_CHPST is not set
+# CONFIG_SETUIDGID is not set
+# CONFIG_ENVUIDGID is not set
+# CONFIG_ENVDIR is not set
+# CONFIG_SOFTLIMIT is not set
 # CONFIG_CHCON is not set
 # CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
 # CONFIG_GETENFORCE is not set
@@ -945,7 +942,7 @@
 CONFIG_ASH_CMDCMD=y
 # CONFIG_ASH_MAIL is not set
 CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
-CONFIG_ASH_RANDOM_SUPPORT=y
+# CONFIG_ASH_RANDOM_SUPPORT is not set
 CONFIG_ASH_EXPAND_PRMT=y
 # CONFIG_CTTYHACK is not set
 CONFIG_HUSH=y
@@ -969,10 +966,10 @@
 # CONFIG_FEATURE_SH_IS_HUSH is not set
 # CONFIG_FEATURE_SH_IS_NONE is not set
 # CONFIG_FEATURE_BASH_IS_ASH is not set
-# CONFIG_FEATURE_BASH_IS_HUSH is not set
-CONFIG_FEATURE_BASH_IS_NONE=y
+CONFIG_FEATURE_BASH_IS_HUSH=y
+# CONFIG_FEATURE_BASH_IS_NONE is not set
 CONFIG_SH_MATH_SUPPORT=y
-CONFIG_SH_MATH_SUPPORT_64=y
+# CONFIG_SH_MATH_SUPPORT_64 is not set
 CONFIG_FEATURE_SH_EXTRA_QUIET=y
 # CONFIG_FEATURE_SH_STANDALONE is not set
 # CONFIG_FEATURE_SH_NOFORK is not set

 

編譯以及安裝 Busybox
 

我們的 Target rootfs 我把它放在 unpacked-rootfs 資料夾. 

 

1. 產生 Target rootfs 相關資目錄, 如 usr/share/udhcpc . 

rm -rf ${PROJDIR}/unpacked-rootfs/*
mkdir -p ${PROJDIR}/unpacked-rootfs
cd ${PROJDIR}/unpacked-rootfs
mkdir -p bin boot dev etc home lib lost+found mnt opt private proc root sbin sys tmp usr var
cd ${PROJDIR}/unpacked-rootfs/etc/
mkdir -p init.d rc.d sysconfig
cd ${PROJDIR}/unpacked-rootfs/usr/
mkdir -p bin lib sbin share
cd ${PROJDIR}/unpacked-rootfs/usr/share/
mkdir -p alsa udhcpc zoneinfo
cd ${PROJDIR}/unpacked-rootfs/var/
mkdir -p run lib log spool/cron
mkdir -p ${PROJDIR}/unpacked-rootfs/proc/self/exe ${PROJDIR}/unpacked-rootfs/lib/modules

 

2. 以 arm9_defconfig 編譯以及安裝 busybox 至 unpacked-rootfs 目錄

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -C busybox arm9_defconfig all
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -C busybox install
[ ! -f busybox/_install/bin/busybox ] && exit 3
sudo rm -rvf ${PROJDIR}/unpacked-rootfs/bin/*
sudo rm -rvf ${PROJDIR}/unpacked-rootfs/sbin/*
/bin/cp -av ${PROJDIR}/busybox/_install/* unpacked-rootfs/

 

安裝 Alsa-lib (Libasound.so)

 

1. Fetch Alsa-lib 原始碼 

git clone git://git.alsa-project.org/alsa-lib.git

 

2. 編譯以及安裝, STRIP並拷貝 libasound*.so* 至 unpacked-rootfs/lib/

cd ${PROJDIR}/alsa-lib ; ./gitcompile || true
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O3 -pipe" \
./configure --host=arm-linux-gnueabi --prefix=/ \
--disable-python --disable-python2 \
--disable-aload --disable-mixer-pymods \
--disable-ucm --disable-topology --disable-rawmidi --disable-seq
sudo make clean
make V=1
cd ${PROJDIR}/alsa-lib/src/.libs/ ; arm-linux-gnueabi-strip libasound.so.2.0.0
cd ${PROJDIR}/alsa-lib
sudo make V=1 DESTDIR=/usr/arm-linux-gnueabi install
sudo rm -rf ${PROJDIR}/unpacked-rootfs/usr/share/alsa/*
sudo /bin/cp -Rpf /usr/arm-linux-gnueabi/share/alsa/* ${PROJDIR}/unpacked-rootfs/usr/share/alsa/
sudo chown -R `whoami`.`whoami` ${PROJDIR}/unpacked-rootfs/usr/share/alsa/
/bin/cp -Rpf ${PROJDIR}/alsa-lib/src/.libs/libasound.so* ${PROJDIR}/unpacked-rootfs/usr/lib/

 

安裝 SDL

 

1. Fetch SDL 原始碼 

git clone https://github.com/vanfanel/SDL-1.2.15-raspberrypi

 

2. 安裝

cd ${PROJDIR}
cat > ${PROJDIR}/patches/SDL_blit_N.c.patch << "EOF"
diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c
index f10733e..9deb6b8 100644
--- a/src/video/SDL_blit_N.c    2012-01-19 14:30:06.000000000 +0800
+++ b/src/video/SDL_blit_N.c    2017-11-20 16:50:05.997531150 +0800
@@ -2031,6 +2031,32 @@
     }
 }
 
+
+//Brian add
+#define YUVPIXEL(Y,Cb,Cr) (((Y)<<24)|((Y)<<8)|((Cr)<<16)|(Cb))
+u_int32_t RGB2YUV(unsigned char R,unsigned char G,unsigned char B)
+{
+  unsigned char Y,Cb,Cr;
+
+  Y  =  ((67316*R)>>18)  + ((132154*G)>>18) + ((25666*B)>>18)  + 16;
+  Cr =  ((115138*R)>>18) - ((96414*G)>>18)  - ((18724*B)>>18)  + 128;
+  Cb = -((38856*R)>>18)  - ((76282*G)>>18)  + ((115138*B)>>18) + 128;
+
+  // Done
+  return(YUVPIXEL(Y,Cb,Cr));
+}
+u_int32_t YUVTable[65536];
+int isYUVinit = 0;
+static void initYUVTable(void)
+{
+    int i;
+    for (i=0; i<65536; i++) {
+        YUVTable[i] = RGB2YUV((i>>11)<<3, ((i>>5)&0x3f)<<2, (i&0x1f)<<3);
+    }
+    isYUVinit = 1;
+}
+
+
 static void BlitNtoN(SDL_BlitInfo *info)
 {
     int width = info->d_width;
@@ -2045,6 +2071,9 @@
     int dstbpp = dstfmt->BytesPerPixel;
     unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0;
 
+    if (!isYUVinit) {
+        initYUVTable();
+    }
     while ( height-- ) {
         DUFFS_LOOP(
         {
@@ -2052,8 +2081,11 @@
             unsigned sR;
             unsigned sG;
             unsigned sB;
-            DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
-            ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
+            //DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
+            //ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
+            //*((Uint32 *)(dst))  = RGB2YUV(sR, sG, sB);
+            *((Uint32 *)(dst)) = YUVTable[*((Uint16 *)(src))];
+            
             dst += dstbpp;
             src += srcbpp;
         },
EOF
cat > ${PROJDIR}/patches/SDL_alsa_audio.c.patch << "EOF"
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index f10733e..9deb6b8 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -520,10 +520,10 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
                 format = SND_PCM_FORMAT_U16_BE;
                 break;
             default:
-                format = 0;
+                format = SND_PCM_FORMAT_UNKNOWN;
                 break;
         }
-        if ( format != 0 ) {
+        if ( format != SND_PCM_FORMAT_UNKNOWN ) {
             status = SDL_NAME(snd_pcm_hw_params_set_format)(pcm_handle, hwparams, format);
         }
         if ( status < 0 ) {
                if ( status < 0 ) {
EOF
cat > ${PROJDIR}/patches/SDL_systhread.c.patch << "EOF"
diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c
index f10733e..9deb6b8 100644
--- a/src/thread/pthread/SDL_systhread.c    2012-01-19 14:30:06.000000000 +0800
+++ b/src/thread/pthread/SDL_systhread.c    2017-11-20 18:37:11.427399387 +0800
@@ -58,6 +58,8 @@
         SDL_SetError("Couldn't initialize pthread attributes");
         return(-1);
     }
+    
+    pthread_attr_setstacksize(&type, 20480);
     pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
 
     /* Create the thread and go! */
EOF

############################################################
# SDL-1.2.15-raspberrypi
cd ${PROJDIR}
[ ! -d SDL-1.2.15-raspberrypi ] && git clone https://github.com/vanfanel/SDL-1.2.15-raspberrypi
cd ${PROJDIR}/SDL-1.2.15-raspberrypi
git checkout ./src/audio/alsa/SDL_alsa_audio.c
git apply --reject --whitespace=fix ${PROJDIR}/patches/SDL_alsa_audio.c.patch
git checkout src/thread/pthread/SDL_systhread.c
git apply --reject --whitespace=fix ${PROJDIR}/patches/SDL_systhread.c.patch
git checkout src/video/SDL_blit_N.c
git apply --reject --whitespace=fix ${PROJDIR}/patches/SDL_blit_N.c.patch
cd ${PROJDIR}/SDL-1.2.15-raspberrypi/
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O2 -pipe" \
./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi --enable-alsa=yes --enable-input-tslib=yes \
--disable-esd --disable-pulseaudio --disable-arts --disable-nas --disable-diskaudio --disable-nasm \
--disable-altivec --disable-video-directfb --disable-video-opengl --disable-video-opengles2 \
--disable-video-x11-dgamouse --disable-video-x11 --disable-video-dga \
--enable-input-tslib=yes \
--with-alsa-prefix=/usr/arm-linux-gnueabi/lib --with-alsa-inc-prefix=/usr/arm-linux-gnueabi/include
sudo make clean && make
cd ${PROJDIR}/SDL-1.2.15-raspberrypi/build/.libs/
arm-linux-gnueabi-strip libSDL-1.2.so.0.11.4
cd ${PROJDIR}/SDL-1.2.15-raspberrypi
sudo make install
/bin/cp -Rpf ${PROJDIR}/SDL-1.2.15-raspberrypi/build/.libs/libSDL-1.2.so* ${PROJDIR}/unpacked-rootfs/usr/lib/

 

產生 share/udhcpc/default.script

 

$ wget https://raw.githubusercontent.com/mschlenker/TinyCrossLinux/master/patches/usr-share-udhcpc-default.script
$ sudo /bin/mv usr-share-udhcpc-default.script unpacked-rootfs/usr/share/udhcpc/default.script

 

產生 etc/hostname , etc/host.conf , etc/resolv.conf , etc/hosts , etc/passwd , etc/group

 

cd ${PROJDIR}
touch unpacked-rootfs/bin/start_getty
chmod 777 unpacked-rootfs/bin/start_getty
echo '#!/bin/sh' > unpacked-rootfs/bin/start_getty ; sudo echo '' >> ${PROJDIR}/unpacked-rootfs/bin/start_getty ; echo '[ -c /dev/$2 ] && /sbin/getty -L $1 $2 $3' >> ${PROJDIR}/unpacked-rootfs/bin/start_getty
echo mk3 > unpacked-rootfs/etc/hostname
echo 'order hosts,bind' > unpacked-rootfs/etc/host.conf ; echo 'multi on' >> unpacked-rootfs/etc/host.conf ; echo 'nameserver    168.95.1.1' > unpacked-rootfs/etc/resolv.conf
echo '127.0.0.1        localhost' > unpacked-rootfs/etc/hosts ; echo '127.0.0.1        mk3' >> unpacked-rootfs/etc/hosts
sudo rm -rf unpacked-rootfs/etc/passwd unpacked-rootfs/etc/group
sudo echo root::0:0:root:/root:/bin/bash > unpacked-rootfs/etc/passwd ; sudo chmod 644 unpacked-rootfs/etc/passwd && sudo chown root.root unpacked-rootfs/etc/passwd
sudo echo root::0: > unpacked-rootfs/etc/group ; sudo chmod 644 unpacked-rootfs/etc/group && sudo chown root.root unpacked-rootfs/etc/group
echo '/bin/sh' > unpacked-rootfs/etc/shells ; echo '/bin/ash' >> unpacked-rootfs/etc/shells ; echo '/bin/hush' >> unpacked-rootfs/etc/shells
/bin/cp -f /etc/services unpacked-rootfs/etc/services

 

產生 etc/fstab /etc/rc.local

 

cd ${PROJDIR}
cat > ${PROJDIR}/unpacked-rootfs/etc/fstab << "EOF"
none                    /proc                            proc    defaults                0 0
none                    /sys                            sysfs    defaults                0 0
tmpfs                    /tmp                            tmpfs    defaults                0 0
tmpfs                    /dev                            tmpfs    defaults                0 0
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/rc.local << "EOF"
#!/bin/bash
source /etc/rc.d/rc.conf
EOF

 

產生 etc/profile

 

Target 系統的 SHELL 顯示是: root@mk3:~#

這與PS1 環境變數有關係. 並且它的正常作用與否, 與 libnss*.so* 以及 libnsl*.so* 存在有關. 因此我們之前把它們拷貝至 unpacked-rootfs/lib/ 目錄. 

 

# busybox whoami
# error: unknown uid 0

當 Target 系統的 `whoami` 出現錯誤訊息 unknown uid 0 時, 這也與 libnss*.so* 以及 libnsl*.so* 存在有關. 把它們拷貝至 target 系統, 問題就解決了. 

 

cat > ${PROJDIR}/unpacked-rootfs/etc/profile << "EOF"
source /etc/rc.d/rc.conf
hostname -F /etc/hostname
export PS1='\u@\h:\w$ '
[ `id -u` -eq 0 ] && export PS1='\u@\h:\w# '
[ `id -u` -eq 0 ] && export HOME=/root
[ `id -u` -eq 0 ] && cd /root
export TZ=Asia/Taipei
export LC_ALL=C
echo -ne "\33[9;0]" > /dev/tty0
echo -ne "\033[?25l" > /dev/tty0
EOF

 

產生 etc/init.d/rcS

 

cd ${PROJDIR}
echo '#!/bin/sh' > unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'mount -a' >> unpacked-rootfs/etc/init.d/rcS ; echo 'mount -n -o remount ro /' >> unpacked-rootfs/etc/init.d/rcS
echo 'echo /sbin/mdev > /proc/sys/kernel/hotplug' >> unpacked-rootfs/etc/init.d/rcS ; echo 'mdev -s' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'hostname -F /etc/hostname' >> unpacked-rootfs/etc/init.d/rcS
echo 'ip addr add 127.0.0.1/8 dev lo' >> unpacked-rootfs/etc/init.d/rcS ; echo 'ip link set lo up' >> unpacked-rootfs/etc/init.d/rcS
echo '' >> unpacked-rootfs/etc/init.d/rcS
echo '[ -x /etc/rc.d/rc.conf ] && . /etc/rc.d/rc.conf' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'mode=${1:-start}' >> unpacked-rootfs/etc/init.d/rcS
echo 'if [ $mode = "start" ]; then services=$cfg_services ; else services=$cfg_services_r ; fi' >> unpacked-rootfs/etc/init.d/rcS
echo 'cfg_services=${2:-$services}' >> unpacked-rootfs/etc/init.d/rcS
echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'for i in $cfg_services ; do [ -x /etc/rc.d/init.d/$i ] && /etc/rc.d/init.d/$i $mode ; done' >> unpacked-rootfs/etc/init.d/rcS
echo '[ $# -ge 2 ] && exit 0' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'echo 8 >  /proc/sys/kernel/printk' >> unpacked-rootfs/etc/init.d/rcS
echo '[ -x /etc/rc.local ] && /etc/rc.local $mode' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
chmod 777 unpacked-rootfs/etc/init.d/rcS

 

產生 etc/inittab

 

如果你的 TARGET_SERIAL_CONSOL 與筆者不一致 , 請自行 export 出來 (eg: ttyAMA0, ttyS0) . 

 

cd ${PROJDIR}
echo '::sysinit:/etc/init.d/rcS' > unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo '::restart:/sbin/init' >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo '::ctrlaltdel:/sbin/reboot' >> unpacked-rootfs/etc/inittab
echo '::shutdown:/etc/shutdown' >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo "${TARGET_SERIAL_CONSOL}::respawn:-/bin/sh" >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo "#${TARGET_SERIAL_CONSOL}::respawn:/bin/start_getty 115200 ${TARGET_SERIAL_CONSOL} vt102" >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo 'tty1::respawn:/sbin/getty 38400 tty1' >> ${PROJDIR}/unpacked-rootfs/etc/inittab ; echo '' >> ${PROJDIR}/unpacked-rootfs/etc/inittab

 

產生 etc/rc.d/rc.conf

 

cd ${PROJDIR}
mkdir -p ${PROJDIR}/unpacked-rootfs/etc/rc.d
cat > ${PROJDIR}/unpacked-rootfs/etc/rc.d/rc.conf << "EOF"
cfg_services="mount-proc-sys udev hostname depmod modules filesystems inetd "
cfg_services_r=" inetd filesystems modules depmod hostname udev mount-proc-sys"
export HOSTNAME=`cat /etc/hostname`
export TMPFS=tmpfs
export LD_LIBRARY_PATH=/usr/lib:/lib ; export SDL_NOMOUSE=1 ; export ALSA_CONFIG_PATH=/usr/share/alsa/alsa.conf
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/profile << "EOF"
source /etc/rc.d/rc.conf
hostname -F /etc/hostname
export PS1='\u@\h:\w$ '
[ `id -u` -eq 0 ] && export PS1='\u@\h:\w# '
[ `id -u` -eq 0 ] && export HOME=/root
[ `id -u` -eq 0 ] && cd /root
export TZ=Asia/Taipei
export LC_ALL=C
echo -ne "\33[9;0]" > /dev/tty0
echo -ne "\033[?25l" > /dev/tty0
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/shutdown << "EOF"
#!/bin/sh
true
EOF
cat > ${PROJDIR}/unpacked-rootfs/init << "EOF"
#!/bin/sh
/bin/mount proc /proc -t proc
/bin/mount sysfs /sys -t sysfs
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
exec switch_root /mnt /sbin/init
EOF
chmod 777 unpacked-rootfs/etc/rc.d/rc.conf unpacked-rootfs/etc/profile unpacked-rootfs/etc/shutdown unpacked-rootfs/init ${PROJDIR}/unpacked-rootfs/etc/rc.local

 

產生 /etc/asound.conf

 

cd ${PROJDIR}
mkdir -p ${PROJDIR}/unpacked-rootfs/usr/share/alsa
sudo /bin/cp -Rpf /usr/arm-linux-gnueabi/share/alsa/* ${PROJDIR}/unpacked-rootfs/usr/share/alsa/ ; sudo chown `whoami`.`whoami` -R ${PROJDIR}/unpacked-rootfs/usr/share/alsa/
cat > ${PROJDIR}/unpacked-rootfs/etc/asound.conf << "EOF"
pcm.!default {
    type hw
    card 0
}
ctl.!default {
    type hw
    card 0
}
EOF

 

產生 Squashfs 之 rootfs 二進位檔案 (Binary)

 

cd ${PROJDIR}
sudo mksquashfs unpacked-rootfs rootfs.img
/bin/mv -f rootfs.img ${PROJDIR}/out/
sudo chown `whoami`.`whoami` -R ${PROJDIR}/out

# system.bin
[ ! -f out/u-boot.bin ] && exit 0
[ ! -f out/mk3-evb.dtb ] && exit 0
[ ! -f out/uImage ] && exit 0
[ ! -f out/rootfs.img ] && exit 0
sudo /bin/rm -rf out/system.bin
dd if=/dev/zero of=out/system.bin bs=1 count=4M
dd if=out/u-boot.bin of=out/system.bin conv=notrunc bs=1
dd if=out/mk3-evb.dtb of=out/system.bin conv=notrunc bs=1 seek=256K
dd if=out/uImage of=out/system.bin conv=notrunc bs=1 seek=320K
dd if=out/rootfs.img of=out/system.bin conv=notrunc bs=1 seek=2176K

 

這樣就大功告成了; 檔案 out/rootfs.img 就是我們所要的. 

 

 

把所有的東西放在一起

 

現在把所有的東西放在一起: 

 

 

bin/mk-rootfs.sh
#!/bin/bash -e

[ ! -f bin/mk-rootfs.sh ] && exit 1

############################################################
# CROSS_COMPILE
if [ ! -f /usr/bin/arm-linux-gnueabi-gcc ]; then
    echo 'CROSS_COMPILE arm-linux-gnueabi-gcc unavailable'
    echo 'TRY: sudo apt-get install -y g++-5-arm-linux-gnueabi gcc-5-arm-linux-gnueabi libstdc++-5-dev-armel-cross linux-libc-dev-armel-cross libc6-dev-armel-cross gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libncurses5-dev'
    exit 1
fi
if [ ! -f /usr/arm-linux-gnueabi.tgz ]; then
    echo 'backup the "/usr/arm-linux-gnueabi" first'
    echo 'TRY: sudo tar zcvf /usr/arm-linux-gnueabi.tgz -C /usr arm-linux-gnueabi'
    exit 1
fi

############################################################
# PROJDIR
PROJDIR=`pwd`
TARGET_SERIAL_CONSOL=ttyMK0
[ -f /etc/ld.so.conf ] && sudo touch /etc/ld.so.conf && sudo ldconfig -v

############################################################
# Test arm-linux-gnueabi-as arm-linux-gnueabi-ld
cd ${PROJDIR}
cat > ${PROJDIR}/prebuild/hello.s << "EOF"
.data

msg:
.ascii "Hello, ARM World!\n"
len = . - msg

.text

.globl _start
_start:
/* write syscall */
mov %r0, $1
ldr %r1, =msg
ldr %r2, =len
mov %r7, $4
swi $0

/* exit syscall */
mov %r0, $0
mov %r7, $1
swi $0
EOF
cd ${PROJDIR}/prebuild
arm-linux-gnueabi-as -o hello.o hello.s
arm-linux-gnueabi-ld -o hello hello.o
# ${PROJDIR}/prebuild/hello

############################################################
# u-boot
cd ${PROJDIR}
if [ -d mk_uboot ]; then
    make CROSS_COMPILE=arm-linux-gnueabi- -C mk_uboot mk3_evb_defconfig u-boot.bin
    /bin/cp -Rpf mk_uboot/u-boot.bin out/
fi

############################################################
# kernel, dtb
cd ${PROJDIR}
if [ -d mk_linux ]; then
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- LOADADDR=18000000 -C mk_linux mk3_defconfig uImage mk3-evb.dtb
    nm mk_linux/vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > mk_linux/System.map
    /bin/cp -Rpf mk_linux/arch/arm/boot/uImage out/ && /bin/cp -Rpf mk_linux/arch/arm/boot/dts/mk3-evb.dtb out/
fi

############################################################
# Basic directory
rm -rf ${PROJDIR}/unpacked-rootfs/*
mkdir -p ${PROJDIR}/unpacked-rootfs
cd ${PROJDIR}/unpacked-rootfs
mkdir -p bin boot dev etc home lib lost+found mnt opt private proc root sbin sys tmp usr var
cd ${PROJDIR}/unpacked-rootfs/etc/
mkdir -p init.d rc.d sysconfig
cd ${PROJDIR}/unpacked-rootfs/usr/
mkdir -p bin lib sbin share
cd ${PROJDIR}/unpacked-rootfs/usr/share/
mkdir -p alsa udhcpc zoneinfo
cd ${PROJDIR}/unpacked-rootfs/var/
mkdir -p run lib log spool/cron
mkdir -p ${PROJDIR}/unpacked-rootfs/proc/self/exe ${PROJDIR}/unpacked-rootfs/lib/modules

############################################################
# busybox with arm9_defconfig
cd ${PROJDIR}
[ ! -d busybox ] && git clone https://git.busybox.net/busybox/
cd ${PROJDIR}/busybox/
git branch -a
git checkout remotes/origin/1_24_stable
sudo rm -rf ${PROJDIR}/busybox/_install/
cd ${PROJDIR}
# diff -uN configs/cygwin_defconfig configs/arm9_defconfig > ../patches/arm9_defconfig.patch
patch -d busybox --verbose configs/cygwin_defconfig --ignore-whitespace -i ../patches/arm9_defconfig.patch --dry-run || exit 2
patch -d busybox --verbose configs/cygwin_defconfig --ignore-whitespace-i ../patches/arm9_defconfig.patch -o configs/arm9_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -C busybox arm9_defconfig all
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -C busybox install
[ ! -f busybox/_install/bin/busybox ] && exit 3
sudo rm -rvf ${PROJDIR}/unpacked-rootfs/bin/*
sudo rm -rvf ${PROJDIR}/unpacked-rootfs/sbin/*
/bin/cp -av ${PROJDIR}/busybox/_install/* unpacked-rootfs/

############################################################
# zlib
cd ${PROJDIR}
rm -rf ${PROJDIR}/unpacked-rootfs/lib/libz.so.1.2.11 ${PROJDIR}/unpacked-rootfs/lib/libz.so.1.2.8
rm -rf ${PROJDIR}/unpacked-rootfs/lib/usr/libz.so.1.2.11 ${PROJDIR}/unpacked-rootfs/usr/lib/libz.so.1.2.8
[ ! -d zlib ] && git clone https://github.com/madler/zlib
cd ${PROJDIR}/zlib/
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O3 -pipe" \
CC=arm-linux-gnueabi-gcc ./configure --prefix=/
make
arm-linux-gnueabi-strip libz.so.1.2.11
sudo make DESTDIR=/usr/arm-linux-gnueabi install
/bin/cp -Rpf libz.so* ${PROJDIR}/unpacked-rootfs/usr/lib/

############################################################
# ...
cd ${PROJDIR}
rm -rf ${PROJDIR}/unpacked-rootfs/lib/libpng12.so.0.50.0 ${PROJDIR}/unpacked-rootfs/lib/libpng.so.3.50.0
rm -rf ${PROJDIR}/unpacked-rootfs/lib/libpng12.so.0.59.0 ${PROJDIR}/unpacked-rootfs/lib/libpng.so.3.59.0
rm -rf ${PROJDIR}/unpacked-rootfs/usr/lib/libpng12.so.0.50.0 ${PROJDIR}/unpacked-rootfs/usr/lib/libpng.so.3.50.0
rm -rf ${PROJDIR}/unpacked-rootfs/usr/lib/libpng12.so.0.59.0 ${PROJDIR}/unpacked-rootfs/usr/lib/libpng.so.3.59.0

############################################################
# libpng
cd ${PROJDIR}
[ ! -f libpng-1.2.50.tar.gz ] && wget http://78.108.103.11/MIRROR/ftp/png/src/history/libpng12/libpng-1.2.50.tar.gz
tar zxvf libpng-1.2.50.tar.gz
cd ${PROJDIR}/libpng-1.2.50
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O3 -pipe" \
./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi
sudo make clean && make
cd ${PROJDIR}/libpng-1.2.50/.libs && arm-linux-gnueabi-strip libpng12.so.0.50.0 libpng.so.3.50.0
/bin/cp -Rpf libpng*.so* ${PROJDIR}/unpacked-rootfs/usr/lib/
cd ${PROJDIR}/libpng-1.2.50
### Avoid multiple versions of linpng
sudo rm -rvf /usr/arm-linux-gnueabi/lib/libpng*
sudo make install

############################################################
# ncurses
cd ${PROJDIR}
[ ! -d ncurses ] && git clone https://github.com/mirror/ncurses
cd ${PROJDIR}/ncurses/
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O3 -pipe" \
./configure --prefix=/usr/arm-linux-gnueabi --host=arm-linux-gnueabi --without-ada --without-progs \
--with-cxx-shared --with-shared --without-normal --disable-widec --enable-symlinks \
--disable-db-install --with-termlib=no
sudo make V=1 uninstall
sudo make V=1 clean ; make V=1
cd ${PROJDIR}/ncurses/lib/
for SO in `find . -mindepth 1 ! -type l -name "*.so"`; do if [ "$SO" != "./libc.so" -a "$SO" != "./libpthread.so" ]; then arm-linux-gnueabi-strip $SO; fi ; done
cd ${PROJDIR}/ncurses/
sudo make V=1 install
/bin/cp -Rpf ${PROJDIR}/ncurses/lib/libform.so* ${PROJDIR}/unpacked-rootfs/usr/lib/
/bin/cp -Rpf ${PROJDIR}/ncurses/lib/libmenu.so* ${PROJDIR}/unpacked-rootfs/usr/lib/
/bin/cp -Rpf ${PROJDIR}/ncurses/lib/libpanel.so* ${PROJDIR}/unpacked-rootfs/usr/lib/
/bin/cp -Rpf ${PROJDIR}/ncurses/lib/libtinfo.so* ${PROJDIR}/unpacked-rootfs/usr/lib/ || true
/bin/cp -Rpf ${PROJDIR}/ncurses/lib/libncurses.so* ${PROJDIR}/unpacked-rootfs/usr/lib/
/bin/cp -Rpf ${PROJDIR}/ncurses/lib/libncurses++.so* ${PROJDIR}/unpacked-rootfs/usr/lib/

############################################################
# alsa-lib
cd ${PROJDIR}
[ ! -d alsa-lib ] && git clone git://git.alsa-project.org/alsa-lib.git
cd ${PROJDIR}/alsa-lib ; ./gitcompile || true
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O3 -pipe" \
./configure --host=arm-linux-gnueabi --prefix=/ \
--disable-python --disable-python2 \
--disable-aload --disable-mixer-pymods \
--disable-ucm --disable-topology --disable-rawmidi --disable-seq
sudo make clean
make V=1
cd ${PROJDIR}/alsa-lib/src/.libs/ ; arm-linux-gnueabi-strip libasound.so.2.0.0
cd ${PROJDIR}/alsa-lib
sudo make V=1 DESTDIR=/usr/arm-linux-gnueabi install
sudo rm -rf ${PROJDIR}/unpacked-rootfs/usr/share/alsa/*
sudo /bin/cp -Rpf /usr/arm-linux-gnueabi/share/alsa/* ${PROJDIR}/unpacked-rootfs/usr/share/alsa/
sudo chown -R `whoami`.`whoami` ${PROJDIR}/unpacked-rootfs/usr/share/alsa/
/bin/cp -Rpf ${PROJDIR}/alsa-lib/src/.libs/libasound.so* ${PROJDIR}/unpacked-rootfs/usr/lib/

############################################################
# alsa-utils, for the first time, Press Return to acknowledge the previous three paragraphs.
cd ${PROJDIR}
[ ! -d alsa-utils ] && git clone git://git.alsa-project.org/alsa-utils.git
cd ${PROJDIR}/alsa-utils
[ ! -f ./configure ] && GITCOMPILE_NO_MAKE=1 ./gitcompile
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O3 -pipe" \
./configure --host=arm-linux-gnueabi --prefix=${PROJDIR}/unpacked-rootfs/usr \
--enable-alsaconf --disable-rst2man --disable-xmlto --with-curses=ncurses \
--disable-alsamixer \
--with-alsa-prefix=/usr/arm-linux-gnueabi/lib --with-alsa-inc-prefix=/usr/arm-linux-gnueabi/include
cd ${PROJDIR}
#make -C ${PROJDIR}/alsa-utils/ || true
make -C ${PROJDIR}/alsa-utils/include
make -C ${PROJDIR}/alsa-utils/aplay clean all install
make -C ${PROJDIR}/alsa-utils/amixer  clean all all
make -C ${PROJDIR}/alsa-utils/speaker-test clean all
rm -rf ${PROJDIR}/unpacked-rootfs/usr/share/man/

############################################################
# glibc
sudo rm -rf ${PROJDIR}/foo
cd ${PROJDIR}
[ ! -d glibc ] && git clone git://sourceware.org/git/glibc.git
cd ${PROJDIR}/glibc/
git branch -a
git checkout remotes/origin/release/2.23/master
mkdir -p ${PROJDIR}/glibc-build
cd ${PROJDIR}/glibc-build
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O2 -pipe" \
../glibc/configure --prefix=/ --host=arm-linux-gnueabi --enable-profile \
--disable-nscd --disable-build-nscd --enable-multi-arch
sudo chown -R `whoami`.`whoami` ${PROJDIR}/glibc-build
make DESTDIR=${PROJDIR}/foo ; make DESTDIR=${PROJDIR}/foo install
cd ${PROJDIR}/foo/sbin/
arm-linux-gnueabi-strip iconvconfig ldconfig sln zdump zic
/bin/cp -av ${PROJDIR}/foo/sbin/ldconfig ${PROJDIR}/unpacked-rootfs/sbin/
cd ${PROJDIR}/foo/lib/
for SO in `find . -mindepth 1 ! -type l -name "*.so"`; do if [ "$SO" != "./libc.so" -a "$SO" != "./libpthread.so" ]; then arm-linux-gnueabi-strip $SO; fi ; done
LIBC_PATH=${PROJDIR}/foo/lib
/bin/cp -av ${LIBC_PATH}/libdl*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/ld-*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libc*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libm*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/lib*thread*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/librt*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libpcprofile*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libnss*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libnsl*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libutil*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libSegFault*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libresolv*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libthread_db*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libBrokenLocale*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libanl*.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -av ${LIBC_PATH}/libcidn*.so* ${PROJDIR}/unpacked-rootfs/lib/

############################################################
# /usr/arm-linux-gnueabi/lib/libgcc_s.so*
/bin/cp -av /usr/arm-linux-gnueabi/lib/libgcc_s.so* ${PROJDIR}/unpacked-rootfs/lib/

############################################################
# lrzsz
cd ${PROJDIR}
[ ! -d lrzsz ] && git clone https://github.com/jnavila/lrzsz
cd ${PROJDIR}/lrzsz/
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O2 -pipe" \
CC="arm-linux-gnueabi-gcc" ./configure --disable-nls --disable-werror
sudo make clean && make
cd src && arm-linux-gnueabi-strip lrz && arm-linux-gnueabi-strip lsz && cd ..
cd ${PROJDIR}
/bin/cp -Rpf ${PROJDIR}/lrzsz/src/lrz ${PROJDIR}/unpacked-rootfs/usr/bin/
/bin/cp -Rpf ${PROJDIR}/lrzsz/src/lsz ${PROJDIR}/unpacked-rootfs/usr/bin/

############################################################
# tslib
cd ${PROJDIR}
[ ! -d tslib ] && git clone  https://github.com/kergoth/tslib
cd ${PROJDIR}/tslib
./autogen.sh
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O2 -pipe" ./configure --host=arm-linux-gnueabi --prefix=/
sudo make V=1 clean
make V=1
cd ${PROJDIR}/tslib/src/.libs/
arm-linux-gnueabi-strip libts.so.0.10.0
/bin/cp -Rpf ${PROJDIR}/tslib/src/.libs/libts.so* ${PROJDIR}/unpacked-rootfs/lib/
cd ${PROJDIR}/tslib/plugins/.libs/
arm-linux-gnueabi-strip debounce.so dejitter.so iir.so input.so invert.so linear.so lowpass.so median.so pthres.so skip.so touchkit.so variance.so waveshare.so
cd ${PROJDIR}/tslib
sudo make V=1 DESTDIR=/usr/arm-linux-gnueabi install
/bin/cp -fv /usr/arm-linux-gnueabi/etc/ts.conf ${PROJDIR}/unpacked-rootfs/etc/
/bin/cp -fv /usr/arm-linux-gnueabi/lib/libts.so* ${PROJDIR}/unpacked-rootfs/lib/
/bin/cp -Rfv /usr/arm-linux-gnueabi/lib/ts ${PROJDIR}/unpacked-rootfs/lib/

############################################################
# SDL-1.2.15-raspberrypi patches
cd ${PROJDIR}
cat > ${PROJDIR}/patches/SDL_blit_N.c.patch << "EOF"
diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c
index f10733e..9deb6b8 100644
--- a/src/video/SDL_blit_N.c    2012-01-19 14:30:06.000000000 +0800
+++ b/src/video/SDL_blit_N.c    2017-11-20 16:50:05.997531150 +0800
@@ -2031,6 +2031,32 @@
     }
 }
 
+
+//Brian add
+#define YUVPIXEL(Y,Cb,Cr) (((Y)<<24)|((Y)<<8)|((Cr)<<16)|(Cb))
+u_int32_t RGB2YUV(unsigned char R,unsigned char G,unsigned char B)
+{
+  unsigned char Y,Cb,Cr;
+
+  Y  =  ((67316*R)>>18)  + ((132154*G)>>18) + ((25666*B)>>18)  + 16;
+  Cr =  ((115138*R)>>18) - ((96414*G)>>18)  - ((18724*B)>>18)  + 128;
+  Cb = -((38856*R)>>18)  - ((76282*G)>>18)  + ((115138*B)>>18) + 128;
+
+  // Done
+  return(YUVPIXEL(Y,Cb,Cr));
+}
+u_int32_t YUVTable[65536];
+int isYUVinit = 0;
+static void initYUVTable(void)
+{
+    int i;
+    for (i=0; i<65536; i++) {
+        YUVTable[i] = RGB2YUV((i>>11)<<3, ((i>>5)&0x3f)<<2, (i&0x1f)<<3);
+    }
+    isYUVinit = 1;
+}
+
+
 static void BlitNtoN(SDL_BlitInfo *info)
 {
     int width = info->d_width;
@@ -2045,6 +2071,9 @@
     int dstbpp = dstfmt->BytesPerPixel;
     unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0;
 
+    if (!isYUVinit) {
+        initYUVTable();
+    }
     while ( height-- ) {
         DUFFS_LOOP(
         {
@@ -2052,8 +2081,11 @@
             unsigned sR;
             unsigned sG;
             unsigned sB;
-            DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
-            ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
+            //DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
+            //ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
+            //*((Uint32 *)(dst))  = RGB2YUV(sR, sG, sB);
+            *((Uint32 *)(dst)) = YUVTable[*((Uint16 *)(src))];
+            
             dst += dstbpp;
             src += srcbpp;
         },
EOF
cat > ${PROJDIR}/patches/SDL_alsa_audio.c.patch << "EOF"
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index f10733e..9deb6b8 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -520,10 +520,10 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
                 format = SND_PCM_FORMAT_U16_BE;
                 break;
             default:
-                format = 0;
+                format = SND_PCM_FORMAT_UNKNOWN;
                 break;
         }
-        if ( format != 0 ) {
+        if ( format != SND_PCM_FORMAT_UNKNOWN ) {
             status = SDL_NAME(snd_pcm_hw_params_set_format)(pcm_handle, hwparams, format);
         }
         if ( status < 0 ) {
                if ( status < 0 ) {
EOF
cat > ${PROJDIR}/patches/SDL_systhread.c.patch << "EOF"
diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c
index f10733e..9deb6b8 100644
--- a/src/thread/pthread/SDL_systhread.c    2012-01-19 14:30:06.000000000 +0800
+++ b/src/thread/pthread/SDL_systhread.c    2017-11-20 18:37:11.427399387 +0800
@@ -58,6 +58,8 @@
         SDL_SetError("Couldn't initialize pthread attributes");
         return(-1);
     }
+    
+    pthread_attr_setstacksize(&type, 20480);
     pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
 
     /* Create the thread and go! */
EOF

############################################################
# SDL-1.2.15-raspberrypi
cd ${PROJDIR}
[ ! -d SDL-1.2.15-raspberrypi ] && git clone https://github.com/vanfanel/SDL-1.2.15-raspberrypi
cd ${PROJDIR}/SDL-1.2.15-raspberrypi
git checkout ./src/audio/alsa/SDL_alsa_audio.c
git apply --reject --whitespace=fix ${PROJDIR}/patches/SDL_alsa_audio.c.patch
git checkout src/thread/pthread/SDL_systhread.c
git apply --reject --whitespace=fix ${PROJDIR}/patches/SDL_systhread.c.patch
git checkout src/video/SDL_blit_N.c
git apply --reject --whitespace=fix ${PROJDIR}/patches/SDL_blit_N.c.patch
cd ${PROJDIR}/SDL-1.2.15-raspberrypi/
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O2 -pipe" \
./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi --enable-alsa=yes --enable-input-tslib=yes \
--disable-esd --disable-pulseaudio --disable-arts --disable-nas --disable-diskaudio --disable-nasm \
--disable-altivec --disable-video-directfb --disable-video-opengl --disable-video-opengles2 \
--disable-video-x11-dgamouse --disable-video-x11 --disable-video-dga \
--enable-input-tslib=yes \
--with-alsa-prefix=/usr/arm-linux-gnueabi/lib --with-alsa-inc-prefix=/usr/arm-linux-gnueabi/include
sudo make clean && make
cd ${PROJDIR}/SDL-1.2.15-raspberrypi/build/.libs/
arm-linux-gnueabi-strip libSDL-1.2.so.0.11.4
cd ${PROJDIR}/SDL-1.2.15-raspberrypi
sudo make install
/bin/cp -Rpf ${PROJDIR}/SDL-1.2.15-raspberrypi/build/.libs/libSDL-1.2.so* ${PROJDIR}/unpacked-rootfs/usr/lib/

############################################################
# SDL test
cd ${PROJDIR}
cd ${PROJDIR}/SDL-1.2.15-raspberrypi/test
CFLAGS="-mcpu=arm926ej-s -march=armv5te -mtune=arm926ej-s -marm -mfpu=vfp -O2 -pipe" \
./configure --host=arm-linux-gnueabi --without-x --with-sdl-exec-prefix=/usr/arm-linux-gnueabi
sudo make clean
make testwin loopwave testhread testvidinfo testbitmap
arm-linux-gnueabi-strip testwin loopwave testhread testvidinfo
#/bin/cp -av ${PROJDIR}/SDL-1.2.15-raspberrypi/test/testwin ${PROJDIR}/unpacked-rootfs/usr/bin/
#/bin/cp -av ${PROJDIR}/SDL-1.2.15-raspberrypi/test/loopwave ${PROJDIR}/unpacked-rootfs/usr/bin/
#/bin/cp -av ${PROJDIR}/SDL-1.2.15-raspberrypi/test/sample.wav ${PROJDIR}/unpacked-rootfs/root/

############################################################
# clone picodrive
cd ${PROJDIR}
[ ! -d picodrive ] && git clone https://github.com/notaz/picodrive
cd ${PROJDIR}/picodrive/platform/libpicofe
git submodule update --init

############################################################
# picodrive configure
cd ${PROJDIR}/picodrive
sed 's/optimize_arm926ej="no"/optimize_arm926ej="yes"/' ./configure > ./configure.tmp
/bin/mv -f ./configure.tmp ./configure
chmod 777 ./configure

############################################################
# picodrive patches
cd ${PROJDIR}/picodrive
cat > ${PROJDIR}/patches/draw_arm.S.patch << "EOF"
diff --git a/pico/draw_arm.S b/pico/draw_arm.S
index 29af1c1..f2b036b 100644
--- a/pico/draw_arm.S
+++ b/pico/draw_arm.S
@@ -1450,10 +1450,14 @@ DrawWindow:
     and     r2,   lr,   \reg,lsr #7  @ b
     and     r3,   lr,   \reg,lsr #3  @ g
     and     \reg, lr,   \reg,lsl #1  @ r
-    orr     r2,   r2,   r3,  lsl #6
-    orr     \reg, r2,   \reg,lsl #11
+    @orr     r2,   r2,   r3,  lsl #6
+    @orr     \reg, r2,   \reg,lsl #11
 
-    and     r2,   r8,   \reg,lsr #4
+    @and     r2,   r8,   \reg,lsr #4
+    orr     \reg,   \reg,   r3,  lsl #6
+    orr     r2, \reg,   r2,lsl #11
+
+    and     \reg,   r8,   r2,lsr #4
     orr     \reg, \reg, r2
 .endm
 
EOF
git checkout pico/draw_arm.S && git apply --reject --whitespace=fix ${PROJDIR}/patches/draw_arm.S.patch
cat > ${PROJDIR}/patches/emu.c.patch << "EOF"
diff --git a/platform/common/emu.c b/platform/common/emu.c
index 0a9f089..ff71b74 100644
--- a/platform/common/emu.c
+++ b/platform/common/emu.c
@@ -578,7 +578,8 @@ void emu_prep_defconfig(void)
 {
     memset(&defaultConfig, 0, sizeof(defaultConfig));
     defaultConfig.EmuOpt    = 0x9d | EOPT_EN_CD_LEDS;
-    defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |
+    //defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |
+    defaultConfig.s_PicoOpt = POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |
                   POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX |
                   POPT_EN_DRC|POPT_ACC_SPRITES |
                   POPT_EN_32X|POPT_EN_PWM;
EOF
git checkout platform/common/emu.c && git apply --reject --whitespace=fix ${PROJDIR}/patches/emu.c.patch
cat > ${PROJDIR}/patches/platform_common_plat_sdl.c.patch << "EOF"
diff --git a/platform/common/plat_sdl.c b/platform/common/plat_sdl.c
index 4446f72..504230d 100644
--- a/platform/common/plat_sdl.c
+++ b/platform/common/plat_sdl.c
@@ -27,12 +27,16 @@ const struct in_default_bind in_sdl_defbinds[] __attribute__((weak)) = {
     { SDLK_LEFT,   IN_BINDTYPE_PLAYER12, GBTN_LEFT },
     { SDLK_RIGHT,  IN_BINDTYPE_PLAYER12, GBTN_RIGHT },
     { SDLK_z,      IN_BINDTYPE_PLAYER12, GBTN_A },
+    { SDLK_WORLD_0,      IN_BINDTYPE_PLAYER12, GBTN_A },
     { SDLK_x,      IN_BINDTYPE_PLAYER12, GBTN_B },
+    { SDLK_WORLD_1,      IN_BINDTYPE_PLAYER12, GBTN_B },
     { SDLK_c,      IN_BINDTYPE_PLAYER12, GBTN_C },
+    { SDLK_WORLD_2,      IN_BINDTYPE_PLAYER12, GBTN_C },
     { SDLK_a,      IN_BINDTYPE_PLAYER12, GBTN_X },
     { SDLK_s,      IN_BINDTYPE_PLAYER12, GBTN_Y },
     { SDLK_d,      IN_BINDTYPE_PLAYER12, GBTN_Z },
     { SDLK_RETURN, IN_BINDTYPE_PLAYER12, GBTN_START },
+    { SDLK_WORLD_3, IN_BINDTYPE_PLAYER12, GBTN_START },
     { SDLK_f,      IN_BINDTYPE_PLAYER12, GBTN_MODE },
     { SDLK_ESCAPE, IN_BINDTYPE_EMU, PEVB_MENU },
     { SDLK_TAB,    IN_BINDTYPE_EMU, PEVB_RESET },
EOF
git checkout platform/common/plat_sdl.c && git apply --reject --whitespace=fix ${PROJDIR}/patches/platform_common_plat_sdl.c.patch
cd ${PROJDIR}/picodrive/platform/libpicofe
cat > ${PROJDIR}/patches/platform_libpicofe_plat_sdl.c.patch << "EOF"
diff --git a/plat_sdl.c b/plat_sdl.c
index bbb466e..86e6feb 100644
--- a/plat_sdl.c
+++ b/plat_sdl.c
@@ -284,6 +284,7 @@ int plat_sdl_init(void)
   }
   plat_target.vout_methods = vout_list;
 
+  SDL_ShowCursor(SDL_DISABLE);
   return 0;
 
 fail:
EOF
git checkout plat_sdl.c && git apply --reject --whitespace=fix ${PROJDIR}/patches/platform_libpicofe_plat_sdl.c.patch

############################################################
# picodrive build
cd ${PROJDIR}/picodrive
SDL_CONFIG=/usr/arm-linux-gnueabi/bin/sdl-config CROSS_COMPILE=arm-linux-gnueabi- ./configure
sudo make clean
sudo make -C ${PROJDIR}/picodrive/cpu/cyclone/ clean
sudo rm -rf ${PROJDIR}/picodrive/cpu/cyclone/Cyclone.o
sed 's/#define HAVE_ARMv6                  1/#define HAVE_ARMv6                  0/' ${PROJDIR}/picodrive/cpu/cyclone_config.h > ${PROJDIR}/picodrive/cpu/cyclone_config_armv5.h
#CONFIG_FILE=`pwd`/cpu/cyclone_config_armv4.h make -C cpu/cyclone/ all
CONFIG_FILE=${PROJDIR}/picodrive/cpu/cyclone_config_armv5.h make -C cpu/cyclone/ all
make
arm-linux-gnueabi-strip PicoDrive
/bin/cp -Rpf ${PROJDIR}/picodrive/PicoDrive ${PROJDIR}/unpacked-rootfs/usr/bin/
/bin/cp -Rpf ${PROJDIR}/prebuild/picodrive/Sonic.md ${PROJDIR}/unpacked-rootfs/usr/bin/
/bin/cp -Rpf ${PROJDIR}/prebuild/picodrive/.picodrive ${PROJDIR}/unpacked-rootfs/usr/bin/

############################################################
# tz (time zone) data, Asia/Taipei
cd ${PROJDIR}
[ ! -d tz ] && git clone https://github.com/eggert/tz
make TOPDIR=${PROJDIR}/unpacked-rootfs -C tz clean install_data
cd ${PROJDIR}/unpacked-rootfs/usr/share/zoneinfo/
ls | grep -v Asia | xargs rm -rf
cd ${PROJDIR}/unpacked-rootfs/usr/share/zoneinfo/Asia/
ls | grep -v Taipei | xargs rm -rf
/bin/cp -Rpf ${PROJDIR}/unpacked-rootfs/usr/share/zoneinfo/Asia/Taipei ${PROJDIR}/unpacked-rootfs/etc/localtime
sed 's/TZDIR=\/\/share\/zoneinfo/TZDIR=\/usr\/share\/zoneinfo/g' ${PROJDIR}/foo/bin/tzselect > ${PROJDIR}/tzselect
/bin/mv -f ${PROJDIR}/tzselect ${PROJDIR}/foo/bin/tzselect
sed 's/#!\/bin\/bash/#!\/bin\/sh/' ${PROJDIR}/foo/bin/tzselect > ${PROJDIR}/unpacked-rootfs/usr/bin/tzselect
chmod 777 ${PROJDIR}/foo/bin/tzselect ${PROJDIR}/unpacked-rootfs/usr/bin/tzselect
rm -rf ${PROJDIR}/unpacked-rootfs/usr/include ${PROJDIR}/unpacked-rootfs/include

############################################################
# /usr/share/udhcpc/default.script
cd ${PROJDIR}
sudo rm -rf usr-share-udhcpc-default.script
wget https://raw.githubusercontent.com/mschlenker/TinyCrossLinux/master/patches/usr-share-udhcpc-default.script
mkdir -p ${PROJDIR}/unpacked-rootfs/usr/share/udhcpc
/bin/mv -f usr-share-udhcpc-default.script ${PROJDIR}/unpacked-rootfs/usr/share/udhcpc/default.script

############################################################
# /bin/start_getty /etc/hostname /etc/host.conf /etc/hosts /etc/passwd /etc/group /etc/shells /etc/services
cd ${PROJDIR}
touch unpacked-rootfs/bin/start_getty
chmod 777 unpacked-rootfs/bin/start_getty
echo '#!/bin/sh' > unpacked-rootfs/bin/start_getty ; sudo echo '' >> ${PROJDIR}/unpacked-rootfs/bin/start_getty ; echo '[ -c /dev/$2 ] && /sbin/getty -L $1 $2 $3' >> ${PROJDIR}/unpacked-rootfs/bin/start_getty
echo mk3 > unpacked-rootfs/etc/hostname
echo 'order hosts,bind' > unpacked-rootfs/etc/host.conf ; echo 'multi on' >> unpacked-rootfs/etc/host.conf ; echo 'nameserver    168.95.1.1' > unpacked-rootfs/etc/resolv.conf
echo '127.0.0.1        localhost' > unpacked-rootfs/etc/hosts ; echo '127.0.0.1        mk3' >> unpacked-rootfs/etc/hosts
sudo rm -rf unpacked-rootfs/etc/passwd unpacked-rootfs/etc/group
sudo echo root::0:0:root:/root:/bin/bash > unpacked-rootfs/etc/passwd ; sudo chmod 644 unpacked-rootfs/etc/passwd && sudo chown root.root unpacked-rootfs/etc/passwd
sudo echo root::0: > unpacked-rootfs/etc/group ; sudo chmod 644 unpacked-rootfs/etc/group && sudo chown root.root unpacked-rootfs/etc/group
echo '/bin/sh' > unpacked-rootfs/etc/shells ; echo '/bin/ash' >> unpacked-rootfs/etc/shells ; echo '/bin/hush' >> unpacked-rootfs/etc/shells
/bin/cp -f /etc/services unpacked-rootfs/etc/services

############################################################
# /etc/init.d/rcS
cd ${PROJDIR}
echo '#!/bin/sh' > unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'mount -a' >> unpacked-rootfs/etc/init.d/rcS ; echo 'mount -n -o remount ro /' >> unpacked-rootfs/etc/init.d/rcS
echo 'echo /sbin/mdev > /proc/sys/kernel/hotplug' >> unpacked-rootfs/etc/init.d/rcS ; echo 'mdev -s' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'hostname -F /etc/hostname' >> unpacked-rootfs/etc/init.d/rcS
echo 'ip addr add 127.0.0.1/8 dev lo' >> unpacked-rootfs/etc/init.d/rcS ; echo 'ip link set lo up' >> unpacked-rootfs/etc/init.d/rcS
echo '' >> unpacked-rootfs/etc/init.d/rcS
echo '[ -x /etc/rc.d/rc.conf ] && . /etc/rc.d/rc.conf' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'mode=${1:-start}' >> unpacked-rootfs/etc/init.d/rcS
echo 'if [ $mode = "start" ]; then services=$cfg_services ; else services=$cfg_services_r ; fi' >> unpacked-rootfs/etc/init.d/rcS
echo 'cfg_services=${2:-$services}' >> unpacked-rootfs/etc/init.d/rcS
echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'for i in $cfg_services ; do [ -x /etc/rc.d/init.d/$i ] && /etc/rc.d/init.d/$i $mode ; done' >> unpacked-rootfs/etc/init.d/rcS
echo '[ $# -ge 2 ] && exit 0' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
echo 'echo 8 >  /proc/sys/kernel/printk' >> unpacked-rootfs/etc/init.d/rcS
echo '[ -x /etc/rc.local ] && /etc/rc.local $mode' >> unpacked-rootfs/etc/init.d/rcS ; echo '' >> unpacked-rootfs/etc/init.d/rcS
chmod 777 unpacked-rootfs/etc/init.d/rcS

############################################################
# /etc/inittab
cd ${PROJDIR}
echo '::sysinit:/etc/init.d/rcS' > unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo '::restart:/sbin/init' >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo '::ctrlaltdel:/sbin/reboot' >> unpacked-rootfs/etc/inittab
echo '::shutdown:/etc/shutdown' >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo "${TARGET_SERIAL_CONSOL}::respawn:-/bin/sh" >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo "#${TARGET_SERIAL_CONSOL}::respawn:/bin/start_getty 115200 ${TARGET_SERIAL_CONSOL} vt102" >> unpacked-rootfs/etc/inittab ; echo '' >> unpacked-rootfs/etc/inittab
echo 'tty1::respawn:/sbin/getty 38400 tty1' >> ${PROJDIR}/unpacked-rootfs/etc/inittab ; echo '' >> ${PROJDIR}/unpacked-rootfs/etc/inittab
sudo rm -rf ${PROJDIR}/unpacked-rootfs/etc/init.d/rc.S ; sudo rm -rf ${PROJDIR}/unpacked-rootfs/etc/init.d/announce
sudo rm -rf ${PROJDIR}/unpacked-rootfs/etc/init.d/halt ; sudo rm -rf ${PROJDIR}/unpacked-rootfs/etc/init.d/reboot

############################################################
# /etc/fstab /etc/rc.local
cd ${PROJDIR}
cat > ${PROJDIR}/unpacked-rootfs/etc/fstab << "EOF"
none                    /proc                            proc    defaults                0 0
none                    /sys                            sysfs    defaults                0 0
tmpfs                    /tmp                            tmpfs    defaults                0 0
tmpfs                    /dev                            tmpfs    defaults                0 0
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/rc.local << "EOF"
#!/bin/bash
source /etc/rc.d/rc.conf
#/bin/cp /usr/bin/.picodrive /tmp -rf
#export HOME=/tmp
#cd /usr/bin
#./PicoDrive Sonic.md &

# cat /dev/urandom | aplay -f S8 -r 44100 -c 2 &
EOF

############################################################
# /etc/rc.d/rc.conf /etc/profile /etc/shutdown /init
cd ${PROJDIR}
mkdir -p ${PROJDIR}/unpacked-rootfs/etc/rc.d
cat > ${PROJDIR}/unpacked-rootfs/etc/rc.d/rc.conf << "EOF"
cfg_services="mount-proc-sys udev hostname depmod modules filesystems inetd "
cfg_services_r=" inetd filesystems modules depmod hostname udev mount-proc-sys"
export HOSTNAME=`cat /etc/hostname`
export TMPFS=tmpfs
export LD_LIBRARY_PATH=/usr/lib:/lib ; export SDL_NOMOUSE=1 ; export ALSA_CONFIG_PATH=/usr/share/alsa/alsa.conf
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/profile << "EOF"
source /etc/rc.d/rc.conf
hostname -F /etc/hostname
export PS1='\u@\h:\w$ '
[ `id -u` -eq 0 ] && export PS1='\u@\h:\w# '
[ `id -u` -eq 0 ] && export HOME=/root
[ `id -u` -eq 0 ] && cd /root
export TZ=Asia/Taipei
export LC_ALL=C
echo -ne "\33[9;0]" > /dev/tty0
echo -ne "\033[?25l" > /dev/tty0
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/shutdown << "EOF"
#!/bin/sh
true
EOF
cat > ${PROJDIR}/unpacked-rootfs/init << "EOF"
#!/bin/sh
/bin/mount proc /proc -t proc
/bin/mount sysfs /sys -t sysfs
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
exec switch_root /mnt /sbin/init
EOF
chmod 777 unpacked-rootfs/etc/rc.d/rc.conf unpacked-rootfs/etc/profile unpacked-rootfs/etc/shutdown unpacked-rootfs/init ${PROJDIR}/unpacked-rootfs/etc/rc.local

############################################################
# /etc/asound.conf /usr/share/alsa /etc/ld.so.conf
cd ${PROJDIR}
mkdir -p ${PROJDIR}/unpacked-rootfs/usr/share/alsa
sudo /bin/cp -Rpf /usr/arm-linux-gnueabi/share/alsa/* ${PROJDIR}/unpacked-rootfs/usr/share/alsa/ ; sudo chown `whoami`.`whoami` -R ${PROJDIR}/unpacked-rootfs/usr/share/alsa/
cat > ${PROJDIR}/unpacked-rootfs/etc/asound.conf << "EOF"
pcm.!default {
    type hw
    card 0
}
ctl.!default {
    type hw
    card 0
}
EOF
cat > ${PROJDIR}/unpacked-rootfs/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/lib
/lib
EOF

############################################################
# rootfs.img
cd ${PROJDIR}
sudo mksquashfs unpacked-rootfs rootfs.img
/bin/mv -f rootfs.img ${PROJDIR}/out/
sudo chown `whoami`.`whoami` -R ${PROJDIR}/out

############################################################
# system.bin
[ ! -f out/u-boot.bin ] && exit 0
[ ! -f out/mk3-evb.dtb ] && exit 0
[ ! -f out/uImage ] && exit 0
[ ! -f out/rootfs.img ] && exit 0
sudo /bin/rm -rf out/system.bin
dd if=/dev/zero of=out/system.bin bs=1 count=4M
dd if=out/u-boot.bin of=out/system.bin conv=notrunc bs=1
dd if=out/mk3-evb.dtb of=out/system.bin conv=notrunc bs=1 seek=256K
dd if=out/uImage of=out/system.bin conv=notrunc bs=1 seek=320K
dd if=out/rootfs.img of=out/system.bin conv=notrunc bs=1 seek=2176K

 

Runtime 執行的結果如下: 
 
U-Boot 2017.03-g29d8d9e (Dec 24 2018 - 13:48:30 +0800)
 
DRAM:  16 MiB
WARNING: Caches not enabled
MMC:
Using default environment
 
In:    serial
Out:   serial
Err:   serial
type=30 1
Hit any key to stop autoboot:  0
## Booting kernel from Legacy Image at 08040000 ...
   Image Name:   Linux-4.10.0+
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1825232 Bytes = 1.7 MiB
   Load Address: 18000000
   Entry Point:  18000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 08030000
   Booting using the fdt blob at 0x8030000
   Loading Kernel Image ... OK
   Loading Device Tree to 18dc3000, end 18dc6a3e ... OK
 
Starting kernel ...
 
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 4.10.0+ (jasonc@bebop) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) ) #45 Mon Dec 24 12:01:33 CST 2018
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
CPU: VIVT data cache, VIVT instruction cache
OF: fdt:Machine model: DMC MK3 Development Kit
bootconsole [earlycon0] enabled
Memory policy: Data cache writeback
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064
Kernel command line: earlyprintk console=ttyMK0,115200n8 mem=16M init=/sbin/init root=/dev/mtdblock0
PID hash table entries: 64 (order: -4, 256 bytes)
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 9052K/16384K available (3072K kernel code, 88K rwdata, 520K rodata, 1024K init, 86K bss, 7332K reserved, 0K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xc1800000 - 0xff800000   ( 992 MB)
    lowmem  : 0xc0000000 - 0xc1000000   (  16 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc0400000   (4064 kB)
      .init : 0xc0500000 - 0xc0600000   (1024 kB)
      .data : 0xc0600000 - 0xc0616080   (  89 kB)
       .bss : 0xc0616080 - 0xc062b8ec   (  87 kB)
NR_IRQS:16 nr_irqs:16 16
clocksource: mk_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 28443011 ns
sched_clock: 32 bits at 1kHz, resolution 1000000ns, wraps every 2147483647500000ns
Console: colour dummy device 80x30
Calibrating delay loop... 118.78 BogoMIPS (lpj=59392)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x18100000 - 0x18100058
VFP support v0.3: not present
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
futex hash table entries: 256 (order: -1, 3072 bytes)
pinctrl core: initialized pinctrl subsystem
DMA: preallocated 256 KiB pool for atomic coherent allocations
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource mk_clocksource
mk-fb 18c00000.framebuffer: framebuffer at 0x18c00000, 0x25800 bytes, mapped to 0xc0c00000
mk-fb 18c00000.framebuffer: format=b5g6r5, mode=320x240x16, linelength=640
Console: switching to colour frame buffer device 40x30
mk-fb 18c00000.framebuffer: fb0: mkfb registered!
workingset: timestamp_bits=30 max_order=12 bucket_order=0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
pinctrl-mk 10000100.pinctrl: Pin controller initialized
10000500.uart: ttyMK0 at MMIO 0x10000500 (irq = 19, base_baud = 0) is a MK UART-1
console [ttyMK0] enabled
console [ttyMK0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
brd: module loaded
(drivers/misc/atgames/dmc_keypad.c 673) dmc_keypad_init()
input: dmc-keys as /devices/virtual/input/input0
random: fast init done
1 ofpart partitions found on MTD device 8000000.nor
Creating 1 MTD partitions on "8000000.nor":
0x000000200000-0x000000800000 : "fs"
mk-pcm 4000080.audio0: can't request region for resource [mem 0x04000080-0x04000083]
mk-pcm 4000080.audio0: snd-soc-dummy-dai <-> 4000080.audio0 mapping ok
ALSA device list:
  #0: Card 4000080.audio0
VFS: Mounted root (squashfs filesystem) readonly on device 31:0.
Freeing unused kernel memory: 1024K
root@mk3:~# random: crng init done
 
root@mk3:~#
 
ALSA player `aplay` 測試結果如下:
 
root@mk3:~# aplay -Dprimary startup.wav
Playing WAVE 'startup.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo
aplay: set_params:1339: Sample format non available
Available formats:
- S8
root@mk3:~#
SDL 測試結果如下:
 
root@mk3:~# SDL_NOMOUSE=1 time testwin -width 320 -height 240 -bpp 16
Set 320x240x16 mode
(video surface located in system memory)
Loading picture: sample.bmp
testwin: setting colors
(image surface located in system memory)
testwin: moving image
testwin: fading out...
testwin: fading in...
testwin: fading over
Time: 151 milliseconds
real    0m 1.93s
user    0m 0.06s
sys     0m 0.67s
root@mk3:~#
 

sdl-testwin.jpg

 
 
 
 
 
 

black_dot.jpg

 
 
 
 
https://www.cnblogs.com/helloworldtoyou/p/6169678.html
 
https://www.cnblogs.com/aaronLinux/
 
https://docs.ubuntu.com/core/en/stacks/audio/alsa-utils/docs/reference/available-utilities
 
https://github.com/maximeh/buildroot
 
http://silverfoxkkk.pixnet.net/blog/post/45000257-lddp%3A%E5%8D%81%E4%B8%80%E3%80%81%E4%B8%AD%E6%96%B7
 
https://www.alsa-project.org/main/index.php/Asoundrc
 
http://www.linuxfromscratch.org/lfs/view/development/chapter06/glibc.html
 
http://www.mauvecloud.net/sounds/index.html
 
http://www.treewalker.org/opendingux/
 
 
 
buildroot
 
1. base config
source <PATH_TO_ROCKCHIP_SDK>/buildroot/build/envsetup.sh rockchip_rk3328
 
2. sdk env
SDK_BASE=<PATH_TO_ROCKCHIP_SDK>/buildroot/output/rockchip_rk3328/host
export PATH=$PATH:$SDK_BASE/bin/
export CC="aarch64-linux-gcc --sysroot=$SDK_BASE/aarch64-buildroot-linux-gnu/sysroot"
export PKG_CONFIG_PATH=$SDK_BASE/aarch64-buildroot-linux-gnu/sysroot/usr/lib/pkgconfig
export SDKTARGETSYSROOT=$SDK_BASE/aarch64-buildroot-linux-gnu/sysroot
 
3. binary files
put data to board/rockchip/rk3328/fs-overlay-64, buildroot will copy to image
 
 
 

black_dot.jpg

 
 

Secondary Boot Loader for Nand-Controller to load U-boot

 

loader.c
#include "loader.h"

#define CONFIG_PLL                                          264000000

#define PINS_SHARING_BETWEEN_EXTERNAL_MEMORIES                0
#define PAGES_PER_BLOCK                                        64
 
#define SUCCESS              (0)
#define FAIL                 (1)
 
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
 
#define u32        unsigned int
#define u16        unsigned short
#define u8        unsigned char

#if (0 == PINS_SHARING_BETWEEN_EXTERNAL_MEMORIES)
static u8 data[2048] = {0};
#else
#endif

static int tick = 100;
#define delay(x)    \
    for (tick = 0; tick < x ; t++)
 
static  inline void writel(u32 val, void *addr) {
    *(volatile u32 *)addr = val;
}
static inline u32 readl(void *addr) {
    u32 val = *(volatile u32 *)addr;
    return val;
}
static inline void writew(u16 val, void *addr) {
    *(volatile u16 *)addr = val;
}
static inline  u16 readw(void *addr) {
    u16 val = *(volatile u16 *)addr;
    return val;
}
static void nandWaitRdy(void) {
    while((pNandCfg3 & NAND_RDY_MASK) != NAND_RDY_MASK);
}
static void nandReset(void) {
    pNandCmd = CMMD(NAND_CMD_RESET);//send command 0x00
    nandWaitRdy();
}
static void nandStatusRead(uint8_t *pu8Status) {
    pNandCmd = CMMD(NAND_CMD_STATUS_READ);//send command 0x70
    *pu8Status = pNandStatus;
}
static void nandInit(uint8_t u8Ratio) {
    pGPIOModeC &= 0xC03F; 
    pGPIOModeC |= 0x0280;    //config pc3,4,5,6 to nand mode
    pGlobalCtrl2 |= NAND_FORCE_MASK;
    CLK_CTR |= NAND_CLK_EN_MASK;
    pNandCfg |= NAND_ECC_EN_MASK;
    pNandCfg |= NAND_AUTO_READ_MASK;
    pNandCfg |= u8Ratio;
    nandReset();
}
static void waitECCDone(void) {
    while((pNandCfg4 & NAND_ECC_DONE_MASK) != NAND_ECC_DONE_MASK);
}
static uint8_t checkECC(void) {
    if((pNandCfg & NAND_ECC_ERR_MASK) == NAND_ECC_ERR_MASK)
        return FAIL;
    return SUCCESS;
}
static uint8_t nandPageRead(uint32_t u32pageIndex, uint8_t *pu8Dst, uint32_t u32Size) {
    uint16_t u16PageSize = VALID_DATA_PER_PAGE;
    uint16_t u16SizePerRead = VALID_SIZE_PER_OPERATE;
    uint16_t i, j, k=0;
    volatile uint8_t *pvu8Data;
    uint8_t u8DummyByte;
 
    pNandCmd = CMMD(NAND_CMD_READ1);//send command 0x00
    pNandCmd = ADDR(0x00);
    pNandCmd = ADDR(0x00);
    pNandCmd = ADDR(u32pageIndex&0xFF);
    pNandCmd = ADDR(u32pageIndex>>8&0xFF);
    pNandCmd = CMMD(NAND_CMD_READ2);//send command 0x30
 
    nandWaitRdy();
    for(i=0; i<u16PageSize; i+=u16SizePerRead) {
        pvu8Data = (volatile uint8_t*)0x11000D00;
        waitECCDone();
        if(FAIL == checkECC())
            return FAIL;
        for(j=0; j<256; j++) {
            if(j<u16SizePerRead && k<u32Size) {
                *pu8Dst++=*pvu8Data++;
                k++;
                continue;
            }
            u8DummyByte=*pvu8Data++;
        }
        pNandCmd = 0x300;
    }
    while(!(pNandStatus & NAND_STATUS_RDY_MASK));
    return SUCCESS;
}
static void pll_set_rate(void) {
    unsigned short t = (CONFIG_PLL/1024/1000);

    writel((2), (void *)0x04000880); //set N=2, OD=0
    writel((CONFIG_PLL/2/1000000), (void *)0x04000884);
 
    writel(0x3, (void *)0x04000888); //reset PLL
    writel(0x0, (void *)0x04000888);
 
    delay(100);
    writew(0x9, (void *)0x10000006);//TV encoder
    writew(0x3, (void *)0x10000002);//VDP
    writew(0x2, (void *)0x1000000a);//SDRAM
    writew(0x2, (void *)0x1000000c);//HCLK
    writew(33, (void *)0x1000000E);

    writew(0xb, (void *)0x10000010); //for hdmi divider 264/11=24(target 24)
    writew(t, (void *)0x10000012);//TIMER
    writew(0x8, (void *)0x10000008);//APB
    writew(0x1b, (void *)0x04000805);

    writew(0x27ba, (void *)0x10000000);
    delay(0x4000);
    // Enable DTCM
    asm volatile("mcr p15, 0, %0, c9, c1, 0" : : "r"(0x700001));
    delay(0x4000);
}
 
// 0x18000000-0x1FFFFFFF
// 18010000
int main(int argc, char *argv[]) {
    volatile u8 *start = (u8 *)0x18010000;
    int page = 0;
    int i;
 
    pll_set_rate();
 
    nandInit(4);
    for (page = 0; page < 2 * PAGES_PER_BLOCK; page++) {

#if (0 == PINS_SHARING_BETWEEN_EXTERNAL_MEMORIES)
        pGlobalCtrl2 |= NAND_FORCE_MASK;
        nandPageRead(page, (void *)data, sizeof(data));
        for (i = 0; i < sizeof(data); i++)
            *(start + (page * sizeof(data)) + i) = data[i];
        pGlobalCtrl2 &= ~NAND_FORCE_MASK;
#else
        nandPageRead(page, (start + page * 2048), 2048);
#endif

    }
    asm volatile("ldr r0, =0x18010000");
    asm volatile("orr ip, ip, r0");
    asm volatile("mov pc, lr");
 
    return 0;
}

 

loader.h
#ifndef _LOADER_H_
#define _LOADER_H_


#define CMMD(c)    (c|NAND_CMD_CLE)
#define ADDR(a)    (a|NAND_CMD_ALE)

#define NAND_CMD_CLE            0x0100
#define NAND_CMD_ALE            0x0200
#define NAND_CMD_RST_WR            0x0400
#define NAND_CMD_RESET            0xFF
#define NAND_CMD_STATUS_READ    0x70
#define NAND_CMD_READ1            0x00
#define NAND_CMD_READ2            0x30
#define NAND_CMD_WRITE1            0x80
#define NAND_CMD_WRITE2            0x10
#define NAND_CMD_BLOCK_ERASE1    0x60
#define NAND_CMD_BLOCK_ERASE2    0xD0

#define NAND_RDY_MASK            0x02
#define NAND_ECC_DONE_MASK        0x02
#define NAND_ECC_ERR_MASK        0x3000    

#define NAND_FORCE_MASK            (0x01<<2)
#define NAND_CLK_EN_MASK        (0x01<<12)
#define NAND_ECC_EN_MASK        (0x01<<5)
#define NAND_AUTO_READ_MASK        (0x01<<6)

#define NAND_STATUS_ERR_MASK    (0x01<<0)
#define NAND_STATUS_RDY_MASK    (0x01<<6)

#define VALID_DATA_PER_PAGE        (247*8)
#define VALID_SIZE_PER_OPERATE    247


/**************************************************************************
 *                          D A T A    T Y P E S                          *
 **************************************************************************/
/* NAND registers */  
#define pGPIOModeC        (*(volatile unsigned short *)0x10000114)
#define pGlobalCtrl2    (*(volatile unsigned short *)0x04000820)
#define    CLK_BASE_ADDR    0x10000000
#define    CLK_CTR            *((volatile unsigned short*)CLK_BASE_ADDR)  

#define NAND_READ_BUFF_ADDR    0x11000D00
#define NAND_WRITE_ADDR        0x11000C08

#define NAND_CTR_STATE_REG        0x11000c28     
#define NAND_CTR_ADDR_REG            0x11000c00
#define SYS_SCTR_ADDR                0x04000808    
#define CLK_GEN_CTR                0x10000000
#define pNandCmd    (*(volatile unsigned short*)0x11000c00)
#define pNandCfg    (*(volatile unsigned short*)0x11000c04)
#define pNandCfg1    (*(volatile unsigned short*)0x11000c10)
#define pNandWr     (*(volatile unsigned short*)0x11000c08)
#define pNandCfg2    (*(volatile unsigned short*)0x11000c0c)
#define pNandCfg3    (*(volatile unsigned char*)0x11000C28)
#define pNandCfg4    (*(volatile unsigned char*)0x11000C2C)
#define pNandRdBuffBase        (*(volatile unsigned char*)0x11000D00)
#define pNandStatus        (*(volatile unsigned char*)0x11000C0C)
#define NAND_BASE_ADDRESS    NAND_CTR_ADDR_REG

#endif

 

loader.lds
MEMORY
{
    ROM (rx) : ORIGIN = 0x03000000 LENGTH = 16K
}

ENTRY(_start)

SECTIONS
{
    .vectors :
    {
        *(.isr_vector)
    } > ROM

    . = ALIGN(4);
    .text :
    {
        *(.text*)
        *(.rodata*)
    } > ROM

    .data :
    {
        *(.data*)
    *(COMMON)
    } > ROM

   .bss :
   {
        . = ALIGN(4);
    *(.bss*)
   } > ROM
}
Makefile
CROSS    = arm-linux-gnueabi-
LD        = $(CROSS)ld
AS        = $(CROSS)as -EL
CC        = $(CROSS)gcc -g
CXX        = $(CROSS)g++ -g
OBJCOPY    = $(CROSS)objcopy
OBJDUMP    = $(CROSS)objdump

S_FLAGS    = -Wall -O0 -g
C_FLAGS    = -c -O0 -g -Wno-int-conversion

H_FILE    = $(wildcard *.h)
S_SRCS    = $(wildcard *.s)
#S_OBJS    = $(patsubst %s, %o, $(S_SRCS))
S_SRCS    += $(wildcard *.c)
S_OBJS    = stackSet.o loader.o 

TARGET    = loader

.PHONY:    all clean

all: $(S_OBJS)
    $(LD) -T loader.lds $^ -o $(TARGET).elf
    $(OBJCOPY) -O binary -S $(TARGET).elf $(TARGET).bin
    $(OBJDUMP) -DS $(TARGET).elf > $(TARGET).dasm

%o: %.s $(H_FILE)
    $(AS) $(S_FLAGS) -o $@ $<
    
%o: %.c $(H_FILE)
    $(CC) $(C_FLAGS) -o $@ $<
    
clean:
    rm -f *.bin *.o *.elf *.dasm

 

 

Makefile
    .global _start
_start:
        mov r0, #0xd3                     
        msr cpsr_fc, r0                  
        ldr sp, =0x03003fe0                           
        mov lr, #0x0                      
        msr spsr_fc, lr                   
        mov r0, #0xd2                    
        msr cpsr_fc, r0                   
        ldr sp, =0x03003fa0
        mov lr, #0x0                      
        msr spsr_fc, lr                   
        mov r0, #0x1f                   
        msr cpsr_fc, r0                   
        ldr sp, =0x03003f00
        
        b main
 

 

 

 

 
 
 
 
black_dot.jpg

 

 

 

 

 

 

 

 

arrow
arrow
    創作者介紹
    創作者 Lexra 的頭像
    Lexra

    Lexra Pixnet

    Lexra 發表在 痞客邦 留言(0) 人氣()