Coder Social home page Coder Social logo

earlephilhower / arduino-pico Goto Github PK

View Code? Open in Web Editor NEW
1.8K 55.0 372.0 47.8 MB

Raspberry Pi Pico Arduino core, for all RP2040 boards

License: GNU Lesser General Public License v2.1

Assembly 0.24% C++ 54.40% C 43.10% Python 1.20% CMake 0.14% Shell 0.39% Makefile 0.01% HTML 0.52% Tcl 0.01%
raspberry pi pico arduino arduino-pico rp2040 freertos smp raspberry-pi picow

arduino-pico's Issues

Won't Install on Raspberry Pi

Trying to install using Board Manager (Arduino IDE 1.8.13) on a Raspberry Pi 4 4Gb using Raspberry Pi OS 32-bit, and get error "Tool pqt-gcc is not available for your operating system."

It installed, and so far works, with no problems in Linux Mint on another machine.

Compile Error for attachinterrupt()

I assume the attachInterrupt() function has not yet been added, it would be great if you add it, as interrupts using micro python are really slow and thanks a lot for this repo.

Does this work on MacOS?

Running Arduino 1.8.13 on MacOS Catalina 10.15.7 I search for pico in the Library Manager and it does not find anything to install.

Adafruit_ILI9341 does not compile

Hi,

I use Adafruit_ILI9341 to drive a 9341 LCD display in my Data General Nova simulator.

https://github.com/marcelvanherk/nova1200-restoration
(folder teensy_nova)

I have successfully compiled this for the pico with your platform (with a few changes) but:

#include "Adafruit_ILI9341.h"

(latest version as well as dependencies) reports:

C:\Users\marcel\Documents\Arduino\libraries\Adafruit_ILI9341\Adafruit_ILI9341.cpp:53:10: fatal error: wiring_private.h: No such file or directory
53 | #include "wiring_private.h"
| ^~~~~~~~~~~~~~~~~~
compilation terminated.

could this be made to work on the pico?

Marcel

Auto mount turn off in Linux, can't flash - Fixed

Hello,
In my dev Linux Laptop I have the auto mounter disabled, so after the pico reset, I was unable to flash the pico.

I fixed my self that in uf2conv.py file in line: 361

From:

        else:
            drives = get_drives()

        if args.output:
            write_file(args.output, outbuf)

To:

        else:
            drives = get_drives()
            #automount turned off fix
            if len(drives) == 0:
                if sys.platform == "linux":
                    os.system('udisksctl mount --block-device /dev/$(ls -n /dev/disk/by-id/usb-RPI_RP2_*-part1 | tail -c 5)')
                    drives = get_drives()

        if args.output:
            write_file(args.output, outbuf)

Just a share a Improvement.

Thanks

No /media mount point

It would appear the mount point for the pico is hardcoded to be "/media". In Manjaro(Arch) usb mount points are in "/run/media". The simple solution is to create a link "/run/media -> /media", works but should be fixed.

Anyway thanks for doing this.

Upload of a substantial program crashes the Arduino IDE

I've now successfully uploaded small programs, such as Blink, and a Serial test. But when I upload a more substantial program of about 80Kbytes when compiled (my uLisp Lisp interpreter) it seems to crash the Arduino IDE on my Mac in a way that even a Force-Quit doesn't fix, and I have to restart my Mac to continue. So this is making further progress a bit slow.

Any suggestions?

How to use multicore_launch_core1();

Hello @earlephilhower

Great work you are doing here, really appreciated.
I am just starting with the Pico and I guess I make a stupid mistake.
In the Pico Examples is some code how to use the multicore functions.
But when I try to #include "pico/multicore.h" compilation fails with file not found. Am I missing something?

If it is not yet implemented here, that is ok, I can wait (or try to implement and do a PR). Just wanted to know before I put time into it.

zero-byte writes in arduino Wire must be handled by bitbanging

a common thing done in arduino libraries is performing a zero-byte-write, like this
https://github.com/arduino-libraries/ArduinoECCX08/blob/master/src/ECCX08.cpp#L440
or in address scanning/checking

the RP2040 I2C peripheral does not permit that, so for writes of 0 bytes, it must be bitbanged, we've done so in CircuitPython and MicroPython does the same

right now, because of this bug, a lot of libraries (including a lot of Adafruit ones) will not work, they will fail on the address detection step!

(cc @sandeepmistry in case Arduino's core needs it too)

Change CPU clock don't work

Hello,
using the function set_sys_clock_khz() without the include of "pico/stdlib.h", report missing function...
But the include is set in platform.txt: "-I{runtime.platform.path}/pico-sdk/src/common/pico_stdlib/include"
if I add the include "pico/stdlib.h", I get multiples errors in linking: multiple definition of _write && multiple definition of _read from stdio.c:(.text._write+0x0):

As I can fix that?

Thanks

ISO C++ forbids converting a string constant to 'char*'

I don't know if this is a bug, or if you have done it by the book when no one else does, but I get a warning when using string arrays.

This is the example sketch from https://www.arduino.cc/reference/en/language/variables/data-types/string/ :

char *myStrings[] = {"This is string 1", "This is string 2", "This is string 3",
"This is string 4", "This is string 5", "This is string 6"
};

void setup() {
Serial.begin(9600);
}

void loop() {
for (int i = 0; i < 6; i++) {
Serial.println(myStrings[i]);
delay(500);
}
}

Compiling it produces a list of warnings like this:
/home/pi/Arduino/sketch_apr05a/sketch_apr05a.ino:1:22: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings]
1 | char myStrings[] = {"This is string 1", "This is string 2", "This is string 3",
| ^~~~~~~~~~~~~~~~~~

It does upload and run though. I've tried compiling it for Arduino, ESP-32 and Seeeduino SAMD boards, and none of them produce a warning.

headfile include fail

When I try to use the third-part library, it shows errors as below:

In file included from /Users/mac/Documents/Arduino/pico_main/pico_main.ino:6:
/Users/mac/Documents/Arduino/libraries/WiFiEsp/src/WiFiEsp.h:23:10: fatal error: Stream.h: No such file or directory
   23 | #include <Stream.h>
      |          ^~~~~~~~~~
compilation terminated.
exit status 1

Still required to set a serial port?

There is automated discovery of boards in bootloader mode, so they show up in the IDE, and the upload command works using the Microsoft UF2 tool (included).

I was still required to set a serial port before uploading code to the board? Upload proceeded by copying a UF2s expected after I'd done that (it works!), but having to set a serial port is going to be pretty confusing, and some users may not have any serial port options offered to them so will be unable to proceed?

CPU hangs when using pgm_read_word with an odd address

when running this code the CPU freezes after writing "word@1" to the serial port.

const PROGMEM unsigned char Config[] = { 0,1,2,3,4,5,6,7,8};
const unsigned char* ptr;


void setup() {
  Serial.begin(115200);
}

void loop() {
  delay(2500);
  ptr = &Config[0];
  Serial.print("word@0:");
  Serial.println(pgm_read_word(ptr));
  ptr = &Config[1];
  Serial.print("word@1:");
  Serial.println(pgm_read_word(ptr));
}

when changing
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
to
#define pgm_read_word(addr) (pgm_read_byte(addr)+(pgm_read_byte(addr+1)<<8))

program works fine.

Maybe this is also an issue with

#define pgm_read_dword(addr)
#define pgm_read_float(addr)
#define pgm_read_ptr(addr) 

NOT_AN_INTERRUPT not #defined

I have a 3rd party library that checks whether digitalPinToInterrupt() returns NOT_AN_INTERRUPT, which isn't defined in this core.

Clearly, all Pico pins are interrupt-capable, but it would still be useful to have this #defined. The AVR core #defines it in Arduino.h as (-1).

I have hacked the library as a workaround so there is no rush for a solution.

If this is an unsurmountable problem, I can ask the library author to handle the Pico as a special case.

Thanks.

Adafruit OLED/TFT libraries don't compile

Adafruit_SSD1306 and Adafruit_ST7735 (the included TFT library) to be exact.

hi, I'm trying to experiment around with some displays on the Pico, but i'm just hitting a brickwall. here is the code for both programs: OLED, TFT

using the Adafruit_SSD1306 Library i'm getting this error:

C:\Users\x\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp: In member function 'bool Adafruit_SSD1306::begin(uint8_t, uint8_t, bool, bool)':
C:\Users\x\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp:495:44: error: 'digitalPinToPort' was not declared in this scope; did you mean 'digitalPinToInterrupt'?
  495 |     dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin));
      |                                            ^~~~~~~~~~~~~~~~
      |                                            digitalPinToInterrupt
C:\Users\x\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp:495:25: error: 'portOutputRegister' was not declared in this scope
  495 |     dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin));
      |                         ^~~~~~~~~~~~~~~~~~
C:\Users\x\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp:496:17: error: 'digitalPinToBitMask' was not declared in this scope
  496 |     dcPinMask = digitalPinToBitMask(dcPin);
      |                 ^~~~~~~~~~~~~~~~~~~
exit status 1
Error compiling for board Raspberry Pi Pico.

with the other Library it was a bit more complicated.

at first i was getting this error:

In file included from C:\Users\oskar\Documents\Arduino\libraries\TFT\src/TFT.h:37,
                 from C:\Users\oskar\Documents\Arduino\Programs\TFT_Testing\TFT_Testing.ino:1:
C:\Users\x\Documents\Arduino\libraries\TFT\src/utility/Adafruit_ST7735.h:30:10: fatal error: avr\pgmspace.h: No such file or directory
   30 | #include <avr\pgmspace.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Raspberry Pi Pico.

after a bit of googling i found some dummy header files in an AVR folder that i was able to just throw into cores\RP2040 and that seem to have worked. Link to SO thread
so the next error i got after that was:

C:\Users\x\Documents\Arduino\libraries\TFT\src\utility\glcdfont.c:3:10: fatal error: avr/io.h: No such file or directory
    3 | #include <avr/io.h>
      |          ^~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Raspberry Pi Pico.

which was caused by this piece of code:

#if !defined(ARDUINO_ARCH_SAM) && !defined(__ARDUINO_ARC__) && \
    !defined(ARDUINO_ARCH_STM32)
#include <avr/io.h>
#endif

it seems to only include avr/io.h if the MCU used is not a 32 bit ARM one... so i just commented the whole thing out and hope it won't cause an issue later on.
now the current error i'm getting is pretty much the same as for the OLED Library.

C:\Users\x\Documents\Arduino\libraries\TFT\src\utility\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(const uint8_t*)':
C:\Users\x\Documents\Arduino\libraries\TFT\src\utility\Adafruit_ST7735.cpp:349:34: error: 'digitalPinToPort' was not declared in this scope; did you mean 'digitalPinToInterrupt'?
  349 |   csport    = portOutputRegister(digitalPinToPort(_cs));
      |                                  ^~~~~~~~~~~~~~~~
      |                                  digitalPinToInterrupt
C:\Users\x\Documents\Arduino\libraries\TFT\src\utility\Adafruit_ST7735.cpp:349:15: error: 'portOutputRegister' was not declared in this scope
  349 |   csport    = portOutputRegister(digitalPinToPort(_cs));
      |               ^~~~~~~~~~~~~~~~~~
C:\Users\x\Documents\Arduino\libraries\TFT\src\utility\Adafruit_ST7735.cpp:350:15: error: 'digitalPinToBitMask' was not declared in this scope
  350 |   cspinmask = digitalPinToBitMask(_cs);
      |               ^~~~~~~~~~~~~~~~~~~
exit status 1
Error compiling for board Raspberry Pi Pico.

i think i documented everything i did, but in case i missed something i can hopefully provide more detail.

Board not being detected by the IDE

Hey, I've been pressing down the BOOTSEL button on boot and its still not recognizing my device

I've tried with multiple picos.

Yes, i have installed the module. I am on windows if that helps.

Default pins for Serial/SPI/I2C not set properly

I was having issues getting any i2c sensor to work so after a lot of testing and searching i came across this issue witch is unrelated but did help me https://github.com/earlephilhower/arduino-pico/issues/38#issuecomment-808835731 the tester that was pointed out also did not work.

no i saw that PICO_DEFAULT_I2C_SCL_PIN and PICO_DEFAULT_I2C_SDA_PIN ar defined but when correctly connected it does not work.

i fixed this by setting the pins at the beginring of my program
Wire.setSCL(PICO_DEFAULT_I2C_SCL_PIN);//gp5 Wire.setSDA(PICO_DEFAULT_I2C_SDA_PIN);//gp4

now i don't know if this is an issue but seeing that they are defined you would expect it to use them if not explicitly told to use different pins right? I figured i would let you know.

Error uploading: No drive to deploy

My application compiles successfully, apart from five warnings:

/Users/david/Library/Arduino15/packages/rp2040/tools/pqt-gcc/1.0.1-base-3a57aed/bin/../lib/gcc/arm-none-eabi/
10.2.0/../../../../arm-none-eabi/bin/ld: warning: changing start of section .bss by 4 bytes

But then the upload fails with:

Converting to uf2, output size: 516096, start address: 0x2000
No drive to deploy.
An error occurred while uploading the sketch

I was able to successfully upload your Fade example. Any suggestions?

Opening a console window on the port does not reset

If I open a console window on the serial port for the pico, it does not reset the pico like it does for Arduino boards. Is this the expected behavior? Is there any way to make it auto reset when the port is opened?

Also, you might note in your readme file that if the first sketch you upload does NOT contain a Serial.begin call, the pico port will not show up.

Thanks.

String(float) not implemented

Hi again,

my tft code has this line:

tft.print(String(mips));

which result in a linker error:

C:\Users\marcel\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\0.9.3\cores\rp2040\api/String.cpp:134: undefined reference to `dtostrf'

So apparently dtostrf.c.impl is not linked in. No urgency, I have coded around it.

Thanks again for your fantastic package!

Marcel

Windows 7 sometimes does not recognize the device as serial port

Windows 7 sometimes does not recognize the device as serial port, even after fresh reinstalling using BOOTSEL button. You still can upload sketch using BOOTSEL mode manually, but it requires disconnecting device each time. Simply, the issue disable easy upload and auto-restart feature.

There is "ArduinoPico" unrecognized device in the device manager list with ID: USB\VID_2E8A&PID_000A&REV_0100 or similar. I am using Arduino IDE 1.8.13. Using different USB port didn't help. Restarting the IDE didn't help. On Windows 10 the same board works without any problems.

I found solution to make it work also on Windows 7:
image
(from https://www.onetransistor.eu/2021/02/set-up-raspberry-pi-pico-for-microphyton.html , btw: I used "Install driver")

Tested on Windows 7 that had previously this issue. Maybe you can add it to README or somewhere?

Building with arduino-cli

Hello,

Thank you for taking the time to create this library! I am not sure if this is a bug or not, but I am attempting to build the standard blink sketch using Arduino-cli. I have added the board to the YAML configuration file, and inside Arduino IDE I can compile and upload the sketch just fine.

However, using the latest version of Arduino-cli I am getting the following error, which I am not sure how to fix.

`joachimhaagenskeie@Joachims-MacBook-Pro b989c882d2b % arduino-cli compile -e -b rp2040:rp2040:rpipico /Users/joachimhaagenskeie/src/arduinocli/b989c882d2b/b989c882d2b.ino
/Users/joachimhaagenskeie/Library/Arduino15/packages/rp2040/hardware/rp2040/0.9.5/cores/rp2040/main.cpp: In function 'int main()':
/Users/joachimhaagenskeie/Library/Arduino15/packages/rp2040/hardware/rp2040/0.9.5/cores/rp2040/main.cpp:27:5: error: 'DEBUG_RP2040_PORT' was not declared in this scope
27 | DEBUG_RP2040_PORT.begin();
| ^~~~~~~~~~~~~~~~~
/Users/joachimhaagenskeie/Library/Arduino15/packages/rp2040/hardware/rp2040/0.9.5/cores/rp2040/main.cpp: In function 'ssize_t _write(int, const void*, size_t)':
/Users/joachimhaagenskeie/Library/Arduino15/packages/rp2040/hardware/rp2040/0.9.5/cores/rp2040/main.cpp:62:12: error: 'DEBUG_RP2040_PORT' was not declared in this scope
62 | return DEBUG_RP2040_PORT.write((const char *)buf, count);
| ^~~~~~~~~~~~~~~~~

Error during build: exit status 1`

EEPROM does not work

Hi,

I managed to compile my Data General Nova simulator with your platform (without tft support). Impressive work! However, EEPROM does not work. I then compiled you eeprom write test, which reports a "failed to commit".

Marcel

overflow in call to pwm_config_set_clkdiv in analogWrite

I believe you have a bug in setting the clock divider for the PWM. I think you meant to divide the clock hz by the product of the analogFreq and analogScale, but instead it is multiplying it and it is overflowing:

extern "C" void analogWrite(pin_size_t pin, int val) {
    if (!pwmInitted) {
        pwm_config c = pwm_get_default_config();
        pwm_config_set_clkdiv( &c, clock_get_hz(clk_sys) / 1.0 * (analogScale * analogFreq));
        pwm_config_set_wrap( &c, analogScale );
        for (int i=0; i<30; i++) {
            pwm_init(pwm_gpio_to_slice_num(i), &c, true);
        }
        pwmInitted = true;
    }

U2conv.py on Win fails if volume names have non-ASCII chars

Hi
No problem with Ubuntu, works great !! Thanks !!

On Windows10 I got u2conv.py error when i try to flash Pico Py board
Windows 10 French
Arduino IDE 1.8.13
Raspberry Pi Pico core version 1.0.1
Same error with Fade or any other example code
Error message :

Resetting COM8
Traceback (most recent call last):
Une erreur est survenue lors du transfert du croquis
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 368, in <module>
Converting to uf2, output size: 439296, start address: 0x2000
    main()
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 355, in main
    drives = get_drives()
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 233, in get_drives
    for line in to_str(r).split('\n'):
  File "C:\Users\Lenovo\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.0.1/tools/uf2conv.py", line 225, in to_str
    return b.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 225: invalid continuation `byte`

Best Regards

Compile problem with pico

Hi,
I follow the step and meet a compile bug:

c:/users/30477/documents/arduinodata/packages/rp2040/tools/pqt-gcc/1.0.1-base-3a57aed/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .rodata by 4 bytes

I only test a gpio demo. How to solve this issue?

User with space not working

On windows I was dumb and have a user with a space in the name and now the file is going to the wrong place. Im sure the package is there
image

Add I2S input (microphones, etc.)

Good to see the I2S output happening...

FYI

The Microcenter Stores cleared out the original Google Voice Kits for $2.99, if you know anyone with one, the I2S mic. (SPH0645LM4H-B) pair connector is:

Blk Gnd
Grn I2S DIN
Wht I2S BCLK
Blu I2S LRCLK
Red 3.3V

Does not work with Arduino IDE 2.0

There is an issue woth Arduino IDE 2.0.
Versions would not go higher as 0.9.9

So I installed newest versions with the old Arduino IDE
installed version 0.9.18 works ok there but now the Pico
does not show up in the boards manager at all anymore in 2.0.

Do not know if it is a problem on your side or on the arduino side.....

List of Pico-Specific Functions?

This may be a silly question, since I am a novice with both arduino and pico. I can't seem to find the documentation on the functions and syntax used to control the pins on the pico.

Please could you direct me to the right place?

For help The compilation project could not find the dma.h file

Arduino:1.8.10 (Windows 10), board:"Raspberry Pi Pico, 2MB (no FS), 125 MHz, Disabled, None"

sketch_apr13a:2:10: error: hardware/dma.h: No such file or directory
    2 | #include <hardware/dma.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.

exit status 1
hardware/dma.h: No such file or directory

LittleFS format() hangs with flash size > 2MB

Trying out LittleFS/SpeedTest on a Feather, the program never returns from format(). Changing the board type to "Generic RP2040 Flash Size 2MB with Boot Stage 2: W25X10CL QSPI /4" works as expected, but upping to Flash Size 4MB fails.

Sketch upload to serial port fails on Mac

Sketch upload to serial port fails on macos because the Arduino IDE uses the callout device "/dev/cu". Adding recognition of "/dev/cu" to uf2conv.py makes the sketch upload work.

        if str(args.serial).startswith("/dev/tty") or str(args.serial).startswith("COM")or str(args.serial).startswith("/dev/cu"):

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.