Lazarus

Programming => Embedded => Operating Systems => Embedded - ARM => Topic started by: MiR on January 22, 2021, 10:14:00 pm

Title: Raspberry Pi Pico and Freepascal
Post by: MiR on January 22, 2021, 10:14:00 pm
Raspberry Organization announced the Raspberry Pi Pico:

https://www.raspberrypi.org/blog/raspberry-pi-silicon-pico-now-on-sale/

https://www.raspberrypi.org/products/raspberry-pi-pico/specifications/

which looks like a quite interesting (and cheap) microcontroller board with dual-core Cortex-M0.

The chip will also show up in Boards from Adafruit, Sparkfun and Arduino so I guess it will get quite popular.

I would like to spend some time in making this board available in Freepascal, anybody interested in joining the effort?

My boards should arrive in a week or so, I already created a version of FreePascal that automagically creates uf2 files for easy uploading of firmware to the board, now there is 'only' the task of creating a good unit for the board.

If you would like to help out please order at least two boards as you can use one board as a debug probe with software provided by Raspberry Foundation.

Michael
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on January 22, 2021, 10:29:46 pm
You beat me to it :-)

Review at https://hackaday.com/2021/01/20/raspberry-pi-enters-microcontroller-game-with-4-pico/

The really interesting question is whether some cut-down version of FPC's threads could be implemented.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on January 22, 2021, 10:46:01 pm
I think Christo Crause has done some threads groundwork for freepascal on the esp32-freertos platform, theoretically freertos should run just fine on the board so what he did should also apply to the Pico.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: ccrause on January 23, 2021, 07:01:23 am
I think Christo Crause has done some threads groundwork for freepascal on the esp32-freertos platform, theoretically freertos should run just fine on the board so what he did should also apply to the Pico.
It (https://github.com/ccrause/fpc-esp-freertos/blob/master/freertos-fpc/fthreads.pp) is a proof of concept with some ESP specific bits, but that can be fixed.  An alternative could be to use the pthreads (https://www.freertos.org/API/FreeRTOS_POSIX_pthread.html) library add-on which should be (more or less) compatible with FPC's cthreads wrapper unit.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on January 23, 2021, 05:21:29 pm
I implemented initial support for Raspi pico boards here:

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

Supported boards are:

RASPI_PICO
FEATHER_RP2040
ITZYBITZY_RP2040

I have not yet received Hardware so expect issues.....

StartupCode will likely need additional fixing to send the 2nd cpu to sleep on startup and names of IRQ Handlers are a mess and will likely have to change, RPI decided to give them non-CMSIS conformant naming (in fact there is no real naming) so I got creative myself here....

The repo also includes support for tons of STM32 chips and support for creating UF2 bootloader images.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on January 29, 2021, 02:12:03 pm
My pico's arrived....

As weather is bad over the weekend I will play with them and will see that I create a pico related page on the Lazarus Wiki......
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on January 30, 2021, 02:11:49 pm
There is a bare metal version of FreePascal for the Raspi: Ultibo.

Are you saying that the FPC compiler will run hosted by Ultibo? Are you also saying that FPC already been ported to the Pico?

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on January 30, 2021, 03:59:19 pm
I guess there is a misunderstanding on Germo's side what the Raspberry Pi Pico is

it is a Cortex-M0 Dualcore and has nothing to do with the original Raspberry Pi, as far as I know Ultibo covers the native Programming on the Raspberry Pi (but honestly I did not check if they also work on a port to the Pico)

fpc will soon be ported to be able to support the raspberry pi pico, this is work in progress and cal be followed in my freepascal repo (which I will upgrade later today to cover the changes I did since I received the hardware)

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

I have also already written some chapters on the Freepascal Wiki, you can already follow the first steps there but I will take the weekend to finish up the initial writeup, currently there are still some todo's in the documentation as I first do all on my Mac and then 'backport' the documentation bits to Windows.

Landing page on the Wiki is here:

https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_FPC_and_the_Raspberry_Pi_Pico



Michael
Title: Re: Raspberry Pi Pico and Freepascal
Post by: PascalDragon on January 30, 2021, 06:33:48 pm
Perhaps these sources could help develop a Pi Pico version of FreePascal

As MiR said, the Raspberry Pi and the Raspberry Pi Pico are two entirely different things. The Pico is essentially a Microcontroller like an Arduino or ESP32 while the normal Pi is a hardware suitable for a normal OS (be it Linux, Windows or Ultibo).
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on January 30, 2021, 06:48:26 pm
No. I tried to say that there is a version of FreePascal (Named Ultibo) that creates Bare Metal code for a Raspberry Pi.
Perhaps these sources could help develop a Pi Pico version of FreePascal

Ultibo is an operating system, not a compiler. Do you know the difference?

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on January 30, 2021, 07:35:07 pm
Ultibo is the version of FreePascal that create 'Bare Metal' code. Do you know what that is?

Rubbish. Ultibo is a minimal OS that runs on a bare-metal RPi, and typically integrates user-defined functionality (i.e. the sort of thing that on a larger-scale OS would be loaded from some sort of file). It is built using standard FPC with some very minor additions to support that specific target, it is still fundamentally the same FPC and the Ultibo and core FPC developers work together... it is NOT a fork of the FPC project and the changes are minimal. Similarly, the Lazarus IDE has minor tweaks to support Ultibo as a target.

The Pico is a completely different chip from what's been used in the conventional RPis, as multiple people are trying to tell you. Neither the Ultibo project nor its supporting tools are substantial help.

And I'd add that I've been doing bare-metal stuff for around 30 years.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: lucamar on January 30, 2021, 07:40:47 pm
No. I tried to say that there is a version of FreePascal (Named Ultibo) that creates Bare Metal code for a Raspberry Pi.
Perhaps these sources could help develop a Pi Pico version of FreePascal
Ultibo is an operating system, not a compiler. Do you know the difference?
MarkMLl

To quote the ultibo site ( http://www.ultibo.org ): [... snip ...]

A, perhaps, better quote would be this, from their FAQ:

Quote
What is Ultibo?
Ultibo core is an embedded or bare metal development environment for Raspberry Pi. It is not an operating system but provides many of the same services as an OS, things like memory management, networking, filesystems and threading plus much more. So you don’t have to start from scratch just to create your ideas.

So it's "kind of but not quite" an OS providing a minimum environment for application level development.  Kind of like MS-DOS on steroids for RPi :D
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on January 30, 2021, 08:11:46 pm
So it's "kind of but not quite" an OS providing a minimum environment for application level development.  Kind of like MS-DOS on steroids for RPi :D

Well of course, "what is an OS" has been a subject of debate ever since MS released their "DOS" which became the immediate butt of jokes from the UNIX crowd.

Is something still an OS if all its application code is preloaded into the same binary image? I think that some of the early Windows versions did that, and more to the point there's a whole lot of embedded OSes from people like Wind River (or were they bought up? I forget) which similarly came as binary modules to which application code was linked.

For that matter, is a hypervisor an OS? After all, in cases like IBM's CP it very often came prebuilt with a small number of CMS VMs and the fact that they could load programs is not directly relevant.

Does an OS have to be preemptive? Is being preemptive a sufficient condition (clearly not, since most embedded hardware uses interrupts).

Does an OS have to have memory protection? No, because- as particular examples- early IBM mainframes didn't have memory protection, and there have been cut-down unix clones which ran without an MMU (e.g. CTOS/BTOS plus things like Coherent).

Is "Arduino" an OS? The water is obviously muddied there because "Arduino" describes lots of different things: the development framework (which includes GCC), the libraries and APIs, the hardware definitions, and a number of actual physical "deliverables".

The important point though is that Ultibo itself is not a compiler, and is of limited direct help when considering porting a compiler to a new target.

MarkMLl

Title: Re: Raspberry Pi Pico and Freepascal
Post by: lucamar on January 30, 2021, 08:23:30 pm
The important point though is that Ultibo itself is not a compiler, and is of limited direct help when considering porting a compiler to a new target.

One (maybe the only?) thing which might relate to that is their adaptation of the RTL. Other than that ... I can think of nothing; maybe they built Ultibo with FPC in mind, so it's better adapted to FP programming than other OS(-alikes) but whether that is germaine to the point ... I don't really know. I don't know that much about it. :-[
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on January 30, 2021, 08:35:58 pm
The important point though is that Ultibo itself is not a compiler, and is of limited direct help when considering porting a compiler to a new target.

One (maybe the only?) thing which might relate to that is their adaptation of the RTL. Other than that ... I can think of nothing; maybe they built Ultibo with FPC in mind, so it's better adapted to FP programming than other OS(-alikes) but whether that is germaine to the point ... I don't really know. I don't know that much about it. :-[

I've never investigated the extent to which Pascal (including FPC's dialect) is adequate for an OS. My suspicion is that the coroutine functionality provided by e.g. Modula-2 helps a lot, and I have in fact used Modula-2 for an x86 protected-mode OS with /no/ assembly-code glue (it did, however, use custom tools to bind the binary to a descriptor table definition hence exploit various hardware-provided gates).

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on January 31, 2021, 06:06:08 pm
I have now pushed latest changes to my freepascal repository, so far things look good, I can run code through the debugger and can also simply drag & drop the generated uf2 binary to my pico when I am in bootloader mode.

GPIO and UART work, time to clean up everything and to wait for first feedback....

Those initial steps were easier than I thought, not too many roadblocks in the way.

Has anybode else beside me already bought a pico?

Michael
Title: Re: Raspberry Pi Pico and Freepascal
Post by: ccrause on January 31, 2021, 06:17:44 pm
Has anybode else beside me already bought a pico?
Not yet, I'm still trying to understand 8 bit AVRs. And ESPs. So much to learn, so little time :o
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on January 31, 2021, 07:21:14 pm
I like it that there are now cheap chips/boards with more Ram and Flash, before the pico showed up i played arround with the Seeduino Xiao and the WIO Terminal (well, mostly Alfred has done quite some magic with that board), not always running out of RAM is such a nice experience....
Title: Re: Raspberry Pi Pico and Freepascal
Post by: petex on February 01, 2021, 08:43:25 pm
Quote
Has anybode else beside me already bought a pico?

Yes, I got one Saturday. Still working on evaluating the STM32 card. It looks more powerful than the STM32 at roughly the same price. The sites selling the PICO in the UK seem to be rationing them at the moment. I will be keen to get working on it soon as possible.

Are my efforts on getting the Pi debugger interface to work on the STM32 transferable to the Pico ?

I am especially interested in the analog conversion side for a project I am looking at. I may be wrong but are less analog channels available on the Pico ?. There are 8 on the STM blue pill card.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on February 01, 2021, 09:31:21 pm
The pico only has 3 anolog inputs, what do you plan to do with analog?

You can use your raspberry pi to debug the pico, in the getting started document are explanations how to build a special version of openocd needed for the pico.

Using a second pico is easier but when you say devices get rationed then the raspi will do.

Debuging the pico in lazarus works the same as debugging the stm32.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: turronet on February 13, 2021, 02:11:49 pm
First of all, areally big Thank You MiR for Your effort on supporting the pico.
I received mine and I immediately look for the fpc way, so I'm here.
As a noob I ordered 1 pico only, so I'll buy the debugger soon.
I'm thinking about creating a unit for each header (pico_gpio.pas, pico_uart.pas, rtc..), does it make sense?

I'm trying to get the blink sample You published working, the first compile and run on a pico without any issue, the problem is on the second example at full speed:
Code: Pascal  [Select][+][-]
  1. Compile Project, OS: embedded, CPU: arm, Target: project1.elf: Exit code 1, Errors: 9, Hints: 3
  2. Hint: Start of reading config file /home/turro/fpc-embedded/fpc/bin/x86_64-linux/fpc.cfg
  3. Hint: End of reading config file /home/turro/fpc-embedded/fpc/bin/x86_64-linux/fpc.cfg
  4. Verbose: Free Pascal Compiler version 3.3.1-r48418 [2021/02/04] for arm
  5. Verbose: Copyright (c) 1993-2020 by Florian Klaempfl and others
  6. Verbose: Target OS: Embedded
  7. Verbose: Compiling project1.lpr
  8. project1.lpr(15,10) Hint: Local proc "__aeabi_uidiv" is not used
  9. Verbose: Assembling project1
  10. Error: /home/turro/fpc-embedded/projects/Blinky_pico/clocks.c.obj: In function `clock_configure':
  11. Error: /home/turro/Documenti/Raspberrypico/pico-sdk/src/rp2_common/hardware_clocks/clocks.c:52: undefined reference to `__aeabi_uldivmod'
  12. Error: /home/turro/Documenti/Raspberrypico/pico-sdk/src/rp2_common/hardware_clocks/clocks.c:46: undefined reference to `__assert_func'
  13. Error: /home/turro/fpc-embedded/projects/Blinky_pico/pll.c.obj: In function `pll_init':
  14. Error: /home/turro/Documenti/Raspberrypico/pico-sdk/src/rp2_common/hardware_pll/pll.c:26: undefined reference to `__assert_func'
  15. Error: /home/turro/Documenti/Raspberrypico/pico-sdk/src/rp2_common/hardware_pll/pll.c:29: undefined reference to `__assert_func'
  16. Error: /home/turro/Documenti/Raspberrypico/pico-sdk/src/rp2_common/hardware_pll/pll.c:35: undefined reference to `__assert_func'
  17. Error: /home/turro/Documenti/Raspberrypico/pico-sdk/src/rp2_common/hardware_pll/pll.c:39: undefined reference to `__assert_func'
  18. Linking /home/turro/fpc-embedded/projects/Blinky_pico/project1
  19. project1.lpr(51,0) Error: Error while linking
  20. project1.lpr(51,0) Verbose: There were 1 errors compiling module, stopping
  21. Verbose: Compilation aborted
  22. Verbose: /home/turro/fpc-embedded/fpc/bin/x86_64-linux/ppcrossarm returned an error exitcode
  23.  

Any suggestion?
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on February 13, 2021, 02:33:57 pm
I have already created units for most stuff, but to be able to publish those changes I need to do some groundwork to better support automagically building new versions of fpc+rtl as there are often also small changes needed to rtl and it is quite time-consuming to manually build & distribute binary builds  of fpc with better pico support.

But I think we are pretty close at having this covered, so please bear with me a few more days.....
 
Did you build the obj files from source yourself or did you use the checked in versions on github?
https://github.com/michael-ring/pico-fpcexamples

There has been a version 1.0.1 of the pico sdk, so if you built the obj yourself they might differ a bit.

If you did not build them yourself and used mine I will have to clean up my mess, so please let me know  ;)

Michael
Title: Re: Raspberry Pi Pico and Freepascal
Post by: turronet on February 13, 2021, 03:31:47 pm
I confirm that using c.objs taken from fpc-examples github compiles and blink, I was previously using c.obj compiled from scratch by me, I assumed they were the same but probably few updates in the sdk make them different.
Ok I wait for Your next update, I trust You, please free me from python  :)
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on February 13, 2021, 09:16:46 pm
Just found this interesting project on github:

https://github.com/majbthrd/pico-debug

looks like it is possible to debug one single raspi with itself.....
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on February 13, 2021, 10:11:30 pm
Just found this interesting project on github:

https://github.com/majbthrd/pico-debug

looks like it is possible to debug one single raspi with itself.....

Now that's /very/ interesting, and immediately has the Pico leapfrogging the Teensy which has been promising proper debugging for years... provided obviously that its I/O complement is adequate.

It reminds me very much of something that Sun did with their earliest enterprise-grade servers, which had originally been designed by Xerox PARC: there were 4x CPUs per board, and one could be reserved to debug the OS etc. running on the others.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on February 16, 2021, 08:46:15 pm
Thirdpartys are coming tothe party, found this nice tiny2040 board from Pimoroni, looks interesting for space constrained projects:


https://shop.pimoroni.com/products/tiny-2040

Picture:

https://cdn.shopify.com/s/files/1/0174/1800/products/tiny-2040-2_1024x1024.jpg?v=1613312180

Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on February 28, 2021, 09:38:10 pm
It finally happened!!!

Perhaps you have seen it elsewhere but DonAlfredo has released a new Version of FPCUpdeluxe which makes instaling and configuring Lazarus + FPC for embedded targets an easy task.

To celebrate the Event I have updated the Wiki with new Articles and I have also uploaded improoved code to the githup repo for the pico....

Please have a look and let me know what else we need, which i2c/spi devices we should show closer in a Tutorial.

Many, many many Thanks to Don Alfredo who has spent quite some weekends to make this new version of FPCUPdeluxe happen.....

Here are some links:

The new Tutorial on how to use FPCUPdeluxe to install embedded targets:

https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_Installing_Lazarus_and_Free_Pascal

Overview Page of Pico Tutorials:

https://wiki.freepascal.org/ARM_Embedded_Tutorial_-_FPC_and_the_Raspberry_Pi_Pico

Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on March 04, 2021, 04:37:00 pm
I today received the TINY 2040, like the size!
Title: Re: Raspberry Pi Pico and Freepascal
Post by: AlanTheBeast on March 07, 2021, 08:13:36 pm
Pico looks great!

The lack of an FPU might be a turn-off for my current project, however, but once I have timing on it (RPi3 B+ / 4B) I might get the Pico to see if it could handle the load.  (I confess that the 4B is probably brute force for the project).  Lots of FP in it however.  To date the project does not use analog I/O but I was thinking of BITEing the project once all is together on the sensor end and that would need analog support (separate small board perhaps).

I've been off in Ultibo land for the weekend.  Nice OS-less environment with an awful lot of device support and a "Lazarus-Ultibo" IDE.  Need to hook deeper - still waiting on h/w from the US (GPS, gyro/accel)...
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on April 02, 2021, 05:02:21 pm
Quick update, obj files were updated to latest v1.1.1 of pico sdk, a few days ago support for st7789 displays was added.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR 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

Title: Re: Raspberry Pi Pico and Freepascal
Post by: dbannon 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
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR 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
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl 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
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on November 07, 2021, 02:53:26 pm
Yes, he is referring to the article.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: VisualLab 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 (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?
Title: Re: Raspberry Pi Pico and Freepascal
Post by: avra on August 21, 2022, 11:53:27 pm
I have just received YD-RP2040 16MB USB-C compatible with single WS2812 and USR key, and it worked great in every test I made so far  :D
Title: Re: Raspberry Pi Pico and Freepascal
Post by: VisualLab on August 22, 2022, 12:54:44 am
I can see that the YD-RP2040 board differs from the original RPi Pico and the clone I bought (Waveshare RP2040-Plus) with the ADC3 signal on pin 35. In the original and the clone:

- pin 35 is used to connect the reference voltage for the ADC,
- ADC3 signal is permanently connected to the temperature sensor.

In the YD-RP2040 board, the pin for connecting the reference voltage for the ADC is leaded out separately. It seems to me that the YD-RP2040 board is better designed than the original (ie RPi Pico) and the Waveshare clone. I do not see any advantages of the solution introduced by the RPi foundation regarding the ADC3 signal. It struck me as a quirk from the beginning.

Anyway, the actions of the RPi foundation are a mixture of good ideas about hardware solutions (e.g. RPi 1-4, RP2040 microcontroller) with stupid software ideas (OS for RPi based on Debian /root account locked in GUI/, choice of Visual Studio Code and CMake for RPi Pico, Python). Python is not suitable for electronics applications (basic of automation). Yes, Python is popular. But with it it is like with the Trabant car in DDR - a lot of people used it because it was cheap. It was mass-produced, because it had a primitive design, which made it easy and cheap to produce.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on August 22, 2022, 09:17:31 am
In the YD-RP2040 board, the pin for connecting the reference voltage for the ADC is leaded out separately. It seems to me that the YD-RP2040 board is better designed than the original (ie RPi Pico) and the Waveshare clone. I do not see any advantages of the solution introduced by the RPi foundation regarding the ADC3 signal. It struck me as a quirk from the beginning.

It must be said that the SDK etc. is intended for the RP2040 rather than for the Pico. The real "gotcha" is that the crosspoint switching between peripherals and pins is subdivided, so UART0 can appear on only a small number of pins, UART1 on a different group and so on. That's not too bad, until you have something like the Cytron board that I've got which has put an ESP8266 on pins which can only be connected to UART0... meaning that any serial output that would normally be on UART0 has to be moved to either UART1 or USB. And whenever the firmware is reloaded is resets the USB, which means that the host computer might allocate it to a different named device.

Quote
Anyway, the actions of the RPi foundation are a mixture of good ideas about hardware solutions (e.g. RPi 1-4, RP2040 microcontroller) with stupid software ideas (OS for RPi based on Debian /root account locked in GUI/,

I presume that you're talking there about the "classic" RPi plus Raspbian or whatever they call it these days: you /are/ aware aren't you that you can set up other named accounts? I'm not sure that's any worse than the Ubuntu philosophy where the standard is (or at least was) to have a root account which can't be logged into directly.

Quote
choice of Visual Studio Code and CMake for RPi Pico, Python). Python is not suitable for electronics applications (basic of automation). Yes, Python is popular. But with it it is like with the Trabant car in DDR - a lot of people used it because it was cheap. It was mass-produced, because it had a primitive design, which made it easy and cheap to produce.

Cmake is pretty gruesome and I'm having a hard time with its documentation for even simple jobs, but I think that what's happened is that they used it for the SDK and assumed it would be welcomed for application firmware as well.

VSCode has a Trojan that I'm still characterising, don't use.

Python... I loathe the language, but the last few years have demonstrated that it's serviceable for tacking stuff together. If you have to criticise anybody, I suggest directing your ire at the people who think that a good way to design a user interface is to embed Javascript and a browser engine into a program.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: avra on August 22, 2022, 12:03:54 pm
I can see that the YD-RP2040 board differs from the original RPi Pico...
I like all the changes they made  8-)

Anyway, the actions of the RPi foundation are a mixture of good ideas about hardware solutions (e.g. RPi 1-4, RP2040 microcontroller) with stupid software ideas (OS for RPi based on Debian /root account locked in GUI/, choice of Visual Studio Code and CMake for RPi Pico, Python). Python is not suitable for electronics applications (basic of automation).
- I like Debian and Manjaro, so I am fine with their default choice. Who doesn't has plenty of options. Changing whole distro, or just a desktop environment is not hard.
- I like VScode editor, debugging and extensions. Without VScode, I would be stuck with Arduino IDE or have to learn a new IDE for each target I need (and yes, I worked with Eclipse).
- Python is fine for many use cases, even in electronics (CircuitPython). It is now what BASIC used to be in 20th century. Yes, for some apliances there might be much better tools, but it is nice for quick prototyping and if that is the only language you know, you will not want to learn a new language unless you hit some serious wall. In today's world bying a bigger hammer is more often used then investing time and knowledge to optimize existing solution (unless we speak of real high volume production where every cent counts and where it is more then justified).

VSCode has a Trojan that I'm still characterising, don't use.
If you can live without some extensions, then maybe VScodium could be the solution:
https://mspoweruser.com/vscodium-is-a-clean-vscode-build-without-the-microsoft-customizations/
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on August 22, 2022, 12:25:36 pm
The RPi's OS does undoubtedly have some significant issues.

* Too much needs root permission on account of GPIO etc. access.

* While kernel GPIO support is improving, the v2 API had major deficiencies when I last looked.

* The home-grown window manager fails to pass various settings to X11, giving some apps major problems.

* It's decidedly short of GUI support for creating new users and modifying access rights.

And so on...

I agree with your (@Avra) point about VSCode being a half-decent IDE, and in any event being vastly superior to Eclipse etc... it's a great pity that Lazarus doesn't have C/C++ support.

However, the only way I'm prepared to run it is either in a Docker container (which will probably break debugging access to the Picoprobe) or completely isolated from my main development system. I've seen some extremely worrying background behaviour, and I'd point out that it's installed with root access and that even on Debian all VSCode updates come directly from MS servers and run MS-supplied installation scripts with root permissions.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: VisualLab on August 22, 2022, 02:31:11 pm
Quote
It must be said that the SDK etc. is intended for the RP2040 rather than for the Pico. The real "gotcha" is that the crosspoint switching between peripherals and pins is subdivided, so UART0 can appear on only a small number of pins, UART1 on a different group and so on. That's not too bad, until you have something like the Cytron board that I've got which has put an ESP8266 on pins which can only be connected to UART0... meaning that any serial output that would normally be on UART0 has to be moved to either UART1 or USB.

That is why I rate the RP2040 positively from the hardware side.

Quote
I presume that you're talking there about the "classic" RPi plus Raspbian or whatever they call it these days: you /are/ aware aren't you that you can set up other named accounts? I'm not sure that's any worse than the Ubuntu philosophy where the standard is (or at least was) to have a root account which can't be logged into directly.

Of course it can be changed. But messing around with various Linux configuration files is a pain. In addition, some changes need to be made in the startup script files. The more that it looks different in different distributions (files and their location in individual directories).

Quote
VSCode has a Trojan that I'm still characterising, don't use.

I am not using VSCode. I generally hate pseudo-programs written with scripting languages (allergic to MS Teams). In particular, I hate monster applications written with JavaScript (including those based on Electron). It works poorly with OS. The performance is also not the best, not to mention ergonomics. In addition, some activities related to programming the microcontroller must be performed in VSCode by typing commands in the console. This is not a step back - it is a step back 30-40 years. It is all the more surprising that RPi Pico was intended by the creators to popularize programming and electronics, and in particular to encourage young people to learn them.

I got used to IDEs such as Delphi, Visual Studio (standard) or NetBeans quite quickly (NetBeans sometimes it is a bit slow, but you can work). They really make life easier. The Foundation could use NetBeans as an IDE, which is free. There are modules (plugins) for it that support C and C++ (I tested, they work).

Quote
Python... I loathe the language, but the last few years have demonstrated that it's serviceable for tacking stuff together. If you have to criticise anybody, I suggest directing your ire at the people who think that a good way to design a user interface is to embed Javascript and a browser engine into a program.

My (very critical) opinion about Python was shaped by its use. The first languages I started programming with were (chronologically): ObjectPascal, Pascal, C++, C, Java, PHP, JavaScript, C#, Python. This is probably why I think JavaScript and Python (PHP too) are crap. It is different with people who know one language, such as Python or JavaScript. When a person gets used to the comforts, then an attempt to use something primitive is painfully felt.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: VisualLab on August 22, 2022, 02:59:49 pm
Quote
- I like Debian and Manjaro, so I am fine with their default choice. Who doesn't has plenty of options. Changing whole distro, or just a desktop environment is not hard.

I used Red Hat for many years, then Fedora (and other derivatives) and CentOS. Then I tried to use Ubuntu, but it "gets on my nerves". I was interested in Linux only as an OS for a workstation/desktop (I'm not interested in servers). And here Linux is pretty poor. This, of course, is not due to the fact that Linux programmers cannot create a desktop version, they just don't want to create such a version. So, after more than 20 years of trying to use Linux on a desk, I don't expect it to come. The architecture and design assumptions (changing every now and then like in a kaleidoscope) mean that there will not be a comfortable desktop version of Linux that could boldly compete with Windows.

Quote
- I like VScode editor, debugging and extensions. Without VScode, I would be stuck with Arduino IDE or have to learn a new IDE for each target I need (and yes, I worked with Eclipse).

For those who start learning with the Arduino IDE (and the Arduino board), they are sufficient. Of course, a real IDE would be better, but it costs money (eg. VisualMicro). Or you have to assemble something yourself from existing applications (and libraries). And a beginner, unfortunately, is unlikely to be able to do it.

Quote
- Python is fine for many use cases, even in electronics (CircuitPython). It is now what BASIC used to be in 20th century.

I completely agree with the trim comparison (it is quite popular on the Internet anyway). But that is criticism rather than praise. A totally deserved criticism.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: avra on August 23, 2022, 03:54:07 pm
I've seen some extremely worrying background behaviour, and I'd point out that it's installed with root access and that even on Debian all VSCode updates come directly from MS servers and run MS-supplied installation scripts with root permissions.
Portable version of VScode that does not update on it self can be used on Windows, and to avoid MS telemetry and scripts VScodium might be a solution. According to https://duckduckgo.com/?q=docker+usb+access&ia=web it seams that some kind of host USB access can be given to a container.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on August 23, 2022, 04:50:49 pm
I've seen some extremely worrying background behaviour, and I'd point out that it's installed with root access and that even on Debian all VSCode updates come directly from MS servers and run MS-supplied installation scripts with root permissions.
Portable version of VScode that does not update on it self can be used on Windows, and to avoid MS telemetry and scripts VScodium might be a solution. According to https://duckduckgo.com/?q=docker+usb+access&ia=web it seams that some kind of host USB access can be given to a container.

This isn't an update issue. It's some sort of background scanner running, possibly talking to Github... I'd rather not say much more until I'm 100% sure of my facts.

I am wrong in one detail of what I've been saying: checking, it came from an MS-sourced .deb rather than Debian's repository, so I can't hold Debian responsible for it. But there's almost certainly something nasty in it, and containerising it wouldn't help as long as it still had network access (I'm pretty sure it would make things worse on at least Docker, since the Picoprobe is not a named device and nobody's found a way of mapping it).

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: funlw65 on September 24, 2022, 10:23:54 pm
I've seen some extremely worrying background behaviour, and I'd point out that it's installed with root access and that even on Debian all VSCode updates come directly from MS servers and run MS-supplied installation scripts with root permissions.
Portable version of VScode that does not update on it self can be used on Windows, and to avoid MS telemetry and scripts VScodium might be a solution. According to https://duckduckgo.com/?q=docker+usb+access&ia=web it seams that some kind of host USB access can be given to a container.

@avra, thank you for the VSCodium, cortex-debug extension is there too. Also, extensions for linker script and arm assembler. A gruvbox theme and I am good to go. Unfortunately, no astyle and Jal (for JAL language) extensions... For JAL, I might ask the developer...
Title: Re: Raspberry Pi Pico and Freepascal
Post by: Mongkey on October 01, 2022, 09:16:35 am
hello all,
has anyone try pi pico for reading sd card on pascal??

thank you.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on October 01, 2022, 10:45:10 am
hello all,
has anyone try pi pico for reading sd card on pascal??

thank you.

No. I'd remark though as general points  that I've used it (soldered to a "project board" with various stuff including an SD-Card socket) for FUZIX, which highlighted (a) you need to check the (SPI) pin allocation carefully and (b) remember that certain pins are usable as one or the other SPI interfaces, certain pins for UARTs and so on: poor choice of /which/ UART is to be used will have implications later if SPI functionality is added.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: Mongkey on October 01, 2022, 11:24:52 am
hello all,
has anyone try pi pico for reading sd card on pascal??

thank you.

No. I'd remark though as general points  that I've used it (soldered to a "project board" with various stuff including an SD-Card socket) for FUZIX, which highlighted (a) you need to check the (SPI) pin allocation carefully and (b) remember that certain pins are usable as one or the other SPI interfaces, certain pins for UARTs and so on: poor choice of /which/ UART is to be used will have implications later if SPI functionality is added.

MarkMLl

i'm new on this field, i used to create something by sample, seems to be hard for me :)
SD card is very important for stand alone logging device i think.
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MiR on October 01, 2022, 11:36:14 am
Found this page, has quite some documentation:

https://github.com/carlk3/no-OS-FatFS-SD-SPI-RPi-Pico
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on October 01, 2022, 11:48:18 am
i'm new on this field, i used to create something by sample, seems to be hard for me :)
SD card is very important for stand alone logging device i think.

Storage is important for a logging device, but an SD-Card might not be a good choice- at least with a standard filesystem.

The issue is that if you're logging, every time you commit data you will be updating metadata (i.e. the directory and FATs in the case of a FAT-based filesystem) which are typically at the start of the storage device. Now my understanding is that an SD-Card /might/, depending on the vendor, go to some trouble to extend the longevity of the low blocks; however since there is no wear levelling they are likely to fail before the remainder of the device: and when that happens your data is lost.

I've got various thoughts on mitigation which I'd prefer not to discuss, but you might find something like https://hackaday.com/2019/01/24/cool-tools-a-little-filesystem-that-keeps-your-bits-on-lock useful.

MarkMLl
Title: Re: Raspberry Pi Pico and Freepascal
Post by: Mongkey on October 01, 2022, 12:57:04 pm
i'm new on this field, i used to create something by sample, seems to be hard for me :)
SD card is very important for stand alone logging device i think.

Storage is important for a logging device, but an SD-Card might not be a good choice- at least with a standard filesystem.

The issue is that if you're logging, every time you commit data you will be updating metadata (i.e. the directory and FATs in the case of a FAT-based filesystem) which are typically at the start of the storage device. Now my understanding is that an SD-Card /might/, depending on the vendor, go to some trouble to extend the longevity of the low blocks; however since there is no wear levelling they are likely to fail before the remainder of the device: and when that happens your data is lost.

I've got various thoughts on mitigation which I'd prefer not to discuss, but you might find something like https://hackaday.com/2019/01/24/cool-tools-a-little-filesystem-that-keeps-your-bits-on-lock useful.

MarkMLl

Thankyou for your advice, is there any litlefs sample on pascal?
Title: Re: Raspberry Pi Pico and Freepascal
Post by: MarkMLl on October 01, 2022, 02:14:11 pm
Thankyou for your advice, is there any litlefs sample on pascal?

Doubt it, but assuming it's C importing it shouldn't be too difficult (but I suggest a different thread, since it's relevant to more than just Pico or ARM).

MarkMLl
TinyPortal © 2005-2018