-
Notifications
You must be signed in to change notification settings - Fork 25
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
Can't get it to run #65
Comments
I moved the discussion by @kjm1102 from #61 (comment) here to this new issue. @kjm1102 - you mentioned you got it to work. Would mind sharing what you did to get it working? Perhaps that can help someone in the future, or we could improve the documentation? |
Also moved from #61, originally by @wnienhaus : That is surprising. Could you paste here what command you used and which port of MicroPython you tried it with? Some things to check/try:
|
Rookie mistake, I hadn't done the import upip; upip.install('micropython-py-esp32-ulp') on the ESP32. In general I find Github posters make a lot of assumptions about the competence of people who might be crusing the site looking for 'HOWTO's. I always struggle with dependicies. Looking at someones code I'm unable to tell which imports are standard upython functions & which need to be added before trying to run the code. |
Glad this project found a new home but, like the first time I tried to use
it, I'm still struggling.
`>>> upip.install('micropython-py-esp32-ulp')
Installing to: /lib/
Warning: micropython.org SSL certificate is not validated
Installing micropython-py-esp32-ulp 1.1.0 from
https://files.pythonhosted.org/packages/b6/59/90b952a291882ad595c3d06bd0bdd0de582017e02b18293136430ebf3dd7/micropython-py-esp32-ulp-1.1.0.tar.gz
>> import counter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'counter'`
I checked lib is in the path
Also I can't work out how to access docs/index.rst.
…On Tue, 8 Feb 2022 at 05:25, TW ***@***.***> wrote:
Also moved from #61
<#61>, originally by
@wnienhaus <https://github.com/wnienhaus> :
That is surprising. Could you paste here what command you used and which
port of MicroPython you tried it with?
Some things to check/try:
- In case you used the unix port and cloned this repo somewhere, make
sure you are in the root directory of this repository (not in the esp32_ulp
subdirectory) when trying import esp32_ulp.
- If you are using the esp32 port and used upip to install the
micropython-py-esp32-ulp module, then upip by usually installs this into
the /lib directory. Ensure that /lib is part of your path, i.e. import
sys; print(sys.path)
—
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV562MYPNXN3GITDSPO4XW3U2AFAVANCNFSM5NX7L65A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
The reason for that error will be that you don't have the There are different ways to upload files, but one would be to use the
would upload the Btw, you should look for |
The
https://github.com/micropython/micropython-esp32-ulp/blob/master/examples/counter.py
I
think shows how to get the count from the ulp into the .py program. However
to setup a ULP counter that counts pulses from a gpio pin (eg the ulp
assembler code at https://esp32.com/viewtopic.php?t=12454 it looks like the
.py program has to send some values (like gpio pin number & debounce info)
to the ULP? Could we maybe have another example for us novices on how to do
that?
…On Sun, 15 May 2022 at 21:24, Wilko Nienhaus ***@***.***> wrote:
The reason for that error will be that you don't have the counter.py file
uploaded to your device (see "Quick start" in README.rst).
There are different ways to upload files, but one would be to use the ampy
tool from Adafruit (https://pypi.org/project/adafruit-ampy/). For example:
ampy -p /dev/tty.SLAB_USBtoUART put examples/counter.py
would upload the counter.py file from this repo's examples directory to
the root directory of your device. Some IDEs also support file uploading
like Mu (https://codewith.mu).
Btw, you should look for docs/index.rst inside this repo, not amongst the
files installed by upip. The installable library intentionally does not
contain any documentation or example files.
—
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV562M5QN4VSAEGFYROL373VKDNG5ANCNFSM5NX7L65A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Please do not post questions across multiple issues. For your last question, there is already issue #70 . Let's discuss that topic there. Did you manage with to get the |
Yes I have, but I haven't been able to figure out how to mod it to print the cumulative count after a deepsleep |
Great! About showing the cumulative count on each wake up, make sure that you load the ULP code only once on power-up and not again after waking up from deepsleep (i.e. make sure that you run lines 35-40 only on first startup. Also lines 15-28 are only needed on the first startup. And you can use |
One step closer to my aim of counting external pulses with the ulp while deepsleeping. load_addr, entry_addr = 0, 4 causes={2:'reset', 1:'hardreset', 3:'wdt', 4:'wakeup', 5:'pwrup'}; cause=causes[reset_cause()]; print(), print('pwrup cause', cause) print('cumulative count', mem32[ULP_MEM_BASE+load_addr] & ULP_DATA_MASK, end=' '); print() Gives `pwrup cause reset rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) pwrup cause wakeup rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) pwrup cause wakeup A couple of questions:
|
Well done!
(Alternatively simply add a number of unnamed
|
Tnx for your patience & peristence with me on this. I decided to play devil's advocate & incorporate non offset rtc.mem just to see what would happen.
seems to work OK
Are you sure you're using the front of rtc.mem? |
Hello. I will say that I am rather surprised by your result. The ESP32 has two "RTC memory areas" named RTC_FAST_MEM and RTC_SLOW_MEM. Looking at ESP-IDF code (here and here), the ESP32 documentation (section 1.3.2.8 and 1.3.2.7) and the MicroPython code (here), it appears that the Looking at your assembly code, there is only 1 The only assumption I can come up with is that perhaps the Ideas for next steps from here:
If I'll find some time, I'll try to repeat your finding on my ESP32. |
I'm using an ESP32 DEVKITV1
I don't think rtc.memory uses slow mem because it's only 512 bytes & all the forums claim 2k for the size of rtc.memory |
Ok. I tested this on my ESP32 and found the answer. The world makes sense again 😄 ! Both the ULP and And both the 512 bytes and the 2k size are also correct :) I could repeat your last case perfectly. I then did a dump of all of the first 512 bytes of the RTC slow memory (0x50000000) and saw that none of those bytes changed when using Then I tried to dump bytes from the RTC Fast memory (0x3ff80000) but got 0x0 for every byte. (This is likely because we're running on the APP processor, which cannot read those addresses - see 1.3.2.7). Then I went back to the RTC Slow memory and dumped the first 2048 bytes. And viola, I found your quick brown fox! It was hiding exactly starting at byte 513 and onwards! You can try this yourself with:
So, now the reasoning:
In other words, the 2048 bytes for the So, as long as your ULP code is less than or equal to 512 bytes (which it must be due to this validation here) you are safe to use PS. Looking at the Micropython code, it seemed that the |
Mate I envy your ability to ferret this info out, I like it when the world
makes sense. Looking forward to your thoughts on my struggles with issue
#70.
…On Fri, 20 May 2022, 4:28 pm Wilko Nienhaus, ***@***.***> wrote:
Ok. I tested this on my ESP32 and found the answer. The world makes sense
again 😄 !
Both the ULP and RTC.memory() use the RTC_SLOW_MEM.
And both the 512 bytes and the 2k size are also correct :)
I could repeat your last case perfectly. I then did a dump of all of the
first 512 bytes of the RTC slow memory (0x50000000) and saw that none of
those bytes changed when using RTC.memory(...) - consistent with your
finding.
Then I tried to dump bytes from the RTC Fast memory (0x3ff80000) but for
0x0 for every byte. (This is likely because we're running on the APP
processor, which cannot read those addresses - see 1.3.2.7
<https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf>
).
Then I went back to the RTC Slow memory and dumped the first 2048 bytes.
And viola, I found your quick brown fox!
It was hiding exactly starting at byte 513 and onwards! You can try this
yourself with:
print([chr(mem8[0x50000000 + i]) for i in range(0,2048)]) //using mem8 to get memory 1 byte at a time
So, now the reasoning:
- Micropython sets a 2048 byte (2k) buffer for the RTC.memory(..)
function here at line 60 and 68
<https://github.com/micropython/micropython/blob/master/ports/esp32/machine_rtc.c#L68>
.
- It uses the RTC_DATA_ATTR flag, to tell the linker this should go
into RTC memory. It's up to the linker to decide where that actually is.
- There is a compile time setting in the ESP-IDF called
CONFIG_ESP32_ULP_COPROC_RESERVE_MEM which defines how much memory to
reserve for the ULP. This is what is set to 512 bytes by default and what
Micropyton returns in esp32.ULP.RESERVE_MEM - see here
<https://github.com/micropython/micropython/blob/master/ports/esp32/esp32_ulp.c#L90>
.
- And this setting is what the linker uses to make space for the ULP
code, exactly the 512 bytes before the quick brown fox string.
In other words, the 2048 bytes for the RTC.memory() come exactly after
the 512 bytes reserved for the ULP.
So, as long as your ULP code is less than or equal to 512 bytes (which it
must be due to this validation here
<https://github.com/espressif/esp-idf/blob/7153f78e20917b3c58ca36f4d4195f07378b2a44/components/ulp/ulp_fsm/ulp.c#L108>)
you are safe to use RTC.memory(..). I.e. you're safe!
PS. Looking at the Micropython code
<https://github.com/micropython/micropython/blame/master/ports/esp32/machine_rtc.c#L66>,
it seemed that the rtc_user_mem_magic and rtc_user_mem_len variables
should come before the data, but it appears the linker arranged them in
reverse order... so looking at the bytes starting from 512+2048=2560 shows
those values there. It all makes sense.
—
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV562MYWGZWEFXUF7JKTZZDVK4WKHANCNFSM5NX7L65A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Originally posted by @kjm1102 in #61 (comment) :
The text was updated successfully, but these errors were encountered: