I tried to link boot_double_tap_check function from pico-sdk which allow us to enter bootloader by double push the reset button.
The function has __attribute__((constructor)) attribute, so it called before main function.
In the case of pico-sdk based program, runtime_init function is called before main function is called to set up some state including clocks.
But in the case of ChibiOS based program, clocks are set up in halInit function called in main function.
As a result, boot_double_tap_check function can not work with ChibiOS startup program.
[DEV] RP2040 support
- Giovanni
- Site Admin
- Posts: 14382
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1065 times
- Been thanked: 908 times
- Contact:
Re: [DEV] RP2040 support
hanya wrote:Please add structure definition for PWM register.Code: Select all
diff --git a/os/common/ext/RP/RP2040/rp2040.h b/os/common/ext/RP/RP2040/rp2040.h
index 01c911d..7423d88 100644
--- a/os/common/ext/RP/RP2040/rp2040.h
+++ b/os/common/ext/RP/RP2040/rp2040.h
@@ -896,6 +896,67 @@ struct {
} CLR;
} ADC_TypeDef;
Hi,
Forgot about this, committed.
Giovanni
- Giovanni
- Site Admin
- Posts: 14382
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1065 times
- Been thanked: 908 times
- Contact:
Re: [DEV] RP2040 support
hanya wrote:I tried to link boot_double_tap_check function from pico-sdk which allow us to enter bootloader by double push the reset button.
The function has __attribute__((constructor)) attribute, so it called before main function.
In the case of pico-sdk based program, runtime_init function is called before main function is called to set up some state including clocks.
But in the case of ChibiOS based program, clocks are set up in halInit function called in main function.
As a result, boot_double_tap_check function can not work with ChibiOS startup program.
I expect many more incompatibilities with the SDK, please feel free to make suggestions on the various topics.
Giovanni
-
- Posts: 77
- Joined: Sat Mar 19, 2016 8:07 pm
- Been thanked: 17 times
Re: [DEV] RP2040 support
Just to keep the RP2040 related posts in this thread:
I have created patches to build the stage2 bootloader into ChibiOS. This allows to boot from flash.
I posted the patches here.
I have created patches to build the stage2 bootloader into ChibiOS. This allows to boot from flash.
I posted the patches here.
-
- Posts: 1
- Joined: Tue Feb 22, 2022 5:34 am
Re: [DEV] RP2040 support
electronic_eel wrote:Just to keep the RP2040 related posts in this thread:
I have created patches to build the stage2 bootloader into ChibiOS. This allows to boot from flash.
I posted the patches here.
I would like to confirm that the demo program supplied compiled successfully and worked on my RP2040.
-
- Posts: 77
- Joined: Sat Mar 19, 2016 8:07 pm
- Been thanked: 17 times
Re: [DEV] RP2040 support
The Raspberry Pi foundation released the pico-sdk 1.3.0 version some time ago.
Updating the pico-sdk in ChibiOS worked without issues, I just had to update the files in the "ext" directory and the version file in "/os/various/pico_bindings/dumb/include/pico/version.h".
In the release notes they mention that the pico-sdk now contains CMSIS headers. Unfortunately they just have included CMSIS-core, meaning just the IRQ definitions, SystemCoreClock and very basic defines like "__CM0PLUS_REV". What is not included are the register and address definitions for all the peripheral functions. They still have those just defined in their own scheme and don't provide them in a CMSIS compatible way. So the custom file "/os/common/ext/RP/RP2040/rp2040.h" can't be replaced with a upstream version.
Updating the pico-sdk in ChibiOS worked without issues, I just had to update the files in the "ext" directory and the version file in "/os/various/pico_bindings/dumb/include/pico/version.h".
In the release notes they mention that the pico-sdk now contains CMSIS headers. Unfortunately they just have included CMSIS-core, meaning just the IRQ definitions, SystemCoreClock and very basic defines like "__CM0PLUS_REV". What is not included are the register and address definitions for all the peripheral functions. They still have those just defined in their own scheme and don't provide them in a CMSIS compatible way. So the custom file "/os/common/ext/RP/RP2040/rp2040.h" can't be replaced with a upstream version.
Re: [DEV] RP2040 support
Hi,
I noticed that the RP2040 PAL driver does not support events so I extended the LL driver to support line events. There are 2 configuration options:
1. RP_PAL_EVENT_CORE_AFFINITY (default 0) - core that handles the interrupts
2. RP_IO_IRQ_BANK0_PRIORITY (default 2) - priority of the interrupt handler
Since the Git repository is RO, I am attaching the two files here.
I noticed that the RP2040 PAL driver does not support events so I extended the LL driver to support line events. There are 2 configuration options:
1. RP_PAL_EVENT_CORE_AFFINITY (default 0) - core that handles the interrupts
2. RP_IO_IRQ_BANK0_PRIORITY (default 2) - priority of the interrupt handler
Since the Git repository is RO, I am attaching the two files here.
- Attachments
-
- hal_pal_lld.zip
- (5.57 KiB) Downloaded 41 times
- Giovanni
- Site Admin
- Posts: 14382
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1065 times
- Been thanked: 908 times
- Contact:
Re: [DEV] RP2040 support
Hi Thanks,
I will handle that, feel free to join our discord server for code contributions, the link is in the standing post.
Giovanni
I will handle that, feel free to join our discord server for code contributions, the link is in the standing post.
Giovanni
Re: [DEV] RP2040 support
Hi,
I just realized that there is a bug in the IRQ handler that suppresses callbacks/events for line # > 7. Here is a diff of the fix:
--- a/hal_pal_lld.c
+++ b/hal_pal_lld.c
@@ -62,11 +62,10 @@ palevent_t _pal_events[30];
OSAL_IRQ_HANDLER(RP_IO_IRQ_BANK0_HANDLER) {
OSAL_IRQ_PROLOGUE();
- int line = 0;
-
for(int i=0; i < 4; ++i) {
uint32_t ints = IO_BANK0->PROC[RP_PAL_EVENT_CORE_AFFINITY].INTS[i];
IO_BANK0->INTR[i] = ints;
+ int line = i*8;
while(ints) {
if (ints & 0x0FU)
_pal_isr_code(line);
BR
I just realized that there is a bug in the IRQ handler that suppresses callbacks/events for line # > 7. Here is a diff of the fix:
--- a/hal_pal_lld.c
+++ b/hal_pal_lld.c
@@ -62,11 +62,10 @@ palevent_t _pal_events[30];
OSAL_IRQ_HANDLER(RP_IO_IRQ_BANK0_HANDLER) {
OSAL_IRQ_PROLOGUE();
- int line = 0;
-
for(int i=0; i < 4; ++i) {
uint32_t ints = IO_BANK0->PROC[RP_PAL_EVENT_CORE_AFFINITY].INTS[i];
IO_BANK0->INTR[i] = ints;
+ int line = i*8;
while(ints) {
if (ints & 0x0FU)
_pal_isr_code(line);
BR
- Giovanni
- Site Admin
- Posts: 14382
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1065 times
- Been thanked: 908 times
- Contact:
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 5 guests