makestuff / libfpgalink

LIB:Library for interacting with an FPGA over USB
https://github.com/makestuff/libfpgalink/wiki/FPGALink
GNU Lesser General Public License v3.0
82 stars 25 forks source link

FX2 firmware doesn't compiling with DEBUG=1 #25

Closed mithro closed 9 years ago

mithro commented 9 years ago

The error is listed below;

$ make FLAGS="-DDEBUG"
sdcc -DDATE=0x20141222 -mmcs51 --code-size 0x1e00 --xram-loc 0xe000 --xram-size 0x0200 -Wl"-b DSCR_AREA=0x1e00" -Wl"-b INT2JT=0x1f00" -DDEBUG -c --disable-warning 85 -I sdcc -I../../../../3rd/fx2lib/include -I../../../../common debug.c
debug.c:6: syntax error: token -> 'at' ; column 7
make: *** [debug.rel] Error 1

The error seems to be the line;

sbit at 0xB7 USART; // Port D7

I'm using sdcc which ships with Ubuntu 14.04;

$ sdcc --version
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.3.0 #8604 (Dec 30 2013) (Linux)

The version of debug.c I have is below;

$ md5sum debug.c 
355f90c004a7cefa0ca1dda66d3c6512  debug.c
mithro commented 9 years ago

It seems the correct format is;

#ifdef DEBUG
__sbit __at (0xB7) USART; // Port D7

However, then sdcc doesn't like the ASM from what I can see?

$ make FLAGS="-DDEBUG"
sdcc -DDATE=0x20141222 -mmcs51 --code-size 0x1e00 --xram-loc 0xe000 --xram-size 0x0200 -Wl"-b DSCR_AREA=0x1e00" -Wl"-b INT2JT=0x1f00" -DDEBUG -c --disable-warning 85 -I sdcc -I../../../../3rd/fx2lib/include -I../../../../common debug.c
debug.c:17: syntax error: token -> 'mov' ; column 5
debug.c:28: syntax error: token -> 'bit' ; column 13
debug.c:35: syntax error: token -> 'uint8' ; column 12
debug.c:36: error 20: Undefined identifier 'ch'
debug.c:37: error 20: Undefined identifier 'ch'
debug.c:37: error 20: Undefined identifier 'ch'
debug.c:37: error 20: Undefined identifier 'ch'
debug.c:38: error 20: Undefined identifier 'ch'
debug.c:38: error 20: Undefined identifier 'ch'
debug.c:39: error 20: Undefined identifier 'ch'
debug.c:40: error 20: Undefined identifier 'ch'
debug.c:40: error 20: Undefined identifier 'ch'
makestuff commented 9 years ago

Our commits crossed, so the merge did nothing. I also added a USE_16K config variable to the Makefile, to avoid the "insufficient memory" error. You can build the firmware with a modern SDCC with debug enabled like this:

make AS8051=sdas8051 FLAGS="-DDEBUG" USE_16K=1

Note the explicit specification of the assembler to use.

Lastly, FYI the debug info appears on whatever pin you configure "USART" to, and by default it's 115200,8,N,1. You'll need a MAX232 or similar to drive RS-232 levels.

mithro commented 9 years ago

Pulled your updated and it compiled fine! Was able to load the firmware onto the FX2 board and successfully able to see MakeStuff FPGALink/FX2 20141222 appear on the serial port (/dev/ttyUSB0).

I'm using one of these -> http://tronixlabs.com/retired/ttl-uart-to-usb-cable-serial-usb-debug-cable/ connected to the following board -> http://www.ebay.com.au/itm/Logic-Analyzer-EEPROM-CY7C68013A-56-EZ-USB-FX2LP-USB2-0-Develope-Board-Module-/380778239854 currently.

My eventual goal is described in https://github.com/makestuff/libfpgalink/issues/30 but wanted to get debug statements working before attempting anything serious :)