実現したいこと
esp32doit-devkit-v1 の開発ボードでWiFi接続をしてセンサーから取った値をhttp通信で送る
発生している問題・分からないこと
WiFi 接続やモード設定のメソッドを呼ぼうとするとESP32が無限ループ?のような状態となりPCとの接続も解除される。
エラーメッセージ
error
1Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. 2PC : 0x40089eb0 PS : 0x00060830 A0 : 0x8013bbb8 A1 : 0x3ffb1db0 3A2 : 0x000000ff A3 : 0x000000fb A4 : 0x000000ff A5 : 0x0000ff00 4A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x64002e2e A9 : 0x3ffb2160 5A10 : 0x00000001 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000 6A14 : 0x3ffb833c A15 : 0x00000000 SAR : 0x0000001e EXCCAUSE: 0x0000001c 7EXCVADDR: 0x000000ff LBEG : 0x400899bc LEND : 0x400899c1 LCOUNT : 0x00000000
該当のソースコード
arduino
1#include <WiFi.h> 2 3const char* ssid = "ssid"; 4const char* password = "password"; 5 6void setup() { 7 Serial.begin(115200); 8 // 次のWiFi.mode() で止まったため 9 Serial.printf("WiFi.status: %s\n", WiFi.status()); 10 WiFi.mode(WIFI_STA); 11 WiFi.begin(ssid, password); 12} 13 14void loop() {} 15
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
・WiFi.h のいくつかのメソッドを動作するか検証した
=>WiFi.disconnect() のみ動作
・Serial.printf("WiFi.status: %s\n", WiFi.status());を試しに実行
=> パニックのエラーメッセージが表示された
・ボードマネージャーの ESP32 を削除 ~ 再インストール
=> 変化なし
・ボードマネージャーの ESP32 のバージョンを最新(2.0.15)から以前動かせていた古い(1.0.6) 版にダウングレード
=> 変化なし
補足
Arduino IDE 2.3.2
Board: ESP32 Dev Module esp32 by Expressif Systems@2.0.15 / 1.0.6
メモリ不足を疑っています。
書き込みのときに「最大~~MBのうち~~MB(~~%)使用しています」みたいなメッセージが出ると思いますがどの程度使っていますか?
コメントありがとうございます。
試行錯誤中でしたが気づいた時点でのスケッチを書き込んだ際の出力は下記のとおりです。
```
Sketch uses 918097 bytes (70%) of program storage space. Maximum is 1310720 bytes.
Global variables use 47540 bytes (14%) of dynamic memory, leaving 280140 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM7
Connecting.......
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c8:f0:9e:51:6b:d8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000f1fff...
Compressed 18992 bytes to 13110...
Writing at 0x00001000... (100 %)
Wrote 18992 bytes (13110 compressed) at 0x00001000 in 0.4 seconds (effective 380.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 473.4 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 688.4 kbit/s)...
Hash of data verified.
Compressed 924800 bytes to 597126...
Writing at 0x00010000... (2 %)
Writing at 0x0001b963... (5 %)
Writing at 0x00027932... (8 %)
Writing at 0x000358f1... (10 %)
Writing at 0x0003d477... (13 %)
Writing at 0x00043321... (16 %)
Writing at 0x0004892b... (18 %)
Writing at 0x0004e1dd... (21 %)
Writing at 0x000535ca... (24 %)
Writing at 0x00058db2... (27 %)
Writing at 0x0005dfba... (29 %)
Writing at 0x000630d9... (32 %)
Writing at 0x00068433... (35 %)
Writing at 0x0006d6b6... (37 %)
Writing at 0x000729bb... (40 %)
Writing at 0x00077e6b... (43 %)
Writing at 0x0007cfa1... (45 %)
Writing at 0x00082364... (48 %)
Writing at 0x00087379... (51 %)
Writing at 0x0008d04a... (54 %)
Writing at 0x00092785... (56 %)
Writing at 0x00097cf0... (59 %)
Writing at 0x0009d1d1... (62 %)
Writing at 0x000a234d... (64 %)
Writing at 0x000a77c0... (67 %)
Writing at 0x000ac9bd... (70 %)
Writing at 0x000b21c2... (72 %)
Writing at 0x000b7993... (75 %)
Writing at 0x000bd627... (78 %)
Writing at 0x000c2f40... (81 %)
Writing at 0x000c8911... (83 %)
Writing at 0x000d169e... (86 %)
Writing at 0x000d9ca4... (89 %)
Writing at 0x000ded4f... (91 %)
Writing at 0x000e4747... (94 %)
Writing at 0x000e9b12... (97 %)
Writing at 0x000ef49d... (100 %)
Wrote 924800 bytes (597126 compressed) at 0x00010000 in 8.6 seconds (effective 859.4 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
```
ESP32のボードライブラリについてくるサンプルプログラムは動きますか?
> 以前動かせていた古い(1.0.6) 版
以前は動いていたプログラムが動かなくなった、ということですか?
であればハード的なトラブル(ペリフェラルが応答を返さなくて無限ループ)なども疑いのスコープに入ってきますが。
スケッチ例の WiFi > WiFiScan を試しで実行してみて動かないことを確認しました。
13行目( WiFi.mode(WIFI_STA); )で止まっているのか
17行目( Serial.println("Setup done"); )が出力されず、シリアル接続も不安定となります。
古い版で動いていたプログラムから、センサーの値読み取り部分のみ変更(ほかWiFi周りなど共通)した
プログラムを今回書いていて不具合に遭遇し、対処に苦慮しています。
また、未開封であった同じ仕様の開発ボードも開封~サンプルプログラムを書き込むも動作せずでした。
※ここまで用いていた開発ボードの USBドライバーは CP2102 です。
※古い版のプログラムを書きこんだボードも同じ仕様のものです。
USBドライバーが異なる(CH340C)下記商品を追加で購入し Arduino IDE の設定は同一のままサンプルスケッチと当初私が書いていたスケッチの両方とも問題なく動作しました。
https://www.amazon.co.jp/gp/product/B0BZK2JJ94/
どこに原因があるか判定するため確認すべきところなど、ご協力いただけますと幸いです。よろしくお願いいたします。
Core Debug LevelをVerboseにしてシリアル出力ログを確認してみてください
私の手元で質問のプログラムをコンパイルすると
---
最大1310720バイトのフラッシュメモリのうち、スケッチが708685バイト(54%)を使っています。
最大327680バイトのRAMのうち、グローバル変数が42436バイト(12%)を使っていて、ローカル変数で285244バイト使うことができます。
---
で随分サイズが違うのがなんだか。(ESP32 2.0.14ライブラリ)
それと、
Serial.printf("WiFi.status: %s\n", WiFi.status());
において
WiFi.status()
はint(enum)を返すので、%sで受けたら高確率で吹っ飛びます。
コメントありがとうございます。
@ozwk 様 Core Debug LevelをVerboseにしてスケッチ例の WiFi > WiFiScan を書き込んでみました。出力は以下のとおりです。
```
Sketch uses 738697 bytes (56%) of program storage space. Maximum is 1310720 bytes.
Global variables use 43408 bytes (13%) of dynamic memory, leaving 284272 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM7
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c8:f0:9e:51:6b:d8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000c5fff...
Compressed 18992 bytes to 13110...
Writing at 0x00001000... (100 %)
Wrote 18992 bytes (13110 compressed) at 0x00001000 in 0.4 seconds (effective 377.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 443.8 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 691.4 kbit/s)...
Hash of data verified.
Compressed 745280 bytes to 480178...
Writing at 0x00010000... (3 %)
Writing at 0x0001c670... (6 %)
Writing at 0x0002726b... (10 %)
Writing at 0x00032c20... (13 %)
Writing at 0x000382fb... (16 %)
Writing at 0x0003da07... (20 %)
Writing at 0x00042fac... (23 %)
Writing at 0x00048185... (26 %)
Writing at 0x0004d3af... (30 %)
Writing at 0x00052646... (33 %)
Writing at 0x00057a20... (36 %)
Writing at 0x0005cb6b... (40 %)
Writing at 0x000620f3... (43 %)
Writing at 0x0006735f... (46 %)
Writing at 0x0006cf07... (50 %)
Writing at 0x00072764... (53 %)
Writing at 0x0007787c... (56 %)
Writing at 0x0007cd00... (60 %)
Writing at 0x00081eee... (63 %)
Writing at 0x0008769d... (66 %)
Writing at 0x0008ce48... (70 %)
Writing at 0x00092b3c... (73 %)
Writing at 0x00098438... (76 %)
Writing at 0x0009dde8... (80 %)
Writing at 0x000a71de... (83 %)
Writing at 0x000ae507... (86 %)
Writing at 0x000b3b10... (90 %)
Writing at 0x000b93c8... (93 %)
Writing at 0x000be9a7... (96 %)
Writing at 0x000c424c... (100 %)
Wrote 745280 bytes (480178 compressed) at 0x00010000 in 7.0 seconds (effective 852.5 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
```
@thkana 様 以前のコメントで乗せていたものはセンサ読み取りなどで別のライブラリも読み込んでいたものです。WiFiScanのスケッチでは 738697 bytes のサイズとなりました。
> Serial.printf("WiFi.status: %s\n", WiFi.status());
> において
> WiFi.status()
> はint(enum)を返すので、%sで受けたら高確率で吹っ飛びます。
意識になかったところでした。ご指摘ありがとうございます
コンパイル時のログじゃなくて動かしたときにシリアルモニタに出る出力です
違う話を混ぜ混ぜにすると訳が分からなくなるので、条件は揃えていただけるとありがたいです。
@ozwk 様 コメントからお時間開いてしまい失礼いたしました。
書き込み後のシリアルモニタの出力です。
@thkana 様 承知いたしました。まずはサンプルスケッチの WiFi > WiFiScan.ino で確認させていただきたく存じます。
---
22:46:41.719 -> ets Jul 29 2019 12:21:46
22:46:41.752 ->
22:46:41.752 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
22:46:41.752 -> configsip: 0, SPIWP:0xee
22:46:41.752 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:46:41.752 -> mode:DIO, clock div:1
22:46:41.752 -> load:0x3fff0030,len:1344
22:46:41.752 -> load:0x40078000,len:13964
22:46:41.752 -> load:0x40080400,len:3600
22:46:41.752 -> entry 0x400805f0
22:46:42.024 -> [ 4][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
22:46:42.024 -> [ 43][V][esp32-hal-uart.c:330] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(3) txPin(1)
22:46:42.056 -> [ 52][V][esp32-hal-uart.c:416] uartBegin(): UART0 not installed. Starting installation
22:46:42.056 -> [ 62][V][esp32-hal-uart.c:463] uartBegin(): UART0 initialization done.
22:46:42.102 -> [ 95][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 0 - WIFI_READY
---
ここまでで出力が止まります。
あなたの回答
tips
プレビュー