Coder Social home page Coder Social logo

arduino-wch32v003's People

Contributors

alexandermandera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-wch32v003's Issues

undefined reference to `analogRead'

c:/users/zanis/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\genericCH32V003F4P6\src\main.cpp.o: in function loop': main.cpp:(.text.loop+0xa): undefined reference to analogRead'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\genericCH32V003F4P6\firmware.elf] Error 1

error no malloc and .L0

riscv-none-elf-g++: warning: '-x c++' after last input file has no effect
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino: In function 'void editln()':
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:26:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
26 | p=findstr(buf," ");
| ^~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:27:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
27 | if(findstr(buf," ")) {
| ^~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino: In function 'void loop()':
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:183:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
183 | puts2("\n\rOk\n\r");
| ^~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:196:48: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
196 | if (!findstr(s,""")){
| ^~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:197:59: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
197 | while(p=findstr(s,"<>"))
| ^~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:199:59: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
199 | while(p=findstr(s,"<="))
| ^~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:201:59: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
201 | while(p=findstr(s,">="))
| ^~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:273:71: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
273 | if(quoted&1 || !findstr(" \t",F))//what in the world does this line do?
| ^~~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:314:74: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
314 | ((q=findstr(buf,"TH"))=0,
| ^~~~
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:357:65: warning: ISO C++ forbids converting a string constant to 'char
' [-Wwrite-strings]
357 | *(q=findstr(buf,"TO"))=0;
| ^~~~
/home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o: in function .L0 ': /tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:75: undefined reference to strtol'
/home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:157: undefined reference to sprintf' /home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o:/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:158: undefined reference to strcat'
/home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o: in function .L0 ': /tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:180: undefined reference to malloc'
/home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o:/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:186: undefined reference to atoi' /home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o: in function .L0 ':
/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:26: undefined reference to malloc' /home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o:/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:242: undefined reference to sprintf'
/home/icelon/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccvXmO9o.ltrans0.ltrans.o:/tmp/.arduinoIDE-unsaved2023915-2954-4dhnw1.15zhd/sketch_oct15a/sketch_oct15a.ino:316: undefined reference to `sprintf'
collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

String class not usable (no malloc)

The Arduino String class uses malloc, free and realloc to dynamically allocate memory for the strings. However, the core doesn't define the sbrk() function as the base function needed for malloc to allocate more memory.

So a sketch like

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
}
static int i=0;
void loop() {
    Serial.println("Hello " + String(i++));
}

fails with

Linking .pio\build\ch32v003f4p6_evt_r0\firmware.elf
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::~String()':
String.cpp:(.text._ZN7arduino6StringD2Ev+0x4): undefined reference to `free'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::invalidate()':
String.cpp:(.text._ZN7arduino6String10invalidateEv+0xc): undefined reference to `free'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::changeBuffer(unsigned int)':
String.cpp:(.text._ZN7arduino6String12changeBufferEj+0x10): undefined reference to `realloc'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: .pio\build\ch32v003f4p6_evt_r0\FrameworkArduino\api\String.cpp.o: in function `arduino::String::String(int, unsigned char)':
String.cpp:(.text._ZN7arduino6StringC2Eih+0x18): undefined reference to `itoa'

So it also uses -nostdlib which causes itoa to not be found and stuff.

If I do make the required fixes per Community-PIO-CH32V@d098d4d, I get a successfull compile

Linking .pio\build\ch32v003f4p6_evt_r0\firmware.elf
Checking size .pio\build\ch32v003f4p6_evt_r0\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  25.8% (used 528 bytes from 2048 bytes)
Flash: [==        ]  19.9% (used 3260 bytes from 16384 bytes)

and it works during runtime.

Question is, do we want this? Should this be allowed usage on a chip with this little memory?

With the "main branch" / no malloc, a blinky sketch of

#include <Arduino.h>
#define LED C1
void setup() { pinMode(LED, OUTPUT); }
void loop() {
    digitalWrite(LED, HIGH);
    delay(1000);
    digitalWrite(LED, LOW);
    delay(1000);
}

uses

RAM:   [==        ]  18.4% (used 376 bytes from 2048 bytes)
Flash: [=         ]   8.7% (used 1420 bytes from 16384 bytes)

and with the malloc branch it uses

RAM:   [==        ]  24.6% (used 504 bytes from 2048 bytes)
Flash: [=         ]  11.2% (used 1832 bytes from 16384 bytes)

So.. even though this sketch shouldn't use malloc, the compiler still adds some baggage, probably because of the nosys and nano specs linking.. :(

I2C slave example?

Thanks for great resource to support CH32V003 on Arduino. It makes life much easier for beginner like me to play with. Is there any slave i2c example? I plan to use this dead cheap mcu in some of my sensors and convert them all to i2c module. Thanks.

No analogread or analogwrite :/

I tried compiling an sketch for my ch32v003, everything else works fine, except analogwrite aswell and analogread i got this error

riscv-none-elf-g++: warning: '-x c++' after last input file has no effect
/home/etore/.arduino15/packages/alexandermandera/tools/riscv-none-elf-gcc/12.2.0-3-xPack/bin/../lib/gcc/riscv-none-elf/12.2.0/../../../../riscv-none-elf/bin/ld: /tmp/ccBBIZmj.ltrans0.ltrans.o: in function .L0 ': /home/etore/Arduino/pcmplayerch32v003/pcmplayerch32v003.ino:9: undefined reference to analogRead' (this is the important part)
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board CH32V003.

And also an undefined reference to "analogwrite"

I understand you haven't implemented everything yet, but i would love for analogwrite and analogread to be implemented instead of having to resort to using digitalwrite and simulated pwm instead of analogwrite

Checking in from ch32v003fun

Not an issue! But I just wanted to check in with you guys. And let you know I want to fully support your work in any way I can. I hope ch32v003 continues to earn your "upstream" business, and let us know if there are any things we can do to further support Arduino.

We'd like to avoid having weird ch32v003fun forks, so if there's any way for all the changes to stay unified, that would be very helpful.

Side-note: I am hoping (though no guarantee) that we can have a firmware-only USB bootloader for the CH32V003 in a few weeks. Feel free to follow the appropriate channels for more information there. But I hope that the "standard" one day will be to just use USB on two GPIOs.

Feel free to join our discord. https://discord.gg/CCeyWyZ

unable to use A2 as GPIO output

#define ledpin A2
#define ledpin2 A1

void setup() {
  pinMode(ledpin, OUTPUT);
  pinMode(ledpin2, OUTPUT);
}

void loop() {
  digitalWrite(ledpin, HIGH);  
  delay(1000);   
  digitalWrite(ledpin, LOW);   
  delay(1000);        
  digitalWrite(ledpin2, HIGH);   
  delay(1000);                       
  digitalWrite(ledpin2, LOW);    
  delay(1000); 
}

At this code, A1 is blinking, but A2 is floating.
These pin was no problem when using ch32v003fun.

I think something wrong in cores/arduino/wiring_digital.cpp at specifying pin number

On arduino. Not an issue but a question.

Hello, I have been following a few people using this Processor. I have a few of them a friend of mine gave me but never used them. I couldn't find anything on them with arduino.

I recently saw your GitHub and now I got excited and would love to use them. Are you still working on this project if so do you think you will get the native usb working as well as spi and i2c?

Joseph

minichlink not executable

I tried to compile and flash blink with the Arduino IDE, but it was throwning an error that it could not execute miniblink:

"/home/zoobab/.arduino15/packages/alexandermandera/tools/minichlink/1.0.0/minichlink" -w "/tmp/arduino/sketches/72B0E73327037FF023DE2707CCD1ACDC/Blink.ino.bin" flash -b
Failed uploading: cannot execute upload tool: fork/exec /home/zoobab/.arduino15/packages/alexandermandera/tools/minichlink/1.0.0/minichlink: permission denied

I did a chmod +x /home/zoobab/.arduino15/packages/alexandermandera/tools/minichlink/1.0.0/minichlink , and then it worked.

Can you reproduce?

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.