From 3344243189b5658e0a8d0fc27c091df69cf6402d Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Thu, 14 Sep 2023 12:22:04 -0500 Subject: [PATCH] switch to ubuntu 23.04 Signed-off-by: Robert Nelson --- .gitignore | 1 + .gitlab-ci.yml | 2 +- 06_generate_ubuntu_console_root.sh | 110 ++++++++++++++++++ .../beagleboard/gateware/change-gateware.sh | 5 + 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100755 06_generate_ubuntu_console_root.sh diff --git a/.gitignore b/.gitignore index 65d579b..5c26048 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ deploy/*-modules.tar.gz deploy/Image deploy/*.dtb deploy/debian* +deploy/ubuntu* /ignore/ /mirror/ /riscv-toolchain/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1a5589..ce3ddb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ build: - ./03_build_u-boot.sh - ./04_build_linux.sh - ./05_generate_payload.bin.sh - - ./06_generate_debian_console_root.sh + - ./06_generate_ubuntu_console_root.sh - ./07_create_sdcard_img.sh - xz -vT8 deploy/images/sdcard.img - tree -s deploy/ diff --git a/06_generate_ubuntu_console_root.sh b/06_generate_ubuntu_console_root.sh new file mode 100755 index 0000000..4a35533 --- /dev/null +++ b/06_generate_ubuntu_console_root.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +if ! id | grep -q root; then + echo "./06_generate_ubuntu_console_root.sh must be run as root:" + echo "sudo ./06_generate_ubuntu_console_root.sh" + exit +fi + +wdir=`pwd` + +if [ -f /tmp/latest ] ; then + rm -rf /tmp/latest | true +fi +wget --quiet --directory-prefix=/tmp/ https://rcn-ee.net/rootfs/ubuntu-riscv64-23.04-minimal/latest || true +if [ -f /tmp/latest ] ; then + latest_rootfs=$(cat "/tmp/latest") + datestamp=$(cat "/tmp/latest" | awk -F 'riscv64-' '{print $2}' | awk -F '.' '{print $1}') + + if [ ! -f ./deploy/ubuntu-23.04-console-riscv64-${datestamp}/riscv64-rootfs-ubuntu-lunar.tar ] ; then + if [ -f ./.gitlab-runner ] ; then + wget -c --directory-prefix=./deploy http://192.168.1.98/rcn-ee.us/rootfs/ubuntu-riscv64-23.04-minimal/${datestamp}/${latest_rootfs} + else + wget -c --directory-prefix=./deploy https://rcn-ee.net/rootfs/ubuntu-riscv64-23.04-minimal/${datestamp}/${latest_rootfs} + fi + cd ./deploy/ + tar xf ${latest_rootfs} + cd ../ + fi +else + echo "Failure: getting image" + exit 2 +fi + +if [ -d ./ignore/.root ] ; then + rm -rf ./ignore/.root || true +fi +mkdir -p ./ignore/.root + +echo "Extracting: ubuntu-23.04-console-riscv64-${datestamp}/riscv64-rootfs-ubuntu-lunar.tar" +tar xfp ./deploy/ubuntu-23.04-console-riscv64-${datestamp}/riscv64-rootfs-ubuntu-lunar.tar -C ./ignore/.root +sync + +mkdir -p ./deploy/input/ || true +cp -v ./deploy/boot.scr deploy/input/ + +echo "label Linux eMMC" > ./deploy/input/extlinux.conf +echo " kernel /Image" >> ./deploy/input/extlinux.conf +#echo " append root=/dev/mmcblk0p3 ro rootfstype=ext4 rootwait console=ttyS0,115200 earlycon uio_pdrv_genirq.of_id=generic-uio net.ifnames=0" >> ./deploy/input/extlinux.conf +echo " fdtdir /" >> ./deploy/input/extlinux.conf +echo " fdt /mpfs-beaglev-fire.dtb" >> ./deploy/input/extlinux.conf +echo " #fdtoverlays /overlays/.dtbo" >> ./deploy/input/extlinux.conf + +#echo "extlinux/extlinux.conf" +#cat ./deploy/input/extlinux.conf + +mkdir -p ./ignore/.root/boot/firmware/ || true + +echo '/dev/mmcblk0p2 /boot/firmware/ auto defaults 0 2' >> ./ignore/.root/etc/fstab +echo '/dev/mmcblk0p3 / auto errors=remount-ro 0 1' >> ./ignore/.root/etc/fstab +echo 'debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0' >> ./ignore/.root/etc/fstab + +rm -rf ./ignore/.root/usr/lib/systemd/system/bb-usb-gadgets.service || true +rm -rf ./ignore/.root/etc/systemd/system/getty.target.wants/serial-getty@ttyGS0.service || true +rm -rf ./ignore/.root/etc/systemd/network/usb0.network || true +rm -rf ./ignore/.root/etc/systemd/network/usb1.network || true + +cp -v ./ignore/.root/etc/bbb.io/templates/eth0-DHCP.network ./ignore/.root/etc/systemd/network/eth0.network || true + +if [ -f ./ignore/.root/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service ] ; then + rm -rf ./ignore/.root/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service || true +fi + +#rm -rf ./ignore/.root/usr/lib/systemd/system/grow_partition.service || true +#cd ./ignore/.root/ +#ln -L -f -s -v /lib/systemd/system/resize_filesystem.service --target-directory=./etc/systemd/system/multi-user.target.wants/ +#cd ../../ + +# setuid root ping+ping6 +chmod u+s ./ignore/.root/usr/bin/ping ./ignore/.root/usr/bin/ping6 + +mkdir -p ./ignore/.root/etc/beagleboard/gateware/board-tests/ +mkdir -p ./ignore/.root/etc/beagleboard/gateware/default/ +mkdir -p ./ignore/.root/etc/microchip/ + +cp -v ./rootfs/etc/beagleboard/gateware/* ./ignore/.root/etc/beagleboard/gateware/ +cp -v ./rootfs/etc/microchip/* ./ignore/.root/etc/microchip/ +chmod +x ./ignore/.root/etc/beagleboard/gateware/change-gateware.sh +chmod +x ./ignore/.root/etc/microchip/update-gateware.sh + +cp -v ./gateware-snapshots/board-tests/*.spi ./ignore/.root/etc/beagleboard/gateware/board-tests/ +cp -v ./gateware-snapshots/default/*.spi ./ignore/.root/etc/beagleboard/gateware/default/ + +if [ -f ./deploy/.modules ] ; then + version=$(cat ./deploy/.modules || true) + if [ -f ./deploy/${version}-modules.tar.gz ] ; then + tar xf ./deploy/${version}-modules.tar.gz -C ./ignore/.root/usr/ + fi +fi + +echo '---------------------' +echo 'File Size' +du -sh ignore/.root/ || true +echo '---------------------' + +dd if=/dev/zero of=./deploy/input/root.ext4 bs=1 count=0 seek=3000M +mkfs.ext4 -F ./deploy/input/root.ext4 -d ./ignore/.root + +if [ -f ./.06_generate_root.sh ] ; then + rm -f ./.06_generate_root.sh || true +fi diff --git a/rootfs/etc/beagleboard/gateware/change-gateware.sh b/rootfs/etc/beagleboard/gateware/change-gateware.sh index 15160d3..83da5bc 100644 --- a/rootfs/etc/beagleboard/gateware/change-gateware.sh +++ b/rootfs/etc/beagleboard/gateware/change-gateware.sh @@ -1,5 +1,10 @@ #!/bin/bash +if ! id | grep -q root; then + echo "must be run as root" + exit +fi + if [ -d $1 ] then echo "Changing gateware."