resources: Update arm-ubuntu README

Corrected the Ubuntu package names for the arm cross compilers.

Added instructions for generating the SSH key pair.

Added instructions on connecting to the QEMU VM with SSH if the
host username is different from what is printed by shell command
"whoami". An example of where this is necessary is when building the
disk image using DArchR computers.

Clarified that cloud-init should finish upon boot in QEMU before
an SSH connection can be made. This usually happens some time after
the VM displays the log in prompt.

Changed the build.sh error messages to specify what caused the error.

The build.sh script currently checks if "name" is set to "ubuntu" to
detect if cloud.txt is unmodified. Added "ubuntu" as the name to the
default provided cloud.txt.

Change-Id: I06c3d2118706886aab3566e4a318a92fd4a72f30
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5-resources/+/65471
Tested-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
diff --git a/src/arm-ubuntu/README.md b/src/arm-ubuntu/README.md
index 42d782d..d5dd071 100644
--- a/src/arm-ubuntu/README.md
+++ b/src/arm-ubuntu/README.md
@@ -49,11 +49,11 @@
 ## Building the disk image
 
 This requires an ARM cross compiler to be installed. The disk image is a 64-bit
-ARM 64 (aarch64) disk iamge. Therefore, we only focus on the 64-bit version of
+ARM 64 (aarch64) disk image. Therefore, we only focus on the 64-bit version of
 the cross compiler. It can be installed by:
 
 ```sh
-sudo apt-get install aarch64-linux-gnu-g++-10 aarch64-linux-gnu-gcc-10
+sudo apt-get install g++-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu
 ```
 
 In order to build the ARM based Ubuntu disk-image for with gem5, build the m5
@@ -99,6 +99,18 @@
 
 # Booting the disk image using QEMU
 
+## Generating an SSH key pair
+```sh
+ssh-keygen -t rsa -b 4096
+```
+Leave all prompted fields empty and hit enter. This will generate a public and
+private key pair in files `~/.ssh/id_rsa` and `~/.ssh/id_rsa.pub`. If your username
+is different from what is printed by command `whoami`, then add `-C "<username>*<hostname>"`
+to the command:
+```sh
+ssh-keygen -t rsa -b 4096 -C "<username>*<hostname>"
+```
+
 ## Making a cloud config file
 
 First, we need a cloud config that will have the authorization information
@@ -120,12 +132,14 @@
 ```
 
 * Note: Do not leave stray spaces in the `cloud.txt` file.
+* If your username is different from what is printed by command `whoami`, then use that for parameter "name" in cloud.txt
 
 More information about generating an ssh rsa key is available
 [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key).
 You can ignore the GitHub email address part.
 
 ## Booting the cloud disk image with the cloud config file
+In the `arm-ubuntu/disk-image` directory,
 
 ```sh
 dd if=/dev/zero of=flash0.img bs=1M count=64
@@ -150,15 +164,19 @@
 
 ## Manipulating the disk image
 
-While the qemu instance is still running, we will use Packer to connect
-to the virtual machine and manipulate the disk image. Before doing that, we
-need to add the private key using `ssh-add`.
+When the qemu instance has fully booted, cloud-init has completed, and while it
+is still running, we will use Packer to connect to the virtual machine and
+manipulate the disk image. Before doing that, we need to add the private key using `ssh-add`.
 
 ```sh
 ssh-add ~/.ssh/id_rsa
 ```
 
-This process is automated. In the `arm-ubuntu/disk-image/` directory,
+If the image was booted in qemu on a port number other than 5555, edit the `ssh_port`
+parameter in `arm-ubuntu/arm-ubuntu.json` accordingly. The disk manipulation
+process is automated. If your username is different from what is printed by
+command `whoami`, then edit `build.sh` and change the value of `USER` to `"<your_username>"`.
+Then in the `arm-ubuntu/disk-image/` directory,
 
 ```sh
 chmod +x build.sh
diff --git a/src/arm-ubuntu/disk-image/arm-ubuntu/cloud.txt b/src/arm-ubuntu/disk-image/arm-ubuntu/cloud.txt
index 4d22189..4eb2627 100644
--- a/src/arm-ubuntu/disk-image/arm-ubuntu/cloud.txt
+++ b/src/arm-ubuntu/disk-image/arm-ubuntu/cloud.txt
@@ -1,6 +1,6 @@
 #cloud-config
 users:
-  - name: ### insert the username here ###
+  - name: ubuntu ### change this name to the current user (use `whoami`) ###
     ssh-authorized-keys:
       - ssh-rsa ### insert the rsa key here ###
     sudo: ['ALL=(ALL) NOPASSWD:ALL']
diff --git a/src/arm-ubuntu/disk-image/build.sh b/src/arm-ubuntu/disk-image/build.sh
index 86332d2..bea8905 100644
--- a/src/arm-ubuntu/disk-image/build.sh
+++ b/src/arm-ubuntu/disk-image/build.sh
@@ -27,7 +27,7 @@
 
         count=`grep "name: ubuntu" arm-ubuntu/cloud.txt |wc -l`
         if [ $count -ne 0 ]; then
-            echo "cloud.txt is not modified correctly! Please refer to the README.md file on how to modify name and ssh-rsa in the cloud.txt file."
+            echo "cloud.txt 'name' is not modified correctly! Please refer to the README.md file on how to modify name and ssh-rsa in the cloud.txt file."
             exit
         fi
 
@@ -38,7 +38,7 @@
         if [[ "$KEY" == *"$USER@$HOSTNAME"* ]]; then
             echo "cloud.txt verified!"
         else
-            echo "cloud.txt is not modified correctly! Please refer to the README.md file on how to modify ssh-rsa in the cloud.txt file."
+            echo "cloud.txt 'ssh-rsa' key is not modified correctly! Please refer to the README.md file on how to modify ssh-rsa in the cloud.txt file."
             exit
         fi
     fi