Skip to content

Ubuntu virtualBox

unknown edited this page Aug 10, 2021 · 9 revisions

Chapters

1. Download stage
2. Install Oracle Virtual Box
3. Setup virtual machine
4. Ubuntu Installation
5. SSH tunneling - obtional 1
6. Shared folder - obtional 2
7. Installing build tools
8. Kernel installation
9. Setup of the environment

Downloading

Well, first of all let's download Oracle Virtual Box. In my case I will use Widows host option.

Then download Ubuntu or Linux. Both Virtual Box and Ubuntu, should be free, so there it would not be any problem with the license stuff. In this example I will use Ubuntu Server 20.04.2 LTS, but you are free to use any Ubuntu version you want.

Prerequites

Now it's time to install and configure Virtual Box. The process it's quite simple, but for the sake of it, I will put all the necessary details.

Step 1
Run the installation of the virtual box. Click next.
vBox_1

Step 2
Choose to take all options, and also pick the location where you want to install Virtual Box. I recommend you to install virtual box on the computer at least, and the OS on the hard drive. Also it's a best practice to use underline or dash instead white spaces.
vBox_2

Step 3
On next step I choosed to uncheck the shorcut of Quick launch Bar, but you can checked up if you want.
vBox_3

Step 4
Next step it's pretty step forward. All you have to to is to press yes,
vBox_4

Step 5
and then press install.
vBox_5

Step 6
After the installation occured, press Finish, with the Start option checked, as we continue the setup, in the next chapter.
vBox_6

Setup virtual image

Now it's time to create a virtual machine with ubuntu os machine we downloaded early.

Step 1
Click New button, for creating a new disk image.
vBox_7

Step 2
Select a name for the image (I choosed Ubuntu Server 20 LTS), the location on the hard drive or external hard drive; For type choose Linux, and for version choose Ubuntu (64 bit).
vBox_8

Step 3
In the next window choose the RAM Memory. More that you allocate, faster guest macine will run. However you should keep some memory also for host machine. In this example I will choose 3100 (3GB), as I think it's more than enough, that we will not have the GUI part of the Linux.
vBox_9

Step 4
Select to create a virtual hard disk now. This will be the virtual image of the operating system.
vBox_10

Step 5
And then choose virtualBox disk Image.
vBox_11

Step 6
Always choose Dinamically allocated, as it save you hard disk space, which is not used by the guest os.
vBox_12

Step 7
And finally, choose a limit of hard drive for ubuntu. This can be as higher as you want. You can change later the location of the image, but you can't choose to upgrade this limmit later.
I will choose 50 GB, as is more than enough for this tutorial or any tools and installation there.
vBox_13

Step 8
Now, go to setings for the image we just created..
vBox_14

Step 9
Under the Storage section, in the Controller: IDE section, with the Host drive E selected..
vBox_15

Step 10
Choose to change the disc with the ubuntu image we just downloaded before. This will mount the image, so that installation can begin.
After that press OK button, for saving the settings.
vBox_16

Step 11
Then we can start the Ubuntu Server 20 LTS, in Detachable Start state.
vBox_17

Installation

Step 12
The actual installation begins. We are prompted to select our language. I will choose English for myself.
vBox_18

Step 13
On next screen we can choose the layout of the keyboard. I will live it as it is. vBox_19

Step 14
We don't need network connection between this computer and other computer, so we will skeep this step.
vBox_20

Step 15
We will skip also the settings for proxy server.
vBox_21

Step 16
Hit next when it asking for ubuntu archive mirror.
vBox_22

Step 17
On the next screen we are asked if we want to use ubuntu on one disc or more. I will live it as default.
vBox_23

Step 18
This is just a Summary of the installation. Hit Done for next, and on the prompt with confirmation of destructive action, choose Continue.
vBox_24

Step 19
Choose a name for the user name of this OS, a name for this "computer", a username and a password. It's a good habbit to fill up al the inputs here.
vBox_25

Step 20
Check in option for install OpenSSH server, and hit Done.
vBox_26

Step 21
Here you can install extra options feature. We can install them later, so we will skip this as well.
vBox_27

Step 22
After installing everything, press Reboot Now.
vBox_28

You may get error for removing optical drive. Hit enter anyway, for continue.

Step 23
Then login with your credentials.
vBox_29

Obtional 1 - copy-paste capability

This section is for accessing VM with SSH from the host OS. This is the only way if you want to use copy-paste between host and the guest.

Press Machine/ ACPI Shutdown, if your virtual machine it's still running. This is the shut down for it.
vBox_30

Step 1
Go again in Settings for this image, but this time on Network section. NAT adappter should be checked in. Click on the Advanced to expand the settings.
vBox_31

Step 2
Then press Port Forwarding. Click on plus icon to add a new rule for the tunnel. And then choose some name and values. As you can see I chosed port 2222 for host, and port 22 for guest. I choosed them as they are not so common ports allocated by other services.
vBox_32

Hit OK button twice for saving the settings.

Step 3
Restart virtual machine by Start/Headless Start.

Step 4
Download PuTTY from here. I have Windows 64 bit version, so I will use putty-64bit-0.75-installer.msi. Installed it by going fast through the installation process. All I did here, is just checked in the desktop shorcut for it.

Step 5
Start the PuTTY. And setup a new connection, but adding localhost on Host Name 2222 for the host port of local machine, and save this connection as Ubuntu vBox.
vBox_33

Step 6
Open the connection with PuTTY. It may pop out a Security Alert window, but we trust the virtual machine we just installed, so we will accept it.
If it crush, just restart the PuTTY.
vBox_34

Step 7
Just login with your credentials, and you are good to go.

Obtional 2 - shared folder

If you want to have more control over virtual machine, like a shared folder, this will show you & me, the know-how. You need VirtualBox Guest Additions installation for this option.

Step 1
Open Putty if you set it up on the previous step, or directly on the console type:

	sudo add-apt-repository multiverse -y
	sudo apt install virtualbox-guest-dkms virtualbox-guest-x11 -y

Step 2
Then reinstall the terminal, and restart the virtual machine.

	sudo apt-get install gnome-terminal -y
	sudo reboot

Exit Putty, and after VM restarted itself, connect again.

Step 3
For having displaying only the console, wihout the new GUI interface that appears after previous step, for keeping the speed of the machine, run this command in the console:

	sudo systemctl set-default multi-user.target


Put your password if it asked for it.

Step 4
Type exit on PuTTY first if is openedcd, and then Show with ACPI Shutdown next on guest machine.
vBox_30

Step 5
Go to settings for the selected virtual image.
vBox_14

Step 6
Select section Shared Folders, and "+" icon. Select the folder you want, and then check Auto-mount. vBox_35

Step 7
Start the virtual machine in the Detachable State, and log in with your credentials.
Then type df -h
vBox_36



As you can see, the selected folder Github, can be seen on the virtual machine under the name sf_Github.

Step 8
Adding the user to the vboxsf group, and then restart the VM:

	sudo adduser cristishor vboxsf
	sudo reboot


where cristishor it's my user.

Now you can change the folder:

	cd /media/sf_Github


or your sf_folder.

Step 9
Now, type ls --all, and you should see all folders and files.

Configuring

Kernel installation

Before we proceed, we need to configuring the usb adapter. In a normal situation this would be done automatically, but in this situation we access the board thorough virtual box.

Step 1
Plug in the usb adapter ( usb - micro-usb) to connect the board and the PC.
vBox_37

Step 2
Right click on the usb icon, on the bellow taskbar of the virtual machine window.
vBox_38

Step 3
Then you can select the device. It should be something like UART Bridge Controller. vBox_39

Step 4
If you want to setup it automatically on the next encounter,
Click on the USB Settings... (see picture from above). Next from the USB section, click on the "+" usb icon, and select the device. In my case is Silicon Labs CP2102N USB to UART Bridge Controller. And then press OK.
vBox_40

Step 5
Type lsusb. If it display your connected device, you completed kernel installation successfully.

Installing build tools

Now it's time to install and configure what we need for developement in ESP8266.

Step 1
Run this command:

	sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python3 python3-serial

Put your password if it asked for it. And press y, for accepting installed these packages.

Setup of Environment

Step 1
Download the arhive depending on the OS bit verssion of Linux you installed.
For 64-bit Linux use: https://dl.espressif.com/dl/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz
For 32-bit Linux use: https://dl.espressif.com/dl/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-i686.tar.gz

It is convenient use Putty tunnel for this.
In my case, I will use the 64 bit verssion, by downloaded it with:

	wget https://dl.espressif.com/dl/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz

Step 2
Create esp directory, and go inside it.

mkdir -p ~/esp
cd ~/esp

Step 3
Extract the archive to esp folder.

tar -xzf ~/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz

Step 4
Next download ESP8266_RTOS_SDK.

git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git

Step 5
Edit the .profile file, which is one level up.

nano ../.profile



At the end of the file we add:

export PATH="$PATH:$HOME/esp/xtensa-lx106-elf/bin"
export IDF_PATH="$HOME/esp/ESP8266_RTOS_SDK"



Then save the file with ctrl + O. And exit with ctrl + x.

Step 6
Type printenv PATH to see if it's installed corectly. If it's Ok, it should give you a long link, else a short error.

Step 7
Type exit on PuTTY, and then login again. Then printenv IDF_PATH should be able to print the link to ESP8266_RTOS_SDK folder.

Step 8
Run sudo apt-get install -y python3-pip for making pip works.

Step 9
Install python dependency by:

python3 -m pip install --user -r $IDF_PATH/requirements.txt

Step 10
For the build setup, run:

	sudo apt-get install python-is-python3

That's it. All you need to do now, it's to pick up an example, and build it.

Content

Clone this wiki locally