Lazarus

Programming => Embedded => Operating Systems => Embedded - ARM => Topic started by: devport on November 26, 2019, 11:11:56 pm

Title: [ARM,LPC1114] First steps
Post by: devport on November 26, 2019, 11:11:56 pm
Hello,

Inspired from
http://j-software.dk/ (http://j-software.dk/)
thank you very much! Good Job

I'm writing libraries under LPC1114.
If anyone was interested, I share my codes.
FreePascal is suitable for embedded devices.
I am living proof of this.

I am aware of the possibility of making mistakes in the code. Be careful.

https://github.com/devport/LPC1114 (https://github.com/devport/LPC1114)

Soon I will also make Lazarus projects available and support for the ETHERNET ENC28J60 module

Best regards to the FreePascal community
Title: Re: [ARM,LPC1114] First steps
Post by: MiR on November 27, 2019, 08:39:58 am
Nice work!

One hint, every Cortex-M CPU has an independent timer that is usually used for creating SysTick. By using that one you can use the chip specific timers for other purposes

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/Bhccjgga.html



Title: Re: [ARM,LPC1114] First steps
Post by: devport on November 27, 2019, 09:57:40 am
Available sources were to run external modules (OLED, temperature sensor) at the moment. I did not focus on configurability, expansion of the uC peripherals. In the near future, however, I will come back to this.

I will show SysTick while creating a multitasking library.
But that soon.
Title: Re: [ARM,LPC1114] First steps
Post by: Thaddy on November 27, 2019, 10:50:54 am
Nice code.
Tip: using trunk you should be able to use the bittwiddlers that are now in trunk:
setbit()
clearbit()
ToggleBit()
and TestBit()
Title: Re: [ARM,LPC1114] First steps
Post by: devport on November 27, 2019, 01:05:09 pm
Thaddy:
these functions use SysUtils which is not useful for me. (SysUtils adds kB of code to hex)
Title: Re: [ARM,LPC1114] First steps
Post by: devport on November 27, 2019, 08:50:51 pm
Whenever possible, I update the lpc11xx.pp file on github. Version in trunk is outdated.
Title: Re: [ARM,LPC1114] First steps
Post by: kupferstecher on November 27, 2019, 11:08:45 pm
(SysUtils adds kB of code to hex)
I experienced that before on a STM32. Anybody knows why smart linking is not working there?
Title: Re: [ARM,LPC1114] First steps
Post by: ccrause on November 28, 2019, 07:51:06 am
(SysUtils adds kB of code to hex)
I experienced that before on a STM32. Anybody knows why smart linking is not working there?

Exception handling related code in initialization/finalization (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/embedded/sysutils.pp?view=markup#l291) which is not smart linked (https://wiki.freepascal.org/Size_Matters#Initialization_and_finalization_sections) would be my guess.
Title: Re: [ARM,LPC1114] First steps
Post by: kupferstecher on November 28, 2019, 09:37:09 pm
Now I just tried and removed the initialization in rtl/embedded/sysutils.pp (call of InitExceptions). The bin size gets reduced from 57kB to 13kB instead of 3kB without used sysutils.
But the smart linking option in the project settings don't have any influence. Do I need to activate smart linking when building the cross compiler (and libs)?
Title: Re: [ARM,LPC1114] First steps
Post by: ccrause on November 30, 2019, 10:37:38 am
Even if the inititialize/finalize code of sysutils is removed, sysutils uses units sysconst and heapmgr.  Sysconst adds some error strings as resource strings (or so it seems from objdump) and heapmgr registers a record with pointers to the heap management code, so basically all the heapmgr code  is referenced and cannot be eliminated by smart linking.

More detail can be observed by analyzing the output of objdump:
Code: Bash  [Select][+][-]
  1. arm-none-eabi-objdump -d project1.elf

Analyzing this output reveals a bunch of code associated with the TEncoding class, not sure where this gets pulled in, probably automatically loaded by the compiler if the sysutils unit is loaded.

The rtl was compiled with OPT='-CX -XX' and the empty test project was compiled with smart linking enabled.
Title: Re: [ARM,LPC1114] First steps
Post by: PascalDragon on November 30, 2019, 11:08:51 am
Analyzing this output reveals a bunch of code associated with the TEncoding class, not sure where this gets pulled in, probably automatically loaded by the compiler if the sysutils unit is loaded.
TEncoding contains both a class constructor and destructor, thus it's always initialized when the unit is used.
Title: Re: [ARM,LPC1114] First steps
Post by: kupferstecher on November 30, 2019, 06:13:10 pm
I just used the objdump on an empty armv7m project.
The TEncoding I could find, but there are also a lot of procedures that shouldn't be used (I guess), like "INT32_TO_FLOAT64", so I still think smart linking somehow doesn't work here.

This is the command line with which I build the cross compiler:
"make.exe clean crossall crossinstall FPC=%PPCBIN% OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7m INSTALL_PREFIX=%INSTALL_PATH% CROSSBINDIR=%GNU_BIN_PATH% CROSSOPT="-O3 -XX -CX" BINUTILSPREFIX=arm-embedded-"

In the project settings I chose the smart linking options -CX and -XX as well.
Title: Re: [ARM,LPC1114] First steps
Post by: devport on November 30, 2019, 11:02:06 pm
MiR: SysTick Support in my Git...
I have update file cortexm0.pp from trunk for this functionaly

Added first version ETH -> ENC28J60 Driver (possible bugs)
I am very slow, I don't have enough time for this hobby :)
TinyPortal © 2005-2018