[ARM,LPC1114] First steps lazarus / 79-Embedded - ARM ---------------------------------------------------------------------- devport · 2019-11-26 22:11 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 ---------------------------------------------------------------------- MiR · 2019-11-27 07:39 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/B hccjgga.html ---------------------------------------------------------------------- devport · 2019-11-27 08:57 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 · 2019-11-27 09:50 Nice code. Tip: using trunk you should be able to use the bittwiddlers that are now in trunk: setbit() clearbit() ToggleBit() and TestBit() ---------------------------------------------------------------------- devport · 2019-11-27 12:05 Thaddy: these functions use SysUtils which is not useful for me. (SysUtils adds kB of code to hex) ---------------------------------------------------------------------- devport · 2019-11-27 19:50 Whenever possible, I update the lpc11xx.pp file on github. Version in trunk is outdated. ---------------------------------------------------------------------- kupferstecher · 2019-11-27 22:08 Quote from: devport on November 27, 2019, 01:05:09 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 · 2019-11-28 06:51 Quote from: kupferstecher on November 27, 2019, 11:08:45 pmQuote from: devport on November 27, 2019, 01:05:09 pm(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 · 2019-11-28 20:37 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 · 2019-11-30 09:37 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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 · 2019-11-30 10:08 Quote from: ccrause on November 30, 2019, 10:37:38 amAnalyzing 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 · 2019-11-30 17:13 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 · 2019-11-30 22:02 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