Page 8 of 11

Re: [DEV] RP2040 support

Posted: Fri Jul 16, 2021 12:44 pm
by alex31
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

Re: [DEV] RP2040 support

Posted: Sat Jul 17, 2021 3:34 pm
by electronic_eel
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?

Re: [DEV] RP2040 support

Posted: Sat Jul 17, 2021 3:50 pm
by Giovanni
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

Re: [DEV] RP2040 support

Posted: Sun Jul 18, 2021 1:54 pm
by szilveszter
Hi,

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

Re: [DEV] RP2040 support

Posted: Sun Jul 18, 2021 2:00 pm
by szilveszter
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.

Code: Select all

SECTIONS
{
    .vectors : ALIGN(1024)
    {
        KEEP(*(.vectors))
    } > VECTORS_FLASH AT > VECTORS_FLASH_LMA
   


Regards,
Szilveszter

Re: [DEV] RP2040 support

Posted: Sun Jul 18, 2021 4:36 pm
by Giovanni
Vectors need to be aligned, the system would crash otherwise.

Giovanni

Re: [DEV] RP2040 support

Posted: Mon Aug 09, 2021 2:20 pm
by hanya
Some base addresses are wrong defined in rp2040.h file.

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

Posted: Sat Aug 14, 2021 1:43 pm
by FXCoder
Fixed in trunk.

Re: [DEV] RP2040 support

Posted: Wed Aug 25, 2021 12:38 pm
by hanya
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.

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

Re: [DEV] RP2040 support

Posted: Wed Aug 25, 2021 5:40 pm
by Giovanni
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