Spaces:
Sleeping
Sleeping
Commit
·
7b872cb
1
Parent(s):
086b12f
Updated portiloop v2 setup file with ap and jupyter setup
Browse files- PortiloopV2.md +158 -12
PortiloopV2.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
# Portiloop V2
|
3 |
|
4 |
You've just got your hands on the hardware for the Portiloop V2 (A Google Coral Mini and a PiEEG board). Here are the steps you need to follow to get started using the EEG capture, the Spindle detection software, and the TPU processing.
|
@@ -6,21 +5,168 @@ You've just got your hands on the hardware for the Portiloop V2 (A Google Coral
|
|
6 |
## Accessing the Google Coral
|
7 |
|
8 |
These first steps will help you set up an SSH connection to the device.
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
If you see a message telling you that screen is busy, you can use `sudo lsof /dev/ttyMC0` and then retry the screen step.
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
Once all of that is done, you should be able to ssh into your device, using either the ip address or the hostname. If some issues arise, make sure you are
|
20 |
|
21 |
## Dependencies
|
22 |
|
23 |
-
To install all dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
## Jupyter notebook
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Portiloop V2
|
2 |
|
3 |
You've just got your hands on the hardware for the Portiloop V2 (A Google Coral Mini and a PiEEG board). Here are the steps you need to follow to get started using the EEG capture, the Spindle detection software, and the TPU processing.
|
|
|
5 |
## Accessing the Google Coral
|
6 |
|
7 |
These first steps will help you set up an SSH connection to the device.
|
8 |
+
|
9 |
+
- Power up the board through the USB power port.
|
10 |
+
- Connect another USB cable to the OTG-port on the board and to your _linux_ host machine. Follow the following steps to connect to the board through serial:
|
11 |
+
- `ls /dev/ttyMC*`
|
12 |
+
- `screen /dev/ttyMC0`
|
13 |
If you see a message telling you that screen is busy, you can use `sudo lsof /dev/ttyMC0` and then retry the screen step.
|
14 |
+
- Login to the board using default username and password: mendel
|
15 |
+
- Once you are logged in, you can now connect to you desired wifi network using nmtui.
|
16 |
+
- If you want to access the board through ssh (which is recommended for any sort of development):
|
17 |
+
_ On the serial console, open the `/etc/ssh/sshd_config` file.
|
18 |
+
_ Scroll down to the `PasswordAuthenticated` line and change the 'no' to a 'yes'.
|
19 |
+
Once all of that is done, you should be able to ssh into your device, using either the ip address or the hostname. If some issues arise, make sure you are connected to the same network.
|
20 |
|
21 |
## Dependencies
|
22 |
|
23 |
+
To install all dependencies, clone it and run the installation.sh script. This script takes care of all the installations for you so it may take a while (~25 minutes).
|
24 |
+
|
25 |
+
## Setting up the Access Point
|
26 |
+
|
27 |
+
### 1. Download dependencies for access point
|
28 |
+
|
29 |
+
To set up an access point, you will need to install a few dependencies. To install them, you can use the following command:
|
30 |
+
|
31 |
+
```bash
|
32 |
+
sudo apt-get update && sudo apt-get install hostapd dnsmasq
|
33 |
+
```
|
34 |
+
|
35 |
+
This will update your system's package list and install the `hostapd` and `dnsmasq` packages.
|
36 |
+
|
37 |
+
### 2. Set up the interface ap0
|
38 |
+
|
39 |
+
Next, you will need to set up a systemd service to configure and enable the `ap0` interface.
|
40 |
+
|
41 |
+
First, we can create a script to create the interface using `sudo nano /usr/local/bin/create_ap0.sh`. The script should contain the following content:
|
42 |
+
|
43 |
+
```bash
|
44 |
+
!/bin/bash
|
45 |
+
|
46 |
+
# Delete the existing p2p0 interface
|
47 |
+
sudo iw dev p2p0 del
|
48 |
+
|
49 |
+
# Reload the Network Manager utility
|
50 |
+
sudo systemctl restart NetworkManager
|
51 |
+
|
52 |
+
# Create a new ap0 interface in AP mode
|
53 |
+
sudo iw phy phy1 interface add ap0 type __ap
|
54 |
+
|
55 |
+
# Disable power management for the ap0 interface
|
56 |
+
sudo iw dev ap0 set power_save off
|
57 |
+
|
58 |
+
# Reload the Network Manager utility again
|
59 |
+
sudo systemctl restart NetworkManager
|
60 |
+
|
61 |
+
# Get an IPV4 address for the server
|
62 |
+
sudo ifconfig ap0 192.168.4.1 up
|
63 |
+
```
|
64 |
+
|
65 |
+
To avoid configuration issues, we need to tell NetworkManager to ignore this interface. Create a file called `/etc/NetworkManager/conf.d/unmanaged.conf`. In this file, write the following:
|
66 |
+
|
67 |
+
```ini
|
68 |
+
[keyfile]
|
69 |
+
unmanaged-devices=interface-name:ap0
|
70 |
+
```
|
71 |
+
|
72 |
+
To make sure this starts works everytime we turn the Portiloop on, we need to create a new service. First, you can create a new service file at `/etc/systemd/system/create_ap.service` with the following content:
|
73 |
+
|
74 |
+
```ini
|
75 |
+
[Unit]
|
76 |
+
Description=Create The Access Point for the coral
|
77 |
+
Before=hostapd.service dnsmasq.service
|
78 |
+
|
79 |
+
[Service]
|
80 |
+
Type=simple
|
81 |
+
ExecStart=/usr/local/bin/create_ap0.sh
|
82 |
+
|
83 |
+
[Install]
|
84 |
+
WantedBy=multi-user.target
|
85 |
+
```
|
86 |
+
|
87 |
+
This service file specifies that it should run the `create_ap0.sh` script once on boot before the hostapd and dnsmasq services start.
|
88 |
+
|
89 |
+
### 3. Configure Hostapd
|
90 |
+
|
91 |
+
Hostapd is the software that will create the wireless access point. First, you will need to open the in `/etc/sysctl.conf` file and change the line for ip_forwarding to `net.ipv4.ip_forward=1`.
|
92 |
+
|
93 |
+
Next, you will need to create a configuration file at `/etc/hostapd/hostapd.conf` with the following content:
|
94 |
+
|
95 |
+
```ini
|
96 |
+
interface=ap0
|
97 |
+
driver=nl80211
|
98 |
+
ssid=YOUR-SSID-HERE
|
99 |
+
hw_mode=g
|
100 |
+
channel=6
|
101 |
+
wpa=2
|
102 |
+
wpa_passphrase=YOUR-PASSWORD-HERE
|
103 |
+
wpa_key_mgmt=WPA-PSK
|
104 |
+
wpa_pairwise=TKIP CCMP
|
105 |
+
rsn_pairwise=CCMP
|
106 |
+
auth_algs=1
|
107 |
+
macaddr_acl=0
|
108 |
+
```
|
109 |
+
|
110 |
+
This configuration file specifies the `ap0` interface, the SSID and password for the access point, and the encryption type to use. Make sure to replace `YOUR-SSID-HERE` and `YOUR-PASSWORD-HERE` with your own values. You now need to specify to hostapd which configuration file to do. Open the hostapd configuration file using `sudo nano /etc/default/hostapd`. Uncomment the DAEMON_CONF line and set it to the path of the configuration file you just created:
|
111 |
+
`DAEMON_CONF="/etc/hostapd/hostapd.conf"`.
|
112 |
+
|
113 |
+
### 4. Configure dnsmasq
|
114 |
+
|
115 |
+
Dnsmasq is the software that will provide DHCP and DNS services for the access point. Start by opening the dnsmasq configuration file with `sudo nano /etc/dnsmasq.conf`. Add the following content at the top of the file:
|
116 |
+
|
117 |
+
```ini
|
118 |
+
|
119 |
+
# Configuration for Access Point
|
120 |
+
interface=ap0
|
121 |
+
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
|
122 |
+
dhcp-option=3,192.168.4.2
|
123 |
+
dhcp-option=6,192.168.4.1
|
124 |
+
server=8.8.8.8
|
125 |
+
```
|
126 |
+
|
127 |
+
This configuration file specifies the `ap0` interface, the range of IP addresses to assign to clients, and the DNS server to use. Note that the IP address of the `dhcp-option=6,...` should be the same as the IP address set in step 2.
|
128 |
+
|
129 |
+
### 5. Start Systemd services
|
130 |
+
|
131 |
+
To make sure that everything happens on startup, we need to enable all services. Execute the following commands:
|
132 |
+
|
133 |
+
```bash
|
134 |
+
sudo systemctl enable create_ap.service
|
135 |
+
sudo systemctl enable hostapd.service
|
136 |
+
sudo systemctl enable dnsmasq.service
|
137 |
+
```
|
138 |
|
139 |
## Jupyter notebook
|
140 |
|
141 |
+
To access the portiloop easily, we recommend setting up a jupyter notebook server which will be available from any browser. To set up the Jupyter server using a systemd service, follow these steps:
|
142 |
+
|
143 |
+
1. On the command line, type `jupyter notebook password`. This will show a prompt where you can enter the desired password.
|
144 |
+
2. Create a new systemd service file using the command `sudo nano /etc/systemd/system/jupyter.service`.
|
145 |
+
3. Add the following lines to the service file:
|
146 |
+
|
147 |
+
```ini
|
148 |
+
[Unit]
|
149 |
+
Description=Jupyter Notebook Server
|
150 |
+
After=create_ap.service
|
151 |
+
After=hostapd.service
|
152 |
+
After=dnsmasq.service
|
153 |
+
|
154 |
+
[Service]
|
155 |
+
Type=simple
|
156 |
+
ExecStart=/bin/bash -c "/usr/bin/jupyter notebook --no-browser --ip 192.168.4.1 --port 8080 --notebook-dir=/home/mendel"
|
157 |
+
User=mendel
|
158 |
+
Group=mendel
|
159 |
+
Restart=on-failure
|
160 |
+
RestartSec=60s
|
161 |
+
|
162 |
+
[Install]
|
163 |
+
WantedBy=multi-user.target
|
164 |
+
```
|
165 |
+
|
166 |
+
4. Save and close the file.
|
167 |
+
5. Reload the systemd daemon to load the new service file: `sudo systemctl daemon-reload`.
|
168 |
+
6. Start the Jupyter service: `sudo systemctl start jupyter`.
|
169 |
+
7. Check the status of the service: `sudo systemctl status jupyter`. If everything is set up correctly, you should see a message indicating that the service is active and running.
|
170 |
+
8. To make sure the service starts automatically on boot, enable it: `sudo systemctl enable jupyter`.
|
171 |
+
|
172 |
+
That's it! Your Jupyter server should now be up and running, listening on IP address 192.168.4.1 and port 8080, and automatically starting whenever the system boots up. You can now access it by typing 192.168.4.1:8080 in your browser. This should lead you to a login page where you'll be prompted for your password. If any issue arise, try with a different web browser.
|