Kopie per scp, start per ssh
- User, Pass: robot, maker
Kopie per scp
Lokales Terminal öffnen,
Datei im lokalen Terminal wie folgt kopieren:
scp main.py robot@192.168.1.267:meinZuAenderndesVerzeichnis/.
Start per ssh
Terminal auf dem Roboter öffnen,
Alias anlegen (falls es dieses noch nicht gibt):
alias run='brickrun -r -- pybricks-micropython main.py'
Dann Programm starten mit
cd verzeichnisWoDasProgrammLiegt
run
Einmaliges Verankern im System ACHTUNG nicht von Hand eingeben. Fehler in diesem Kommando können den Roboter dauerhaft ausser Gefecht setzen.
echo "alias run='brickrun -r -- pybricks-micropython main.py'" >> ~/.bashrc source ~/.bashrc
Native Python auf EV3 mit VSCode
- SSH: user robot, password maker
- hostnamectl set-hostname LEGO12
- WiFi-Daten in var/lib/connman
- Use
ddwith theconv=sparseoption. It will seek instead of write. Exactly what we need
- Wifi stuff is in
var/lib/connman/, tied to (I guess) the MAC-Adresse of the Wifi-Interface. So with all robots connected
nmap --open 192.168.1.80-254 -p 22 -oG - | grep open | grep -v Nmap | awk '{ print "title: Lego " $2 ";; command: ssh-copy-id robot@" $2 ";; profile: laptops"}' > tabsfile konsole --tabs-from-file ./tabsfile nmap --open 192.168.1.80-254 -p 22 -oG - | grep open | grep -v Nmap | awk '{ print "scp -r robot@" $2 ":/var/lib/connman/wifi_* ."}' > configs_from_lego.bash bash ./configs_from_lego.bash nmap --open 192.168.1.80-254 -p 22 -oG - | grep open | grep -v Nmap | awk '{ print "scp -r wifi_* robot@" $2 ":/var/lib/connman/."}' > configs_to_lego.bash bash ./configs_to_lego.bash
sudo dd if=ev3-200-32gb.img of=/dev/sda status=progress conv=sparse bs=1M
/etc/wpa_supplicant/wpa_supplicant.conf
- wpa_suplicant
#ctrl_interface=/var/run/wpa_supplicant #ctrl_interface_group=benutzergruppe # Die Gruppe muss natürlich angepasst werden eapol_version=1 # 0: Der Treiber des Interfaces kümmert sich um das Scannen von Netzen und die AP-Auswahl. # Dieser Modus sollte benutzt werden, wenn man eine Verschlüsselung auf ein Kabelnetzwerk legt. # 1: wpa_supplicant kümmert sich um das Scannen von Netzen und die AP-Auswahl. # 2: Fast wie 0, es wird aber mit Hilfe von Sicherheitsrichtlinien und der SSID zu APs verbunden (BSSID wird nicht unterstützt) # # Normalerweise funktioniert entweder Modus 1 oder Modus 2. ap_scan=1 network={ ssid="tech-lab" scan_ssid=1 psk="tech-lab" }
Way better than stuff below (also, you could take the image and then zero is out while mounted as loopback, much quicker!)
def cmd(c) puts c r = `#{c}` return r end raise "Provide hostname (like LEGO01)" unless $ARGV[0] hostname = $ARGV[0] img = "lego01.img" cmd("losetup -Pf #{img}") dev = cmd("losetup -j #{img}").split(":")[0] p2 = dev+"p2" cmd("mkdir -p p2") cmd("mount #{p2} p2") puts "Writing hostname #{hostname} to image" cmd("echo #{hostname} > p2/etc/hostname") cmd("umount p2") cmd("losetup -d ${dev}") puts "Image is ready. Write it with" puts "dd if=#{img} of=/dev/sdXXXX status=progress bs=1M conv=sparse"
# Get Info sudo fdisk -lu lego12.img Disk lego12.img: 14.84 GiB, 15931539456 bytes, 31116288 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xf5e5f871 Device Boot Start End Sectors Size Id Type lego12.img1 8192 106495 98304 48M b W95 FAT32 lego12.img2 106496 31116287 31009792 14.8G 83 Linux # Mount Partition, -o Start*512, --sizelimit Sectors*512 sudo losetup -o 54525952 -b 512 --sizelimit 15877013504 /dev/loop16 lego12.img # Check filesystem sudo e2fsck -f /dev/loop16 # Resize filesystem sudo resize2fs /dev/loop16 3750000 # Mount filesystem mount /dev/loop16 /mnt # Zero out disk dd if=/dev/zero of=zero.txt bs=1M status=progress # Truncate image (size obtained from target SD-Card with fdisk -lu /dev/sda) truncate -s 15634268160 lego12.img