Raspberry Pi Pico Setup in Linux (Ubuntu)

The Raspberry Pi Pico’s documentation currently only covers setup and building on a Raspberry Pi, so here is how to quickly install the SDK and run your first Pico application on your Linux machine!

Make sure you have the build toolchain (CMake, GNU Embedded Toolchain for Arm, etc.) installed and up-to-date:

$ sudo apt update
$ sudo apt install cmake build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib

Note: If you are not using a Debian-based distro such as Ubuntu, replace instances of “apt” with your distro’s package manager (pacman, dnf, etc.) and associated packages.

I am choosing to install the SDK to the standard “local source code” directory /usr/local/src:

$ cd /usr/local/src/
$ mkdir pi
$ cd pi
$ mkdir pico
$ cd pico

Clone the pico-sdk repository and download submodules:

$ git clone -b master https://github.com/raspberrypi/pico-sdk.git
$ cd pico-sdk
$ git submodule update --init
$ cd ..

Clone the pico-examples repository if you desire:

$ git clone -b master https://github.com/raspberrypi/pico-examples.git

Add the SDK directory to the PICO_SDK_PATH environment variable:

$ nano ~/.bash_aliases

Set this to wherever you decided to install your SDK:

export PICO_SDK_PATH=/usr/local/src/pi/pico/pico-sdk

Make a directory for your project and copy the “pico-sdk/external/pico_sdk_import.cmake” file into it. Import and initialize the Pico SDK by using the copied “pico_sdk_import.cmake” file at the beginning of your “CMakeLists.txt” as follows:

cmake_minimum_required(VERSION 3.13)

# Include the SDK using the PICO_SDK_PATH environment variable:
# (before project())
include(pico_sdk_import.cmake)

project(project_name)

# Initialize the Raspberry Pi Pico SDK: (after project())
pico_sdk_init()

# The rest of your project goes here!
Use CMake to generate a makefile, then build your project:

$ mkdir build
$ cd build
$ cmake ..
$ make -j 4

To install your program onto your Pico, plug it in via USB while holding the “BOOTSEL” button and a new USB Mass Storage Device should automatically mount. Drag and drop the compiled “.uf2” file into the newly mounted Pico directory. The Pico should automatically unmount, restart, and run the application.

To view serial output from the Pico you must first add your username to the “dialout” group, then restart your computer:

$ sudo usermod -a -G dialout $USER
$ sudo restart -r now

Install the screen program:

$ sudo apt install screen

The screen program syntax is as follows:

$ screen [DEVICE NAME] [BAUDRATE]

With the Pico connected, find the device name:

$ ls -l /dev/ttyUSB* /dev/ttyACM*

With my Pico connected via USB; my serial port is mounted to “/dev/ttyACM0” and the Pico’s baudrate is 115200, so the screen program should be ran as follows:

$ screen /dev/ttyACM0 115200

To exit the screen program, press Ctrl+A to enter command mode, type “:quit” then press the enter key.

Download the test project here.

Space TV




Space TV is a Smash TV inspired top-down shooter prototype developed as a group project for school using Unreal Engine 4. Pick up a variety of weapons dropped by enemies including a rifle, shotgun, and the elusive “PCP” super weapon! Defend the point from waves of enemies to advance to the next room, and watch out for the highly lethal “Barrel Guy” who would love nothing more than to explode right in your face! Don’t worry, you will hear him coming šŸ˜‰ Defeat the “Bullet Sponge” in the final room to claim victory! Good luck… you’re going to need it.

Download here:
Windows (64-bit)
MacOS (COMING SOON!)
Linux (64-bit)

How to Create a Bootable Windows 10 USB in MacOS

So, you have tried to create a bootable Windows 10 USB drive from a Windows 10 ISO file using software such as balenaEtcher, but when you attempt to install Windows 10 on a PC you get the strange error “No device drivers were found. Make sure that the installation media contains the correct drivers, and then click OK.” Turns out, this has to do with the fact that MacOS CANNOT format the USB drive as NTFS. MacOS cannot even write to an already NTFS formatted USB stick, only read from one. If you have time, I hear you can use FUSE but I have not tested it. I opted for a free trial of Tuxera. After installing Tuxera and restarting your Mac, you can use the Disk Utility which now has an option to format the USB stick as NTFS. Just click Erase, choose NTFS, and when its finished formatting open up the Windows 10 ISO and simply drag and drop all of the files onto the NTFS formatted USB stick and VOILA it magically works!
Tuxera

The GNU GPL Virus

If you are just an average Joe who just wishes to use GNU GPL (General Public License) licensed software, you have nothing to worry about. However, if you are a developer, stay far far away from any software licensed under the GNU GPL.

Letā€™s say you are developing a video game that you may wish to sell for a profit some day. You have your game up and running great, but you want to make it much more realistic by adding dynamic physics, like you see in games such as Half-Life 2. After researching, you find a great physics library you want to use so you donā€™t have to spend months learning physics to write your own. Unfortunately, the physics libraryā€™s license is the dreaded GNU GPL. If you were to integrate the physics library into your application, all of the source code that you have written all by yourself is suddenly GLP-ed and you MUST release the source code for free! Like a virus, the GNU GPL spreads across all code attached to anything licensed under the GPL! You can still sell your game of course, but anyone who wishes to get it for free can do so by downloading your gameā€™s source code that you were required to freely release, compiling it, and running it themselves. Obviously, this results in a loss of sales.

Donā€™t get me wrong, thereā€™s nothing wrong with releasing your source code. Perhaps you wish to sell your application for a few years, then release the source code for free when it gets old and sales decline or stop all together ā€“ much like id software did with Quake and Doom.

Not all off the GNU licenses are bad though, just stay away from specifically the ā€œGPLv2,ā€ ā€œGPLv3,ā€ and so on. Two specific variants, the LGPL and the GPL+CE, are fine to use.

The LGPL is merely OK because it allows you to dynamically link (not statically) a library licensed under the LGPL and not have to release your source code. However, it allows anyone to legally reverse-engineer your software for ā€œdebugging and such modifications.ā€ The LGPL is unsuitable for mobile devices such as the iPhone where you must statically link everything together into one single binary. If you are just targeting desktop computers where you are able to get away with dynamically linking the LGPL library, and you donā€™t care about hackers legally reverse-engineering your software, the LGPL is OK.

Probably the best GPL-ed software is going to be licensed under the GPL + Classpath Exception. This version of the GPL adds a special exception clause which allows linking (static or dynamic) to the library and releasing the combined application under your own licensing terms. This means you can simply use the free library in your project without having to worry about your software having ā€œGPL compatible licensingā€ or releasing your source code for free. This is exactly how it should be, you shouldnā€™t have to hire a lawyer to use software that is supposedly ā€œfreeā€ and ā€œopen-sourceā€ in your application! You absolutely shouldnā€™t be forced to abide by someone elseā€™s terms for simply using a LIBRARY in YOUR application!

In conclusion, if you are a developer, unless itā€™s licensed under the GPL+CE do NOT use GPL-ed software in your project! The GNU GPL is a virus to your project in itā€™s entirety and is considered to be ā€œfree as in speechā€ rather than ā€œfree as in beer.ā€ To me, free should mean free, not freedom; as they are two completely different terms. I personally only choose to use libraries and other software in my projects that are licensed under the MIT, BSD, zlib, or other similarly styled licenses.

NetBeans CMake Setup macOS

To make Apache NetBeans cooperate with CMake projects on your Mac it requires just a few extra steps. CMake used to have a tool to do this for you, but now navigating in CMake to Tools->How to Install for Command Line Use shows you this:

I’m going to chose the symlink option, open up the Terminal App and type:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

Now that CMake is properly installed to the command line tool chain, open up NetBeans and go to the Preferences and click on the C/C++ tab. Enter the newly created symlink path /usr/local/bin/cmake for the CMake Command and click apply:

Now navigate to File->New Project. Choose C/C++ Project with Existing Sources and click next:

Browse to find your project root directory containing the CMakeLists.txt file, and everything should be good to go, just click finish!

NetBeans should run CMake to generate the Makefile, and should you edit your CMakeLists.txt file, just right-click the CMakeLists.txt file in the project tree and select Generate Makefile to generate a fresh one. All done and good to go! Happy coding!

Apache NetBeans C/C++ Setup macOS

If you’re weird like me, you don’t really like using Xcode to program C/C++ on your Mac. If you haven’t already done so, setup the command line tools since macOS does not come with them pre-installed. NetBeans is typically used for Java programming, and is written in Java, therefore you need the Java Development Kit (JDK) installed to run it. Recently, Oracle has introduced a new versioning scheme and licensing which at first glance can seem very confusing and overwhelming. To sum it up, unless you are a large corporation or development studio that requires paid commercial support, just download OpenJDK. Any OpenJDK 8+ (including the official Oracle OpenJDK) will work, but the easiest and most painless route is downloading AdoptOpenJDK which installs binaries exactly where they need to go. Personally, I chose the package containing OpenJDK 13 with HotSpot, but any combination works just fine for our purposes.

Anyway, once you have the command line tools, OpenJDK, and finally NetBeans installed, run the Apache NetBeans 11.2 application. Navigate to Tools->Plugins and you will notice there is no longer a C/C++ plugin under the Available Plugins tab in the new Apache version!

Click on the Settings tab and check the box next to NetBeans 8.2 Plugin Portal to activate the old plugins:

Then go to the Updates tab, click on Check for Updates and then press Update:

You will notice the number of Available Plugins has increased! Go ahead and install the C/C++ plugin!

Restart the IDE after the installation is complete and start coding in good old fashioned C/C++ using Apache NetBeans!

Darcula LAF

If you would like this nice IntelliJ IDEA and Eclipse IDE style dark theme to go along with your Catalina Dark Mode you can download the Darcula LAF plugin. To install go back to Tools->Plugins, click on the Downloaded tab and press Add Plugins. Find your downloaded Darcula plugin and install!

NetBeans is currently my go-to IDE for C/C++ and PHP projects, since I have been using it for many many years and have had zero problems! Next week I begin Java classes for school… I will try out Eclipse and IntelliJ IDEA to see how they compare for Java programming and report back. If you don’t know the differences I will sum it up: NetBeans is the official Java IDE which was recently taken over by Apache (previously owned/developed by Sun – the creators of Java,) Eclipse is the most commonly used Java IDE, and IntelliJ IDEA has both paid and free versions which was used as the basis for Android Studio. Alternatively, for C/C++ projects I enjoy coding the old fashioned way with Sublime Text for my text editor and CMake for cross platform makefile generation. For using CMake with NetBeans see this article.

C/C++ Programming Setup on macOS 10.15 Catalina

Unfortunately, macOS does not come with development tools pre-installed like on Linux, BSD, and other *nix systems. Luckily, it’s simple and easy to do. Open up the Terminal application (Applications/Utilities/Terminal.app) and type:

xcode-select --install

This installs all of the standard command line tools you should be used to, since it’s no longer an option to do so inside of the Xcode IDE. Speaking of which, you no longer need an Apple Developer account to install Xcode. Simply open up the App Store application, search for, and install Xcode:

All done, start programming away!