* [PATCH 0/3] scripts: imx: imx-usb-loader: fix mingw compilation
@ 2025-11-28 14:08 Maud Spierings via B4 Relay
2025-11-28 14:08 ` [PATCH 1/3] scripts: common: fix pread_full() for windows Maud Spierings via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Maud Spierings via B4 Relay @ 2025-11-28 14:08 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings
Compiling imx-usb-loader for windows targets had become broken, fix it.
Signed-off-by: Maud Spierings <maudspierings@gocontroll.com>
---
Maud Spierings (3):
scripts: common: fix pread_full() for windows
scripts: imx: Makefile.mingw64: add _GNU_SOURCE
gitignore: ignore *.exe
.gitignore | 1 +
scripts/common.c | 6 +++++-
scripts/imx/Makefile.mingw64 | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
---
base-commit: 3e01efb6c6527ca72a1213000006be1902db7be9
change-id: 20251128-imx_usb-410bbb57e068
Best regards,
--
Maud Spierings <maudspierings@gocontroll.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/3] scripts: common: fix pread_full() for windows 2025-11-28 14:08 [PATCH 0/3] scripts: imx: imx-usb-loader: fix mingw compilation Maud Spierings via B4 Relay @ 2025-11-28 14:08 ` Maud Spierings via B4 Relay 2025-11-28 14:56 ` Ahmad Fatoum 2025-11-28 14:08 ` [PATCH 2/3] scripts: imx: Makefile.mingw64: add _GNU_SOURCE Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 3/3] gitignore: ignore *.exe Maud Spierings via B4 Relay 2 siblings, 1 reply; 7+ messages in thread From: Maud Spierings via B4 Relay @ 2025-11-28 14:08 UTC (permalink / raw) To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings From: Maud Spierings <maudspierings@gocontroll.com> pread() is not available for windows, convert to lseek() + read() Signed-off-by: Maud Spierings <maudspierings@gocontroll.com> --- I think this modifies the state of fd, I am not sure if pread() did this too. May be necessary to point the file pointer where it was before? On the other hand this reads the whole file so why. --- scripts/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/common.c b/scripts/common.c index a6eee968b7..544d295b7f 100644 --- a/scripts/common.c +++ b/scripts/common.c @@ -202,8 +202,12 @@ int pread_full(int fd, void *buf, size_t size, loff_t offset) size_t insize = size; int now; + now = lseek(fd, offset, SEEK_SET); + if (now < 0) + return now; + while (size) { - now = pread(fd, buf, size, offset); + now = read(fd, buf, size); if (now == 0) break; if (now < 0) -- 2.52.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] scripts: common: fix pread_full() for windows 2025-11-28 14:08 ` [PATCH 1/3] scripts: common: fix pread_full() for windows Maud Spierings via B4 Relay @ 2025-11-28 14:56 ` Ahmad Fatoum 2025-11-28 15:00 ` Maud Spierings 0 siblings, 1 reply; 7+ messages in thread From: Ahmad Fatoum @ 2025-11-28 14:56 UTC (permalink / raw) To: maudspierings, Sascha Hauer, BAREBOX Hi, On 11/28/25 3:08 PM, Maud Spierings via B4 Relay wrote: > From: Maud Spierings <maudspierings@gocontroll.com> > > pread() is not available for windows, convert to lseek() + read() > > Signed-off-by: Maud Spierings <maudspierings@gocontroll.com> > > --- > > I think this modifies the state of fd, I am not sure if pread() did this > too. May be necessary to point the file pointer where it was before? On > the other hand this reads the whole file so why. I would prefer to ship a pread implementation for windows instead that takes care to lseek to wherever we need to read from and then lseek back to the original offset as not to induce subtle breakage into other host tools. Cheers, Ahmad > --- > scripts/common.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/scripts/common.c b/scripts/common.c > index a6eee968b7..544d295b7f 100644 > --- a/scripts/common.c > +++ b/scripts/common.c > @@ -202,8 +202,12 @@ int pread_full(int fd, void *buf, size_t size, loff_t offset) > size_t insize = size; > int now; > > + now = lseek(fd, offset, SEEK_SET); > + if (now < 0) > + return now; > + > while (size) { > - now = pread(fd, buf, size, offset); > + now = read(fd, buf, size); > if (now == 0) > break; > if (now < 0) > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] scripts: common: fix pread_full() for windows 2025-11-28 14:56 ` Ahmad Fatoum @ 2025-11-28 15:00 ` Maud Spierings 2025-11-28 15:11 ` Ahmad Fatoum 0 siblings, 1 reply; 7+ messages in thread From: Maud Spierings @ 2025-11-28 15:00 UTC (permalink / raw) To: Ahmad Fatoum, Sascha Hauer, BAREBOX On 11/28/25 15:56, Ahmad Fatoum wrote: > Hi, > > On 11/28/25 3:08 PM, Maud Spierings via B4 Relay wrote: >> From: Maud Spierings <maudspierings@gocontroll.com> >> >> pread() is not available for windows, convert to lseek() + read() >> >> Signed-off-by: Maud Spierings <maudspierings@gocontroll.com> >> >> --- >> >> I think this modifies the state of fd, I am not sure if pread() did this >> too. May be necessary to point the file pointer where it was before? On >> the other hand this reads the whole file so why. > > I would prefer to ship a pread implementation for windows instead that > takes care to lseek to wherever we need to read from and then lseek back > to the original offset as not to induce subtle breakage into other host > tools. > just read the manpage a little better: pread() reads up to count bytes from file descriptor fd at offset offset (from the start of the file) into the buffer starting at buf. The file offset is not changed. So yeah it should indeed seek back, I'll get on that. > >> --- >> scripts/common.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/scripts/common.c b/scripts/common.c >> index a6eee968b7..544d295b7f 100644 >> --- a/scripts/common.c >> +++ b/scripts/common.c >> @@ -202,8 +202,12 @@ int pread_full(int fd, void *buf, size_t size, loff_t offset) >> size_t insize = size; >> int now; >> >> + now = lseek(fd, offset, SEEK_SET); >> + if (now < 0) >> + return now; >> + >> while (size) { >> - now = pread(fd, buf, size, offset); >> + now = read(fd, buf, size); >> if (now == 0) >> break; >> if (now < 0) >> > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] scripts: common: fix pread_full() for windows 2025-11-28 15:00 ` Maud Spierings @ 2025-11-28 15:11 ` Ahmad Fatoum 0 siblings, 0 replies; 7+ messages in thread From: Ahmad Fatoum @ 2025-11-28 15:11 UTC (permalink / raw) To: Maud Spierings, Sascha Hauer, BAREBOX Hi, On 11/28/25 4:00 PM, Maud Spierings wrote: > On 11/28/25 15:56, Ahmad Fatoum wrote: >> Hi, >> >> On 11/28/25 3:08 PM, Maud Spierings via B4 Relay wrote: >>> From: Maud Spierings <maudspierings@gocontroll.com> >>> >>> pread() is not available for windows, convert to lseek() + read() >>> >>> Signed-off-by: Maud Spierings <maudspierings@gocontroll.com> >>> >>> --- >>> >>> I think this modifies the state of fd, I am not sure if pread() did this >>> too. May be necessary to point the file pointer where it was before? On >>> the other hand this reads the whole file so why. >> >> I would prefer to ship a pread implementation for windows instead that >> takes care to lseek to wherever we need to read from and then lseek back >> to the original offset as not to induce subtle breakage into other host >> tools. >> > > just read the manpage a little better: > pread() reads up to count bytes from file descriptor fd at offset > offset (from the start of the file) into the buffer starting at > buf. The file offset is not changed. > > So yeah it should indeed seek back, I'll get on that. The new implementation should only be used when building for mingw. Maybe just link it in the mingw makefile. Cheers, Ahmad > >> >>> --- >>> scripts/common.c | 6 +++++- >>> 1 file changed, 5 insertions(+), 1 deletion(-) >>> >>> diff --git a/scripts/common.c b/scripts/common.c >>> index a6eee968b7..544d295b7f 100644 >>> --- a/scripts/common.c >>> +++ b/scripts/common.c >>> @@ -202,8 +202,12 @@ int pread_full(int fd, void *buf, size_t size, >>> loff_t offset) >>> size_t insize = size; >>> int now; >>> + now = lseek(fd, offset, SEEK_SET); >>> + if (now < 0) >>> + return now; >>> + >>> while (size) { >>> - now = pread(fd, buf, size, offset); >>> + now = read(fd, buf, size); >>> if (now == 0) >>> break; >>> if (now < 0) >>> >> > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] scripts: imx: Makefile.mingw64: add _GNU_SOURCE 2025-11-28 14:08 [PATCH 0/3] scripts: imx: imx-usb-loader: fix mingw compilation Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 1/3] scripts: common: fix pread_full() for windows Maud Spierings via B4 Relay @ 2025-11-28 14:08 ` Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 3/3] gitignore: ignore *.exe Maud Spierings via B4 Relay 2 siblings, 0 replies; 7+ messages in thread From: Maud Spierings via B4 Relay @ 2025-11-28 14:08 UTC (permalink / raw) To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings From: Maud Spierings <maudspierings@gocontroll.com> imx.c uses asprintf which requires _GNU_SOURCE to be defined, include defines.h to define it. Signed-off-by: Maud Spierings <maudspierings@gocontroll.com> --- scripts/imx/Makefile.mingw64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/imx/Makefile.mingw64 b/scripts/imx/Makefile.mingw64 index e012d833f1..101b39e917 100644 --- a/scripts/imx/Makefile.mingw64 +++ b/scripts/imx/Makefile.mingw64 @@ -30,7 +30,7 @@ $(if $(obj),, \ # $(realpath ...) resolves symlinks obj := $(realpath $(obj)) -CPPFLAGS := -I $(LIBUSB_MINGW)/include/libusb-1.0 -I $(src)/../include/ -I $(src)/../../include/mach/ +CPPFLAGS := -I $(LIBUSB_MINGW)/include/libusb-1.0 -I $(src)/../include/ -I $(src)/../../include/mach/ -include $(src)/../include/defines.h LDFLAGS := -L $(LIBUSB_MINGW)/lib -lusb-1.0 -static OBJECTS := $(addprefix $(obj)/, imx.o imx-usb-loader.o) -- 2.52.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] gitignore: ignore *.exe 2025-11-28 14:08 [PATCH 0/3] scripts: imx: imx-usb-loader: fix mingw compilation Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 1/3] scripts: common: fix pread_full() for windows Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 2/3] scripts: imx: Makefile.mingw64: add _GNU_SOURCE Maud Spierings via B4 Relay @ 2025-11-28 14:08 ` Maud Spierings via B4 Relay 2 siblings, 0 replies; 7+ messages in thread From: Maud Spierings via B4 Relay @ 2025-11-28 14:08 UTC (permalink / raw) To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings From: Maud Spierings <maudspierings@gocontroll.com> windows scripts produce .exe files, which should not be added. Add it to the gitignore. Signed-off-by: Maud Spierings <maudspierings@gocontroll.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a235f9f7de..74cb7b0928 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ *.dcd *.dcd.S *.elf +*.exe *.i *.ko *.lex.c -- 2.52.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-28 15:12 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-11-28 14:08 [PATCH 0/3] scripts: imx: imx-usb-loader: fix mingw compilation Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 1/3] scripts: common: fix pread_full() for windows Maud Spierings via B4 Relay 2025-11-28 14:56 ` Ahmad Fatoum 2025-11-28 15:00 ` Maud Spierings 2025-11-28 15:11 ` Ahmad Fatoum 2025-11-28 14:08 ` [PATCH 2/3] scripts: imx: Makefile.mingw64: add _GNU_SOURCE Maud Spierings via B4 Relay 2025-11-28 14:08 ` [PATCH 3/3] gitignore: ignore *.exe Maud Spierings via B4 Relay
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox