Skip to content

Commit

Permalink
update build script, add wifi firmware, add scripts for target
Browse files Browse the repository at this point in the history
  • Loading branch information
cvetaevvitaliy committed Dec 4, 2021
1 parent baecaae commit b2f944a
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 44 deletions.
129 changes: 85 additions & 44 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ export LC_ALL=C

# TODO: need to make config file for configure build versions
UBOOT_VERSION="v2021.10"
KERNEL_VERSION="v5.15.x"
UBUNTU_VERSION="ubuntu-20.04.3"
KERNEL_VERSION="5.8.5-armv7-lpae-x11"
ROOTFS_NAME="ubuntu-18.04.6-minimal-armhf-2021-11-02.tar.xz"
ROOT_FS_LINK="wget -c https://rcn-ee.com/rootfs/eewiki/minfs/${ROOTFS_NAME}"
UBUNTU_VERSION="ubuntu"

CUR_PATH=$(pwd)

Expand Down Expand Up @@ -94,7 +96,7 @@ function build_kernel(){

if ! [ -d ./armv7-lpae-multiplatform ]; then
echo "============================================"
echo "Start get Kernel source"
echo "Init submodule Kernel source"
git submodule init
git submodule update
fi
Expand All @@ -103,7 +105,10 @@ function build_kernel(){
echo "Start build Kernel"
cd armv7-lpae-multiplatform

git checkout origin/${KERNEL_VERSION} -b tmp
echo "Get Kernel version '${KERNEL_VERSION}'"
git reet --hard
git checkout ${KERNEL_VERSION}
echo "Start build Kernel ${KERNEL_VERSION}"
(exec "$BUILD_KERNEL")
cd ..

Expand Down Expand Up @@ -157,14 +162,14 @@ function download_ubuntu(){
echo "Download ${UBUNTU_VERSION} "
check_download_dir

if ! [ -f ./download_dir/${UBUNTU_VERSION}-minimal-armhf-2021-11-02.tar.xz ]; then
wget -P ./download_dir https://rcn-ee.com/rootfs/eewiki/minfs/${UBUNTU_VERSION}-minimal-armhf-2021-11-02.tar.xz
if ! [ -f ./download_dir/${ROOTFS_NAME} ]; then
wget -P ./download_dir ${ROOT_FS_LINK}
fi

if ! [ -d ./${UBUNTU_VERSION} ]; then
mkdir ./${UBUNTU_VERSION}
echo "Extract to ${CUR_PATH}/${UBUNTU_VERSION} "
tar xvf ./download_dir/${UBUNTU_VERSION}-minimal-armhf-2021-11-02.tar.xz -C ./${UBUNTU_VERSION}
tar xvf ./download_dir/${ROOTFS_NAME} -C ./${UBUNTU_VERSION}
fi
}

Expand All @@ -180,17 +185,21 @@ function check(){

function calenup(){
echo ""
echo "Clean up loop device"

echo "Try umount folder: '${MOUNT_PATH}'"
sudo umount ${MOUNT_PATH}
case "$?" in
0) echo "Umount OK" ;;
*) echo "Error Umount" ;;
0) echo "umount '${MOUNT_PATH}' OK" ;;
*) echo "Error mmount folder '${MOUNT_PATH}'" ;;
esac

echo "Try clean up loop: '${LOOP_DEVICE}' "
sudo losetup -D
case "$?" in
0) echo "Clean ${LOOP_DEVICE} device OK" ;;
*) echo "Error clean ${LOOP_DEVICE} device " ;;
0) echo "Clean loop '${LOOP_DEVICE}' device OK" ;;
*) echo "Error clean '${LOOP_DEVICE}' device " ;;
esac
echo "Finish"
exit 0
}

Expand Down Expand Up @@ -249,70 +258,93 @@ function create_image(){
sudo dd if=./output/u-boot.img of=${LOOP_DEVICE}p3
else
echo "First need build U-Boot, please make './build.sh uboot'"
exit 0
fi

echo ""

echo "Format RootFS Partition:"
echo ""
sudo mkfs.ext4 -L rootfs ${LOOP_DEVICE}p4
check
check

MOUNT_PATH="./output/rootfs"

echo "Mount rootfs file system to ${MOUNT_PATH}"
echo ""
sudo mkdir -p ${MOUNT_PATH}
sudo mount /dev/loop0p4 ${MOUNT_PATH}
check
check

echo ""
if [ -d ./armv7-lpae-multiplatform/deploy ]; then
kernel_ver=$(basename ./armv7-lpae-multiplatform/deploy/*.zImage | rev | cut -c 8- | rev )
echo "Kernel version ${kernel_ver}"

kernel_ver=$(basename ./armv7-lpae-multiplatform/deploy/*.zImage | rev | cut -c 8- | rev )
echo "Kernel version ${kernel_ver}"
else
echo "First need build Kernel, please make './build.sh kernel'"
echo "First need build Kernel, please make './build.sh kernel'"
exit 0
fi


echo ""
echo "Copy Root File System"
if [ -d ./${UBUNTU_VERSION} ]; then
mkdir ./${UBUNTU_VERSION}
echo "Extract to ${CUR_PATH}/${UBUNTU_VERSION} "
sudo tar xfp ./${UBUNTU_VERSION}/ubuntu-*-*-armhf-*/armhf-rootfs-*.tar -C ${MOUNT_PATH}
check
echo "Extract to ${CUR_PATH}/${UBUNTU_VERSION} "
sudo tar xfp ./${UBUNTU_VERSION}/*/*.tar -C ${MOUNT_PATH}
check
else
echo "First need get rootfs, please make './build.sh ubuntu'"
echo "First need get rootfs, please make './build.sh ubuntu'"
exit 0
fi



echo ""
echo "Setup extlinux.conf"
sudo mkdir -p ${MOUNT_PATH}/boot/extlinux/
sudo sh -c "echo 'label Linux ${kernel_ver}' > ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
sudo sh -c "echo ' kernel /boot/vmlinuz-${kernel_ver}' >> ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
sudo sh -c "echo ' append console=ttySTM0,115200 console=tty1,115200 console=tty0,115200 fbcon=rotate:3 root=/dev/mmcblk0p4 ro rootfstype=ext4 rootwait' >> ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
sudo mkdir -p ${MOUNT_PATH}/boot/extlinux/
sudo sh -c "echo 'label Linux ${kernel_ver}' > ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
sudo sh -c "echo ' kernel /boot/vmlinuz-${kernel_ver}' >> ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
sudo sh -c "echo ' append console=ttySTM0,115200 console=tty1,115200 fbcon=rotate:3 root=/dev/mmcblk0p4 ro rootfstype=ext4 rootwait' >> ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
sudo sh -c "echo ' fdtdir /boot/dtbs/${kernel_ver}/' >> ${MOUNT_PATH}/boot/extlinux/extlinux.conf"
check

echo ""
echo "Copy Kernel Image"
sudo cp -v ./armv7-lpae-multiplatform/deploy/${kernel_ver}.zImage ${MOUNT_PATH}/boot/vmlinuz-${kernel_ver}
check
sudo cp -v ./armv7-lpae-multiplatform/deploy/${kernel_ver}.zImage ${MOUNT_PATH}/boot/vmlinuz-${kernel_ver}
check


echo ""
echo "Copy Kernel Device Tree Binaries"
sudo mkdir -p ${MOUNT_PATH}/boot/dtbs/${kernel_ver}/
sudo tar xf ./armv7-lpae-multiplatform/deploy/${kernel_ver}-dtbs.tar.gz -C ${MOUNT_PATH}/boot/dtbs/${kernel_ver}/
check



echo ""
echo "Copy Kernel Modules"
sudo tar xf ./armv7-lpae-multiplatform/deploy/${kernel_ver}-modules.tar.gz -C ${MOUNT_PATH}
sudo tar xfv ./armv7-lpae-multiplatform/deploy/${kernel_ver}-modules.tar.gz -C ${MOUNT_PATH}
check

#sudo sh -c "echo 'auto eth0' >> ${MOUNT_PATH}/etc/network/interfaces"
#sudo sh -c "echo 'iface eth0 inet dhcp' >> ${MOUNT_PATH}/etc/network/interfaces"

echo ""
echo "Copy WiFi firmware"
sudo mkdir -p ${MOUNT_PATH}/lib/firmware/brcm/
sudo cp -v ./wifi_firmware/brcmfmac43430* ${MOUNT_PATH}/lib/firmware/brcm/
sudo cp -v ./wifi_firmware/brcmfmac43430-sdio.txt ${MOUNT_PATH}/lib/firmware/brcm/brcmfmac43430-sdio.st,stm32mp157c-dk2.txt
check

# activate welcome message
sudo chmod +x ${MOUNT_PATH}/etc/update-motd.d/00-header
sudo chmod +x ${MOUNT_PATH}/etc/update-motd.d/10-help-text
sudo chmod +x ${MOUNT_PATH}/etc/update-motd.d/50-motd-news
sudo chmod +x ${MOUNT_PATH}/etc/update-motd.d/80-esm
sudo chmod +x ${MOUNT_PATH}/etc/update-motd.d/80-livepatch

echo ""
echo "Copy helper scripts"
sudo cp -v ./script/resize_sd.sh ${MOUNT_PATH}/usr/bin/
sudo cp -v ./script/activate_wifi.sh ${MOUNT_PATH}/usr/bin/

echo ""
echo "File Systems Table (/etc/fstab)"
Expand All @@ -321,10 +353,10 @@ function create_image(){

sync
case "$?" in
0) echo "Sync OK" ;;
*) echo "Error sync " ;;
0) echo "Sync OK" ;;
*) echo "Error sync " ;;
esac

calenup

}
Expand All @@ -347,6 +379,14 @@ function build_info(){
echo "Build information"
}

function compress_img(){
echo "Compress SD card image"
TAR_NAME=$(basename ${ROOTFS_NAME} | cut -c 1-14)
echo "${TAR_NAME}"
# tar cfv - ./output/sdcard-stm32mp157.img | pv | xz -z -T0 - > ./output/${TAR_NAME}-full-sd-image.tar.xz
pv ./output/sdcard-stm32mp157.img | gzip > ./output/${TAR_NAME}-full-sd-image.img.gz
}



if echo $@|grep -wqE "help|-h"; then
Expand Down Expand Up @@ -376,6 +416,7 @@ for option in ${OPTIONS}; do
mkimage) create_image ;;
cleanall) build_cleanall ;;
check) check_env ;;
compress_img) compress_img ;;
info) build_info ;;
*) usage ;;
esac
Expand Down
33 changes: 33 additions & 0 deletions ch-mount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
function mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}/proc
sudo mount -t sysfs /sys ${2}/sys
sudo mount -o bind /dev ${2}/dev
sudo chroot ${2}

}
function umnt() {
echo "UNMOUNTING"
sudo umount ${2}/proc
sudo umount ${2}/sys
sudo umount ${2}/dev
}
if [ "$1" == "-m" ] && [ -n "$2" ];
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or both parameters were missing"
echo ""
echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
echo ""
echo "For example: ch-mount -m /media/sdcard/"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : ${2}
fi
8 changes: 8 additions & 0 deletions script/activate_wifi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/bash

sudo apt update
sudo apt install rfkill -y
sudo rfkill list all
sudo rfkill unblock all
sudo ifconfig wlan0 up
ifconfig
5 changes: 5 additions & 0 deletions script/resize_sd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash

sudo growpart /dev/mmcblk0 4
sudo resize2fs /dev/mmcblk0p4
df -h
59 changes: 59 additions & 0 deletions wifi_firmware/brcmfmac43430-sdio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# NVRAM file for BCM943430WLSELG
# 2.4 GHz, 20 MHz BW mode

# The following parameter values are just placeholders, need to be updated.
manfid=0x2d0
prodid=0x0726
vendid=0x14e4
devid=0x43e2
boardtype=0x0726
boardrev=0x1202
boardnum=22
macaddr=00:90:4c:c5:12:38
sromrev=11
boardflags=0x00404201
boardflags3=0x08000000
xtalfreq=37400
#xtalfreq=19200
nocrc=1
ag0=255
aa2g=1
ccode=ALL

pa0itssit=0x20
extpagain2g=0

#PA parameters for 2.4GHz, measured at CHIP OUTPUT
pa2ga0=-168,7161,-820
AvVmid_c0=0x0,0xc8
cckpwroffset0=5

# PPR params
maxp2ga0=84
txpwrbckof=6
cckbw202gpo=0
legofdmbw202gpo=0x66111111
mcsbw202gpo=0x77711111
propbw202gpo=0xdd

# OFDM IIR :
ofdmdigfilttype=18
ofdmdigfilttypebe=18
# PAPD mode:
papdmode=1
papdvalidtest=1
pacalidx2g=32
papdepsoffset=-36
papdendidx=61

il0macaddr=00:90:4c:c5:12:38
wl0id=0x431b

deadman_to=0xffffffff
# muxenab: 0x1 for UART enable, 0x2 for GPIOs, 0x8 for JTAG
muxenab=0x1
# CLDO PWM voltage settings - 0x4 - 1.1 volt
#cldo_pwm=0x4

#VCO freq 326.4MHz
spurconfig=0x3
Binary file added wifi_firmware/cyfmac43430-sdio.1DX.clm_blob
Binary file not shown.
Binary file added wifi_firmware/cyfmac43430-sdio.bin
Binary file not shown.

0 comments on commit b2f944a

Please sign in to comment.