Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

piCore 9.0.3 and RPi Zero W Support #1

Open
hanoschi opened this issue Jul 1, 2018 · 0 comments
Open

piCore 9.0.3 and RPi Zero W Support #1

hanoschi opened this issue Jul 1, 2018 · 0 comments

Comments

@hanoschi
Copy link

hanoschi commented Jul 1, 2018

RPi Zero W needs additional firmware and serial console settings like RPi 3

`
--- picore-headless-setup.sh 2018-07-01 13:07:58.214843119 +0200
+++ picore-headless-setup_9.0.3.sh 2018-07-01 20:45:59.565317199 +0200
@@ -1,18 +1,19 @@
#/bin/bash

PICORE_ARCH="armv6"
-PICORE_VERSION="8.x"
-PICORE_SUBVERSION="8.1.5"
-PICORE_KERNEL_VERSION="4.4.39"

-WORK_DIR=~/picore-$PICORE_SUBVERSION
-MNT_DIR="$WORK_DIR/mnt"
+PICORE_VERSION="9.x"
+PICORE_SUBVERSION="9.0.3"
+PICORE_KERNEL_VERSION="4.9.22"
+
+WORK_DIR=./picore-$PICORE_SUBVERSION
+MNT1_DIR="$WORK_DIR/mnt1"
+MNT2_DIR="$WORK_DIR/mnt2"

IMG_BLOCKSIZE=512
IMG_BLOCKS=204800 # 512 * 204800 = 104857600 (~100MB)

@@ -22,9 +23,10 @@ PICORE_RELEASES_URL="$PICORE_REPOSITORY_
PICORE_PACKAGES_URL="$PICORE_REPOSITORY_URL/tcz"
PICORE_PACKAGE_EXTESION="tcz"
PICORE_RELEASE_URL="$PICORE_RELEASES_URL/piCore-$PICORE_SUBVERSION.zip"
-PICORE_KERNEL_SUFFIX="-$PICORE_KERNEL_VERSION-piCore+"
+PICORE_KERNEL_SUFFIX="-$PICORE_KERNEL_VERSION-piCore"
PICORE_LOCAL_PACKAGE_PATH="tce/optional"
PICORE_LOCAL_MYDATA="tce/mydata"
+PICORE_FILESYSTEM_DIR=$(mktemp -d ${WORK_DIR}/filesystem.XXXXXXXXXX)

PICORE_PACKAGES=( "file"
"ncurses"
@@ -38,6 +40,7 @@ PICORE_PACKAGES_WLAN_CLIENT=( "libnl"
"wpa_supplicant"
"openssl"
"openssh"\

  •                                                           "firmware-rpi3-wireless"\
    

)

WPA_SUPPLICANT_CONF="
@@ -79,7 +82,8 @@ DEPENDENCIES=( "wget"\

function prepare_dirs(){
[ -d $WORK_DIR ] || mkdir $WORK_DIR

  • [ -d $MNT_DIR ] || mkdir $MNT_DIR
  • [ -d $MNT1_DIR ] || mkdir $MNT1_DIR
  • [ -d $MNT2_DIR ] || mkdir $MNT2_DIR
    }

function command_exists() {
@@ -160,17 +164,22 @@ function make_image(){
sudo e2fsck -f "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img2"
sudo resize2fs "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img2"

  • echo " * Mount custom image partition"
  • sudo mount "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img2" $MNT_DIR
  • echo " * Mount custom image partition 1"
  • sudo mount "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img1" $MNT1_DIR
  • echo " * Mount custom image partition 2"
  • sudo mount "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img2" $MNT2_DIR
    }

function cleanup(){
echo "*** Cleaning up ***"

  • sudo umount $MNT_DIR && [ -d "$MNT_DIR" ] && rm "$MNT_DIR" -r
  • sudo umount $MNT1_DIR && [ -d "$MNT1_DIR" ] && rm "$MNT1_DIR" -r
  • sudo umount $MNT2_DIR && [ -d "$MNT2_DIR" ] && rm "$MNT2_DIR" -r
    sudo kpartx -d "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img"
    [ -L "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img1" ] && rm "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img1"
    [ -L "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img2" ] && rm "$WORK_DIR/piCore-$PICORE_SUBVERSION.custom.img2"
    [ -e "$WORK_DIR/piCore-$PICORE_SUBVERSION.zip" ] && rm "$WORK_DIR/piCore-$PICORE_SUBVERSION.zip"
  • [ -d "$PICORE_FILESYSTEM_DIR" ] && sudo rm "$PICORE_FILESYSTEM_DIR" -rf
    }

function test_package_urls(){
@@ -196,35 +205,35 @@ function get_packages(){
do
URL="$PICORE_PACKAGES_URL/$i.$PICORE_PACKAGE_EXTESION"
echo " * $i" "($URL)"

  •    sudo wget -N $WGET_OPTS $URL -P "$MNT_DIR/$PICORE_LOCAL_PACKAGE_PATH/"
    
  •   sudo wget -N $WGET_OPTS "$URL.md5.txt" -P "$MNT_DIR/$PICORE_LOCAL_PACKAGE_PATH/"
    
  •    sudo wget -N $WGET_OPTS $URL -P "$MNT2_DIR/$PICORE_LOCAL_PACKAGE_PATH/"
    
  •   sudo wget -N $WGET_OPTS "$URL.md5.txt" -P "$MNT2_DIR/$PICORE_LOCAL_PACKAGE_PATH/"
    
    done
    }
    function make_onboot_list(){
    echo "*** Adding packages to onboot.lst ***"
  • sudo sh -c "> $MNT_DIR/tce/onboot.lst"
  • sudo sh -c "> $MNT2_DIR/tce/onboot.lst"
    for i in "${PICORE_PACKAGES[@]}"
    do
  •   sudo sh -c "echo $i.tcz >> $MNT_DIR/tce/onboot.lst"
    
  •   sudo sh -c "echo $i.tcz >> $MNT2_DIR/tce/onboot.lst"
    
    done
  • sudo sh -c "echo rng-tools-5.tcz >> $MNT_DIR/tce/onboot.lst"
  • sudo cat "$MNT_DIR/tce/onboot.lst"
  • sudo sh -c "echo rng-tools-5.tcz >> $MNT2_DIR/tce/onboot.lst"
  • sudo cat "$MNT2_DIR/tce/onboot.lst"
    }

function config_wpa_supplicant(){

  • sudo sh -c "echo '$WPA_SUPPLICANT_CONF' > '$MNT_DIR/$PICORE_LOCAL_MYDATA/opt/wpa_supplicant.conf'"
  •   sudo sh -c "echo -e 'opt/wpa_supplicant.conf' >> '$MNT_DIR/$PICORE_LOCAL_MYDATA/opt/.filetool.lst'"
    
  • sudo sh -c "echo '$WPA_SUPPLICANT_CONF' > '$MNT2_DIR/$PICORE_LOCAL_MYDATA/opt/wpa_supplicant.conf'"
  •   sudo sh -c "echo -e 'opt/wpa_supplicant.conf' >> '$MNT2_DIR/$PICORE_LOCAL_MYDATA/opt/.filetool.lst'"
    

}

function config_bootlocal(){

  • sudo sh -c "echo '$BOOTLOCAL_SCRIPT' > '$MNT_DIR/$PICORE_LOCAL_MYDATA/opt/bootlocal.sh'"
  • sudo sh -c "echo '$BOOTLOCAL_SCRIPT' > '$MNT2_DIR/$PICORE_LOCAL_MYDATA/opt/bootlocal.sh'"
    }

function make_mydata(){
echo "*** Adjust mydata.tgz ***"

  • [ -d "$MNT_DIR/$PICORE_LOCAL_MYDATA" ] || sudo mkdir "$MNT_DIR/$PICORE_LOCAL_MYDATA"
  • sudo tar xfz "$MNT_DIR/$PICORE_LOCAL_MYDATA.tgz" -C "$MNT_DIR/$PICORE_LOCAL_MYDATA"
  • [ -d "$MNT2_DIR/$PICORE_LOCAL_MYDATA" ] || sudo mkdir "$MNT2_DIR/$PICORE_LOCAL_MYDATA"

  • sudo tar xfz "$MNT2_DIR/$PICORE_LOCAL_MYDATA.tgz" -C "$MNT2_DIR/$PICORE_LOCAL_MYDATA"

    echo " * WPA Supplicant"
    config_wpa_supplicant
    @@ -233,11 +242,59 @@ function make_mydata(){
    config_bootlocal

    echo " * finalizing"

  • cd "$MNT_DIR/$PICORE_LOCAL_MYDATA"
  • cd "$MNT2_DIR/$PICORE_LOCAL_MYDATA"
    sudo tar -zcf ../mydata.tgz .
    cd -
    }

+function extract_filesystem(){

  • echo "*** Extracting filesystem ***"
  • sudo sh -c "chmod a+rwx $PICORE_FILESYSTEM_DIR"
  • sudo sh -c "zcat ${MNT1_DIR}/${PICORE_SUBVERSION}.gz | (cd $PICORE_FILESYSTEM_DIR && sudo cpio -i -H newc -d)"
    +}

+function rebuild_filesystem(){

  • echo "*** Rebuilding filesystem ***"
  • sudo sh -c "(cd $PICORE_FILESYSTEM_DIR && find | cpio -o -H newc) | gzip -2 > ${MNT1_DIR}/${PICORE_SUBVERSION}.gz"
    +}

+function patch_startserialtty(){

  • piCore 9.0.3 /usr/sbin/startserialtty misses support for RPi Zero W's

  • serial configuration, which is like RPi 3, not like RPi 1/2/Zero:

  • Console is on /dev/ttyS0, not /dev/ttyAMA0

  • maybe RPi Zero W support will be fixed in piCore 9.0.>3, so check, if it

  • is already done

  • ZERO_W_SUPPORT=$(grep "Raspberry Pi Zero W" ${PICORE_FILESYSTEM_DIR}/usr/sbin/startserialtty)
  • if [ "$ZERO_W_SUPPORT" = "" ] ; then
  •  echo "* Patching ${PICORE_FILESYSTEM_DIR}/usr/sbin/startserialtty) for Raspberry Pi Zero W support"
    
  •  PATCH="
    

+--- usr/sbin/startserialtty
++++ usr/sbin/startserialtty
+@@ -4,6 +4,8 @@
+

  • if [ "${model:0:20}" = "Raspberry Pi 3 Model" ]; then
  • port=ttyS0
    

++elif [ "${model:0:19}" = "Raspberry Pi Zero W" ]; then
++ port=ttyS0

  • else
  • port=ttyAMA0
    
  • fi
    +"
  •  FULLPATH="$(pwd)/${WORK_DIR}"
    
  •  echo "$PATCH" > ${WORK_DIR}/startserialtty.patch
    
  •  sudo sh -c "(cd $PICORE_FILESYSTEM_DIR && sudo patch -p0 < ${FULLPATH}/startserialtty.patch)"
    
  •  sudo sh -c "rm -rf ${FULLPATH}/startserialtty.patch"
    
  • else
  •  echo "* ${PICORE_FILESYSTEM_DIR}/usr/sbin/startserialtty) already supports Raspberry Pi Zero W - no patch needed"
    
  • fi
    +}

check_dependencies
prepare_dirs
get_release
@@ -246,4 +303,7 @@ test_package_urls
get_packages
make_onboot_list
make_mydata
+extract_filesystem
+patch_startserialtty
+rebuild_filesystem
cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant