Recent

Author Topic: Raspberry Pi Pico and Freepascal  (Read 9873 times)

MiR

  • Full Member
  • ***
  • Posts: 225
Re: Raspberry Pi Pico and Freepascal
« Reply #30 on: April 03, 2021, 07:23:48 pm »
Today I have adjusted code to a major internal change in the pico-sdk, to better support flash chips in different sizes and from different manufacturers the foundation has created board specific 2nd stage bootloaders.

I have implemented this also in my repo, but there are also changes needed in the fpc compiler itself to support this.

So, please make sure that you upgrade to both latest/greatest versions of both of my repositories:

https://github.com/michael-ring/freepascal

and

https://github.com/michael-ring/pico-fpcexamples

Users of fpcupdeluxe should select 'embedded' as FPC-Version in Basic Tab and then Install/update FPC only or both FPC+Laz.

Then switch to Cross Tab, select 'arm' and 'embedded' and then select subarch armv6m and then 'Install Compiler'

Please currently do not us 'update all' as there may be an issue with that function, please see:

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues/374

Update:

for now, please use

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/1.8.2m

version, this fixes the issue that after rebuild the system unit cannot be found.


Update: latest fpcupdeluxe 1.8.2r fixes the issues

Have fun,

Michael

« Last Edit: April 15, 2021, 04:06:12 pm by MiR »

dbannon

  • Hero Member
  • *****
  • Posts: 2045
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Raspberry Pi Pico and Freepascal
« Reply #31 on: May 04, 2021, 03:20:09 am »
Hi Michael, time I said thanks for this, especially the well written docs on the wiki.  Great job !

Documenting stuff is boring but essential for our open source ideals !

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

MiR

  • Full Member
  • ***
  • Posts: 225
Re: Raspberry Pi Pico and Freepascal
« Reply #32 on: May 07, 2021, 06:46:15 pm »
Thank you!

Just a quick update, I did a workaround to fix a crash when sysutils are used, please both update fpc and my repo if you need to use sysutils

(See issue #38864)

Michael

MarkMLl

  • Hero Member
  • *****
  • Posts: 4766
Re: Raspberry Pi Pico and Freepascal
« Reply #33 on: November 07, 2021, 02:39:58 pm »
I've just been reading through this thread, since I've noticed somebody I'm likely to buy some oddments from selling a Pico on a development breakout board for about £16.

Any idea what the poster @turronet means here:

As a noob I ordered 1 pico only, so I'll buy the debugger soon.

Is he referring entirely to something like https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_Raspberry_Pi_Pico_Debugging_the_onboard_LED where a second Pico is used as a remote debugging bridge for gdb?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MiR

  • Full Member
  • ***
  • Posts: 225
Re: Raspberry Pi Pico and Freepascal
« Reply #34 on: November 07, 2021, 02:53:26 pm »
Yes, he is referring to the article.

VisualLab

  • New Member
  • *
  • Posts: 28
Re: Raspberry Pi Pico and Freepascal
« Reply #35 on: February 05, 2022, 01:34:49 am »
I purchased an RPi Pico clone (RP2040-Plus) a week ago. And I've been browsing the Raspberry Pi Pico SDK for a few days now. In the header file address_mapped.h in the directory (relative path): ... \pico-sdk-master\src \rp2_common\hardware_base\include\hardware, I came across a line of code:

Code: C  [Select][+][-]
  1. *(io_rw_32 *) hw_set_alias_untyped((volatile void *) addr) = mask;

The file address_mapped.h is available at: https://raspberrypi.github.io/pico-sdk-doxygen/address__mapped_8h_source.html. The quoted line comes from the function: hw_set_bits. Its code is:

Code: C  [Select][+][-]
  1. __force_inline static void hw_set_bits(io_rw_32 *addr, uint32_t mask) {
  2.     *(io_rw_32 *) hw_set_alias_untyped((volatile void *) addr) = mask;
  3. }

This line has a macro named "hw_set_alias_untyped" (located in the same file). The question is: to "what" is assigned the value of "mask" argument?

On the left side there is a macro "hw_set_alias_untyped" which will be replaced with: "((uintptr_t) (addr))". After its substitution and expansion, the following expression will appear (unless I made a mistake):

Code: C  [Select][+][-]
  1. *(io_rw_32 *) ((uintptr_t)(volatile void *) addr) = mask;

The argument "addr" is the address of register RP2040, mapped to memory. This address ("addr") is cast to the amorphous pointer ("volatile void *") and then to the pointer "uintptr_t" (again: unless I made a mistake). To make the analysis easier, I simplified it to:

Code: C  [Select][+][-]
  1. macro_result = ((uintptr_t)(volatile void *) addr) // simplification that I mean
  2. *(io_rw_32 *) macro_result = mask; // the resulting expression after simplification

Is the macro output some "anonymous variable" (no name)? Is the left part of the expression a dereference of a pointer of type "io_rw_32" whose content is computed from this expression? Does this mean that the contents of the "mask" argument are assigned to "that something" that arises after dereference?

 

TinyPortal © 2005-2018