Try   HackMD

🛠️ 【軟體】網路、通訊 🛠️

不同通訊下的開發方式(樹梅派)

因為不知道樹梅派燒錄筆記要放哪,就順便放這吧~

樹梅派 燒錄教學

派的前置作業

這裡是在 Raspberry PI 4 上裝 Ubuntu Server 20.04 。請根據自己需求更換版本。

需要的東西有:

  • 樹梅派、筆電
  • micro SD 卡 / micro SD 讀卡機
  • micro HDMI to HDMI 轉接線
  • Raspberry Pi 燒錄器

燒錄 Ubuntu 至 microSD

1. 下載 RPi燒錄器

2. 將裝有 micro SD 卡的讀卡機插進電腦。

接著就照著下面按就可以了。

此裝 Ubuntu Server 20.04 LTS x64,新手可裝 Desktop 版本(有 GUI)。

3. 按右下角的齒輪或是用快捷鍵 ctrl+shift+x 進入高級設置。

請自行調整主機名(hostname)及 Wi-Fi SSID/pswd。

4. 燒錄
就按燒錄,等他燒完就可以直接拔出來了。


1. 開發方式一: 外接螢幕與鍵盤

樹莓派開發最直接的方式是 RPi 外接螢幕和鍵盤,但個人覺得這樣很麻煩。


2. 開發方式二: UART 串口通訊

可改用 UART 串口通訊,只要準備 USB2TTL 模組 就可以了。

1. 筆電插上 micro SD 讀卡機,在 boot/config.txt 的末端新增一行。

enable_uart=1

2. 筆電安裝XShell 7

3. 將樹莓派連 USB2TTL,並插上筆電 USB 槽即可。
(若怕 GPIO 供電不穩,可以移除 5V 線,改用 Type-C 供電。)

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

4. 開啟 XShell

  • 檔案 > 新增 > 連線 > 通訊協定,選擇 SERIAL
  • 串口 > 端口號,選擇自己的 port。其他設定使用預設值。
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

3. 開發方式三: SSH 遠端連線

最優雅的方式還是遠端開發,SSH 訪問。樹莓派上電即可遠端連線開發。

1. 連網
sudo apt update 測試網路運作,不正常請回燒錄步驟確認網路設置。

2. 查 IP

sudo apt install net-tools ifconfig

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

3. VSCode 中設置 C:\Users\User.ssh\config。

VSCode 中左下角,開啟遠端視窗 > 在目前的視窗中連線至主機 > 設定 SSH 主機 > C:\Users\User.ssh\config

# 留意空格和空行 Host 192.168.50.103 #填入RPi的IP HostName ditrobotics #不確定可輸入hostname查詢 User pomelo #不確定可輸入whoami查詢

儲存後,開啟遠端視窗 > 在目前的視窗中連線至主機 > 192.168.50.103 > linux > 繼續

每次都要查 IP 很麻煩?
那你可以到 router 設定 static DHCP/IP 或是 使用mDNS