GithubHelp home page GithubHelp logo

Comments (6)

skullandbones avatar skullandbones commented on September 28, 2024

In the good case:

/run/test/temp/temp2/RomWBW$ find . | grep bios.bin
./Tools/Linux/bios.bin
./Tools/zxcc/bios.bin - is in git repo
./Tools/unix/zxcc/bios.bin
./Tools/unix/zxcc/cpm/bios.bin - is in git repo
./Source/pSys/bios.bin

In the bad case:

/tmp/RomWBW$ find . | grep bios.bin
./Tools/zxcc/bios.bin
./Tools/Linux/bios.bin
./Tools/unix/zxcc/cpm/bios.bin
./Tools/unix/zxcc/bios.bin

So it seems that ./Source/pSys/bios.bin is missing at the point the build fails.

The error message Cannot locate bios.bin comes from Tools/unix/zxcc.c:

void load_bios(void)
{
	char dir[CPM_MAXPATH + 1], fname[CPM_MAXPATH + 1];
	char* q;
	size_t bios_len;

	FILE* fp = fopen("bios.bin", "rb");
	if (!fp)
	{
		strcpy(fname, bindir80);
		strcat(fname, "bios.bin");
		fp = fopen(fname, "rb");
	}
	if (!fp)
	{
#ifdef _WIN32
		dir[0] = 0;	/* use strncat in case the path is very long */
		strncat(dir, _pgmptr, CPM_MAXPATH - 8);   /* copy the executable path */
#elif defined(__APPLE__)
		uint32_t size = CPM_MAXPATH - 8;
		_NSGetExecutablePath(dir, &size);
#else
		readlink("/proc/self/exe", dir, CPM_MAXPATH - 8);   /* allow room for bios.bin */
#endif
		q = strrchr(dir, DIRSEPCH);
		*++q = 0;
		strcpy(fname, dir);
		strcat(fname, "bios.bin");
		fp = fopen(fname, "rb");
	}
	if (!fp)
	{
		fprintf(stderr, "%s: Cannot locate bios.bin\n", progname);    <---- Appears to fail here
		zxcc_term();
		zxcc_exit(1);
	}
	bios_len = fread(RAM + 0xFE00, 1, 512, fp);
	if (bios_len < 1 || ferror(fp))
	{
		fclose(fp);
		fprintf(stderr, "%s: Cannot load bios.bin\n", progname);
		zxcc_term();
		zxcc_exit(1);
	}
	fclose(fp);

	DBGMSGV("Loaded %d bytes of BIOS\n", bios_len);
}

from romwbw.

skullandbones avatar skullandbones commented on September 28, 2024

Modified zxcc.c to show the bios.bin path and filename:
https://github.com/skullandbones/RomWBW/tree/Issue-362_RPI4_no_bios.bin

Repeated a failed build and the reported path shows corruption in the path string:

make[3]: Leaving directory '/tmp/RomWBW/Source/Apps/Test'
+ make --directory ZMP
make[3]: Entering directory '/tmp/RomWBW/Source/Apps/ZMP'
../../../Tools/Linux/zxcc MLOAD25 -ZMP.COM=ZMPX.COM,ZMO-RW01
+ ../../../Tools/Linux/zxcc MLOAD25 -ZMP.COM=ZMPX.COM,ZMO-RW01
zxcc: Cannot locate /tmp/RomWBW/Tools/Linux/zxccV/bios.bin

                                                          make[3]: *** [Makefile:10: zmp.com] Error 1
make[3]: Leaving directory '/tmp/RomWBW/Source/Apps/ZMP'
make[2]: *** [../../Tools/Makefile.inc:136: all] Error 2
make[2]: Leaving directory '/tmp/RomWBW/Source/Apps'
make[1]: *** [../Tools/Makefile.inc:136: all] Error 2
make[1]: Leaving directory '/tmp/RomWBW/Source'
make: *** [Makefile:3: all] Error 2

The path string contains a "V" that should not be there.

from romwbw.

wwarthen avatar wwarthen commented on September 28, 2024

Wow, this is very odd. I admit that I did see this exact error once when I first tried an RPi build, but it disappeared after I ran the build again.

Nothing about the build has changed with respect to this. Also, I am not seeing this anywhere but Raspberry Pi. I don't see an obvious problem with the code. Can't imagine how the "V" got there.

The "bios.bin" in the pSys directory is produced by the build. It is not the same bios.bin as the others. It is not in GitHub and should not be. I think you see it in the successful builds because the build produced it.

I will take a look at this in more detail, but probably won't be able to get to it until Monday. Very busy weekend for me. If you have more time to play with this, it would be helpful to see the output of readlink before it is manipulated. It sort of looks like the readlink call is producing invalid results.

Thanks,

Wayne

from romwbw.

wwarthen avatar wwarthen commented on September 28, 2024

Had a few spare minutes and quickly looked up the documentation on readlink(). So... turns out that readlink() does NOT null terminate the resulting string. Basically, it is a miracle that this bug has not been encountered before. The fix is trivial; just need to null terminate the string using the length returned by the readlink() call.

I can take care of this in the next day or two.

Thanks,

Wayne

from romwbw.

skullandbones avatar skullandbones commented on September 28, 2024

@wwarthen I have created PR #363 based on your suggestion of adding a NUL termination to the dir string.

My testing on my RPi4 is now successful with no load bios.bin failures.

Please take a look at my PR and provide review comments. If you think the PR is good enough then please go-ahead and merge it.

Thanks,
Dean

from romwbw.

wwarthen avatar wwarthen commented on September 28, 2024

Hi @skullandbones,

Your PR was great and has been merged. I will be closing this issue now.

Thank you!

Wayne

from romwbw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.