Problem with assembler for STM32 [SOLVED] lazarus / 79-Embedded - ARM ---------------------------------------------------------------------- petex · 2021-01-13 13:13 I have recently built the embedded ARM cross compiler using the FpcupDeluxe utility. I am intending to cross compile programs for the "blue pill" STM32F103C8T6 card. I am compiling the simple "Blink" example and I get errors in the assembly from the compiler... I basically followed instructions in the WIKI and running Lazarus under Windows. Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:9: Error: lo register required -- `stmfd r13!,{r11,r12,r14,r15}' etc.etc. The full message listing  is at the end. The compiler options are as follows:- 'C:\FreePascalDeluxe\fpc\bin\x86_64-win64\fpc.exe'  -Tembedded -Parm -CpARMV7R -MObjFPC -Scghi -l -vewnhibq -Filib\arm-embedded -Fu. -FUlib\arm-embedded -FE. -oproject1 -WpSTM32F103X8 the source is :- Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1;{$O-} procedure delay;var  i : uint32;begin  for i := 0 to 500000 do    begin      asm        nop   // empty instruction      end;    end;end; begin  // turn on Port C  RCC.APB2ENR := RCC.APB2ENR or (%1 shl 4);   // Pin 13 from Port C to Output  PortC.CRH := $00300000;   // Note: The LED lights up at LOW.  while true do    begin      // Pin 13 - High      PortC.BSRR := 1 shl 13;      Delay;       // Pin 13 - Low      PortC.BRR := 1 shl 13;      Delay;    end;end. MESSAGE LISTING ====> QuoteCompile Project, OS: embedded, CPU: arm, Target: project1: Exit code 1, Errors: 1, Hints: 4 Note: Changed CPU type to be consistent with specified controller Hint: Start of reading config file C:\FreePascalDeluxe\fpc\bin\x86_64-win64\fpc.cfg Hint: End of reading config file C:\FreePascalDeluxe\fpc\bin\x86_64-win64\fpc.cfg Note: Changed CPU type to be consistent with specified controller Verbose: Free Pascal Compiler version 3.2.0-r45643 [2021/01/12] for arm Verbose: Copyright (c) 1993-2020 by Florian Klaempfl and others Verbose: Target OS: Embedded Verbose: Compiling project1.lpr Verbose: Assembling project1 Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s: Assembler messages: Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:9: Error: lo register required -- `stmfd r13!,{r11,r12,r14,r15}' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:10: Error: lo register required -- `sub r11,r12,#4' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:12: Error: unshifted register required -- `mvn r0,#0' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:13: Error: lo register required -- `str r0,[r11,#-48]' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:16: Error: lo register required -- `ldr r0,[r11,#-48]' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:18: Error: lo register required -- `str r0,[r11,#-48]' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:22: Error: lo register required -- `ldr r0,[r11,#-48]' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:24: Error: unshifted register required -- `orr r1,r1,#288' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:29: Error: lo register required -- `ldmea r11,{r11,r13,r15}' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:40: Error: lo register required -- `stmfd r13!,{r11,r12,r14,r15}' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:41: Error: lo register required -- `sub r11,r12,#4' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:46: Error: unshifted register required -- `orr r0,r0,#16' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:66: Error: lo register required -- `ldmea r11,{r11,r13,r15}' Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:23: Error: invalid immediate: 499712 is out of range Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:23: Error: value of 499712 too large for field of 2 bytes at 8 Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:44: Error: invalid offset, target not word aligned (0x0000002E) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:44: Error: invalid offset, value too big (0x00000026) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:47: Error: invalid offset, target not word aligned (0x0000002E) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:47: Error: invalid offset, value too big (0x00000022) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:49: Error: invalid immediate: 3145728 is out of range Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:49: Error: value of 3145728 too large for field of 2 bytes at 16 Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:50: Error: invalid offset, target not word aligned (0x00000032) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:50: Error: invalid offset, value too big (0x00000022) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:55: Error: invalid immediate: 8192 is out of range Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:56: Error: invalid offset, target not word aligned (0x00000036) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:56: Error: invalid offset, value too big (0x0000001E) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:59: Error: invalid immediate: 8192 is out of range Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:60: Error: invalid offset, target not word aligned (0x0000003A) Debug: C:\temp-svn\blue pill\lib\arm-embedded\project1.s:60: Error: invalid offset, value too big (0x00000016) project1.lpr(41,0) Error: Error while assembling exitcode 1 project1.lpr(41,0) Verbose: There were 2 errors compiling module, stopping Verbose: Compilation aborted Verbose: C:\FreePascalDeluxe\fpc\bin\x86_64-win64\ppcrossarm.exe returned an error exitcode [Edited to add code tags - please see How to use the Forums.] ---------------------------------------------------------------------- MiR · 2021-01-13 13:20 Try -CpARMV7M instead of ARMV7R ---------------------------------------------------------------------- ccrause · 2021-01-13 14:16 Quote from: MiR on January 13, 2021, 02:20:38 pmTry -CpARMV7M instead of ARMV7R +1 Or omit -Cp if using FPC 3.2 or trunk.  The compiler will then look up the CPU type based on the controller name. ---------------------------------------------------------------------- petex · 2021-01-13 14:31 new compiler options:- C:\FreePascalDeluxe\fpc\bin\x86_64-win64\fpc.exe -Tembedded -Parm -MObjFPC -Scghi -l -vewnhibq -Filib\arm-embedded -Fu. -FUlib\arm-embedded -FE. -oproject1 -CpARMV7M -WpSTM32F103X8 I get past the assembler errors, but now getting an unknown linker error ===> Compile Project, OS: embedded, CPU: arm, Target: project1: Exit code 1, Errors: 1, Hints: 2 Hint: Start of reading config file C:\FreePascalDeluxe\fpc\bin\x86_64-win64\fpc.cfg Hint: End of reading config file C:\FreePascalDeluxe\fpc\bin\x86_64-win64\fpc.cfg Verbose: Free Pascal Compiler version 3.2.0-r45643 [2021/01/12] for arm Verbose: Copyright (c) 1993-2020 by Florian Klaempfl and others Verbose: Target OS: Embedded Verbose: Compiling project1.lpr Verbose: Assembling project1 Verbose: Linking C:\temp-svn\blue pill\project1 Debug: STM32F10X_MD Usage: C:\FreePascalDeluxe\cross\bin\arm-embedded\arm-none-eabi- objcopy.exe [option(s)] in-file [out-file]  Copies a binary file, possibly transforming it in the process  The options are:   -I --input-target       Assume input file is in format   -O --output-target      Create an output file in format   -B --binary-architecture   Set output arch, when input is arch-less   -F --target             Set both input and output format to      --debugging                   Convert debugging information, if possible   -p --preserve-dates              Copy modified/access timestamps to the output   -D --enable-deterministic-archives                                    Produce deterministic output when stripping archives   -U --disable-deterministic-archives                                    Disable -D behavior (default)   -j --only-section          Only copy section into the output      --add-gnu-debuglink=    Add section .gnu_debuglink linking to   -R --remove-section        Remove section from the output      --remove-relocations    Remove relocations from section   -S --strip-all                   Remove all symbol and relocation information   -g --strip-debug                 Remove all debugging symbols & sections      --strip-dwo                   Remove all DWO sections      --strip-unneeded              Remove all symbols not needed by relocations   -N --strip-symbol          Do not copy symbol      --strip-unneeded-symbol                                    Do not copy symbol unless needed by                                      relocations      --only-keep-debug             Strip everything but the debug information      --extract-dwo                 Copy only DWO sections      --extract-symbol              Remove section contents but keep symbols   -K --keep-symbol           Do not strip symbol      --keep-file-symbols           Do not strip file symbol(s)      --localize-hidden             Turn all ELF hidden symbols into locals   -L --localize-symbol       Force symbol to be marked as a local      --globalize-symbol      Force symbol to be marked as a global   -G --keep-global-symbol    Localize all symbols except   -W --weaken-symbol         Force symbol to be marked as a weak      --weaken                      Force all global symbols to be marked as weak   -w --wildcard                    Permit wildcard in symbol comparison   -x --discard-all                 Remove all non-global symbols   -X --discard-locals              Remove any compiler-generated symbols   -i --interleave[=]       Only copy N out of every bytes      --interleave-width    Set N for --interleave   -b --byte                   Select byte in every interleaved block      --gap-fill               Fill gaps between sections with      --pad-to                Pad the last section up to address      --set-start             Set the start address to     {--change-start|--adjust-start}                                    Add to the start address     {--change-addresses|--adjust-vma}                                    Add to LMA, VMA and start addresses     {--change-section-address|--adjust-section-vma} {=|+|-}                                    Change LMA and VMA of section by      --change-section-lma {=|+|-}                                    Change the LMA of section by      --change-section-vma {=|+|-}                                    Change the VMA of section by     {--[no-]change-warnings|--[no-]adjust-warnings}                                    Warn if a named section does not exist      --set-section-flags =                                    Set section 's properties to      --add-section =   Add section found in to output      --update-section =                                    Update contents of section with                                    contents found in      --dump-section =  Dump the contents of section into      --rename-section =[,] Rename section to      --long-section-names {enable|disable|keep}                                    Handle long section names in Coff objects.      --change-leading-char         Force output format's leading character style      --remove-leading-char         Remove leading character from global symbols      --reverse-bytes=         Reverse bytes at a time, in output sections with content      --redefine-sym =    Redefine symbol name to      --redefine-syms         --redefine-sym for all symbol pairs                                      listed in      --srec-len            Restrict the length of generated Srecords      --srec-forceS3                Restrict the type of generated Srecords to S3      --strip-symbols         -N for all symbols listed in      --strip-unneeded-symbols                                    --strip-unneeded-symbol for all symbols listed                                      in      --keep-symbols          -K for all symbols listed in      --localize-symbols      -L for all symbols listed in      --globalize-symbols     --globalize-symbol for all in      --keep-global-symbols   -G for all symbols listed in      --weaken-symbols        -W for all symbols listed in      --add-symbol =[
:][,]  Add a symbol      --alt-machine-code     Use the target's 'th alternative machine      --writable-text               Mark the output text as writable      --readonly-text               Make the output text write protected      --pure                        Mark the output file as demand paged      --impure                      Mark the output file as impure      --prefix-symbols      Add to start of every symbol name      --prefix-sections     Add to start of every section name      --prefix-alloc-sections                                    Add to start of every allocatable                                      section name      --file-alignment         Set PE file alignment to      --heap [,]   Set PE reserve/commit heap to /                                          --image-base
        Set PE image base to
     --section-alignment      Set PE section alignment to      --stack [,]  Set PE reserve/commit stack to /                                          --subsystem [:]                                    Set PE subsystem to [& ]      --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]                                    Compress DWARF debug sections using zlib      --decompress-debug-sections   Decompress DWARF debug sections using zlib      --elf-stt-common=[yes|no]     Generate ELF common symbols with STT_COMMON                                      type   -M  --merge-notes                Remove redundant entries in note sections       --no-merge-notes             Do not attempt to remove redundant notes (default)   -v --verbose                     List all object files modified   @                          Read options from   -V --version                     Display this program's version number   -h --help                        Display this output      --info                        List object formats & architectures supported C:\FreePascalDeluxe\cross\bin\arm-embedded\arm-none-eabi-objcopy.exe: supported targets: elf32-littlearm elf32-bigarm elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex project1.lpr(41,0) Error: Error while linking project1.lpr(41,0) Verbose: There were 1 errors compiling module, stopping Verbose: Compilation aborted Verbose: C:\FreePascalDeluxe\fpc\bin\x86_64-win64\ppcrossarm.exe returned an error exitcode ---------------------------------------------------------------------- MiR · 2021-01-13 14:39 Hmmm... havent seen binutils tools creating an error before, strange..... Please add -sh parameter to your build, this will give you a linker script and a linker file. The Linker file includes all the searchpaths so you can check if you have correctly set all needed searchpaths. Running the linker script manually may also help to better identify the issue. When stuck, please post content of the files ---------------------------------------------------------------------- petex · 2021-01-13 15:32 hmmmm..... I took the space out of the project folder "blue pill" to "blue-pill" and it worked. (in so much as I got a hex output file, not checked it yet)  Not the first time this has happened to me, never seem to learn !! Thanks for your help. ---------------------------------------------------------------------- ccrause · 2021-01-13 17:09 Quote from: petex on January 13, 2021, 04:32:35 pmhmmmm..... I took the space out of the project folder "blue pill" to "blue-pill" and it worked. (in so much as I got a hex output file, not checked it yet)The compiler is supposed to properly quote the paths passed to external tools as required, so this sounds like a potential bug.  It would be interesting to see the contents of the linker script files (ppas.bat and linkxxx.res I think) generated with the -sh option (and a space in the path) as suggested by MiR.