xref: /openwifi/user_space/populate_kernel_image_module_reboot.sh (revision d684d4e9ecda8d3893804513b67aa6c877258f40)
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
17else
18    IMAGE_FILENAME=uImage
19fi
20
21mv ./kernel_modules/ad9361_drv.ko ./openwifi/ -f || true
22mv ./kernel_modules/adi_axi_hdmi.ko ./openwifi/ -f || true
23mv ./kernel_modules/axidmatest.ko ./openwifi/ -f || true
24mv ./kernel_modules/lcd.ko ./openwifi/ -f || true
25mv ./kernel_modules/xilinx_dma.ko ./openwifi/ -f || true
26
27rm -rf /lib/modules/$(uname -r)
28ln -s /root/kernel_modules /lib/modules/$(uname -r)
29
30depmod
31
32umount /mnt || /bin/true
33mount /dev/mmcblk0p1 /mnt
34if test -f "./kernel_modules/$IMAGE_FILENAME"; then
35    cp ./kernel_modules/$IMAGE_FILENAME /mnt/
36fi
37if test -f "./kernel_modules/BOOT.BIN"; then
38    cp ./kernel_modules/BOOT.BIN /mnt/
39fi
40cd /mnt/
41sync
42cd ~
43umount /mnt
44
45reboot now
46