Blinkinlabs / ch554_sdcc

CH554 software development kit for SDCC
295 stars 70 forks source link

UsbHostHub_KM example fails to compile #36

Closed prosper00 closed 3 years ago

prosper00 commented 3 years ago

sdcc -c -V -mmcs51 --model-small --xram-size 0x380 --xram-loc 0x080 --code-size 0x3800 -I/home/bdroy/CH55x-base/ch554_sdcc/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 ../../include/debug.c

/usr/bin/sdcpp -nostdinc -Wall -std=c11 -I/home/bdroy/CH55x-base/ch554_sdcc/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 -obj-ext=.rel -DSDCC_CHAR_UNSIGNED -DSDCC_MODEL_SMALL -DSDCC_FLOAT_REENT -DSDCC=4_0_7 -DSDCC_VERSION_MAJOR=4 -DSDCC_VERSION_MINOR=0 -DSDCC_VERSION_PATCH=7 -DSDCC=407 -DSDCC_REVISION=11994 -D__SDCC_mcs51 -DSTDC_NO_COMPLEX=1 -DSTDC_NO_THREADS=1 -DSTDC_NO_ATOMICS=1 -DSTDC_NO_VLA=1 -DSTDC_ISO_10646=201409L -DSTDC_UTF_16=1 -DSTDC_UTF_32=1 -isystem /usr/bin/../share/sdcc/include/mcs51 -isystem /usr/local/share/sdcc/include/mcs51 -isystem /usr/bin/../share/sdcc/include -isystem /usr/local/share/sdcc/include ../../include/debug.c

/usr/bin/sdas8051 -plosgffw debug.rel debug.asm sdcc UsbHostHub_KM.rel usbhost.rel debug.rel -V -mmcs51 --model-small --xram-size 0x380 --xram-loc 0x080 --code-size 0x3800 -I/home/bdroy/CH55x-base/ch554_sdcc/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 -o UsbHostHub_KM.ihx

/usr/bin/sdld -nf UsbHostHub_KM.lk ?ASlink-Error-Could not get 46 consecutive bytes in internal RAM for area DSEG.

/usr/bin/sdld -nf UsbHostHub_KM.lk returned errorcode 256 make: *** [../Makefile.include:40: UsbHostHub_KM.ihx] Error 1

$sdcc --version SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.7 #11994 (Linux) published under GNU General Public License (GPL)

$lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.10 Release: 20.10 Codename: groovy

If I delete the usb_host_KM dir from examples, all the rest build correctly.

jjmz commented 3 years ago

SDCC 4.0.7 ... Compiles with printf_small instead of printf (#define printf printf_small in usbhost.c and UsbHostHub_KM.c) - I have not checked if code was working on real hardware yet.

prosper00 commented 3 years ago

Great! I'll try it on real chips as soon as they arrive. I bought a bunch to play with, and am excited to try them out

jjmz commented 3 years ago

Code compiles and 'works', but debug information on the Uart output is not the expected one...

Start @ChipID=T2X (should be : printf( "Start @ChipID=%02X\n", (uint16_t)CHIP_ID ); ) Wait Device In Query Mouse @␀4X Query Mouse @␀4X

I think it would be better to remove all printf and replace by some custom putstring/printhex to reduce footprint.

jjmz commented 3 years ago

I have made some tests on my github repository : the ch554_sdcc debug code as library (the linker will not include getchar for example), and 4 functions to print str/hex2/hex4/linefeed (also as library). Not very clean regarding the Makefile. It fits with full debug in usbhost and Usb_Host_KM. Result looks like this on TX pin P3.1 (9600bps)

Start @ChipID=54
Wait Device In
USB dev in
EnumUSBDev
Reset USB Port
GetDevDescr: x12 x01 x00 x02 x00 x00 x00 x08 x6D x04 x77 xC0 x00 x72 x01 x02 x00 x01 
GetCfgDescr: x09 x02 x22 x00 x01 x01 x00 xA0 x32 x09 x04 x00 x00 x01 x03 x01 x02 x00 x09 x21 x11 x01 x00 x01 x22 x2E x00 x07 x05 x81 x03 x04 x00 x0A 
01 
AnalyzeHidIntEndp 01
CtrlSetUsbConfig 01
GetHIDReport: x05 x01 x09 x02 xA1 x01 x09 x01 xA1 x00 x05 x09 x19 x01 x29 x03 x15 x00 x25 x01 x95 x08 x75 x01 x81 x02 x05 x01 x09 x30 x09 x31 x09 x38 x15 x81 x25 x7F x75 x08 x95 x03 x81 x06 xC0 xC0 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 
USB-Mouse Ready
Query Mouse @0000
Query Mouse @0000
prosper00 commented 3 years ago

I got my 554's in the mail today! Can confirm that these tweaks work.

Thank you! I'm totally going to poach your library too :)