Closed salocinx closed 3 years ago
Hi, nice to hear :) Yes I think it will be possible, I haven't done it myself with VBCC though, but what you'll need to do is to link your build with the debug.lib where kprintf resides. In gcc you use -ldebug or -L/path/to/lib/directory. I don't know about VBCC specifics. To be able to test and watch output from a real Amiga machine you will need to hook up a null-modem cable to the serial port and then connect it to for example a linux machine on the other end. Then you can do something like "sudo cat /dev/ttyS0" on the linux machine and follow the output. I followed these instructions when making a cable DB9<->DB25. It works, https://www.amigaforever.com/kb/13-105
Thanks for your quick reply! The serial cable shouldn't be the problem, I either use a second Amiga with null-modem cable or otherwise I follow your link and build a cable to connect to my Linux machine - thanks.
I am stuck with the Makefile
. I have set up a hello-world program to test kprintf()
with a skeleton from the sdbox
repository.
The good news are, that debug.lib
seems to be found by the compiler, getting no errors regarding this (EXTRA_LDFLAGS += -ldebug
).
My current Makefile
looks like this:
FILENAME=test
DIR=build
OBJECTS=main.o timer.o
SRCDIRS=. ../common
INCDIRS=. ../common
EXTRA_CFLAGS += -DDEBUG -mcrt=clib2
EXTRA_LDFLAGS += -ldebug
include ../common/common.mk
I get the following output with errors when executing make
(some conflicts, multiple definitions):
make -C sd
make[1]: Entering directory '/home/nicolas/Downloads/code/sd'
m68k-amigaos-gcc -m68000 -s -O2 -Wall -fomit-frame-pointer -noixemul -fbaserel -I. -I../common -DDEBUG -mcrt=clib2 -Wl,-Map=build/test.map -ldebug -o build/test build/main.o build/timer.o
/opt/m68k-amigaos/m68k-amigaos/clib2/lib/nbcrt0.o(.text+0x1a):/opt/m68k-amigaos/m68k-amigaos/clib2/lib/nbcrt0.o: multiple definition of `geta4'
/opt/m68k-amigaos/m68k-amigaos/libnix/lib/libnix/nbcrt0.o(.text+0xca):/opt/m68k-amigaos/m68k-amigaos/libnix/lib/libnix/nbcrt0.o: first defined here
/opt/m68k-amigaos/m68k-amigaos/bin/ld: cannot find -lclib2
collect2: ld returned 1 exit status
../common/common.mk:23: recipe for target 'build/test' failed
make[1]: *** [build/test] Error 1
make[1]: Leaving directory '/home/nicolas/Downloads/code/sd'
Makefile:6: recipe for target 'sd' failed
make: *** [sd] Error 2
I then read here that clib2
is not available for VBCC
, only for GCC
, but newlib
and vclib
should be available for VBCC
as well.
When changing EXTRA_CFLAGS += -DDEBUG -mcrt=clib2
to EXTRA_CFLAGS += -DDEBUG -mcrt=newlib
, I get the following error (same for vclib
):
/opt/m68k-amigaos/m68k-amigaos/bin/ld: cannot find -lnewlib
So newlib
and vclib
are not included in my VBCC toolchain as I understand? Obviously I don't have too much knowledge of Makefiles
as you obviously can recognize ;-)
I would highly appreciate if you could point me to the right direction, as I ran out of ideas after researching for many hours yesterday and today. Hoping for ideas of any kind :-)
Hi that output looks like you are building with the gcc-2.95.3-toolchain
since VBCC compiles with the VC command. If you want the kprintf to work with the gcc-2.95.3-toolchain
then this should work...remove -mcrt=clib2
from your makefile and use -noixemul
flag, it then links with LibNIX http://cahirwpz.users.sourceforge.net/gcc-amigaos/Invocation.html and add flags like this:
EXTRA_CFLAGS=-ramiga-dev -DDEBUG
EXTRA_LDFLAGS=-ldebug
CFLAGS=-m68000 -s -O2 -Wall -fomit-frame-pointer -noixemul -fbaserel
You can remove the -s
(strip) and the -O2
(optimization) on a debug build as well, it is for release optimization.
Hope it helps!
Oh that's embarrassing! I don't know why I thought I was using VBCC
, probably because I had installed that on another machine lately. But sure, I am using your sdbox
common.mk which is linked in the Makefile
above and it's using m68k-amigaos-gcc
. I am sorry about that...!
Okay had problems with -ramiga-dev
but now seems to work. I added the following line to __UserDevOpen() function:
KPrintF((CONST_STRPTR) "UserDevOpen()\n");
Getting the following output containing errors:
nicolas@m68k:~/Downloads/sdbox$ make
make -C sd
make[1]: Entering directory '/home/nicolas/Downloads/sdbox/sd'
m68k-amigaos-gcc -m68000 -Wall -fomit-frame-pointer -noixemul -fbaserel -I. -I../common -ramiga-dev -c -o build-device/device.o device.c
device.c: In function `__UserDevOpen':
**device.c:123: warning: implicit declaration of function `KPrintF'**
device.c:127: parse error before `struct'
device.c:130: `iostd' undeclared (first use in this function)
device.c:130: (Each undeclared identifier is reported only once
device.c:130: for each function it appears in.)
device.c:136: `err' undeclared (first use in this function)
device.c:142: warning: control reaches end of non-void function
../common/common.mk:29: recipe for target 'build-device/device.o' failed
make[1]: *** [build-device/device.o] Error 1
make[1]: Leaving directory '/home/nicolas/Downloads/sdbox/sd'
Makefile:6: recipe for target 'sd' failed
make: *** [sd] Error 2
Do I miss any #include
statement in the file I am using KPrintF ?
Basically I am just trying to use KPrintF
in your sdbox project. I am able to compile the entire project just fine (without KPrintF
)... Maybe it would be easier if you could try to integrate a KPrintF
call in the sdbox project instead of helping me with my stupid questions here? I am really eager to experiment with the sdbox box code, but I first need KPrintF
to work...
Yes, you need something like this for the KPrintF:
#if DEBUG
#include <clib/debug_protos.h>
#endif
No worries. It can be a little confusing since VBCC (and Vasm) is indeed included in the toolchain, a slightly older version I think, but it is not used in this project, only GCC and its assembler AS is. You can check for VBCC under m68k-amigaos\bin
m68k-amigaos\m68k-amigaos\bin
m68k-amigaos\m68k-amigaos\vbcc
and alter your Makefile CC to point to either VC or vbccm68k should you want to use VBCC I think.
The -ramiga-dev
flag for gcc-2.95.3-toolchain adds device driver functionality to simplify device driver development, You have a simple skel here that explains it:
https://github.com/adtools/amigaos-cross-toolchain/blob/master/examples/simple-device.c
Hope it helps!
Thanks for your ongoing support! Yes, I already had #include <clib/debug_protos.h>
added to the beginning of the device.c
file. The compiler also recognizes the header, since if I rename it, the compiler complains.
Basically I am fine with GCC
and I don't want to switch the compiler to VBCC
. I just want KPrintF()
to work... :-)
I now searched the toolchain folder at /opt/m68k-amigaos/...
for KPrintF
and it gave me some results:
VOID KPrintF( CONST_STRPTR formatString, ... );
VOID kprintf( CONST_STRPTR formatString, ... );
But when compiling, I still get this error:
nicolas@m68k:~/Downloads/sdbox$ make
make -C sd
make[1]: Entering directory '/home/nicolas/Downloads/sdbox/sd'
m68k-amigaos-gcc -m68000 -Wall -fomit-frame-pointer -noixemul -fbaserel -I. -I../common -ramiga-dev -c -o build-device/device.o device.c
device.c: In function `__UserDevOpen':
device.c:132: parse error before `struct'
device.c:135: `iostd' undeclared (first use in this function)
device.c:135: (Each undeclared identifier is reported only once
device.c:135: for each function it appears in.)
device.c:141: `err' undeclared (first use in this function)
device.c:147: warning: control reaches end of non-void function
../common/common.mk:29: recipe for target 'build-device/device.o' failed
make[1]: *** [build-device/device.o] Error 1
make[1]: Leaving directory '/home/nicolas/Downloads/sdbox/sd'
Makefile:6: recipe for target 'sd' failed
make: *** [sd] Error 2
It somehow doesn't recognize kprintf("TEST")
although #include <clib/debug_protos.h>
is in place:
#include <clib/debug_protos.h>
int __UserDevOpen(struct IORequest *ioreq, uint32_t unit, uint32_t flags)
{
kprintf("TEST");
struct IOStdReq *iostd = (struct IOStdReq*)ioreq;
int err = IOERR_OPENFAIL;
if (iostd && unit == 0) {
if (sd_open() == 0) {
/* Device is open */
iostd->io_Unit = &ctx->unit;
ctx->unit.unit_flags = UNITF_ACTIVE;
ctx->unit.unit_OpenCnt = 1;
err = 0;
}
}
iostd->io_Error = err;
return err;
}
I already tried to move the #include
up and down. Also a guy here says that -ldebug
should be the last flag set to the linker (which is the case when using EXTRA_LDFLAGS=-ldebug
I guess).
Any idea why it's not linked correctly / not recognized ?
Hi, I did a fix so it should now be possible to build a debug-build and use kprintf
's
To build with debug, cd into the sd directory and type the following:
make -f Makefile.debug
to clean:
make -f Makefile.debug clean
to change debug level, alter -DDEBUG=3
in the Makefile.debug
to other integer, check in common.h for different levels.
It creates a directory with name build-device-debug
with a debug driver in it. Hope this helps.
You can check exactly what I did here: https://github.com/jbilander/sdbox/commit/fc042aba37bc3ca6a2484e1a31ef84eadc527224
Hi, you are a real STAR ! Thank you so much, now working excellent 👍🏼 ! So it looks like the ordering for CFLAG and LDFLAG is quite important. Great, now I am ready for doing some extensive experiments. I will report back as soon as I accomplished anything useful.
Here and here some pictures of my Amiga development setup ;-)
Hi.
I am interested to dive deeper into the code and solve some issues (e.g. CRC). Is there any hope to use
kprintf
withVBCC
like demonstrated in your other project?Thanks!