dmfaber1 / TunerPi

Raspberry Pi Guitar Tuner
1 stars 0 forks source link

As a Ken, I want to be able to have a developer setup for Raspberry Pi Zero #3

Closed dmfaber1 closed 3 years ago

dmfaber1 commented 3 years ago

First thing you will need to do is setup your laptop to enable you to work on this stuff. This link is the basics for how to write an image to the SD card that will run on the raspberry pi: https://www.raspberrypi.org/documentation/installation/installing-images/README.md. Then you will need a bunch of other stuff set up as well:

  1. Need SD card writer
  2. Need RaspberryPi Imager tool installed.
  3. Need SSH client - I recommend using Windows Subsystem for Linux (https://docs.microsoft.com/en-us/windows/wsl/install-win10). This way you are just using the native linux ssh.
  4. Need Github account created.
  5. Need to install git for windows (https://gitforwindows.org/)
  6. Need to add ssh key from git for windows to your gitlab account (https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
  7. Need to install python for windows (https://wiki.python.org/moin/BeginnersGuide/Download)
  8. Need to install VSCode (https://code.visualstudio.com/) This is the best way to develop and test python.
dmfaber1 commented 3 years ago

So we should probably set up an evening where we can jump on a Google Meet or something, and share desktops, so I can help explain and show you some of the stuff here.

dmfaber1 commented 3 years ago

So for #6, you can test it out by committing a readme file to the github project. I invited you to be a contributor, so you should be able to now. As for the confusion on the github project, it is dmfaber1/TunerPi, since I own the project. You are still logged in as your own user, and with the invite, can now contribute.

So the easiest way is probably just to use Git bash. Opening Git bash will open up a command line terminal in your windows user folder. First I would just create a folder in your windows user dir as a git workspace:

mkdir git_views

Then a folder for TunerPi:

mkdir git_repos/TunerPi

Then change directory into that folder:

cd git_repos/TunerPi

Then you should be able to follow the instructions on the main code page for initializing a readme:

echo "# TunerPi" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:dmfaber1/TunerPi.git
git push -u origin main
faberke611 commented 3 years ago

okay now i see where to add comments on GitHub

faberke611 commented 3 years ago
  1. Got Ubunto 18.04 LTS working. Was able to run “sudo apt update” and “sudo apt upgrade”. Took almost 2 hrs. Note Git Bash doesn’t recognize sudo command.
  2. Found another website on how to setup headless. Instructions had 1 new line in wpa_supplicant.conf: “key_mgmt=WPA-PSK”. Instructions to connect using PuTTY, still got “host does not exist”. It also explained: “If it detects a file called wpa_supplicant.conf, Raspbian will copy the file into /etc/wpa_supplicant, replacing any existing wpa_supplicant.conf file that may be there. The file in the boot directory is then removed. If an empty file named ssh is detected, Raspbian will adjust it's settings to accept SSH connections. The ssh file is then deleted.” wpa_supplicant was not moved to /etc/, but explains why both files disappear after booting.
  3. Site also says: “If you wish, you can include more than one network block. wpa_supplicant will select the network that it rates as the best choice.” WiFi here has both 5 and 2.4 GHz. So modified wpa_supplicant to look for both. It worked! Site suggested changing host name, changed from “raspberrypi” to “kenpi-1”. Rebooted username “pi” and changed password to “Gohawks322”.
  4. Rebooted and logged in successfully using Git Bash: ssh pi@kenpi-1, password: Gohawks322. Success!
faberke611 commented 3 years ago

Now I get it, my Pi Zero only has 2.4 GHz WiFi

dmfaber1 commented 3 years ago

Got Ubunto 18.04 LTS working. Was able to run “sudo apt update” and “sudo apt upgrade”. Took almost 2 hrs. Note Git Bash doesn’t recognize sudo command.

Awesome! Yeah this is the Ubuntu equivalent of running a Windows Update, not surprised it took forever on the internet there. Yeah git bash is a very minimal linux command line interface, really only supports a few things. The Ubuntu WSL is much more of a full Linux OS.

Found another website on how to setup headless. Instructions had 1 new line in wpa_supplicant.conf: “key_mgmt=WPA-PSK”. Instructions to connect using PuTTY, still got “host does not exist”. It also explained: “If it detects a file called wpa_supplicant.conf, Raspbian will copy the file into /etc/wpa_supplicant, replacing any existing wpa_supplicant.conf file that may be there. The file in the boot directory is then removed. If an empty file named ssh is detected, Raspbian will adjust it's settings to accept SSH connections. The ssh file is then deleted.” wpa_supplicant was not moved to /etc/, but explains why both files disappear after booting.

Interesting, I will have to look into this a little more. I'm not too familiar with what Raspbian will be doing during it's init scripts. I wouldn't think you would need to update the boot partition for every boot, but could be. It could also mean those files are deleted on the mounted root partition, but will still remain on the boot partition.

Rebooted and logged in successfully using Git Bash: ssh pi@kenpi-1, password: Gohawks322. Success!

Awesome!!! This is the big step that unblocks a lot of what we can do next.

dmfaber1 commented 3 years ago

So I think the only thing left on this issue is getting your git config set up. We can look at this next time we talk, or you can try a few things out on your own.

So you can authenticate with Github using an ssh key or username and password. You tried with the ssh key, something didn't seem to be working correctly though. That may be tricky to debug remotely. We can try the username and password though.

So in Windows File Explorer, just create a folder under your user dir named git_repos, so C:\Users\ken\git_repos. If anything exists in that folder already just delete it.

Then in git bash:

cd git_repos
git clone https://github.com/dmfaber1/TunerPi.git

Then you can open up this git_repos/TunerPi folder in VSCode.

Using you VSCode, you should be able to edit the README.md file. You can add anything in here, just a line that says "Ken was here" and save.

Then there is a toolbar on the left side of VSCode, and there is a icon for Source Control. If you click on this you will see a side panel for using Git. It should show a change in README.md. The process for using Git is to stage the change (identify the changes you want to commit), commit the change (write the change set to your local git repository) and push the change (push changes to github). So you can do this by:

  1. Hit the plus icon when highlighting the README.md file in the source control left side browser (Stage)
  2. Write a commit message in the text box that says "Message (Ctrl + enter to commit on main). Just type something like "ken's first commit". Then hit ctrl + enter (commit)
  3. Next to the message text box there is a ... icon for more actions. Hit this and go to Push, this should bring up a window to sign into Github (Push)

This will push your change to github and should then be visible on this page https://github.com/dmfaber1/TunerPi. Then that's how you use Git!

Periodically you will also have to update your local git repository with the changes someone else pushed to the github page. You do this by going to the same menu you used for Push, and just select Pull.

In VSCode, if you want to go back to the file browser view instead of the source control view, it is just the top icon on the left side.

faberke611 commented 3 years ago

Deleted files under git_repos, ran git clone, looks like it copied all the same files back there. Used VSCode to edit README, and did a stage, commit, and post. I assume I could the same on the GitHub website, but maybe you want me to get used to VSCode (?).

Booted the board again today and connected using Git Bash and PuTTY. What do you think of PuTTY? Also when will I be using Git Bash vs. Ubuntu? I think they do the same basic stuff but Ubuntu has more (?)

A few weeks ago, I "Using GitBash, I Generated a new SSH key, Added SSH key to the ssh-agent, created a C:\Users\faber.bashrc file using NotePad, and added code from the link: https://docs.github.com/en/github/authenticating-to-github/working-with-ssh-key-passphrases for "Auto-launching ssh-agent on Git for Windows". My passphrase is faberke611. When I ran GitBash again it created a .bash_profile file." I'm not sure what's the difference between "authenticate with Github using an ssh key or username and password. "

dmfaber1 commented 3 years ago

Deleted files under git_repos, ran git clone, looks like it copied all the same files back there. Used VSCode to edit README, and did a stage, commit, and post. I assume I could the same on the GitHub website, but maybe you want me to get used to VSCode (?).

Excellent! You know have everything in this issue working. Yeah, you can commit directly into github, but most of the time using git it is code files that you are editing and testing on your machine. That's why you would use a program like VSCode.

Booted the board again today and connected using Git Bash and PuTTY. What do you think of PuTTY? Also when will I be using Git Bash vs. Ubuntu? I think they do the same basic stuff but Ubuntu has more (?)

PuTTy is great, it is the universally used windows tool for this kind of thing. The one thing it doesn't have is scp, or essentially copy over ssh. This is how we will transfer files to the RaspberryPi. There are other tools that fill this function on windows, like WinSCP or just using FTP instead of scp, but I usually just default to using a virtualized linux bash shell with ssh and scp all built in (like Ubuntu WSL and git bash). But yeah, git bash is basically just a very minimal bash shell, with openssh and the other libraries needed to use Git. Ubuntu WSL is a full blown virtualized linux container. It has pretty much everything you would expect a headless linux machine to have. The big difference for most applications of the two is the Ubuntu WSL has the gcc toolchain. This lets us compile programs for Linux (in our project we are looking at compiling that PortAudio).

A few weeks ago, I "Using GitBash, I Generated a new SSH key, Added SSH key to the ssh-agent, created a C:\Users\faber.bashrc file using NotePad, and added code from the link: https://docs.github.com/en/github/authenticating-to-github/working-with-ssh-key-passphrases for "Auto-launching ssh-agent on Git for Windows". My passphrase is faberke611. When I ran GitBash again it created a .bash_profile file." I'm not sure what's the difference between "authenticate with Github using an ssh key or username and password. "

Just a different method of authentication. Think of it as an app on your phone letting you sign in with your fingerprint instead of the username and password. It is all about efficiency in your development workflow why you would use one over the other. The setup you have with username and password seems to be plenty good enough, especially with VSCode's abiliity to store and manage those credentials for you.