Am 03.04.2013 00:27 schrieb Carl-Daniel Hailfinger: > Am 02.04.2013 22:58 schrieb Stefan Tauner: >> On Mon, 1 Apr 2013 19:08:30 +0400 >> Maksim Kuleshov <[email protected]> wrote: >> >>> From 62ffe98744aba140e5959635abb46c32a47887d2 Mon Sep 17 00:00:00 2001 >>> From: Maksim Kuleshov <[email protected]> >>> Date: Mon, 1 Apr 2013 19:03:43 +0400 >>> Subject: [PATCH 3/3] udelay.c: usleep() not found in MinGW, used Sleep() >>> >>> Signed-off-by: Maksim Kuleshov <[email protected]> >> I don't think that we ever had a problem with that. (Please correct >> me... Idwer?). What version of MinGW are you using? What's your make >> command and what does it print as error? > If it fixes a real problem (I didn't need the patch in my > cross-compile-for-mingw environment), this looks sane. > Acked-by: Carl-Daniel Hailfinger <[email protected]>
I now see that the patch is correct. However, the code for non-Windows was broken as well (too big values for udelay), so I extended your patch a bit. usleep() is not found in all versions of MinGW, use Sleep() on Windows. Handle long sleeps on non-Windows correctly. Signed-off-by: Maksim Kuleshov <[email protected]> Signed-off-by: Carl-Daniel Hailfinger <[email protected]> Index: flashrom-long_delay_fix/buspirate_spi.c =================================================================== --- flashrom-long_delay_fix/buspirate_spi.c (Revision 1666) +++ flashrom-long_delay_fix/buspirate_spi.c (Arbeitskopie) @@ -286,7 +286,7 @@ /* The Bus Pirate can't handle UART input buffer overflow in BBIO mode, and sending a sequence * of 0x00 too fast apparently triggers such an UART input buffer overflow. */ - usleep(10000); + internal_sleep(10000); } /* We know that 20 commands of \0 should elicit at least one BBIO1 response. */ if ((ret = buspirate_wait_for_string(bp_commbuf, "BBIO"))) Index: flashrom-long_delay_fix/programmer.h =================================================================== --- flashrom-long_delay_fix/programmer.h (Revision 1666) +++ flashrom-long_delay_fix/programmer.h (Arbeitskopie) @@ -250,6 +250,7 @@ /* udelay.c */ void myusec_delay(int usecs); void myusec_calibrate_delay(void); +void internal_sleep(int usecs); void internal_delay(int usecs); #if CONFIG_INTERNAL == 1 Index: flashrom-long_delay_fix/udelay.c =================================================================== --- flashrom-long_delay_fix/udelay.c (Revision 1666) +++ flashrom-long_delay_fix/udelay.c (Arbeitskopie) @@ -169,13 +169,23 @@ msg_pinfo("OK.\n"); } +/* Not very precise sleep. */ +void internal_sleep(int usecs) +{ +#ifdef _WIN32 + Sleep((usecs + 999) / 1000); +#else + sleep(usecs / 1000000); + usleep(usecs % 1000000); +#endif +} + +/* Precise delay. */ void internal_delay(int usecs) { - /* If the delay is >1 s, use usleep because timing does not need to - * be so precise. - */ + /* If the delay is >1 s, use internal_sleep because timing does not need to be so precise. */ if (usecs > 1000000) { - usleep(usecs); + internal_sleep(usecs); } else { myusec_delay(usecs); } -- http://www.hailfinger.org/ _______________________________________________ flashrom mailing list [email protected] http://www.flashrom.org/mailman/listinfo/flashrom
