源码目录: https://github.com/yuzibo/vf2-linux
使用 vf2 开头的分支,首先交叉编译出相应的 kernel riscv64 的 deb 包。 配置可以使用 debian_defconfig
或者你可以直接使用 prebuilt image
download from here
sudo debootstrap --arch=riscv64 unstable /tmp/riscv64-chroot http://mirrors.tuna.tsinghua.edu.cn/debian/
sudo systemd-nspawn -D /tmp/riscv64-chroot/ -M debian --bind-ro=/etc/resolv.conf
sudo apt update
sudo apt upgrade
sudo apt-get install initramfs-tools openssh-server systemd-timesyncd rsync bash-completion u-boot-menu
4.1 配置 网络接口
cat <<EOF >> /etc/network/interfaces
allow-hotplug eth0
iface eth0 inet dhcp
EOF
echo vf2 > /etc/hostname
pass # vf2
# add new user
root@debian:/# adduser debian
info: Adding user `debian' ...
info: Selecting UID/GID from range 1000 to 59999 ...
info: Adding new group `debian' (1000) ...
info: Adding new user `debian' (1000) with group `debian (1000)' ...
info: Creating home directory `/home/debian' ...
info: Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for debian
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
info: Adding new user `debian' to supplemental / extra groups `users' ...
info: Adding user `debian' to group `users' ...
# passwd for debian is `debian`
passwd debian
New password:
Retype new password:
passwd: password updated successfully
usermod -aG sudo debian
接下来需要配置与启动最直接相关的 u-boot 了:
主要一个是 /etc/default/u-boot
,另一个是 uEnv.txt
. 引导设备最好在dd 时再操作。
mkdir -p /boot/efi
apt install locales
apt clean
exit
然后这个时候可以分别向sd或者nvme copy rootfs 了
最好需要 double check 你的设备,以免讲自己的 host 给格式化了。
可以使用命令 lsblk
确认。
一般情况下, sd 在 host 上显示 /dev/mmcblk**
, 在 guest 上显示 /dev/sd**
nvme 在 host 上显示 /dev/nvme0n1**
, 在 guest 上显示 /dev/sd**
sudo sgdisk -g --clear --new=1:0:+16M: --new=2:0:+100M: -t 2:EF00 --new=3:0:-1M: --attributes 3:set:2 -d 1 /dev/sdb
The operation has completed successfully.
再次确认:
sudo fdisk -l /dev/sdb
Disk /dev/sdb: 116.36 GiB, 124939927552 bytes, 244023296 sectors
Disk model: STORAGE DEVICE
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7A77DCC4-1EFD-469D-A05E-0DAA9EC15112
Device Start End Sectors Size Type
/dev/sdb2 34816 239615 204800 100M EFI System
/dev/sdb3 239616 244021214 243781599 116.2G Linux filesystem
然后分别格式化对应的分区:
sudo mkfs.vfat /dev/sdb2
sudo mkfs.ext4 -m 0 -L root /dev/sdb3
mount sd:
sudo mkdir -p /mnt/sdcard
sudo mount /dev/sdb3 /mnt/sdcard
sudo cp -a /tmp/riscv64-chroot/* /mnt/sdcard/
# change boot dev
cd /mnt/sdcard/boot
sudo sed -i -e 's|root=[^ ]*|root=/dev/mmcblk1p3|' extlinux/extlinux.conf
# 一定注意这里两点. 1: /dev/mmcblk1p3 一定不能写成 sdb3;2. 注意 extlinux/extlinux.conf
double check 下,主要看这里(append root=/dev/mmcblk1p3):
cat extlinux/extlinux.conf
label l0
menu label Debian GNU/Linux trixie/sid 6.6.1+
linux /boot/vmlinuz-6.6.1+
initrd /boot/initrd.img-6.6.1+
fdtdir /usr/lib/linux-image-6.6.1+/
append root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
最后:
sync
umount /mnt/sdcard
这个时候就可以拔除 sd
.
nvme 同理,需要注意的 nvme 的 root 的分区是 /dev/nvme0n1p3
,在使用时注意区分。
大部分细节与 sd 卡一致,其改动的部分如下:
sudo sed -i -e 's|root=[^ ]*|root=/dev/nvme0n1p3|' extlinux/extlinux.conf
boot 码选择模式
00:1-bit QSPI Nor Flash
01: SDIO3.0
10: eMMC
11: eMMC
主要参考这篇文章: https://blog.inuyasha.love/linuxeveryday/start-visionfive2-with-debian-sid.html
作为应聘 Debian/RevyOS 实习生的一个硬性条件,需要完成以下目标:
下载 Debian hello
源代码, 修改其中的 src/hello.c
文件,然后重新打包并安装、运行
vimer@dev:~$ hello -h
Usage: hello [OPTION]...
Print a friendly, customizable greeting.
-h, --help display this help and exit
-v, --version display version information and exit
-t, --traditional use traditional greeting
-g, --greeting=TEXT use TEXT as the greeting message
hello, revyos
其中
hello, revyos
不是必须的,可出现自定义的 string 的即可。参考资料:
http://www.aftermath.cn/2022/02/17/sbuild-build-riscv-on-debian/ https://github.com/yuzibo/talks/blob/main/debian/2022-08-17-debian-fix-ftbfs-riscv64.pptx
说明,基于时效性,以上参考资料中的 URL 中带有 *debian-ports/
可自动调整为 debian/
.
在我看来, cron 用法简洁,比一般的 systemd timer 要简单不少,所以,这里记录下我用 cron 时踩过的坑。
有2篇比较不多的文章:
我目前的环境是升级完系统后,需要在它的 /etc/crontab
修改为
SHELL=/bin/bash
基本上可以通过以上的文章了解到 cron 的一些基本用法,这里只是简单的记录我自己在使用过程的一些心得。
vimer@dev:~/check_log$ crontab -l
# 每6个小时的第15min执行一次
# https://www.cnblogs.com/kaituorensheng/p/4494321.html
15,30,45,59 * * * * /bin/bash /home/vimer/check_log/connect_test.sh > /tmp/test.txt 2>&1
其实主要的问题就是 SHELL 环境变量被修改了,直接编辑 /etc/crontab
就可以。
https://etherpad.openeuler.org/p/cron_summary
创建和使用应用专用密码
重要提示:若要创建应用专用密码,您需要为 Google 帐号开启两步验证。
如果您已开启两步验证,并且在登录帐号时收到了“密码不正确”错误消息,可以尝试使用应用专用密码。 前往您的 Google 帐号。
首先应该看一下这个wiki: https://gist.github.com/F21/b0e8c62c49dfab267ff1d0c6af39ab84
可以根据wiki
通过这个wiki,我们反向理解,并且我加上自己真实案例予以说明。
S老师给我做了一个名为msg.asc
的加密消息,其内容应该就是s老师给我的签名key。
cat msg.asc
-----BEGIN PGP MESSAGE-----
...
...
这就是加密的消息。下面是重点,我们需要使用--decrypt
选项将这个加密消息进行解密:
vimer@dev:~/tmp$ gpg --decrypt msg.asc
gpg: encrypted with 4096-bit RSA key, ID 66681FECEFF9AC75, created 2022-04-09
"Bo YU <[email protected]>"
...
Hi,
please find attached the user id
Bo YU <[email protected]>
of your key 954E6A70100598A2 signed by me.
If you have multiple user ids, I sent the signature for each user id
separately to that user id's associated email address. You can import
the signatures by running each through `gpg --import`.
Note that I did not upload your key to any keyservers. If you want this
new signature to be available to others, please upload it yourself.
With GnuPG this can be done using
gpg --keyserver hkp://pool.sks-keyservers.net --send-key 954E6A70100598A2
...
------------=_1689674421-10093-0
Content-Type: application/pgp-keys;
name="0x954E6A70100598A2.1.signed-by-0xxxxxxxx.asc"
Content-Disposition: attachment;
filename="0x954E6A70100598A2.1.signed-by-0xxxxxx.asc"
Content-Transfer-Encoding: 7bit
Content-Description: PGP Key 0x954E6A70100598A2, uid Bo YU <[email protected]>
(1), signed by 0xxxxxxxxxxx
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----
注意,这个PUBLIC KEY BLOCK
的内容才是最重要的内容,我的做法是copy出来保存到一个xx.asc文件,然后再 import
.
vimer@dev:~/tmp$ gpg --import sun.asc
gpg: key 954E6A70100598A2: 1 signature not checked due to a missing key
gpg: key 954E6A70100598A2: "Bo YU <[email protected]>" 1 new signature
gpg: Total number processed: 1
gpg: new signatures: 1
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
vimer@dev:~/tmp$ gpg --keyserver keyserver.ubuntu.com --send-keys 100598A2
gpg: sending key 954E6A70100598A2 to hkp://keyserver.ubuntu.com
Update:
change private domain
sudo mmdebstrap --arch=riscv64 --include=fakeroot,build-essential,ca-certificates,apt-transport-https sid sid-riscv64-revyos-sbuild.tar.xz "deb [trusted=yes] ** revyos-addons main" "deb [trusted=yes] **/revyos-base sid main contrib non-free"
```bash mkdir -p tmp/rv64-chroot cd tmp/rv64-chroot/ sudo tar -xvf ../../sid-riscv64-revyos-sbuild.tar.xz sudo chroot .
3. make image
# 根据需要确定
```bash
sudo virt-make-fs --partition=gpt --type=ext4 --size=6G tmp/rv64-chroot/ rootfs.img
qemu-system-riscv64 -nographic -machine virt -m 1.9G \
-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0 \
-append "console=ttyS0 rw root=/dev/vda1" \
-device virtio-blk-device,drive=hd0 -drive file=rootfs.img,format=raw,id=hd0 \
-device virtio-net-device,netdev=usernet -netdev user,id=usernet,hostfwd=tcp::22222-:22
user: root psswd: riscv64