Recent

Author Topic: [ARM,LPC1114] First steps  (Read 873 times)

devport

  • New Member
  • *
  • Posts: 26
[ARM,LPC1114] First steps
« on: November 26, 2019, 11:11:56 pm »
Hello,

Inspired from
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

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

Best regards to the FreePascal community
« Last Edit: November 26, 2019, 11:20:31 pm by devport »

MiR

  • Jr. Member
  • **
  • Posts: 80
Re: [ARM,LPC1114] First steps
« Reply #1 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




devport

  • New Member
  • *
  • Posts: 26
Re: [ARM,LPC1114] First steps
« Reply #2 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.

Thaddy

  • Hero Member
  • *****
  • Posts: 9399
Re: [ARM,LPC1114] First steps
« Reply #3 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()
also related to equus asinus.

devport

  • New Member
  • *
  • Posts: 26
Re: [ARM,LPC1114] First steps
« Reply #4 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)
« Last Edit: November 27, 2019, 03:39:40 pm by devport »

devport

  • New Member
  • *
  • Posts: 26
Re: [ARM,LPC1114] First steps
« Reply #5 on: November 27, 2019, 08:50:51 pm »
Whenever possible, I update the lpc11xx.pp file on github. Version in trunk is outdated.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 331
Re: [ARM,LPC1114] First steps
« Reply #6 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?

ccrause

  • Full Member
  • ***
  • Posts: 216
Re: [ARM,LPC1114] First steps
« Reply #7 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 which is not smart linked would be my guess.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 331
Re: [ARM,LPC1114] First steps
« Reply #8 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)?

ccrause

  • Full Member
  • ***
  • Posts: 216
Re: [ARM,LPC1114] First steps
« Reply #9 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.

PascalDragon

  • Hero Member
  • *****
  • Posts: 849
  • Compiler Developer
Re: [ARM,LPC1114] First steps
« Reply #10 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.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 331
Re: [ARM,LPC1114] First steps
« Reply #11 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.

devport

  • New Member
  • *
  • Posts: 26
Re: [ARM,LPC1114] First steps
« Reply #12 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 :)
« Last Edit: November 30, 2019, 11:29:48 pm by devport »