-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CLUE display issues with 6.0.0-alpha3 #3367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
PyPortal works normally with 6.0.0.alpha3 |
It broke between these 2 builds from S3 last working build
not working
|
EDITED to ADD -- ignore this -- this was not the breaking commit -- see below this commit made some changes to code common to all ports - no idea why to would impact CLUE and not PyPortal though ... a15f948 Nothing in the other commits jumps out as a likely cause. |
hmm weird -- now
|
Repeated the search and now find that the last working version was Adafruit CircuitPython 6.0.0-alpha.2-26-gb7e6bf959 on 2020-07-25; Adafruit CLUE nRF52840 Express with nRF52840 and first broken version was Adafruit CircuitPython 6.0.0-alpha.2-43-g7ab5c520e on 2020-07-25; Adafruit CLUE nRF52840 Express with nRF52840 HOWEVER when I reloaded 6.0.0-alpha.2-43-g7ab5c520e. it worked for REPL, but not when I ran a program that used the display. It did display but with odd behavior (extra lines in "spirit level") -- after that it no longer worked for REPL either. 6.0.0-alpha.2-26-gb7e6bf959 appears to be stable This would implicate #3190 which chawed the compiler optimizations. |
Reverting the changes in #3190 seems to fix it.
now works on the tip of main 6.0.0-alpha.3-62-gf0e60da51-dirty Note: the above changes only reverted the "default" build changes in the Makefile -- there were also changes in the "debug' build. I am not sure if there are other implications of changing this. |
A similar fix was offered at #3249 but closed without merge because @dhalbert filed #3281 and @DavePutz reported that it fixed #3247. Were any other nrf-with-display boards tested? This reminds me, I had trouble with the Sharp Memory Display corrupting random lines of the display with nrf52840 and not on other micros. I chalked it up to the particular device being a Particle Xenon rather than an Adafruit board and moved on with a different board (that happened to be non-nRF) |
Issue #3296 is another case where compiling with -O2 optimization on the Clue broke something (in that case, BLE). @dhalbert has mentioned that these sorts of issues are most often due to a bug such as an uninitialized variable or something that should be volatile is not. I have spent a lot of time looking at #3296, and have traced it down to compiling ports/nrf/common-hal/busio/SPI.c with -O2 causing the BLE issue. But, I have not found anything in that source file that would seem to fit Dan's categories. Given the number of issues compiling with -O2 on the Clue seems to be causing, perhaps we should re-visit #3249? |
this keeps getting stranger -- With the build I created yesterday - reverting the optimization settings, the CLUE works normally as long as it is connected to the computer USB port. If I power it via a battery alone, the Display does not work. The program in code.py runs, but nothing is displayed. If I go back to CP 5.3.1 it works normally via battery.... It seems like something in the display is requiring the USB connection to be active... |
I can reproduce this as well. But, I don't think we can blame this one on
the -O2 optimization. I tried the
first build after that change went in (7ab5c52
<https://adafruit-circuit-python.s3.amazonaws.com/bin/clue_nrf52840_express/en_US/adafruit-circuitpython-clue_nrf52840_express-en_US-20200725-7ab5c52.uf2>)
and the display still works with the battery. I'll see if I can
narrow down which commit broke this functionality.
…On Wed, Sep 2, 2020 at 2:42 PM jerryneedell ***@***.***> wrote:
this keeps getting stranger -- With the build i crated yesterday -
reverting the optimization settings, the CLUE works normally as long as it
is connected to the computer USB port. If I power it via a battery alone,
the Display does not work. The program in code.py runs, but nothing is
displayed. If I go back to CP 5.3.1 it works normally via battery.... It
seems like something in the display is requiring the USB connection to be
active...
I'm confused!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKESUBW3BQIFILH4HQ7DSD2N2ZANCNFSM4QR72YQA>
.
|
Seems that the cause of this is PR #3244. The intent was to turn off QSPI
when USB was not connected.
Looks like this is interfering with the display on the Clue ??
…On Wed, Sep 2, 2020 at 5:08 PM Dave Putz ***@***.***> wrote:
I can reproduce this as well. But, I don't think we can blame this one on
the -O2 optimization. I tried the
first build after that change went in (7ab5c52
<https://adafruit-circuit-python.s3.amazonaws.com/bin/clue_nrf52840_express/en_US/adafruit-circuitpython-clue_nrf52840_express-en_US-20200725-7ab5c52.uf2>)
and the display still works with the battery. I'll see if I can
narrow down which commit broke this functionality.
On Wed, Sep 2, 2020 at 2:42 PM jerryneedell ***@***.***>
wrote:
> this keeps getting stranger -- With the build i crated yesterday -
> reverting the optimization settings, the CLUE works normally as long as it
> is connected to the computer USB port. If I power it via a battery alone,
> the Display does not work. The program in code.py runs, but nothing is
> displayed. If I go back to CP 5.3.1 it works normally via battery.... It
> seems like something in the display is requiring the USB connection to be
> active...
> I'm confused!
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#3367 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFNJKESUBW3BQIFILH4HQ7DSD2N2ZANCNFSM4QR72YQA>
> .
>
|
@xiongyihui - what was your intent with the PR #3244 patch in regard to displays? Right now I see that qspi_enable() is being called during startup after qspi_disable(); but the Clue display does not come back on. I see that you did not use the NRF provided nrf_qspi_disable() to turn off QSPI, but you did use nrf_qspi_enable() to turn it back on. Was there a reason for this? I did find out the commenting out the |
This issue appears to have been resolved -- at least, it works on my CLUE now ... should this be closed? NEVERMIND--- still not working on battery -- sorry for the confusion |
Hmm, interesting that yours is now working. I just pulled and built the
latest main (commit 9256e6b)
and I still have nothing on the display when booting the Clue off a
battery, and running some
displayio code still produces nothing.
…On Fri, Sep 11, 2020 at 10:54 AM jerryneedell ***@***.***> wrote:
This issue appears to have been resolved -- at least, it works on my CLUE
now ... should this be closed?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKEU53TAVUDFXWCKPCJLSFJB2VANCNFSM4QR72YQA>
.
|
Sorry -- it is not working on battery -- I updated my comment above.... |
@jepler - do you know what the intent was for PR #3244? I asked @xiongyihui but have not received any response. Since qspi_disable() is called in port_sleep_until_interrupt(), any routine that calls mp_hal_delay_ms() will turn off QSPI. In effect, this disables QSPI by default at boot time when USB is not connected, as several startup routines have short delays in them. The effect on the Clue is to disable the display (which uses SPI) and there does not seem to be any way to turn it back on. Calling qspi_enable() does not turn the display back on. So, do we really want to have the Clue unable to use the display when on battery power? |
QSPI is not SPI. Normally, they don't affect each other. Does SPI share pins with QSPI? |
From what I can see SPI and QSPI do not share pins on the Clue.
From boards/clue_nrf52840_express/board.c:
void board_init(void) {
...
&pin_P0_13, // TFT_DC Command or data
&pin_P0_12, // TFT_CS Chip select
&pin_P1_03, // TFT_RST Reset
...
&pin_P1_05, // backlight pin
and in supervisor/qspi_flash.c:
nrfx_qspi_config_t qspi_cfg = {
.xip_offset = 0,
.pins = {
.sck_pin = MICROPY_QSPI_SCK, // defined as NRF_GPIO_PIN_MAP(0,
19)
.csn_pin = MICROPY_QSPI_CS, // defined as NRF_GPIO_PIN_MAP(0,
20)
.io0_pin = MICROPY_QSPI_DATA0, // defined
as NRF_GPIO_PIN_MAP(0, 17)
...
qspi_cfg.pins.io1_pin = MICROPY_QSPI_DATA1; // defined
as NRF_GPIO_PIN_MAP(0, 22)
qspi_cfg.pins.io2_pin = MICROPY_QSPI_DATA2; // defined
as NRF_GPIO_PIN_MAP(0, 23)
qspi_cfg.pins.io3_pin = MICROPY_QSPI_DATA3; // defined
as NRF_GPIO_PIN_MAP(0, 21)
One thing I have seen in my testing is that in qspi_disable() taking out
the line
NRF_QSPI->TASKS_DEACTIVATE = 1;
allows the display to work. I have not found in the nrf52840 documentation
a mention about
doing this. Is it required?
…On Tue, Sep 15, 2020 at 7:20 PM Yihui Xiong ***@***.***> wrote:
QSPI is not SPI. Normally, they don't affect each other. Does SPI share
pins with QSPI?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKETQMID6WO5NGFQDRDDSGAAE7ANCNFSM4QR72YQA>
.
|
The intent of #3244 was to turn off the QSPI peripheral while going to sleep so that the high speed clock would be turned off and save a bunch of power. It should start back up at the next file access. The SPI to the display should be separate from QSPI. Perhaps the SPI isn't keeping the high speed clock active? |
I did some further testing, and it isn't only the display that's affected. An externally connected SPI device works with USB power but |
@DavePutz I tested it on nrf52840 m.2 devkit which has a SPI display. Turning off QSPI doesn't affect the SPI display. |
My test code is:
|
On issue #3360, it seems turning off QSPI doesn't affect SPI too. |
This seems very weird that USB vs battery would be different. Does the Clue wake up OK in this case? It seems like it must be related to the regulator: https://cdn-learn.adafruit.com/assets/assets/000/087/877/original/adafruit_products__CLUE_sch.png?1580423083 The only difference it will see is 5v from USB vs <4.2V from the battery. @xiongyihui Is your schematic open source? I wonder how the power circuitry differs. |
The schematic is at https://github.com/makerdiary/nrf52840-m2-devkit |
Just as a point of information, We tried a Feather nRF52840 Express with a
TFT Featherwing and see the
same issue - the display lights up (backlight?) but does not show any
outputs from the code.py script. So, this
does not look like just a Clue issue.
…On Thu, Sep 17, 2020 at 7:55 PM Yihui Xiong ***@***.***> wrote:
The schematic is at https://github.com/makerdiary/nrf52840-m2-devkit
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKEVNC7NDABIJ3HLJOADSGKVZVANCNFSM4QR72YQA>
.
|
Thanks @xiongyihui! The power does look different on the feather as well. Looks like vbat goes through the diode of the transistor before the regulator. @DavePutz do other things work ok? This is so weird that it works on USB but not battery power. |
I determined that the calls to common_hal_time_delay_ms() in common_hal_displayio_fourwire_reset are the reason for this issue. Since common_hal_time_delay_ms() ends up calling port_sleep_until_interrupt(), which is where qspi_disable() is called; I suspect there must be some timing issue with disabling QSPI while the fourwire is being initialized. @tannewt , I see those delays were added in a commit for e-paper. If these delays are needed for e-paper to work, is there some other way to accomplish that? Maybe use mp_hal_delay_us()? |
@DavePutz why would that only break when on battery power? |
@tannewt - qspi_disable() only does the disabling when USB is not connected. |
There are 2 test cases here.
1. Boot on battery power only.
2. Boot on USB Power with battery plugged in and then remove USB power
without reseting.
Both the CLUE and Feather with TFT work ok for test case 2 .
Both fail for test case 1.
…On Fri, Sep 18, 2020 at 1:57 PM Scott Shawcroft ***@***.***> wrote:
@DavePutz <https://github.com/DavePutz> why would that only break when on
battery power?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFM7PVJ4QZQXKOTNQHJ4HHTSGOUSNANCNFSM4QR72YQA>
.
|
@DavePutz
I tried it. The SPI display still works when QSPI is off and USB is connected. |
OK, here is the issue the way I see it. If the two calls to common_hal_time_delay_ms(1) in common_hal_displayio_fourwire_reset() are replaced with mp_hal_delay_us(1000) then the SPI TFT displays on Clue and Feather work fine. However, an e-paper display on the Feather still does not work, due to the call to common_hal_time_delay_ms() in send_command_sequence(). The delay there looks like it might be for quite a long time (up to 500ms). Assuming that the e-paper displays need that delay, I can think of two alternatives. Either send_command_sequence() gets modified in some way to not call common_hal_time_delay_ms(); or we need to take the qspi_disable() call out of port_sleep_until_interrupt() (possibly by making it a call of its own, so it is a deliberate choice and not the default?) @tannewt , @xiongyihui - any thoughts? |
Is the sleep too short when qspi is disabled? I still don't understand the connection between disabling QSPI and SPI display. Maybe there is a clock glitch on the SPI lines when sleeping? |
I do not understand why disabling QSPI affects SPI at all. And yet, it
clearly does.
There are no pin conflicts that I have found, it just looks like some sort
of timing
issue or conflict on the nrf chip. The only issue with sleeping while
initializing an
SPI device is that it will end up calling qspi_disable(); it doesn't matter
how long or short
the sleep is.
…On Mon, Sep 21, 2020 at 3:04 PM Scott Shawcroft ***@***.***> wrote:
Is the sleep too short when qspi is disabled? I still don't understand the
connection between disabling QSPI and SPI display. Maybe there is a clock
glitch on the SPI lines when sleeping?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKEWJTYQ7IVFU3ZCZKTTSG6WTXANCNFSM4QR72YQA>
.
|
|
@xiongyihui I doubt those delays are broken if it takes longer than expected. Is there some way for the delay to shorten with the qspi disable? |
I have not determined the root cause of the qspi_disable interfering with
regular SPI
peripherals. We can't use common_hal_delay_ms() with a value less than 1 in
any
case. I'm not sure if it is the length of the delay causing the issue, or
something in the
SPI/QSPI subsystems that have some sort of dependency on each other. I do
know that
once the SPI display is initialized properly, subsequent calls to
qspi_disable() do not have any
effect on it.
…On Tue, Sep 22, 2020 at 12:39 PM Scott Shawcroft ***@***.***> wrote:
@xiongyihui <https://github.com/xiongyihui> I doubt those delays are
broken if it takes longer than expected. Is there some way for the delay to
shorten with the qspi disable?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKETKC4A7VTZTLWUSXB3SHDOL5ANCNFSM4QR72YQA>
.
|
I think |
It seems as though the fix for nRF52840 Revision 1 Errata V1.4 - 3.8 in qspi_disable() is doing something to the SPI. If I comment out the two lines from that errata, SPI works correctly. Then running on battery I do not see QSPI in the peripheral list generated by the script above from @xiongyihui . However, I don't have a way of measuring any differences in the current draw from the battery with or without that code. I have not been able to find any reference saying what the line |
@DavePutz Thank you for finding that! That's enough root cause for me. |
Issue #3367 Changed delay calls to avoid conflicts with qspi_disable
With 6.0.0-Alpha3 and later, on a CLUE I am not seeing the REPL displayed on the screen.
I also tried running the 'spirit level' demo does not display anything -- no errors, just no display.
works ok with CP 5.3.1
and
6.0.0.alpha2
The REPL is woking OK in the terminal session, just not echoing to the display.
The text was updated successfully, but these errors were encountered: