Last active
October 12, 2021 05:11
-
-
Save Rajssss/301866721b8d2e5cf3cc896415139c51 to your computer and use it in GitHub Desktop.
Colab_Build_Systems_Setup.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Colab_Build_Systems_Setup.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"display_name": "Python 3", | |
"name": "python3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/Rajssss/301866721b8d2e5cf3cc896415139c51/colab_build_systems_setup.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "uvFO744R1q0p" | |
}, | |
"source": [ | |
"Step-1: Setup build server" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "H4I-ghpdFyb0" | |
}, | |
"source": [ | |
" from google.colab import drive\n", | |
"\n", | |
"import random, string\n", | |
"#Setup sshd\n", | |
"! apt-get install -qq -o=Dpkg::Use-Pty=0 openssh-server pwgen > /dev/null\n", | |
"\n", | |
"#Set root password \"colab\"\n", | |
"! echo root:colab | chpasswd\n", | |
"! mkdir -p /var/run/sshd\n", | |
"! echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config\n", | |
"! echo \"PasswordAuthentication yes\" >> /etc/ssh/sshd_config\n", | |
"\n", | |
"\n", | |
"#Run sshd\n", | |
"get_ipython().system_raw('/usr/sbin/sshd -D &')\n", | |
"\n", | |
"#add user ubuntu\n", | |
"! adduser --disabled-password --gecos \"\" ubuntu\n", | |
"! usermod -aG sudo ubuntu\n", | |
"! echo ubuntu:colab | chpasswd\n", | |
"\n", | |
"\n", | |
"#setup ngrok\n", | |
"! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n", | |
"! unzip -qq -n ngrok-stable-linux-amd64.zip\n", | |
"\n", | |
"import getpass\n", | |
"#replace with your ngrock acccount authtoken\n", | |
"authtoken = \"<your_ngrock_auth_token>\"\n", | |
"\n", | |
"#Create tunnel\n", | |
"get_ipython().system_raw('./ngrok authtoken $authtoken && ./ngrok tcp 22 &')\n", | |
"\n", | |
"\n", | |
"#mount gdrive, needs to be on root to access\n", | |
"drive.mount('/content/gdrive/')\n", | |
"\n", | |
"#create dirs\n", | |
"#! mkdir -p dev/bbg/bin dev/bbg/tools\n", | |
"\n", | |
"#download the toolchain\n", | |
"#! cd dev/bbg/tools\n", | |
"#! wget -c https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz\n", | |
"#! tar xf *\n", | |
"#! echo \"export PATH=$PATH:$PWD/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin\" >> ~/.bashrc\n", | |
"#! echo \"export CROSS_COMPILE=arm-linux-gnueabihf-\" >> ~/.bashrc\n", | |
"#! echo \"export ARCH=arm\" >> ~/.bashrc\n", | |
"#! source ~/.bashrc\n", | |
"#! ${CROSS_COMPILE}gcc --version\n", | |
"\n", | |
"#install packages\n", | |
"! apt-get -q -y install ccache bison flex screen nano tree bc lzop u-boot-tools cpio fakeroot lzma gettext libmpc-dev ffmpeg python3-pip gperf libelf-dev libssl-dev build-essential lzop u-boot-tools net-tools bison flex libssl-dev libncurses5-dev libncursesw5-dev unzip chrpath xz-utils minicom wget git-core\n", | |
"\n", | |
"\n", | |
"#clone linux sources\n", | |
"#! cd ..\n", | |
"#! git clone https://github.com/beagleboard/linux -b 4.9 bb-4.9\n", | |
"\n", | |
"\n", | |
"print(\"Done!\")\n" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "SknYnzU6zgDw" | |
}, | |
"source": [ | |
"Step-2:**Hold** on running. ( DO not input anything in the box or hit enter, just keep it running)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "fe02TWNX7xXO" | |
}, | |
"source": [ | |
"\n", | |
"\n", | |
"import getpass\n", | |
"authtoken = getpass.getpass()" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "EmlOKp5tzdmQ" | |
}, | |
"source": [ | |
"Unmount Gdrive (run when needed)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "Upyd6rTW7Qs4" | |
}, | |
"source": [ | |
"from google.colab import drive\n", | |
"drive.flush_and_unmount()" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "sP263TqqNzGt" | |
}, | |
"source": [ | |
"Mount more Gdrive?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "zLvc1C6yNwHn" | |
}, | |
"source": [ | |
"!apt-get install -y -qq software-properties-common python-software-properties module-init-tools\n", | |
"!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null\n", | |
"!apt-get update -qq 2>&1 > /dev/null\n", | |
"!apt-get -y install -qq google-drive-ocamlfuse fuse\n", | |
"from google.colab import auth\n", | |
"auth.authenticate_user()\n", | |
"from oauth2client.client import GoogleCredentials\n", | |
"creds = GoogleCredentials.get_application_default()\n", | |
"import getpass\n", | |
"!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL\n", | |
"vcode = getpass.getpass()\n", | |
"!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}\n", | |
"!mkdir -p /drive2\n", | |
"!google-drive-ocamlfuse /drive2" | |
], | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment