Setting-up a development environment on LattePanda Alpha with Windows 10
In this article I will go thru setting-up a generic development environment on Windows 10. I recently received a fantastic SBC from LattePanda called LattePanda Alpha. It has beefy specs and great expandability, totally suited for most tasks, also since it's pocket-sized, it can be carried around as your go-around PC.
My main computer is a 15-inch Macbook Pro but with the huge amount of people developing on Windows and it’s new capabilities and applications, this article make sense even to me as a secondary environment with an alternative OS.
LattePanda Alpha
I will briefly overview the SBC since there are already lots of amazing reviews of this amazing board on the internet.
Some details:
- CPU:Intel 7th Gen Core m3–7y30
- Core:1.6–2.6GHz Dual-Core,Four-Thread
- Graphics:Intel HD Graphics 615, 300–900MHz
- RAM:8G LPDDR3 1866MHz Dual-Channel
- Memory:64GB eMMC V5.0l
- WiFi / Bluetooth / 3 USB 3.0 ports / M.2 slots for storage
It’s specs are similar to the Asus Transformer 3 or the Macbook 12-inch. It even have an embedded Arduino for development!
More details on DFRobot and LattePanda websites.
Package Management
With the advent of package management on other platforms (Homebrew on Mac, apt/yum on Linux), installing applications and utilities became much simpler and straightforward. With Chocolatey, installing on Windows also became a matter of choco install app
, simple as that!
To install Chocolatey, just drop into CMD in Administrative Mode, searching for cmd in the search bar and instead of hitting Enter, right-click it and select Run as Administrator.
In the prompt, enter the following command on CMD to install:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
And it's done! To search for an app, just type choco search app
. To install it, choco install app
.
To upgrade the packages and Chocolatey itself, use:
choco upgrade all
or choco upgrade [package]
If you need more details, check the install page or the main site.
Linux on Windows (yes, you read it right)
Next we will install WSL. It provides all utilities and benefits of running Linux on your Windows box without the hassle of setting up virtual machines, heavy virtualization resource consumption (great for boards like this or laptops), and you even have Linux distribution options.
First you have to enable the WSL on PowerShell in Administrative Mode. To run, search for "powershell" on search bar, right-click it and select "Run as Administrator". On the console, type:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
And reboot after finish. After rebooting, open Windows Store, search for "Linux" and all available distros are shown:
Since I'm used to Debian, this was the distribution I installed. Some minutes later, you have Debian installed and ready to run and create your user. Select your distro and install like any other app from the store.
Add your user to allow passwordless sudo:
echo "$USER ALL=(ALL) NOPASSWD:ALL" |sudo tee -a /etc/sudoers
Customizing the console
The next step to a more useable command line is installing CMDer. It's a very flexible terminal and with it's tabbed interface the productivity is improved. Also let's install a nice font to go with it. With Chocolatey, it's just a matter of:
choco install -y cmder firacode
Refresh the environment with the command refreshenv
and run cmder
. You can pin it to the bar after start. Let’s configure a few parameters.
Click the bottom-right button and select Settings. in the Settings panel, choose General -> Fonts and set the Main Font to Fira Code Medium. I use size 16.
What is great about CMDer, is that it supports multiple tabs of different consoles. You can have a Linux shell in one tab, a PowerShell on another and a Windows command prompt on another one. It’s a matter of two clicks, one in the +
button and another on the terminal type, cmd for command prompt, PowerShell or on WSL your Linux.
Installing Zsh and oh-my-zsh
Zsh is a shell replacement for bash. It provides a lot of new functionality, plugins and prompt customization. Oh-my-zsh is a framework and extension for Zsh to provide these plugins.
First install Zsh and some pre-requisites and utilities. On my Debian Linux, I run:
$ sudo apt-get install git zsh ack jq wget curl htop tree
Then install Oh-my-zsh and change your user’s default shell to it with:
$ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
$ chsh -s /usr/bin/zsh
Close and reopen the console to run Zsh as default shell, then, install some useful plugins:
# Install Spaceship Prompt
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"# Link the theme
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"# Configure the prompt as default
sed s/'ZSH_THEME.*'/'ZSH_THEME=spaceship"' -i ~/.zshrc# Install the auto suggestion plugin
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Zsh is very customizable, you can check the plugins I use and my config on my repo. Also there are lots of references for it here.
Make CMDer run with Zsh
Some final adjustments are needed to make CMDer run and call Zsh.
On Startup -> Tasks, add a new task using the "+" button, with the following parameters and commands:
Parameters: -icon “%USERPROFILE%\AppData\Local\lxss\bash.ico”
Command: %windir%\system32\bash.exe ~ -cur_console:p
Name it zsh and Save. And change this new “Task” to be the default one on launch:
Then, add to the end of the file ~/.bashrc
the commands below so bash will call zsh on start:
cat <<EOT >> ~/.bashrc
if test -t 1; then
exec zsh
fi
EOT
CMDer, paired with FiraCode font, Zsh and it’s plugins and themes provide a fantastic experience where you have suggestions on the command line and lots of info in the prompt for example on Git repositories like the screen below:
Check out my dotfiles and the way I customize my environment on Github.
Configuring your editor
My editor of choice is Visual Studio Code. I used Sublime Text previously (and VIM previous to that) and now I believe VSCode provides fantastic functionality and a great community that develops extensions. As usual, VSCode ia installed with Chocolatey in CMD:
choco install vscode
And you can start installing all extensions you want/need for your own code. Here are the ones I use:
ActiveFileInStatusBar v1.0.3
ansible v0.2.8
beautify v1.4.7
blank-line-organizer v0.1.5
Bookmarks v9.1.0
bracket-jumper v1.1.8
bracket-pair-colorizer v1.0.60
code-settings-sync v3.2.0
devicetree v0.1.1
erlang v0.4.6
Go v0.6.93
highlight-words v0.0.8
json-tools v1.0.2
LogFileHighlighter v2.4.2
markdown-all-in-one v1.7.0
material-icon-theme v3.6.0
notetree v0.0.4
python v2018.9.2
trailing-spaces v0.2.11
vsc-material-theme v2.5.1
vscode-ansible v0.5.2
vscode-dired v0.0.4
vscode-docker v0.3.1
vscode-fileutils v2.11.0
vscode-markdown-to-clipboard v0.0.2
vscode-markdownlint v0.21.0
vscode-yaml v0.0.17
word-count v0.1.1
xml v2.3.2
One of the most important is “Settings Sync” where you can sync all configuration and extensions and keep them in a private Gist. Check it out it’s instructions on install and config here.
Installing your language of choice
Finally, with the power of Chocolatey, installing your language of choice is just a matter of choco install lang
in CMD. For example:
Go
$ choco install golang -yChocolatey v0.10.11
Installing the following packages:
golang
By installing you accept licenses for the packages.
Progress: Downloading golang 1.11.2... 100%golang v1.11.2 [Approved]
golang package files install completed. Performing other installation steps.
Downloading golang 64 bit
from 'https://dl.google.com/go/go1.11.2.windows-amd64.msi'
Progress: 100% - Completed download of C:\Users\LattePanda\AppData\Local\Temp\chocolatey\golang\1.11.2\go1.11.2.windows-amd64.msi (110.72 MB).
Download of go1.11.2.windows-amd64.msi (110.72 MB) completed.
Hashes match.
Installing golang...
golang has been installed.
golang may be able to be automatically uninstalled.
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The install of golang was successful.
Software installed as 'msi', install location is likely default.Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).$ refreshenv
Refreshing environment variables from registry for cmd.exe. Please wait...Finished..$ go version
go version go1.11.2 windows/amd64
As a comparison to show the processing power of the LattePanda Alpha, here is a benchmark for the crypto library on Go 1.11.2 comparing the FireFly RK3399, an hexa-core ARM64 SBC, the LattePanda Alpha and my 2018 15-inch Macbook Pro:
RK3399
LattePanda Alpha
Macbook Pro
And a comparison between them:
As can be seen, the LattePanda is in average 3.2x faster than the RK3399 and my Macbook Pro is 2.1x faster than the Alpha. This is in no way a scientific benchmark but gives an idea of the power of this small board.
Docker
Docker is also just a command away with choco install docker docker-for-windows -y
Logout, log back in and run the Docker for Windows icon created on your desktop. If you get this question, enable Hyper-V and restart:
After reboot, run Docker For Windows icon and Docker will be ready to run:
And run a Nginx container to show the functionality: docker run -p 8080:80 nginx
then open your browser on https://localhost:8080
Conclusion
This article demonstrate that you can have a very functional, complete and portable development environment on your Windows 10 box allowing any language and tool to be used. Also with a small and portable SBC like the LattePanda Alpha, you have the power and flexibility to bring this anywhere.
With a price around $350,00 it’s not the cheapest computer you can get but it’s hard to beat it’s performance and portability in this price-point. Highly recommended.