guild icon
Toit
#wifi.scan causes an Assertion_Failed error
Thread channel in help
Tej
Tej 11/18/2024 03:35 PM
Has someone used [toit-zygote](https://github.com/kasperl/toit-zygote/tree/main) with 2.0.0-alpha.164?

I am consistently getting an error:

[jaguar] INFO: program 2ac875c7-df00-7451-802b-18ee470e6a99 started INFO: scanning for wifi access points ****************************************************************************** Decoding by `jag`, device has version <2.0.0-alpha.164> ****************************************************************************** ASSERTION_FAILED error. 0: NetworkServiceClient <sdk>/system/api/network.toit:116:5 1: WifiServiceClient <sdk>/system/api/wifi.toit:33:5 2: service_ <sdk>/net/wifi.toit:33:34 3: run-global-initializer__.<block> <sdk>/core/objects.toit:291:28 4: run-global-initializer__ <sdk>/core/objects.toit:257:1 5: scan <sdk>/net/wifi.toit:136:14 6: run src/setup.toit:71:20 7: main.<block> src/setup.toit:61:53 8: catch.<block> <sdk>/core/exceptions.toit:124:10 9: catch <sdk>/core/exceptions.toit:122:1 10: catch <sdk>/core/exceptions.toit:85:10 11: main src/setup.toit:61:3 ****************************************************************************** [jaguar] ERROR: program 2ac875c7-df00-7451-802b-18ee470e6a99 stopped - exit code 1

This minimal example is also enough to trigger the error:

// wifi_scan.toit import log import net.wifi main: log.info "scanning for wifi access points" channels := ByteArray 12: it + 1 print "channels: $(channels)" // next line triggers assertion_failed error access_points := wifi.scan channels print access_points

Test:
jag flash jag run wifi_scan.toit
Contribute to kasperl/toit-zygote development by creating an account on GitHub.
floitsch
floitsch 11/18/2024 03:37 PM
Thanks.
We recently enabled asserts by default. Without looking at the code it is likely that there is an assert here that (wrongly?) triggers.

We will look at it. In the meantime try to run with -O2
(edited)
Tej
Tej 11/18/2024 03:44 PM
Actually I think this is jag interfering with the application.

jag run -D jag.disabled wifi_ap.toit does not cause the assertion_failed error but the scan fails in any case. The issue with setup.toit appears to be related but different - I will dig further.
floitsch
floitsch 11/18/2024 03:45 PM
Interesting. Thanks for investigating.
Could also be that the assertion assumes that no wifi connection was established.
Tej
Tej 11/18/2024 03:53 PM
git clone https://github.com/kasperl/toit-zygote.git cd toit-zygote jag pkg install jag flash jag container install setup src/setup.toit -D jag.disabled -D jag.timeout=2m jag container install app src/main.toit jag monitor

results in:

[toit] INFO: starting <v2.0.0-alpha.164> [toit] DEBUG: clearing RTC memory: invalid checksum [toit] INFO: running on ESP32 - revision 1.0 [jaguar] INFO: container 'app' started [jaguar] INFO: container 'setup' started with {jag.disabled: true, jag.timeout: 120} INFO: scanning for wifi access points ****************************************************************************** Decoding by `jag`, device has version <2.0.0-alpha.164> ****************************************************************************** ASSERTION_FAILED error. 0: NetworkServiceClient <sdk>/system/api/network.toit:116:5 1: WifiServiceClient <sdk>/system/api/wifi.toit:33:5 2: service_ <sdk>/net/wifi.toit:33:34 3: run-global-initializer__.<block> <sdk>/core/objects.toit:291:28 4: run-global-initializer__ <sdk>/core/objects.toit:257:1 5: scan <sdk>/net/wifi.toit:136:14 6: run src/setup.toit:71:20 7: main.<block> src/setup.toit:61:53 8: catch.<block> <sdk>/core/exceptions.toit:124:10 9: catch <sdk>/core/exceptions.toit:122:1 10: catch <sdk>/core/exceptions.toit:85:10 11: main src/setup.toit:61:3 ****************************************************************************** [jaguar] ERROR: container 'setup' stopped - exit code 1 [wifi] DEBUG: connecting [wifi] DEBUG: connected ...

Not sure why this would cause the assertion if jag.disabled is true.
(edited)
bitphlipphar
bitphlipphar 11/18/2024 03:54 PM
I'll take a look!
๐Ÿ‘1
TejOPTej
``` git clone https://github.com/kasperl/toit-zygote.git cd toit-zygote jag pkg install jag flash jag container install setup src/setup.toit -D jag.disabled -D jag.timeout=2m jag c...(edited)
floitsch
floitsch 11/18/2024 03:54 PM
The assertion seems to be unrelated to Jaguar.
bitphlipphar
bitphlipphar 11/18/2024 04:03 PM
Is it the assertion I already fixed, perhaps?
Tej
Tej 11/18/2024 04:08 PM
As suggested by @floitsch, adding -O2 worked:

jag container install setup src/setup.toit -D jag.disabled -D jag.timeout=2m -O2 jag container install app src/main.toit -O2
bitphlippharbitphlipphar
Tej
Tej 11/18/2024 04:11 PM
I am using the pre-built envelopes, specifically v2.0.0-alpha.164/firmware-esp32.envelope - is this commit merged into this?
bitphlipphar
bitphlipphar 11/18/2024 04:13 PM
I don't think we've merged this to the release branch, but I'll check again.
bitphlipphar
bitphlipphar 11/18/2024 04:15 PM
Here are the changes on master that aren't on the 164 branch: https://github.com/toitlang/toit/compare/branch-164...master
bitphlipphar
bitphlipphar 11/18/2024 04:16 PM
The fix (2a13c0d606e894bf97d1717fc9b7df906db21212) is on master, but not on the release branch.
bitphlipphar
bitphlipphar 11/18/2024 04:16 PM
We'll have to merge it over or release from master. Thanks for making us aware!
bitphlipphar
bitphlipphar 11/18/2024 04:20 PM
The issue is that the Zygote code is explicitly requesting the wifi service - not just any network service - and that leads to this assertion failure.
bitphlipphar
bitphlipphar 11/18/2024 04:21 PM
The assertion has been fixed; we'll get a fix out in Jaguar tomorrow.
๐Ÿ‘1
Tej
Tej 11/18/2024 04:58 PM
Thanks. We do the same STA->AP flow with our IDF code but I didn't quite grasp the service assertion nuances when I dug into the traceback.

I must say I am enjoying both writing Toit code and getting rapid responses and fixes for issues!
๐Ÿ™2
bitphlipphar
bitphlipphar 11/19/2024 07:26 AM
Decided to go for cherry picking the single needed change and to release a small fix in the form of SDK v2.0.0-alpha.165. It is brewing on the build bots. We will release the new SDK and update Jaguar when it is ready.
๐Ÿ‘1
bitphlipphar
bitphlipphar 11/19/2024 07:26 AM
I will keep you posted!
bitphlipphar
bitphlipphar 11/19/2024 09:46 AM
Just sent out Jaguar v1.43.4 with the updated SDK. Do give it a spin!
Tej
Tej 11/19/2024 09:53 AM
Just did and it works as expected - thanks! Closing this issue.
๐Ÿ‘1
22 messages in total