nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with u8g2.ssd1327_i2c_ea_w128128 (and all other ssd1327_i2c driver)

webstatic opened this issue · comments

Expected behavior

Do not reboot itself

Actual behavior

It causes the device to reboot.

Many times it reboots after print('init ssd1327_i2c_ea_w128128').
Sometimes it reboots after print('sendBuffer'), and show "hello" on display.
About one to five chance that it will display "hello" and reboot.

But It never pass disp:sendBuffer() line.

Test code

local scl = 1
local sda = 2

local sla = 0x3C
i2c.setup(0, sda, scl, i2c.SLOW)
print('init ssd1327_i2c_ea_w128128')
disp = u8g2.ssd1327_i2c_ea_w128128(0, sla)
print('setFontRefHeightExtendedText')
disp:setFontRefHeightExtendedText()
print('setDrawColor')
disp:setDrawColor(1)
print('setFontPosTop')
disp:setFontPosTop()
print('setFontDirection')
disp:setFontDirection(0)

print('clearBuffer')
disp:clearBuffer()
print('setFont')
disp:setFont(u8g2.font_6x10_tf)
print('drawStr')
disp:drawStr(0, 0, "hello");
print('sendBuffer')
disp:sendBuffer()

NodeMCU startup banner

branch: dev
commit: 6316b33
release:
release DTS: 202101162126
SSL: false
build type: float
LFS: 0x0 bytes total capacity
modules: bit,file,gpio,i2c,net,node,spi,tmr,u8g2,uart,wifi
build 2021-01-18 08:47 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)

Hardware

• 3V3 -> VCC
• GND -> GND
• D2 -> SDA
• D1 -> SCL
ty

And when use disp:drawXBM, it displays about haft of the image before the reboot, with random progress.

IMG_20210118_165145

It can be:
power issue (onboard 3.3V regulator is not powerful enough) - use external voltage regulator
watchdog timed out - increase I2C speed; ssd1327 datasheet says on page 62 that it supports clock up to 400 kHz

Check "rst cause" after reboot:
Reset Cause | Description
0 | Unidentified
1 | Power reboot or normal boot
2 | External reset using reset pin or wake up from deep sleep
3 | Software reset
4 | Hardware watchdog (WDT) reset

Thank you for your reply.

Yes, I think the reason is watchdog timed out.
When I change some code to

node.setcpufreq(node.CPU160MHZ)
i2c.setup(0, sda, scl, i2c.FASTPLUS)

the chance that it will not reboot is higher.

reset_reason is 3

Can I do something about it?

You could try and feed the software watchdog. https://nodemcu.readthedocs.io/en/release/modules/tmr/#tmrwdclr
You could also split the code in several methods which you separate by node.task.post()

You could also post (some of) the output of the reboot.

node.bootreason() returns 2 Values, the second contains better diagnostics. see https://nodemcu.readthedocs.io/en/release/modules/node/#nodebootreason

Thank you for your reply.

The watchdog reset comes inside single C function
u8g2.ssd1327_i2c_ea_w128128(0, sla)
or
disp:sendBuffer()
so tmr.wdclr() in lua won't work.

I not sure about node.task.post(), sometimes it works, sometimes don't

node.bootreason() is 2 3, reset (software?) and software watchdog reset.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.