xref: /openwifi/user_space/populate_kernel_image_module_reboot.sh (revision ce4469b31b4197367649f770b36e35101071b0c1)
1#!/bin/bash
2
3# Author: Xianjun Jiao
4# SPDX-FileCopyrightText: 2019 UGent
5# SPDX-License-Identifier: AGPL-3.0-or-later
6
7set -ex
8
9MACHINE_TYPE=`uname -m`
10
11mkdir -p kernel_modules
12rm -rf kernel_modules/*
13tar -zxvf kernel_modules.tar.gz
14
15if [ ${MACHINE_TYPE} == 'aarch64' ]; then
16    IMAGE_FILENAME=Image
17    DTB_FILENAME="system.dtb"
18else
19    IMAGE_FILENAME=uImage
20    DTB_FILENAME="devicetree.dtb"
21fi
22
23mv ./kernel_modules/ad9361_drv.ko ./openwifi/ -f || true
24mv ./kernel_modules/adi_axi_hdmi.ko ./openwifi/ -f || true
25mv ./kernel_modules/axidmatest.ko ./openwifi/ -f || true
26mv ./kernel_modules/lcd.ko ./openwifi/ -f || true
27mv ./kernel_modules/xilinx_dma.ko ./openwifi/ -f || true
28
29rm -rf /lib/modules/$(uname -r)
30ln -s /root/kernel_modules /lib/modules/$(uname -r)
31
32depmod
33
34umount /mnt || /bin/true
35mount /dev/mmcblk0p1 /mnt
36if test -f "./kernel_modules/$IMAGE_FILENAME"; then
37    cp ./kernel_modules/$IMAGE_FILENAME /mnt/
38fi
39if test -f "./kernel_modules/BOOT.BIN"; then
40    cp ./kernel_modules/BOOT.BIN /mnt/
41fi
42if test -f "./kernel_modules/$DTB_FILENAME"; then
43    cp ./kernel_modules/$DTB_FILENAME /mnt/
44fi
45cd /mnt/
46sync
47cd ~
48umount /mnt
49
50reboot now
51