2120 views|6 replies

58

Posts

1

Resources
The OP
 

[Raspberry Pi Pico Review] FreePascal RPI Pico Engineering Structure Analysis [Copy link]

This post was last edited by tjCFeng on 2021-3-29 11:07

Last time, I installed the IDE and compiled the examples to run Pico, but I didn't read the code, and I didn't know how the whole program worked. This time, I will take a look at the structure of the project, understand the author's method, and see how he did it.

Let's open the example project file first. Again, without looking at the code, we can directly open the project properties to see the settings. There are several differences between FreePascal's Pico project and a normal application project:

1. Compiler settings:

2. Selection of runtime library:

If you create a Windows project directly, the target platform settings are all default and change with the operating system, and there is no choice for the runtime library. The biggest differences are basically these two points. There is nothing much to say about the compiler, just choose the corresponding one, and the runtime library also needs to be selected correctly. This runtime library is actually the definition of the register address and structure of each RP2040. If you develop it according to the conventional register operation method, it is already considered to include all files. But did the author really design it this way?

Go directly into the folder of Example. First, you can see several folders of adc, blinky, i2c, spi, and uart. You can tell from the names that they are routines for corresponding functions. Then there are several .sh files. These should be script files used when compiling under Linux. Ignore them for now. The most important one is the folder of units, which contains many .obj and .pas files, as well as a .a file. We all know that .pas files are Pascal files, that is, files for developers to call. So what are these .obj files used for? Shouldn't temporary files be deleted?

Students who use C language to write programs know that the main process of compiling a program is:

Source code →

Preprocessor →

compiler →

Assembler →

object code →

Linker →

Executables

The third to last step is the .obj file. Linking it with the resource file through the linker will generate the final binary file. But what role does this "temporary file" of C language play in Pascal projects? The .obj file is a compiled binary file. It has complete functions and can provide external interfaces. At this time, through the macro definition of the code, the Pascal compiler will include it as a static link library into the final program.

When using, you must first declare the name, parameters, and calling method of each function you need. This name is consistent with the name provided by .obj. If you want to change the name you want, you need to redefine it with the keyword "name". This method is exactly the same as the method of Pascal calling dynamic link libraries, except that dynamic link files cannot be included in the program, and they must be released with a lot of small tails (.dll files); static link files can be included, and only a binary file is generated in the end.

It is undoubtedly a huge workload to use registers directly to complete all functions, so the author "scammed" and compiled Pico's SDK with a C compiler in advance, so that these "temporary files" can be used by me, and the same is true for .a files.
(End)

This post is from DIY/Open Source Hardware

Latest reply

It feels very good!!!   Details Published on 2021-3-31 12:50

赞赏

1

查看全部赞赏

 

6548

Posts

0

Resources
2
 

This method is good, the workload is much less

This post is from DIY/Open Source Hardware

Comments

Thanks for your support  Details Published on 2021-3-30 19:43
 
 

1w

Posts

204

Resources
3
 

Ha, thank you for sharing, it's very interesting~~

This post is from DIY/Open Source Hardware
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Comments

Thanks Thanks  Details Published on 2021-3-30 19:40
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 
 

58

Posts

1

Resources
4
 
okhxyyo posted on 2021-3-30 10:02 Ha, thank you for sharing, it's very interesting~~

Thanks Thanks

This post is from DIY/Open Source Hardware
 
 
 

58

Posts

1

Resources
5
 
Jacktang posted on 2021-3-29 11:50 This method is good, the workload is much less

Thanks for your support

This post is from DIY/Open Source Hardware
 
 
 

1942

Posts

2

Resources
6
 

It feels very good!!!

This post is from DIY/Open Source Hardware

Comments

Thanks for your support  Details Published on 2021-3-31 19:10
 
 
 

58

Posts

1

Resources
7
 
w494143467 posted on 2021-3-31 12:50 It feels very good! ! !

Thanks for your support

This post is from DIY/Open Source Hardware
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list