Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

复刻完成 OLED屏幕/USB 网卡/点灯 正常 #28

Open
smilelc3 opened this issue Apr 26, 2024 · 3 comments
Open

复刻完成 OLED屏幕/USB 网卡/点灯 正常 #28

smilelc3 opened this issue Apr 26, 2024 · 3 comments

Comments

@smilelc3
Copy link

smilelc3 commented Apr 26, 2024

image

@smilelc3
Copy link
Author

image

@gysworld007
Copy link

gysworld007 commented Jul 13, 2024

可以分享一下测试代码或文件吗

@smilelc3
Copy link
Author

可以分享一下测试代码或文件吗

基本就这些命令

sudo docker pull ubuntu:latest
sudo docker run -it --name F1C200s_env --network host \
-p 8022:22 \
-v /tmp/F1C200s_env/workspace:/workspace \
--privileged \
ubuntu:latest

sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list
sed -i 's@//.*security.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list

apt update
apt install sudo wget git unzip -y
apt install libncurses-dev gcc gcc-arm-linux-gnueabi make bison flex bc libssl-dev python3 python3-setuptools python3-dev swig bzip2 file g++ cpio rsync -y

workspace_path=/workspace
cd ~/

export ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-


# uboot
git clone --depth=1 https://github.com/u-boot/u-boot.git
cd u-boot
make licheepi_nano_defconfig
make menuconfig
#load mmc 0:1 0x80008000 zImage;load mmc 0:1 0x80c08000 suniv-f1c100s-licheepi-nano.dtb;bootz 0x80008000 - 0x80c08000;
#console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw
make -j $(nproc)
cp u-boot-sunxi-with-spl.bin  ${workspace_path}/
sudo dd if=/tmp/F1C200s_env/workspace/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8



# linux
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/linux.git

wget https://files.cnblogs.com/files/twzy/linux-licheepi_nano_defconfig.zip
unzip linux-licheepi_nano_defconfig.zip
cp cp linux-licheepi_nano_defconfig linux/arch/arm/configs/
cd linux 

make menuconfig
make -j $(nproc)

cp arch/arm/boot/zImage ${workspace_path}/
cp arch/arm/boot/dts/allwinner/suniv-f1c100s-licheepi-nano.dtb ${workspace_path}/


# busybox
git clone --depth=1 git://busybox.net/busybox.git
cd busybox
make menuconfig

#Settings ---->
#   Build Options      [*]Build static binary(no shared libs)

make -j $(nproc)
make install
cd _install

mkdir etc dev mnt tmp sys proc root

cat >etc/fstab <<EOF
proc        /proc           proc        defaults        0        0
tmpfs       /tmp            tmpfs       defaults        0        0
sysfs       /sys            sysfs       defaults        0        0
EOF

mkdir -p etc/init.d/
cat >etc/init.d/rcS <<EOF
echo -e "Welcome to nanoLinux"
/bin/mount -a
echo -e "Remounting the root filesystem"
mount  -o  remount,rw  /
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
EOF
chmod 755 etc/init.d/rcS 

cat >etc/inittab <<EOF
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
EOF
chmod 755 etc/inittab
mknod dev/console c 5 1
mknod dev/null c 1 3
mknod dev/tty1 c 4 1 

dd if=/dev/zero of=root/swap bs=1M count=512
mkswap root/swap
swapon root/swap

echo "/root/swap swap swap defaults 0 0" >> etc/fstab

make modules_install INSTALL_MOD_PATH=${workspace_path}/

tar -czvf rootfs.tar.gz *
mv rootfs.tar.gz ${workspace_path}/



# buildroot
git clone --depth=1 https://github.com/buildroot/buildroot.git
cd buildroot
cat >configs/nano_linux_defconfig <<EOF
BR2_arm=y
BR2_PACKAGE_GLIBC_UTILS=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_CCACHE=y
BR2_ENABLE_LTO=y
BR2_TARGET_GENERIC_HOSTNAME="nanoLinux"
BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot for the NanoLinux"
BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
BR2_SYSTEM_ENABLE_NLS=y
BR2_TARGET_TZ_INFO=y
BR2_PACKAGE_BZIP2=y
BR2_PACKAGE_ZIP=y
BR2_PACKAGE_LIBGPIOD=y
BR2_PACKAGE_LIBGPIOD_TOOLS=y
BR2_PACKAGE_LIBEVENT=y
BR2_PACKAGE_LRZSZ=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_RSYNC=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_NANO=y
EOF
make nano_linux_defconfig
make -j $(nproc)
cp output/images/rootfs.tar ${workspace_path}/



modprobe sunxi
modprobe configfs
modprobe libcomposite
modprobe u_ether
modprobe usb_f_rndis
mount -t configfs none /sys/kernel/config/

cd /sys/kernel/config/usb_gadget
mkdir g1
cd g1
echo "0x1d6b" > idVendor
echo "0x0104" > idProduct
mkdir functions/rndis.rn0
mkdir configs/c1.1
ln -s functions/rndis.rn0 configs/c1.1/
echo "musb-hdrc.1.auto" > UDC

ifconfig usb0 up
ifconfig usb0 192.168.137.2 netmask 255.255.255.0
route add default gw 192.168.137.1
mkdir /uboot
mount /dev/mmcblk0p1 /uboot


#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
leds {
    compatible = "gpio-leds";

    led-0 {
        function = LED_FUNCTION_STATUS;
        color = <LED_COLOR_ID_GREEN>;
        gpios = <&pio 4 6 GPIO_ACTIVE_LOW>; /* PE6 */
        linux,default-trigger = "heartbeat";
    };
};


apt update
apt install debootstrap qemu-user-static 
mkdir rootfs

debootstrap --foreign --verbose --arch=armel bookworm rootfs http://mirrors.huaweicloud.com/debian/
cd rootfs
mount --bind /dev dev/
mount --bind /sys sys/
mount --bind /proc proc/
mount --bind /dev/pts dev/pts/
cd ..
cp /usr/bin/qemu-arm-static rootfs/usr/bin/
chmod +x rootfs/usr/bin/qemu-arm-static
LC_ALL=C LANGUAGE=C LANG=C chroot rootfs /debootstrap/debootstrap --second-stage --verbose
LC_ALL=C LANGUAGE=C LANG=C chroot rootfs

apt install gpiod i2c-tools lrzsz

另外i2c屏幕的驱动显示代码见我的仓,屏幕用的sh1107 oled 12880
https://github.com/smilelc3/sh1107_oled_12880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants