blinkinlabs / ch554_sdcc Goto Github PK
View Code? Open in Web Editor NEWCH554 software development kit for SDCC
CH554 software development kit for SDCC
I'm stuck on Linux today ... wondering about this error.
rasyoung@vic2016:~/code_test/8051/wch/ch554_sdcc/examples/pwm$ sudo make flash
wchisptool -f pwm.bin -g
Error while bulking in: LIBUSB_ERROR_OVERFLOW
Libre CH551 Flasher 2018
The chip id 0xFFFFFFD0 is currently not support in this program
Do you know fix for this ? Thanks for excellent postings!
https://github.com/Blinkinlabs/ch554_sdcc/blob/master/examples/Makefile.include#L24
The specs for the CH554 state, 14KB Code Flash 2KB BootLoader. I've tested on a CH552T, and get verify errors when I try to upload more than 14kB.
The specs for the CH551 state, "10KB Code Flash 2KB BootLoader", but I've been able to upload 12kB before I get verify errors on the CH551.
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 -D__SDCC_CHAR_UNSIGNED -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCC=4_0_7 -D__SDCC_VERSION_MAJOR=4 -D__SDCC_VERSION_MINOR=0 -D__SDCC_VERSION_PATCH=7 -DSDCC=407 -D__SDCC_REVISION=11994 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF_16__=1 -D__STDC_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.
Per @mogenson, the version of SDCC used in the Travis build is quite old (from 2013), and should be updated to something more modern.
I am writing an email to [email protected] for this issue. Also submit an issue here, in case anyone meets the same problem.
The &=
operator is misused in the ADCInit()
method in adc.c. The expression on the right side of the operator &=
will be calculated first, it may lead to an unexpected value in a certain case.
ADC_CFG &= ~bADC_CLK | speed;
// It implies
ADC_CFG = ADC_CFG & (~bADC_CLK | speed);
The 3rd case failed to set the bit.
- 0x00 & (0xfe | 0) = 0x0
- 0x01 & (0xfe | 0) = 0x0
- 0x00 & (0xfe | 1) = 0x0 // Failed to set the bit
- 0x01 & (0xfe | 1) = 0x1
It should have been like this.
ADC_CFG = ADC_CFG & ~bADC_CLK | speed;
All cases work as expected.
- 0x00 & 0xfe | 0 = 0x0
- 0x01 & 0xfe | 0 = 0x0
- 0x00 & 0xfe | 1 = 0x1
- 0x01 & 0xfe | 1 = 0x1
UartByteCount is modified in the UART1 ISR and in main. If the UART1 interrupt occurs between lines 590 and 598, the received byte will be dropped.
https://github.com/Blinkinlabs/ch554_sdcc/blob/master/examples/usb_device_cdc/main.c#L598
I don't see a simple fix. I think it would be best to replace the ring buffer code with a thread-safe version. I recently published a tiny ring buffer that would be a good fit.
https://github.com/nerdralph/RingBuffer
I changed the blink example to use an function for changing the pin mode, so it will work with any GPIO pin on P1 or P3.
https://github.com/nerdralph/ch554_sdcc/blob/master/examples/blink/main.c
The LED GPIO is defined by its SFR bit address. I wanted to use the address of the port bit, but SDCC doesn't permit the address operator on __sbit i.e. pushPull(&P1_4);
.
If you like this solution, I'll submit a pull request.
I was able to reduce the compiled size of the blink example from 700B to 232B by conditionally excluding the UART functions. Another 36B can be saved by excluding the WDT functions. Instead of adding #ifdef BUILD_UART around the code, another option would be to break up debug.c into separate files and build it as a library. Then the linker will only pull in .rel files that are actually used.
Looks like WCH has some English datasheets on their site!:
CH554: http://www.wch-ic.com/downloads/file/229.html
CH551 / 552: http://www.wch-ic.com/downloads/file/309.html
Like, now let's compile and oops nothing happened!
These superfluous words, expressions and actions are very annoying, because at least they spend time.
I would understand if it was some kind of novel or other literary adventure.
But I think people coming here hope to quickly connect everything and make everything work right away.
Thank's
U1TI should be cleared in the ISR. After the first transmit interrupt, the ISR will run repeatedly, only running one instruction after reti before running the ISR again.
https://github.com/Blinkinlabs/ch554_sdcc/blob/master/examples/usb_device_cdc/main.c#L546
git clone https://github.com/Blinkinlabs/ch554_sdcc.git
cd ch55x_sdcc/examples
make
It should be ch554_sdcc
Hello good people,
Not an issue with SDCC or CH554 per se , but ...
I downloaded the SDCC source from the blinkinlabs repo. When I open the code with VScode, i am able to see the chinese comments which I am able to translate with google.
when I download the code repo from the WCH website (for Keil) the chinese comments are not rendered properly. Is there any advice on how to get the comments in a translatable format ?
I am trying to use CH554 as a logger with a USB pen drive. I think udrive is still not ported to SDCC.
TIA
I was getting an error in the device manager for my WCH551 and WCH552 boards.
I tried setting the driver to libusbK using zadig, and still got an error. libusb-win32 worked.
The CH552 VID/PID is 4348 55E0.
Here's my source code. But I'm not sure that whether or not it works on CH552/554.
Hi,
it seem to me the USB handling code in the examples directory is not very user friendly (at least for beginners or people not familiar with USB devices). I tried to improve it, and came up with a slightly better solution. See here: https://github.com/ole00/ch554_sdcc_usb_blinky
Anyway, thanks for sharing the project, it's very useful.
The Makefile sets "CPU_FREQ = 16000000" - which is incorrect and does nothing; it should read 'FREQ_SYS = 16000000'
At least 'usb_host_KM' is broken with SDCC 4.2.0 in Debian 12. It complies under SDCC 4.0.0 in Debian 11.
Specifically:
make[1]: Entering directory '/build/examples/usb_host_KM'
sdcc -c -V -mmcs51 --model-small --xram-size 0x380 --xram-loc 0x080 --code-size 0x3800 -I/build/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 UsbHostHub_KM.c
+ /usr/bin/sdcpp -nostdinc -Wall -std=c11 -I/build/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 -obj-ext=.rel -D__SDCC_CHAR_UNSIGNED -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCCCALL=0 -D__SDCC=4_2_0 -D__SDCC_VERSION_MAJOR=4 -D__SDCC_VERSION_MINOR=2 -D__SDCC_VERSION_PATCH=0 -DSDCC=420 -D__SDCC_REVISION=13081 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF_16__=1 -D__STDC_UTF_32__=1 -isystem /usr/bin/../share/sdcc/include/mcs51 -isystem /usr/share/sdcc/include/mcs51 -isystem /usr/bin/../share/sdcc/include -isystem /usr/share/sdcc/include UsbHostHub_KM.c
/build/examples/../include/debug.h:52: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
+ /usr/bin/sdas8051 -plosgffw UsbHostHub_KM.rel UsbHostHub_KM.asm
sdcc -c -V -mmcs51 --model-small --xram-size 0x380 --xram-loc 0x080 --code-size 0x3800 -I/build/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 usbhost.c
+ /usr/bin/sdcpp -nostdinc -Wall -std=c11 -I/build/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 -obj-ext=.rel -D__SDCC_CHAR_UNSIGNED -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCCCALL=0 -D__SDCC=4_2_0 -D__SDCC_VERSION_MAJOR=4 -D__SDCC_VERSION_MINOR=2 -D__SDCC_VERSION_PATCH=0 -DSDCC=420 -D__SDCC_REVISION=13081 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF_16__=1 -D__STDC_UTF_32__=1 -isystem /usr/bin/../share/sdcc/include/mcs51 -isystem /usr/share/sdcc/include/mcs51 -isystem /usr/bin/../share/sdcc/include -isystem /usr/share/sdcc/include usbhost.c
usbhost.c:82: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
usbhost.c:924: warning 84: 'auto' variable 's' may be used before initialization
usbhost.c:1408: warning 84: 'auto' variable 'i' may be used before initialization
+ /usr/bin/sdas8051 -plosgffw usbhost.rel usbhost.asm
sdcc -c -V -mmcs51 --model-small --xram-size 0x380 --xram-loc 0x080 --code-size 0x3800 -I/build/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 ../../include/debug.c
+ /usr/bin/sdcpp -nostdinc -Wall -std=c11 -I/build/examples/../include -DFREQ_SYS=16000000 -DMAX_PACKET_SIZE=64 -obj-ext=.rel -D__SDCC_CHAR_UNSIGNED -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCCCALL=0 -D__SDCC=4_2_0 -D__SDCC_VERSION_MAJOR=4 -D__SDCC_VERSION_MINOR=2 -D__SDCC_VERSION_PATCH=0 -DSDCC=420 -D__SDCC_REVISION=13081 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF_16__=1 -D__STDC_UTF_32__=1 -isystem /usr/bin/../share/sdcc/include/mcs51 -isystem /usr/share/sdcc/include/mcs51 -isystem /usr/bin/../share/sdcc/include -isystem /usr/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/build/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[1]: *** [../Makefile.include:40: UsbHostHub_KM.ihx] Error 1
make[1]: Leaving directory '/build/examples/usb_host_KM'
make: *** [Makefile:6: usb_host_KM/] Error 2
make: *** [Makefile:19: build] Error 2
Have one error on the translation Table 5.3.1 General 8051 Register List
A,ACC correct Adress is E0h not DOh as is written on the pdf
The datasheet is confusing about what voltages are supported at different clock speeds and temperatures. TA32M states >28MHz is supported in the range of -20C to 70C vs <28MHz is OK from -40C to 85C. Then in table 18.4, Fsys at 24M is specified as requiring 4.4V. I think 24M is safe with VCC >= 3V3 at normal temperature ranges.
For the USB CDC example, where the MCU is most likely powered from VBUS (USB 5V), in which case 24M should be safe over the full temperature range.
The benefit of 24M over 16M is much more accurate UART timing at high speeds. At 16M, the counter reload value for 115.2kbps is 9 vs an ideal value of 8.68, making the timing 3.5% slow. At 24M, the reload value will be 13 vs an ideal of 13.02, making it only 0.16% fast.
One of the utilities mentioned in the readme - LibreCH551 - appears to be abandoned, and doesn't work with current chips (or, at least, not with current bootloaders on current chips). I'd recommend removing it from the readme, as well as using a different tool in your Makefiles
I've found a handful of alternative utilities that DO work:
VNPro (patched for more CH55x chips) (https://github.com/LoveMHz/vnproch55x)
This is what's used in ch55xduino
ch55x-isptool (https://github.com/ElectronicCats/ch55x-isptool)
chflasher (https://github.com/atc1441/chflasher)
There is a minor issue in the readme where S_FILES
should be C_FILES
:
Line 87 in 05ddb79
Tested with SDCC 4.0.0 #11528 (MINGW64)
The error reported is:
main.c:5:19: fatal error: ch554.h: No such file or directory
You have to change
#include <ch554.h>
#include <debug.h>
to
#include "../../include/ch554.h"
#include "../../include/debug.h"
I had to change FREQ_FSYS in Makefile.include to 12000000 to make it work, otherwise no LED in the strip lights on. Tested with a ws2812 24 LED ring and a 72 LED strip
https://github.com/Blinkinlabs/ch554_sdcc/blob/master/include/debug.c#L164
Making them volatile stops SDCC from doing constant folding and propagation, which bloats the code size. By making them non-volatile, the blink example compiles to 364 bytes instead of 700.
You don't need MinGW, I would suggest that you consider that some users will have the Linux subsystem for windows installed, Who will have the goods from both worlds Windows and Linux turning the work a little easyer
Take a look on what I'm talking about
Sharing an arduino wrapper over ch554_sdcc I made.
Is there any plan to add software i2c support?
To the best of my knowledge, the CH554 doesn't have hardware i2c support and the official SDK doesn't provide a software implementation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.