Skip to content

Instantly share code, notes, and snippets.

@yogithesymbian
Created February 5, 2025 22:29
Show Gist options
  • Save yogithesymbian/2805da81a3f6894c404c1e7df8522299 to your computer and use it in GitHub Desktop.
Save yogithesymbian/2805da81a3f6894c404c1e7df8522299 to your computer and use it in GitHub Desktop.
pi.md

Ya, benar! Port USB-C di Raspberry Pi 4 Model B yang biasanya untuk power bisa juga digunakan untuk komunikasi data melalui USB Ethernet Gadget Mode.

Jadi, caranya:
Hubungkan kabel USB-C ke USB-C dari port USB-C di Raspberry Pi 4 ke port USB-C di MacBook M1.
✅ Raspberry Pi akan terdeteksi sebagai perangkat jaringan (Ethernet virtual) di MacBook.
✅ Setelah konfigurasi, kamu bisa SSH ke Raspberry Pi langsung via kabel USB-C tanpa perlu WiFi atau adapter tambahan.


Langkah-Langkah Konfigurasi "USB Ethernet Gadget Mode" di Raspberry Pi 4

1️⃣ Persiapan Kartu microSD Raspberry Pi

  1. Masukkan microSD ke MacBook.
  2. Buka partisi boot/ (FAT32) dari kartu SD yang sudah di-flash dengan Raspberry Pi OS.

2️⃣ Edit config.txt untuk Aktifkan USB Ethernet Mode

  1. Buka config.txt yang ada di boot/.
  2. Tambahkan baris berikut di paling bawah:
    dtoverlay=dwc2
  3. Simpan dan tutup file.

3️⃣ Edit cmdline.txt untuk Load Modul Ethernet USB

  1. Buka cmdline.txt di boot/.
  2. Cari tulisan rootwait, lalu tambahkan ini setelahnya:
    modules-load=dwc2,g_ether
  3. Pastikan semua tetap dalam satu baris!
    Contoh sebelum:
    console=serial0,115200 console=tty1 root=PARTUUID=xxxxxx rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
    
    Setelah ditambah:
    console=serial0,115200 console=tty1 root=PARTUUID=xxxxxx rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether
    
  4. Simpan dan tutup file.

4️⃣ Buat File ssh Agar SSH Aktif Otomatis

  1. Di dalam boot/, buat file kosong bernama ssh (tanpa ekstensi).
    touch /Volumes/boot/ssh
  2. Ini akan mengaktifkan SSH otomatis saat boot.

5️⃣ Pasang microSD & Hubungkan USB-C

  1. Keluarkan microSD dari MacBook dan masukkan ke Raspberry Pi.
  2. Sambungkan Raspberry Pi ke MacBook menggunakan kabel USB-C ke USB-C.
  3. Tunggu beberapa detik, lalu cek koneksi di MacBook.

6️⃣ Cek di MacBook & SSH ke Raspberry Pi

  1. Cek di "System Preferences" > "Network"

    • Harus muncul perangkat baru seperti "RNDIS/Ethernet Gadget" atau "USB Ethernet".
    • Jika tidak muncul, coba reboot Raspberry Pi.
  2. SSH ke Raspberry Pi
    Coba koneksi via terminal:

    Jika muncul permintaan password, masukkan:

    raspberry
    

    (default username: pi, password: raspberry)


7️⃣ Set IP Statis (Opsional, Jika .local Tidak Bekerja)

Jika raspberrypi.local tidak bisa diakses, kamu bisa set IP statis di Mac:

  1. Buka System Preferences > Network > RNDIS/Ethernet Gadget

  2. Pilih "Manually", lalu atur:

    • IP Address: 192.168.2.1
    • Subnet Mask: 255.255.255.0
    • Router: kosongkan
  3. SSH ke IP statis Raspberry Pi:


Selesai! 🚀

Sekarang MacBook bisa langsung terhubung ke Raspberry Pi 4 hanya dengan kabel USB-C tanpa perlu WiFi atau port Ethernet!

💡 Tips: Jika ingin Raspberry Pi juga punya akses internet, bisa share koneksi dari MacBook ke USB Ethernet melalui "Internet Sharing".

Kalau ada kendala, kasih tahu ya! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment