使用F1C200S从零制作掌机之构建debian文件系统

前情:使用buildrootfs构建的文件系统调试了很久NES模拟器,执行InfoNES模拟器的时候一直黑屏,无内容显示,调不通了,所以改用debian系统试试。

一、环境配置

首先下载两个工具:qemu-arm-static和debootstrap。

  • qemu-arm-static:通过qemu-arm-static,我们在x86的Ubuntu PC机上,可以模拟ARM处理器,就像运行在ARM上一样进行各种操作。这样既实现了ARM环境,又利用了x86 PC的处理能力。
  • debootstrap:是Debian/Ubuntu下的一个工具,用来构建一套基本的系统(根文件系统)。生成的目录符合Linux文件系统标准(FHS),即包含了/boot、/etc、/bin、/usr等等目录,但它比发行版本的Linux体积小很多,当然功能也没那么强大,因此,只能说是“基本的系统”。
sudo apt install qemu-user-static -y
sudo apt install debootstrap -y
mkdir debian_rootfs

二、构建

2.1 下载

使用清华镜像源抽取根文件系统。其中foreign表示若目标架构与本机架构不符时,需要携带该参数;arch代表架构,armhf (支持硬件浮点)、armel (软浮点);verbose表示不打印wget等包下载数据,进行静默安装。

从https://www.debian.org/mirror/list.zh-cn.html

image-20240705134439996

华为镜像源

cd debian_rootfs
sudo debootstrap --foreign --verbose --arch=armel bullseye rootfs http://mirrors.huaweicloud.com/debian/

至此,已经下载了最小的Debian系统, 你也可以将它想象为"最小系统"类似的存在,没有其他 “外设” 。这里改为bullseye,网上大部分使用的buster提示出错,不知道以后bullseye会不会也出错。在buster下找不到binary-armel。

2.2 文件挂载

cd rootfs
sudo mount --bind /dev dev/
sudo mount --bind /sys sys/
sudo mount --bind /proc proc/
sudo mount --bind /dev/pts dev/pts/

2.3 模拟

sudo cp /usr/bin/qemu-arm-static  usr/bin/
cd ..
对拉取的Debian根文件系统进行配置。
sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs /debootstrap/debootstrap --second-stage --verbose
进入qemu虚拟器
sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs

2.4 配置

更新源
vi /etc/apt/sources.list
#写入: 
deb http://mirrors.huaweicloud.com/debian bullseye main
deb http://ftp.cn.debian.org/debian bullseye main 
apt-get update

安装软件
apt-get install wpasupplicant #安装WIFI配置相关的组件
apt-get install net-tools     #安装网络基础组件、如使用ifconfig等
apt-get install udhcpc        #当wifi连接成功后,需要用这个组件去获取IP地址
apt-get install evtest        #触摸屏测试
apt-get install mplayer
apt-get install alsa-utils    #音频测试
apt-get install wireless-tools 
apt install sudo vim openssh-server htop
apt install pciutils usbutils acpi #acpi我没有安装成功,换了其他的源也不可以

设置root账号密码
passwd root
123456

adduser wxc
passwd wxc
123456

echo wangpi > /etc/hostname
vim /etc/hosts
127.0.0.1 wangpi

#触摸屏
apt-get install i2c-tools
apt-get install libts-bin libts-dev
#sudo cp /etc/ts.conf /etc/ts.conf.bak
#echo "module_raw input">/etc/ts.conf  
#sudo /etc/init.d/tslib restart
#find / -name input.so

sudo vi /etc/profile
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/arm-linux-gnueabi/ts0  # input.so所在目录
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
source /etc/profile

配置时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

配置SSH
vi /etc/ssh/sshd_config
#写入: PermitRootLogin yes

apt-get install file
#hexdump
apt-get install bsdmainutils

apt clean #清理
exit #退出chroot
sudo rm rootfs/usr/bin/qemu-arm-static #删除之前拷贝的文件

cd rootfs
sudo umount   dev/pts/ # 一定要在/dev前面umount
sudo umount   dev/
sudo umount   sys/
sudo umount   proc/

sudo tar cvf ../rootfs.tar ./ #在rootfs目录下执行

2.5 启动

tar -xvf rootfs.tar -C /media/wang/rootfs/

uboot bootargs:

console=tty1 console=ttyS1,115200 panic=5 rootwait root=/dev/mmcblk0p2 rootfstype=ext4 earlyprintk rw Loglevel=7

2.6 增加swap分区(按需,在开发板执行)

free -m
dd if=/dev/zero of=/swap1 bs=1M count=512  #count是SWAP大小,512就是512MB
mkswap /swap1
swapon /swap1

vi /etc/fstab
# 最后一行添加 
/swap1 swap swap defaults 0 0

三、编译InfoNES

apt-get install gcc
apt-get install g++
apt-get install make
apt-get install libasound2-dev
apt-get install zlib1g-dev

使用的模拟器源码:https://files.cnblogs.com/files/twzy/arm-NES-linux-master.zip

源码进入linux目录,直接编译即可。拷贝nes游戏到文件系统。

在开发启动程序,屏幕可显示游戏界面。

四、注意

debian的版本,使用buster会报错,使用oldstable无法启动。最后改用bullseye。

修改rootfs分区大小为2048M。

五、debian系统下外设

待完成。

六、移植好的文件系统

https://download.csdn.net/download/weixin_36117563/89524570

七、参考

https://whycan.com/t_4236_10.html

https://blog.csdn.net/qq_41709234/article/details/128570505

https://blog.csdn.net/qq_41709234/article/details/128758130

https://www.cnblogs.com/twzy/p/15356127.html

https://mirrors.tuna.tsinghua.edu.cn/debian/dists/oldstable/main/

  • 31
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值