Commit Graph

15 Commits

Author SHA1 Message Date
Lasse Dalegaard a7b01857f5 flash_usb: use sudo for rp2040 flashing
The rp2040 can be flashed without sudo when using udev rules to give the
user permission, but in a standard configuration sudo is required.

Here we make it possible for flash_usb to use sudo for the rp2040
target, and make it the default when using `make flash` for the rp2040.
As for other targets, one can set `NOSUDO=1` to not call through sudo.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2022-01-31 11:10:02 -05:00
Lasse Dalegaard 090fcf928f rp2040: implement I2C
This implements I2C for the rp2040 target. All output groupings of both
I2C blocks are available for use.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2022-01-12 11:44:31 -05:00
Lasse Dalegaard 7c0559c6e6 rp2040: add make flash support
This adds `make flash` support for the rp2040 target. Flashing is
performed using a custom `rp2040_flash` tool that uses the PICOBOOT
protocol. Root is not required.

The user specifies the serial device of the rp2040 they wish to flash as
the device. This device is reset into bootsel mode and `rp2040_flash`
is invoked on the original USB device path.

If the device is already in bootloader mode, the user can specify
'first' as `FLASH_DEVICE` which will simply invoke `rp2040_flash` with
no bus/address options.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2022-01-06 17:32:54 -05:00
Kevin O'Connor 689231df3a stepper: Add support for stepping on both edges of a step pulse
Add an optimized step function for drivers that support stepping on
both rising and falling edges of the step pin.  Enable this
optimization on 32bit ARM micro-controllers.  Automatically detect
this capability in the host code and enable on TMC drivers running in
SPI/UART mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-04 12:06:27 -04:00
Kevin O'Connor 627c1c5d2a rp2040: Add barrier() around all memcpy() calls in usbserial.c
Make sure gcc doesn't reorder any of the memcpy() calls to the usb
data ram.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-27 11:16:34 -04:00
Lasse Dalegaard de33180236 rp2040: add barrier in usb_read_ep0_setup
Some versions of gcc, in some cases, decide that it is OK to move the
read to `INTR` to right after clearing the `SETUP_REC` bit of
`SIE_STATUS`, instead of after the `memcpy`.

The rp2040 datasheet doesn't appear to say anything about how quickly
the `SETUP_REC` bit will be cleared in `INTR`, but regardless the
compiler should not be re-ordering the read like this.

Here we force the correct ordering using a memory barrier.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-10-27 11:10:17 -04:00
Lasse Dalegaard 84523f2811 rp2040: implement SPI
This implements SPI for the rp2040 target. All output groupings of both
SPI blocks are available for use.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-07-15 13:30:20 -04:00
Lasse Dalegaard 28f60f7ef6 rp2040: hardware PWM support
This implements hardware PWM support for the rp2040. The maximum
value(100% duty) is set to 255 to match the other controllers. Cycle
time is clamped automatically, and uses the full 8.4 fractional range of
the rp2040 PWM block. This allows a maximum PWM frequency of 490kHz and
a minimum frequency of 1915 Hz.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-07-09 11:23:48 -04:00
Kevin O'Connor f2b4d353d8 rp2040: Add _ramfunc macro to internal.h and use in bootrom.c and chipid.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 12:45:27 -04:00
Lasse Dalegaard ba958468b7 rp2040: add chipid support
The rp2040 doesn't have a chip ID, but the flash chip connected does. We
can get this ID by asking the flash chip directly, but doing so requires
disengaging the XIP layer, performing the interrogation of the flash
chip, and then re-enabling the XIP layer. This gives us a 64-bit unique
ID that we can use as our USB serial number.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-07-04 12:43:45 -04:00
Lasse Dalegaard 0597210cb9 rp2040: support usb_request_bootloader
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 11:30:19 -04:00
Lasse Dalegaard bb2f27f928 rp2040: remove unused linker option
In binutils 2.36 and above the -nostartfiles option is no longer
ignored. -nostartfiles is actually a gcc option, and so isn't supported
by ld. Earlier versions of binutils however had less error checking, and
thus just ignored the option.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-07-04 16:36:52 +02:00
Kevin O'Connor c5667193c9 rp2040: Initial USB support
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 10:11:02 -04:00
Kevin O'Connor 59fe878241 rp2040: Add initial adc support
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 10:11:02 -04:00
Kevin O'Connor 045bfa4e8d rp2040: Add initial support for the rp2040 mcu
Support the rp2040 (as tested on a Raspberry Pi Pico board).  This
adds basic uart, timer, gpio, and watchdog support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-04 10:11:02 -04:00