Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Add Raspberry Pi RP2040 support #14877

Merged
merged 14 commits into from
Jun 30, 2022

Conversation

KarlK90
Copy link
Member

@KarlK90 KarlK90 commented Oct 18, 2021

Building on the great work of @hanya, @xyzz and @tzarc this PR adds support for RP2040 to QMK.

Todo

QMK:

  • General code style
  • Documentation updates
  • QMK moves to ChibiOS 21.11.x or Trunk builds
  • Rebase onto develop
  • Double Tap reset to jump to bootloader
  • Sort out USB driver hacks for correct HID enumeration [RP2040] Init USB out endpoints on transfer start ChibiOS/ChibiOS-Contrib#316
  • SIO Split Keyboard Driver (This needs patches to ChibiOS)
  • I2C Driver
  • SPI Driver
  • PIO Half-duplex split comms
  • PIO WS2812 driver

Chibi OS:

  • Apply SIO and RP2040 Patches (Part of 21.11.2 and Trunk)
  • later Initialization of RAM areas in crt1.c has to be done in assembly. (If using the memcpy/memset functions from rp2040 bootrom)
  • later Add *.preinit_array sections to xtors in order to call the VTABLE population for the functions in rp2040 bootrom
  • later Port USB bootup fixes from pico-sdk to USB Driver (Only affects B0 and B1 Revisions of the RP2040 chips)

Future work after this PR

  • RP2040 optimized Math function compiler intrinsics support
  • EEPROM emulation for via(l) support
  • WS2812 PIO driver uses DMA (actually done in this PR)
  • PWM Audio output, this needs a ChibiOS driver
  • PWM LED output, this needs a ChibiOS driver
  • ADC support, this needs a ChibiOS driver

Description

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@KarlK90 KarlK90 changed the base branch from master to develop October 18, 2021 17:36
@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch 2 times, most recently from 567eb4b to feb98ab Compare October 18, 2021 17:47
@drashna drashna added the awaiting_pr Relies on another PR to be merged first label Oct 18, 2021
.gitmodules Show resolved Hide resolved
tmk_core/chibios.mk Outdated Show resolved Hide resolved
@zykrah
Copy link
Contributor

zykrah commented Dec 30, 2021

Hi, i was just wondering if work is still being done on this?

@tzarc
Copy link
Member

tzarc commented Dec 30, 2021

Hi, i was just wondering if work is still being done on this?

Can't move until ChibiOS/ChibiOS-Contrib#307 is sorted.

@zykrah
Copy link
Contributor

zykrah commented Dec 31, 2021

Hi, i was just wondering if work is still being done on this?

Can't move until ChibiOS/ChibiOS-Contrib#307 is sorted.

I have a fork of chibios contrib 21.6.x that succesfully builds. Though you will have to see how i did it, as i didnt actually update the other MCUs to 21.11.x, rather it uses the master branch of chibios just for building the rp2040 and the other stuff still builds using chibios 20.3.x. (This was the only way i could get it to build properly without making major changes)

@zykrah
Copy link
Contributor

zykrah commented Dec 31, 2021

This is the fork for reference: https://github.com/zykrahgaming/ChibiOS-Contrib

@zykrah
Copy link
Contributor

zykrah commented Jan 1, 2022

ChibiOS/ChibiOS-Contrib#310
I have made a PR which has updated ChibiOS-Contrib to the ChibiOS master branch (21.11.x)

@KarlK90
Copy link
Member Author

KarlK90 commented Jan 16, 2022

@zykrahgaming Thanks for your interest and effort in pushing RP2040 support forward 💪 I hope that contrib resurrects from the winter sleep soonish. To support split keebs I started #15907 which brings split comms support for the RP2040.

@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from feb98ab to ef2a469 Compare January 27, 2022 15:31
@github-actions github-actions bot added keymap via Adds via keymap and/or updates keyboard for via support labels Jan 27, 2022
@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from ef2a469 to 1dbf90d Compare February 4, 2022 22:19
@github-actions github-actions bot removed keymap via Adds via keymap and/or updates keyboard for via support labels Feb 4, 2022
@hanya
Copy link

hanya commented Feb 5, 2022

Double tap reset to enter bootloader have to be called after platform_setup() function in main() function.
Because ChibiOS initialize clocks for USB in chSysInit() function called in platform_setup function.
The following code supports double tap reset.
https://gist.github.com/hanya/57eb9703361a38d40bad6b05340ccc91
The boot_double_reset_bootloader function does not work if called in board_init() function.
So if we have entry point between platform_setup and protocol_setup functions, put it there.

@KarlK90
Copy link
Member Author

KarlK90 commented Feb 5, 2022

@hanya thank you for the bootloader code and all the previous work on the contrib code. I'll have a more in depth look next week.

Giovanni the maintainer of ChibiOS also voiced interest to move the rp2040 contrib drivers into mainline, but wants somebody to actively maintain them. This might be interesting for you?

@stefancrain
Copy link

Good news! ChibiOS/ChibiOS-Contrib#310 (comment)

@KarlK90
Copy link
Member Author

KarlK90 commented Jun 20, 2022

Rebased and adjusted on top of current develop, so all dependent PRs are now merged.

I replaced the KB2040 pin-out picture with Sparkfuns RP2040 because that should be considered the canonical pin out.

@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch 2 times, most recently from 984ce63 to 3df6518 Compare June 26, 2022 16:08
@KarlK90 KarlK90 requested review from tzarc and zvecr June 26, 2022 22:32
@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from 3df6518 to 7e7ec4a Compare June 28, 2022 09:56
@KarlK90
Copy link
Member Author

KarlK90 commented Jun 28, 2022

For people that wondered why their build failed with error messages when including an rp2040.h file to their keyboard folder. This is due to a naming conflict with another header file from CMSIS with the same name. To mitigate the issue do not include a file with the name rp2040.h in your keyboard folder.

@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from 7e7ec4a to 6564276 Compare June 29, 2022 10:32
@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from 6564276 to b41756d Compare June 29, 2022 22:29
@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from d16761f to b9a404e Compare June 29, 2022 23:26
docs/ws2812_driver.md Outdated Show resolved Hide resolved
platforms/chibios/drivers/serial_usart.c Outdated Show resolved Hide resolved
platforms/chibios/drivers/serial_usart.c Outdated Show resolved Hide resolved
keyboards/handwired/onekey/rp2040/rp2040.c Outdated Show resolved Hide resolved
docs/platformdev_rp2040.md Outdated Show resolved Hide resolved
docs/platformdev_rp2040.md Outdated Show resolved Hide resolved
docs/platformdev_rp2040.md Outdated Show resolved Hide resolved
docs/platformdev_rp2040.md Outdated Show resolved Hide resolved
docs/platformdev_rp2040.md Outdated Show resolved Hide resolved
docs/platformdev_rp2040.md Outdated Show resolved Hide resolved
KarlK90 and others added 8 commits June 30, 2022 13:00
Supports regular and open-drain output configuration. RP2040 GPIOs are
sadly not 5V tolerant, so this is a bit use-less or needs extra hardware
or you take the risk to fry your hardware.
Co-authored-by: Nick Brassel <nick@tzarc.org>
@KarlK90 KarlK90 force-pushed the feature/raspberry-pi-rp2040-support branch from 2f2dfb0 to 44cced4 Compare June 30, 2022 11:04
@KarlK90 KarlK90 merged commit d717396 into qmk:develop Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RP2040 PR branch support