-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[TRACKING] cpu/esp8266: Open problems of the ESP8266 port based on the ESP8266 RTOS SDK #12707
Comments
@maribu Even if you are unfamiliar with ESP8266, I appreciate your in-depth knowledge of compiler, optimization, and the NewLib. So I'd be very grateful if you could take a look at the three issues I found while testing the reimplementation of the ESP8266 port. I can provide you with more details if necessary. Finally, I would like to discuss what the best way would be to fix them. |
Possible solutions and their pros and cons as far as I can see:
(I have a meeting now, I'll continue later.) |
@maribu Thanks for taking a first look. Unfortunately, a number of these options are not in our hand because
Because Line 181 in 6afeea7
printf from the newlib which leads to the same problem 😟
Saving the correct interrupt state over several calls of these locking function is not an easy task because the
I don't see how to realize it in that way. BTW, when I deactivate all locking functions, everything works fine but isn't thread-safe. I bet that most of the RIOT platforms that use the |
This should also be a problem on ARM then, it doesn't support unaligned access either. |
Obviously not. I have tested Line 30 in 5a70576
0x00000000200014e9 . This variable is used as parameter for function sign , there for function hash and there for function extractFromState . Finally, it is assigned to an uint32_t * pointer variable in extractFromState for faster copy operation. The unaligned 32-bit access works on an STM32F4, I have debugged it.
|
Casting a pointer with a low alignment requirement (like So this is definitely a bug in pkg_qdsa that needs to be fixed. Once the bug is fixed, no work around is needed. This by the way again shows that diversity in the platform RIOT supports is inherently valuable, as the bug wouldn't have shown up without. |
I believe this is absolutely fine, as
|
Could you map this to RIOTs WDT API? If I understand this correctly, the current WDT is transparently handled without the code in RIOT being aware of this. I think this approach simply has its limits and the easiest way would be to just only provide a watchdog timer, if the RIOT application asks for it and is prepared to feed it regularly. |
Thanks for the hint. This API is new, I did not know about it until now. I am not sure if this mapping is possible because I do not know if it is possible to avoid initializing the WDT at all. I have to check. |
I tried to debug this. This hangs on an assert() in xtimer because long_offset is not 0: Line 279 in 9256970
This stack trace is not relevant. The reason it fails is because the The stack trace at the call is roughly (line numbers not exact because I added some debug to obtain this):
Line 63 in 9256970
However, the second mutex_lock doesn't block and the I see a few options:
I don't know what you expect if interrupts are disabled and you call vTaskDelay. @gschorcht WDYT? |
Description
When testing the reimplementation of the ESP866 port based on the ESP8266 RTOS SDK in PR #11108, the following open problems were identified (#11108 (comment)):
Lock functions for newlib
The lock functions in
cpu/esp8266/syscalls.c
don't work if an application calls anewlib
function from an ISR and thenewlib
uses_lock_acquire
or_log_acquire_recursive
to be thread-safe. The reason is that the esp8266 implementation of these lock functions usesmutex
andrmutex
which do not work in the interrupt context. For example,puts
is used intests/isr_yield_higher
from an ISR:make BOARD=esp8266-esp-12x -C tests/isr_yield_higher flash test
Workaround: lock functions are disabled for the moment
RIOT/cpu/esp8266/syscalls.c
Line 167 in 6afeea7
RIOT/cpu/esp8266/syscalls.c
Line 185 in 6afeea7
Watchdog timer
The watchdog timer will reset if threads take a long time to complete without yielding and if no interrupts occur. For example,
tests/libfixmath
is doing time consuming calculation within a loop without yielding.make BOARD=esp8266-esp-12x -C tests/libfixmath flash test
Workaround: Watchdog timer is disabled at the moment.
RIOT/cpu/esp8266/vendor/esp-idf/esp8266/source/task_wdt.c
Line 30 in 5b002b8
Compile Option
-Os
With
-Os
, char arrays have not to be 32-bit word aligned. This leads to an alignment exception when the address of a char array is assigned to anuint32_t
pointer and the pointer is used for the access. This problem could occur in any part of the code at any time. For example,tests/pkg_qdsa
defines an array that is used in cryptographic functions after assigning their addresses touint32_t
pointers:make BOARD=esp8266-esp-12x -C tests/pkg_qda flash test
Workaround:
-O2
is used for optimization.RIOT/cpu/esp8266/Makefile.include
Line 126 in 5b002b8
ROM
strlen
function crashes for NULL pointer.Reboot hangs if
esp_wifi
is associated with an AP until the watchdog timer hard resets the esp8266.Module
esp_gdbstub
doesn't work since it redefines theputchar
function provided by the newlib.Messages from vendor WiFI libraries have to be disabled. These are messages like
(fixed by PR cpu/esp: cleanup of ESP SDK log outputs #12998)
After the merge of PR gnrc_netif: introduce distinction if an interface supports 6Lo or if it performs ND according to RFC 6775 #10499,
esp-now
no longer gets a link-local address by default (fixed by PR sys/net/gnrc: Flag esp_now as 6LN #13561)Erasing a sector in SPI flash hangs if WiFi module
esp_wifi
is enabled (issue esp8266: Hangs when erasing spi sector on mtd0 if using esp_wifi #16281)Expected results
The test applications should without the workarounds.
Actual results
The test applications hang or crash.
Versions
The text was updated successfully, but these errors were encountered: