Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

New custom compilers.

2 posters

Go down  Message [Page 1 of 1]

1New custom compilers. Empty New custom compilers. Thu Sep 30, 2021 9:32 am

arcachofo

arcachofo

Custom compilers basic implementation is finished.

Now it is possible to define your compilers or modify the already existing.
There are also new separate dialogs for Editor and Compilers (see video at the end).

Compiler are defined in xml files that must be placed in:
SimulIDE_1.x.x/data/codeeditor/compilers/compilers
SimulIDE_1.x.x/data/codeeditor/compilers/assemblers


There are some substitutions that can be done:

$filePath   - Complete path to file in Editor.
$fileDir    - Complete path to file folder.
$fileName   - File name without extension.
$fileExt    - File extension with dot.
$inclPath   - Include path defined in dialog or xml file.
$buildPath  - build path define in xml file.
$family     - Family/Architecture defined in dialog or source file.
$device     - Device name defined in dialog or source file.


There are some compiler already available, for example this one for avr-gcc.
Here you can have an idea of how to create or modify a compiler:

Code:
<compiler name="Avrgcc" type="avrgcc" buildPath="build_$fileName" useDevice="true">
    <step
        command="avr-gcc"
        arguments=" -mmcu=$device -Wall -g -Os -o $buildPath$fileName.elf $filePath"
    />
    <step
        command="avr-objcopy"
        arguments=" -j .text -j .data -O ihex $buildPath$fileName.elf $buildPath$fileName.hex"
    />
</compiler>

In some cases it is possible to debug.
There is support to debug for these compilers/assemblers:
- Arduino.
- Avr-gcc.
- SDCC.
- GcBasic.
- Avra.
- Gavrasm.
- Gpasm.

But in some cases it is possible to debug for other compilers if they provide a .lst file, don't use relative adressing and just happens that simulide can undestand it.

For PIC, AVR and 8051 asm is very likely that the debuger can work for not-supported assemblers.

The type of compiler/assembler can be defined in "type" field in xml file.
It can be a known one, like "avrgcc" or an unknown one with a number like "asm1"  (this still need some work).

In this video you can get an idea of how it works:



Other features added:
- Defining Device, Family/Architecture or Board (Arduino) in source file.
- 8051 asm automatic recognition and highlighting.
- Hex files basic highlighting.

Any suggestions, ideas, etc are very welcome.



Last edited by arcachofo on Mon Mar 20, 2023 2:43 pm; edited 1 time in total

2New custom compilers. Empty Re: New custom compilers. Sun Oct 02, 2022 4:20 pm

KerimF

KerimF

You keep doing a wonderful work; a big jump indeed.
Thank you.

3New custom compilers. Empty Re: New custom compilers. Sun Oct 02, 2022 6:23 pm

KerimF

KerimF

[1]
From avra.xml located at:
.\SimulIDE_1.0.0-RC3_Win32\data\codeeditor\compilers\assemblers

Note: Below, I replaced < and > with [ and ] to let the xml lines be visible on the post.
;==============================================

[!DOCTYPE SimulIDE]

[compiler name="Avrasm2" inclPath="./" type="avrasm2"]
   [step
       command="avrasm2"
       arguments=" -W NoRegDef -l $buildPath$fileName.lst -I $inclPath $filePath"
   /]
[/compiler]

Will it work? Or it needs more changes?

;==============================================

[2]
On the popup menu ‘Compiler Settings’:

Tool Path:? I guess it means the path of ‘avrasm2.exe’. Right?

Include Path? I guess it means the path of the files included on the source code.

Family:? Is it in my case AVR? (I work now with ATmega8 MCU)

[3]
Zooming is working well now; even by using my very old (genuine) mouse. Thank you.

4New custom compilers. Empty Re: New custom compilers. Sun Oct 02, 2022 8:21 pm

KerimF

KerimF

The compilation succeeded.
But I noticed that 'lst' and 'obj' files only were added; no hex file.

So, I copied/pasted the hex file, generated by AVR Studio.
And when I loaded it on the MCU ATmega8, I got:

Warning: Not supported Record type: 2 at line "0"
Firmware succesfully loaded


Then, I started the debugger... but I couldn’t find how to set a breakpoint.

Starting Circuit Simulation...

Created 43 eNodes 122 Pins
Initializing 151 eElements
Initializing 49 eNodes

Initializing Matrix: 49 eNodes

Circuit Matrix looks good

FPS: 20 Frames per Sec
Speed: 100 %
Speed: 1000000000000 ps per Sec
ps/Fr: 50000000000 ps per Frame
NonLi: 100000 Max Iterations

Simulation Running...


;=======================

FirmWare Uploaded to mega8
D:/SimulIDE/SimulIDE_1.0.0-RC3_Win32/projects/REG_5BD/REG_5BD_10.hex


Mapping Flash to Source... 42 lines mapped

Debugger Started


;======================

That is it for now.

5New custom compilers. Empty Re: New custom compilers. Mon Oct 03, 2022 2:30 am

arcachofo

arcachofo

The compilation succeeded.
But I noticed that 'lst' and 'obj' files only were added; no hex file.
I don't know how Avrasm2 works.
First you need to determine which commands and arguments to use.
You can have a look at Avrasm2 manual or see which commands are used in AVR Studio or whatever.

Maybe you need to use several steps.
For example AvrGcc compiler uses 2 steps: one to generate the .elf file and another to generate the .hex file.
Have a look at data/codeeditor/compilers/compilers/avrgcc.xml:
Code:
<compiler name="Avrgcc" type="avrgcc" buildPath="build_$fileName" useDevice="true">
    <step
        command="avr-gcc"
        arguments=" -mmcu=$device -Wall -g -Os -o $buildPath$fileName.elf $filePath"
    />
    <step
        command="avr-objcopy"
        arguments=" -j .text -j .data -O ihex $buildPath$fileName.elf $buildPath$fileName.hex"
    />
</compiler>

6New custom compilers. Empty Re: New custom compilers. Mon Oct 03, 2022 2:41 am

arcachofo

arcachofo

On the popup menu ‘Compiler Settings’:

Tool Path:? I guess it means the path of ‘avrasm2.exe’. Right?

Include Path? I guess it means the path of the files included on the source code.

Family:? Is it in my case AVR? (I work now with ATmega8 MCU)
Tool Path: Yes.
Include Path: Yes (if needed).
Family: You are not using any family in your build command so you don't need it.

You only need "Family" or "Device" it if you use in your compiler.xml file.
For example SDCC compiler uses both.
Note "useFamily" and "useDevice" are set to true.
Then $family and $device are replaced for the values entered in Settings dialog:
Code:
<compiler name="SDCC" type="sdcc" buildPath="build" useFamily="true" useDevice="true">
   <step
       command="sdcc"
       arguments=" --use-non-free -m$family -p$device -o$buildPath $filePath"
   />
</compiler>

7New custom compilers. Empty Re: New custom compilers. Mon Oct 03, 2022 2:50 am

arcachofo

arcachofo

Then, I started the debugger... but I couldn’t find how to set a breakpoint.
Right-click in the number area and add/remove breakpoints (video above at 09:32).

8New custom compilers. Empty Re: New custom compilers. Mon Oct 03, 2022 9:20 am

KerimF

KerimF

So what I need to know now is to find out how to let avrasm2 generate the hex file.

Thank you.

9New custom compilers. Empty Re: New custom compilers. Mon Oct 03, 2022 11:55 am

KerimF

KerimF

Generating the hex file is done after adding, in avrasm2.xml, the two parameters:
-fi -o $buildPath$fileName.hex

But, when I load REG_5BD_10.asm, I got:

-------------------------------------------------------
File: D:/SimulIDE/SimulIDE_1.0.0-RC3_Win32/projects/REG_5BD/REG_5BD_10.asm

File recognized as: Unknown asm

-------------------------------------------------------

How could we let it be known by SimulIDE?

Naturally, since the type of the asm file is unknown, the highlight syntax is turned off as if it is a txt file.
But, I wonder how it is not recognized even after selecting its compiler and running the Debugger.

Note: I will add any further notes on a new topic “About Working with AVARASM2 assembler”.

10New custom compilers. Empty Re: New custom compilers. Mon Oct 03, 2022 2:42 pm

arcachofo

arcachofo

-------------------------------------------------------
File: D:/SimulIDE/SimulIDE_1.0.0-RC3_Win32/projects/REG_5BD/REG_5BD_10.asm

File recognized as: Unknown asm

-------------------------------------------------------
Would be nice to know why it is not recognized as Avr asm.
You mentioned something about C-stile comments, this could be one cause.
If you can share the source code I will have a look.

How could we let it be known by SimulIDE?
This feature is missing in 1.0.0.
I will solve this issue.

I wonder how it is not recognized even after selecting its compiler and running the Debugger.
It might seem weird, but the compiler or debugger knows nothing about what kind of asm it is.
The compiler just run the command you set in the xml file, whatever it is.
And the debugger just maps source code line numbers to flash addresses reading the .lst file.

Note: I will add any further notes on a new topic “About Working with AVARASM2 assembler”.
Thanks, it will be useful for other people.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum