AdaCore / bb-runtimes

Source repository for the GNAT Bare Metal BSPs
Other
65 stars 51 forks source link

Add support for Raspberry Pi Pico (RP2040) #51

Closed damaki closed 3 years ago

damaki commented 3 years ago

This adds support for the dual-core RP2040 microcontroller and the Raspberry Pi Pico board.

Support is added for Ravenscar-full and Ravenscar-sfp runtimes only. Projects on the Pico that require a ZFP runtime can use the the generic zfp-cortex-m0p runtime, with startup code available in the pico_bsp crate in Alire.

Two runtime variants are supported for the Pico:

task Run_On_First_Core  with CPU => 1;
task Run_On_Second_Core with CPU => 2;

Further details are documented in arm/rpi/rp2040/README

damaki commented 3 years ago

One general comment about this pull request is that there is a lot of code copy pasted from various sources (like Pico SDK) with different copyright holders and I am not comfortable merging all this in our repo.

I understand your concern. The files that were adapted from the Pico SDK are:

The SVD files were generated from rp2040.svd that was contributed to the svd2ada project.

All other files in this contribution were written from scratch (e.g. s-bootro.adb), or were adapted from existing sources in bb-runtimes.

I could delete the code that was copied from the Pico SDK and replaced it with code that was adapted from other sources in bb-runtimes. For example, delete crt0.S.tmpl and replace it with an implementation adapted from arm/stm32/stm32f0xx/start-rom.S, and similarly for the memory maps.

The only remainining file would be boot2__w25q080.S which was pre-compiled from Pico SDK. I can look into replacing this with a pure Ada implementation.

Would that be acceptable to you?

damaki commented 3 years ago

One general comment about this pull request is that there is a lot of code copy pasted from various sources (like Pico SDK) with different copyright holders and I am not comfortable merging all this in our repo.

In commit db35c4c I've removed the startup code and linker scripts that were copied from the Pico SDK (i.e. the crt0.S.tmpl and memmap_*.ld files) and have replaced them with files that were adapted from existing sources in bb-runtimes (from the STM32 runtimes).

The only thing that still remains from Pico SDK is the precompiled bootloader (boot2__w25q080.S). I did some experiments trying to write a pure Ada implementation, but ran into several problems that made it quite difficult. Would you be happy to keep this file, or does it also need to be replaced?

JeremyGrosser commented 3 years ago

It's worth noting that all of the code that was copied from pico-sdk is BSD-3-Clause licensed and I've made rp2040_hal, pico_bsp, and pico_examples available under the same. The boot2 code is generated by preprocessing the BSD licensed code with Debian's FSF GCC toolchain which does not impose any additional license requirements on generated artifacts.

Fabien-Chouteau commented 3 years ago

Thanks for the update @damaki

The only thing that still remains from Pico SDK is the precompiled bootloader (boot2__w25q080.S). I did some experiments trying to write a pure Ada implementation, but ran into several problems that made it quite difficult.

What was the problem?

Would you be happy to keep this file, or does it also need to be replaced? Ideally having a source version would be best.

Fabien-Chouteau commented 3 years ago

The boot2 code is generated by preprocessing the BSD licensed code with Debian's FSF GCC toolchain which does not impose any additional license requirements on generated artifacts.

It is not so much about the license, but the Contributor License Agreement.

damaki commented 3 years ago

What was the problem?

The main challenges I came across was a) fitting it all in 252 bytes, and b) lack of initialsation on entry to the bootloader. Mainly it was getting it all to fit into 252 bytes, though, given that I needed more initialisation in the pure Ada code (e.g. needed a stack pointer).

Ideally having a source version would be best.

It is not so much about the license, but the Contributor License Agreement.

Thanks for clarifying. I'll continue working on a clean implementation of the bootloader, along with associated scripts to generate the CRC etc during runtime generation.

damaki commented 3 years ago

Closing this PR as this work has since been updated & rebased to the community-2021 branch. See #55.