Hi,
Thanks for the answer, nice to know it's possible to do it,
can you point me any link to example for gcc ?
When you speak of scatter file, you means gcc linker script, or is it another file ?
ps: if this ITCM thread question grows, perhaps one must move it outside RP2040 thread.
Alexandre
[DEV] RP2040 support
-
- Posts: 77
- Joined: Sat Mar 19, 2016 8:07 pm
- Been thanked: 17 times
Re: [DEV] RP2040 support
Giovanni wrote:You need to create a custom scatter file, you can place things where you want.
To my knowledge, scatter files are used by the ARM compilers (armcc and armclang) and Keil. They are the equivalent to GCC linker scripts and serve the same purpose, just have a different syntax. GCC doesn't support these scatter files, you have to use linker scripts when you are using gcc and gnu ld.
Both, scatter files and linker scripts, allow you to place code in different parts of the memory. But they both rely on section names in the code to do this. So you have to add section attributes to the code to be able to place different parts of the code into different sections.
So to my knowledge scatter files and linker scripts are one part of the puzzle for support of loading code into RAM or ITCM. The other part is how and where to assign the section attributes to the functions.
Or am I misunderstanding something there?
- 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
Scatter files are a synonym of linker scripts.
GCC assigns each function a separate section name, you can allocate those section names freely. You may leverage the common prefix "ch" of function names also.
Giovanni
GCC assigns each function a separate section name, you can allocate those section names freely. You may leverage the common prefix "ch" of function names also.
Giovanni
-
- Posts: 12
- Joined: Mon Jun 14, 2021 5:42 pm
- Has thanked: 9 times
- Been thanked: 5 times
- Contact:
Re: [DEV] RP2040 support
Hi,
As I know it is right, the code is executed directly from the FLASH (XIP), but be aware my knowledge in this area is pretty limited. At this stage it wasn't a priority to copy things over to the RAM anyway, I focused on getting the Pico to boot from flash. There is a memmap_copy_to_ram.ld linker script in the PICO SDK which theoretically does what you want to achieve. The .data and .text sections are copied from flash to ram by marking the flash as the load memory address (LMA) and the RAM as the virtual memory address(VMA), but I don't know what does copy over the marked sections at runtime.
Szilveszter
From looking at your linker script it looks like you put the whole executable code into the flash and execute it directly from there (XIP). Is this correct?
As I know it is right, the code is executed directly from the FLASH (XIP), but be aware my knowledge in this area is pretty limited. At this stage it wasn't a priority to copy things over to the RAM anyway, I focused on getting the Pico to boot from flash. There is a memmap_copy_to_ram.ld linker script in the PICO SDK which theoretically does what you want to achieve. The .data and .text sections are copied from flash to ram by marking the flash as the load memory address (LMA) and the RAM as the virtual memory address(VMA), but I don't know what does copy over the marked sections at runtime.
Szilveszter
-
- Posts: 12
- Joined: Mon Jun 14, 2021 5:42 pm
- Has thanked: 9 times
- Been thanked: 5 times
- Contact:
Re: [DEV] RP2040 support
Hi again,
This time I want to ask Giovanni or other ChibiOS experts, that what are the consequences if I remove the ALIGN(1024) from the line 21 in os/common/startup/ARMCMx/compilers/GCC/ld/rules_code.ld.
Regards,
Szilveszter
This time I want to ask Giovanni or other ChibiOS experts, that what are the consequences if I remove the ALIGN(1024) from the line 21 in os/common/startup/ARMCMx/compilers/GCC/ld/rules_code.ld.
Code: Select all
SECTIONS
{
.vectors : ALIGN(1024)
{
KEEP(*(.vectors))
} > VECTORS_FLASH AT > VECTORS_FLASH_LMA
Regards,
Szilveszter
- 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
Some base addresses are wrong defined in rp2040.h file.
USB is 0x50110000, PIOs are 0x50200000 and 0x50300000. Another zero is added to these addresses.
Code: Select all
#define __USB_BASE (__AHBPERIPH_BASE + 0x01100000U)
#define __PIO0_BASE (__AHBPERIPH_BASE + 0x02000000U)
#define __PIO1_BASE (__AHBPERIPH_BASE + 0x03000000U)
USB is 0x50110000, PIOs are 0x50200000 and 0x50300000. Another zero is added to these addresses.
Re: [DEV] RP2040 support
I tried to write USB low level but it did not work well. The code is here: https://github.com/hanya/ChibiOS-Contri ... 558d3d7419
USB driver: https://github.com/hanya/ChibiOS-Contri ... LLD/USBDv1
Test code: https://github.com/hanya/ChibiOS-Contri ... 0-PICO-HID
It looks the device can respond to GET_DESCRIPTOR request. But the state does not proceed from SET_ADDRESS state.
The address received from the host is set to USB->DEVADDRCTRL register in usb_lld_set_address function.
But after that, anothre or more set address request is received from the host. So it seems somthings wrong in the response.
I have no enough knowledge to fix this problem.
Here is the result when I run the code, this output is came from UART by the picoprobe for debugging.
USB driver: https://github.com/hanya/ChibiOS-Contri ... LLD/USBDv1
Test code: https://github.com/hanya/ChibiOS-Contri ... 0-PICO-HID
It looks the device can respond to GET_DESCRIPTOR request. But the state does not proceed from SET_ADDRESS state.
The address received from the host is set to USB->DEVADDRCTRL register in usb_lld_set_address function.
But after that, anothre or more set address request is received from the host. So it seems somthings wrong in the response.
I have no enough knowledge to fix this problem.
Here is the result when I run the code, this output is came from UART by the picoprobe for debugging.
Code: Select all
-- Started in c1
1, setup
2, copy setup data, setup data is following 8 bytes
0x1000680, GET_DESCRIPTOR, device descriptor, device to host
0x400000, length up to 64
4, start_in
7, endpoint done
1
2
0x1000680
0x400000
4
7
1
2
0x160500, SET_ADDRESS, address 0x16, host to device
0x0, always zero
3, set_address from data
1
2
0x1000680
0x400000
4
7
1
2
- 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
If I remember well there was an option in the USB HLD about 2 possible modes of handling SET ADDRESS, you should look into that and decide which one matches this device.
Edit: search for USB_SET_ADDRESS_MODE in hal_usb.c.
Giovanni
Edit: search for USB_SET_ADDRESS_MODE in hal_usb.c.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 5 guests