The first thing I want to do is to be able to compile and build his repos without any warnings or errors. This C development stuff for embedded devices is a bit new to me, so if you spot any glaring errors please feel free to advise and correct.
I started off with a totally clean Linux (Ubuntu 20.04 minimal) system running on a Core i3 Intel NUC device.
I will put my steps here as soon as possible and will attempt to keep them updated here.
I will also look at doing the same with Windows 10 and using the Windows Subsystem for Linux (wsl2) that also uses Ubuntu 20.04.
Finally I will look at pure windows.
So please keep looking here. (I will upload relevant documentation to the Open Firmware EBike repo as soon as possible too.)
edit: Setting up pure Ubuntu 20.04 toolchain.
1) I took the Ubuntu 20.04 distribution and installed a minimal version on my PC. (Intel Core i3 NUC)
(As an aside: I work headless from my Dell Core i7 laptop and use x11vnc - man I can't tell you how many problems I had
getting that to work properly (took 5 installs as I kept breaking my boot up), but eventually I did. If you need the tech details
give me a shout
)
2) As always
Code:
sudo apt clean
sudo apt update
sudo apt upgrade
Also allow Ubuntu to do it's automatic updating ... there is a Software Updater app in the Ubuntu menu.
3) (For me I added x11vnc server so I could work remotely from the machine on my laptop)
(I am now following the Developer steps from the repo (@Ranana did this I think?)
4)
Code:
sudo usermod -a -G dialout USER_NAME --reboot
I don't know what this does?
5) Using the Ubuntu software application I installed Add VSCode (I use the Insiders version, but the stable version is available too)
As a note when you get messages about updating VS Code there are a number of options. I created a script:
updateVSCode
Code:
sudo apt-get update
sudo apt-get install code
Change the file permissions chmod a+x updateVSCode and run as ./updateVSCode. (Choose your own security permissions)
There may be easier, better ways of doing this, let us know.
Check that VSCode runs.
$ code . I think does it or from the Ubuntu menu if you use a GUI. (Gnome)
6) Install some extensions to VS Code
install C/C++ extension (to edit C/C++ source files)
install Cortex-Debug extension (to be able to debug ARM microcontroller)
install Task Manager extension (to call makefile and other commands) – Zhang Shen
7) Install git and the Github extension - for cloning if this is how you like to work (I assume you can just download the repo as a zip and unzip into a directory?)
Code:
sudo apt-get install git
git config --global user.name "Gordon Moore" <-- use your own name!!!
git config --global user.email g@gordon.etc" <-- not certain this is required?
Install the GitHub Pull Requests and Issues extension
see
https://code.visualstudio.com/docs/editor/github
These next steps weren't straightforward. Ubuntu uses some kind of security protection - a keyring. If you automatically login then this will popup as you attempt to connect VS Code with github - the password is your Ubuntu password. It's a right pain.
Click on github icon in left trim stack (vertical bar)
You’ll then see a 1 on people icon – requesting a github signin, just do what it says I guess including the (gnome?) keyring. (Do you have a github account?)
Click on git source control icon to see if we are in business
It will attempt to cnnect to github, gets some authentication code, hopefully returns you to VS Code (and then the keyring pops up - wish I could stop this, but because I autologon...
(Use seahorse (called password and keys now) and blank out the password in the default keyring or just delete it? - it didn't work.)
Probably not a bad idea to do a reload of VS Code (or even a full reboot - though this is Linux not Windows :wink: )
Open the command palette ( Ctrl + Shift + P ) and search for and execute the command: >Reload Window.
8) Back to Dev instructions on repo:
Code:
sudo apt-get install openocd
sudo apt-get install gdb-multiarch
sudo apt-get install gcc-arm-none-eabi
sudo apt-get install binutils-arm-none-eabi //not sure this is needed as it didn't do anything?
sudo apt-get install libnewlib-arm-none-eabi //ditto?
9) I found I needed to install "make"
Code:
sudo apt install make
(might need full gcc path at some later point? so perhaps
sudo apt-get install build-essential
would be better? (advice?)
10) I needed to install nrfutil. The instructions on the Nordic site didn't work. Now the way I did it might not be the best way as it needed some adjustments to the $PATH environment. The following method installed nrfutil into my local bin directory, not the global one /bin ? I would be grateful for any insights on this as I'm sure there must be a better way.
Check that Python 3 is installed - it should be
Now install the pip python installer (pypi?)
Code:
sudo apt install python3-pip
//Now install nrfutil
//Now you need to adjust the environment $PATH as it installs into the local ~/.local/bin
For me I went into the .bashrc and added some lines I got from the ~/.profile file
Code:
sudo nano .bashrc
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
activate it
As I said there may be a better way?
(Note I also added it to the /etc/profile in the same way - I think this is better?????)
Nearly there...
11) So now in VS code and if you clone repos
Create a directory where you want your cloned/downloaded repo to go (I use ~/ebike) i.e. mkdir ebike
Click on the Explorer icon on the left trim stack (vertical menu bar).
It should have an option to clone?
Clone the repo: https://github.com/OpenSourceEBike/TSDZ2_wireless into th ebike directory
It's up to you whether you open a folder or open a workspace. There is a workspace file there so I used that.
File Menu Open workspace
Navigate to the ebike/TSDZ2_wireless/EBike_wireless_TSDZ2/firmware folder
A message for the workspace file should come up - click on it.
Voila, your files await.
12) To clean and build
On the left trim stack menu, select the task icon (it may be hidden in the ... icon depending on your available screen resolution.)
You should see the menu:
Click on the green arrow for clean and then on the green arrow for build. (Not sure what the difference is between build and build development - it will be in tasks.json)
Your code should now compile and run nrfutil and create your zip. (But currently there are some issues - see next post.
Please let us know how it goes and what issues and I'll update this asap.
Gordon
13 May 2021