2022年10月8日 星期六

MicroPython v1.19 釋出

最近因為開始建置太陽能儲能系統, 打算用 ESP8266 製作智慧插座 (smart switch), 追蹤目前 NicroPython 版本, 發現早已在 6 月發布 v1.19 版 :


我上一次更新韌體是在今年 2 月的時候, 參考 : 


目前最新的是 v1.19.1, 主要是修正 v1.19 版的臭蟲. v1.19 版主要亮點如下 :
  1. 新版的 .mpy 檔的檔案格式減少了 10% 的大小, 節省記憶體空間, 提升了 bytecode 的存取效率. 這種檔案是 .py 原始碼編譯後的二進位容器, 當使用 import foo.py 匯入模組時, 解譯器會先去看看有沒有 foo.mpy 檔, 有的話就直接匯入 foo.mpy 來用, 否則才匯入 foo.py.
  2. 遵循 PEP 448 規範新增了函式呼叫時的多重 *args 與 **args 用法. 
  3. 更新了 ESP32 的 ADC 類別; 删除了 ESP8266 esp.info 和 machine.WDT.deinit.
參考 :

以下是在 NodeMCU ESP-WROOM-32 開發板上燒錄 MicroPython 韌體過程 :


1. 檢查 Flash :   

D:\ESP32>esptool.py --port COM9 flash_id   
esptool.py v2.6
Serial port COM9
Connecting....
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 80:7d:3a:b7:c0:8c
Uploading stub...
Running stub...
Stub running...
Manufacturer: 68
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

可見板載 4M Bytes Flash. 此指令 ESP8266/ESP32 通用, 下面抹除與燒錄則參數不同, 且按 Enter 執行前須按住 USB 右側的 Flash 按鈕. 


2. 抹除 Flash : 

D:\ESP32>esptool.py --chip esp32 --port COM9 erase_flash    
esptool.py v2.6
Serial port COM9
Connecting.....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 80:7d:3a:b7:c0:8c
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 4.0s
Hard resetting via RTS pin...


3. 燒錄 :    

D:\ESP32>esptool.py --chip esp32 --port COM9 write_flash -z 0x1000 esp32-20220618-v1.19.1.bin  
esptool.py v2.6
Serial port COM9
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 80:7d:3a:b7:c0:8c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 1560976 bytes to 1029132...
Wrote 1560976 bytes (1029132 compressed) at 0x00001000 in 91.6 seconds (effective 136.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

D:\ESP32>

燒錄完成用 Putty 連線 COM 埠 :

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4540
ho 0 tail 12 room 4
load:0x40078000,len:12344
ho 0 tail 12 room 4
load:0x40080400,len:4124
entry 0x40080680
MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32
Type "help()" for more information.
>>> import os   
>>> os.uname()   
(sysname='esp32', nodename='esp32', release='1.19.1', version='v1.19.1 on 2022-06-18', machine='ESP32 module with ESP32') 



如果是 ESP8266 開發板, 只要將抹除與燒錄韌體指令改成如下即可 : 

esptool.py --chip esp8266 --port COM8 erase_flash    
esptool.py --port COM8 --baud 115200 write_flash --flash_size=detect -fm dio 0 esp8266-20220618-v1.19.1.bin   

參考 :


下面是在 Witty Cloud 開發板燒錄韌體過程 (與 D1 Mini 規格大致相同, D1 mini 燒錄前要將 D3 接地; Witty Cloud 要按住 Flash 鈕直到出現 % 燒錄進度讀數才能放開) : 

D:\ESP8266>esptool.py --port COM8 flash_id    
esptool.py v2.6
Serial port COM8
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: e8:db:84:a8:f5:14
Uploading stub...
Running stub...
Stub running...
Manufacturer: 54
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

D:\ESP8266>esptool.py --chip esp8266 --port COM8 erase_flash    
esptool.py v2.6
Serial port COM8
Connecting....
Chip is ESP8266EX
Features: WiFi
MAC: e8:db:84:a8:f5:14
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 10.6s
Hard resetting via RTS pin...

D:\ESP8266>esptool.py --port COM8 --baud 115200 write_flash --flash_size=detect -fm dio 0 esp8266-20220618-v1.19.1.bin   
esptool.py v2.6
Serial port COM8
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: e8:db:84:a8:f5:14
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0240
Compressed 634844 bytes to 419808...
Wrote 634844 bytes (419808 compressed) at 0x00000000 in 37.0 seconds (effective 137.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

其實用命令列更方便. 關於 Witty Cloud 開發板參考 :


沒有留言:

張貼留言