Open nikitos1550 opened 1 week ago
Hi @nikitos1550, thanks for noticing this. You are right, calculation is incorrect. This reminded me the already opened issue here. Your solution fixes the issue you talk about, but another problem is that clock()
function measures time consumed by program, real time might be a bit different. Are you willing to open pull request with the solution or you want us to take care of it? If you are not, I will try to fix it soon, just so you know that timeout with clock() function might be a bit longer.
Hi @nikitos1550, thanks for noticing this. You are right, calculation is incorrect. This reminded me the already opened issue here. Your solution fixes the issue you talk about, but another problem is that
clock()
function measures time consumed by program, real time might be a bit different. Are you willing to open pull request with the solution or you want us to take care of it? If you are not, I will try to fix it soon, just so you know that timeout with clock() function might be a bit longer.
Hi! You are right about clock(), so I reworked it following way (added https://github.com/solemnwarning/timespec to submodules )
static struct timespec s_time_end;
// ...
void loader_port_start_timer(uint32_t ms)
{
struct timespec now, add;
clock_gettime(CLOCK_MONOTONIC, &now);
add = timespec_from_ms(ms);
s_time_end = timespec_add(now, add);
}
uint32_t loader_port_remaining_time(void)
{
struct timespec now, diff;
clock_gettime(CLOCK_MONOTONIC, &now);
if (timespec_ge(s_time_end, now)) {
diff = timespec_sub(s_time_end, now);
return timespec_to_ms(diff);
}
return 0;
}
If you are ok with additional submodule dep I can make PR.
anyway here you are
I will close the PR and implement it directly without submodule if you are OK with that. Anyway thanks for noticing.
I will close the PR and implement it directly without submodule if you are OK with that. Anyway thanks for noticing.
I am ok, sure! I am using respberry based Linux port with custom utility, so it make no sense for me.
I will close the PR and implement it directly without submodule if you are OK with that. Anyway thanks for noticing.
Please also pay attention to open tty dev file flags, there is NONBLOCK flag that means VMIN, VTIME options will not work.
Today I also got issue on some device samples, after more detailed debug I found that start timer
, remaining timer
does not cover all issues (as I thought before), It comes out that during read VTIME is setuped (each time), but as port opened NONBLOCKING, it does not work. I removed flag and it become much better. But I still expirience issue when first esp32-serial connection attempt does not work, need run it twice, something about tty port options I suppose, but I cannot figure out what exactly.
P.S. I will provide log later, maybe you can help me figure out what is going on.
I cannot reproduce it right now :( Maybe later I will have luck.
Thanks for letting me know. It is planned to rewrite the Raspberry pi port completely in the future. Feel free to send the log later, I can take a look.
Port
raspberry
Target chip
ESP32S3
Hardware Configuration
ESP32-S3-WROOM-1U based pcba connected via UART to custom mdm9207 (GNU/Linux OS) based pcba.
Log output
More Information
https://github.com/espressif/esp-serial-flasher/blob/f1183069e23ee89dbab9b411724e88e170dbd874/port/raspberry_port.c#L292C1-L297C1
Here if
(s_time_end - clock())
will be less then 1000, then we still have some time to wait, but function will return 0.I locally patched it
And now I can sucessfully burn esp32s3. Seems I faced some hardware compatibility issue, because our previous ESP32-S3-WROOM-1U based pcba did not have such issue, anyway I think my point is reasonable.