2017年11月4日 星期六

MicroPython 燒錄 main.py


1) 下載 MicroPython 的 firmware 


Firmware for ESP8266 boards
The following files are stable firmware for the ESP8266. Program your board using the esptool.py program as described in the tutorial.
The following are daily builds of the ESP8266 firmware. They have the latest features and bug fixes, WebREPL is not automatically started, and debugging is enabled by default.
The following are daily builds of the ESP8266 firmware tailored for modules with only 512kbytes of flash. Certain features are disabled to get the firmware down to this size.

  2. 下載燒錄工具 

 http://ghostysoft.blogspot.tw/2016/07/nodemcu-esp8266.html

先到https://github.com/nodemcu/nodemcu-flasher按下  Download ZIP  下載燒錄工具,然後執行Win32Win64 Release目錄下之ESP8266Flasher.exe



3. 一鍵燒錄韌體更新

Operation頁面選擇COM Port


Config頁面,預設會自動使用INTERNAL://NODEMCU,位址設定為0x00000


如果想手動變更燒錄檔,可以按下齒輪按鈕選擇所需要的檔案並設定燒錄的位址預設的檔案是在Resource\Binary\nodemcu_integer_0.9.5_20150318.bin


  

Advanced頁面,使用預設值即可

  

回到Operation頁面,按下  FLASH(F)  開始燒錄,開始燒錄後會自動取得MAC位址,NodeMCUESP8266-12模組GPIO-4LED開始閃動,此時可以切換到Log頁面看燒錄狀況

       

      

如果燒錄失敗,先按下  STOP(S)  停止,再按下  FLASH(F)  重新燒錄即可。如果失敗太多次,可以到Advance頁面將Baudrate降低 (例如115200) 試試看。

              

燒錄完成後要按下NodeMCURST按鈕,重新開機後才能使用。





uPYCraft 程式 put 到  NedeMCU上 main.py


檔案系統最重要的是根目錄 / 下的兩個 python 執行檔 boot.py 與 main.py, 
韌體在開機後首先會去根目錄下找尋 boot.py, 有找到的話就先執行此開機檔,
然後再尋找 main.py, 有的話就執行此程式, 一般而言, main.py 
裡面主要就是一個執行特定應用邏輯無窮迴圈. 
因此通常會在 boot.py 裡面進行系統設定, 
例如開啟關閉 debug 或 webrepl 功能等. 一般 boot.py 的內容如下 :

#import esp
#esp.osdebug(None)
import gc
import webrepl
webrepl.start(password="123456")
gc.collect()









利用Git Bash 程式

在 Windows 中安裝

在 Windows 中安裝 Git 也有很多種方式。 最正式的安裝程式在 Git 官方網站可供下載。 你只需要連到 http://git-scm.com/download/win 然後下載就會自動開始。


這裡很重要的是 OPTION 中的 port, 在 Windows 是用 COMx (慣例是用大寫), 所以要先在裝置管理員中確定 USB-TTL 轉接線是哪一個 COM 埠. 另外因為 ampy 要使用串列埠, 所以如果有使用   uPyCraft 開啟該 COM 埠的話, 必須關掉uPyCraft, 否則 ampy 的指令都會報錯,

alex@alex-PC MINGW64 /d/mini3
$ cd d:/mini3/

alex@alex-PC MINGW64 /d/mini3
$ ampy --port com15 ls
boot.py
blink.py
main.py

alex@alex-PC MINGW64 /d/mini3
$


alex@alex-PC MINGW64 /d/mini3
$ ampy --help
Usage: ampy [OPTIONS] COMMAND [ARGS]...

  ampy - Adafruit MicroPython Tool

  Ampy is a tool to control MicroPython boards over a serial connection.
  Using ampy you can manipulate files on the board's internal filesystem and
  even run scripts.

Options:
  -p, --port PORT  Name of serial port for connected board.  Can optionally
                   specify with AMPY_PORT environemnt variable.  [required]
  -b, --baud BAUD  Baud rate for the serial connection (default 115200).  Can
                   optionally specify with AMPY_BAUD environment variable.
  --version        Show the version and exit.
  --help           Show this message and exit.

Commands:
  get    Retrieve a file from the board.
  ls     List contents of a directory on the board.
  mkdir  Create a directory on the board.
  put    Put a file or folder and its contents on the...
  reset  Perform soft reset/reboot of the board.
  rm     Remove a file from the board.
  rmdir  Forcefully remove a folder and all its...
  run    Run a script and print its output.

沒有留言:

張貼留言

2024年4月24日 星期三 Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --2

 2024年4月24日 星期三 Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --2 AngularJS 實例 <!DOCTYPE html> <html> <head> &...