[Beremiz-devel] Build sources using avr-gcc

classic Classic list List threaded Threaded
34 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
I'm wondering how to correctly compile the sources using avr-gcc?
I need minimal working example (makefile and changes in the generated source code).

Viacheslav N. Mezentsev

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Hi Viacheslav,

On 17-10-24 16:25, [hidden email] wrote:
> I'm wondering how to correctly compile the sources using avr-gcc?
What have you tried so far?

> I need minimal working example (makefile and changes in the generated source code).

matiec C library has some problems with compilation for 8bit
microcontroller. int is 16bits on AVR. I've attached patch that is
necessary to apply to matiec for that. Most likely some other problems
may appear later.

Mario, do you care about AVR support?
I think it'd be nice to have Arduino out-of-the-box
support in Beremiz.


I've attached very simple Beremiz project that compiles IEC program
using avr-gcc. It's missing avr hardware handling (I've mocked this in
main_avr.c).

In attached Beremiz project I placed already patched header file from
matiec in project_files directory and it overrides matiec's original file
using include path (see CFLAGS in the Makefile). Don't do this in
production, it's just quick and dirty fix to test the idea.

Short instruction: unpack archive, open the project in Beremiz and click
build button. As a result in the project directory 'build' directory
will be created with a firmware.elf file inside.

--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

avr_uc_test.tar.xz (10K) Download Attachment
fix_compilation_on_avr.patch (1K) Download Attachment
signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Hi All!

On AVR there is only a few kilobytes of RAM, so int and double (doube is 32bits on AVR with AVR-libc) are the bigest problem!

That's why we didn't consider using AVR when we started YAPLC project.

Regards,
Paul Beltyukov



2017-10-24 19:41 GMT+05:00 <[hidden email]>:
Hi Viacheslav,

On 17-10-24 16:25, [hidden email] wrote:
> I'm wondering how to correctly compile the sources using avr-gcc?
What have you tried so far?

> I need minimal working example (makefile and changes in the generated source code).

matiec C library has some problems with compilation for 8bit
microcontroller. int is 16bits on AVR. I've attached patch that is
necessary to apply to matiec for that. Most likely some other problems
may appear later.

Mario, do you care about AVR support?
I think it'd be nice to have Arduino out-of-the-box
support in Beremiz.


I've attached very simple Beremiz project that compiles IEC program
using avr-gcc. It's missing avr hardware handling (I've mocked this in
main_avr.c).

In attached Beremiz project I placed already patched header file from
matiec in project_files directory and it overrides matiec's original file
using include path (see CFLAGS in the Makefile). Don't do this in
production, it's just quick and dirty fix to test the idea.

Short instruction: unpack archive, open the project in Beremiz and click
build button. As a result in the project directory 'build' directory
will be created with a firmware.elf file inside.

--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
On 17-10-25 15:59, [hidden email] wrote:
> Hi All!
>
> On AVR there is only a few kilobytes of RAM, so int and double (doube is
> 32bits on AVR with AVR-libc) are the bigest problem!
Why is it the bigest problem?
I've used float on AVR without an issue.
Sure, RAM/FLASH/CPU resources are pretty limited.
But if you don't need debugging and logging functionality.
That should be enough to implement some logic.


> 2017-10-24 19:41 GMT+05:00 <[hidden email]>:
>
> > Hi Viacheslav,
> >
> > On 17-10-24 16:25, [hidden email] wrote:
> > > I'm wondering how to correctly compile the sources using avr-gcc?
> > What have you tried so far?
> >
> > > I need minimal working example (makefile and changes in the generated
> > source code).
> >
> > matiec C library has some problems with compilation for 8bit
> > microcontroller. int is 16bits on AVR. I've attached patch that is
> > necessary to apply to matiec for that. Most likely some other problems
> > may appear later.
> >
> > Mario, do you care about AVR support?
> > I think it'd be nice to have Arduino out-of-the-box
> > support in Beremiz.
> >
> >
> > I've attached very simple Beremiz project that compiles IEC program
> > using avr-gcc. It's missing avr hardware handling (I've mocked this in
> > main_avr.c).
> >
> > In attached Beremiz project I placed already patched header file from
> > matiec in project_files directory and it overrides matiec's original file
> > using include path (see CFLAGS in the Makefile). Don't do this in
> > production, it's just quick and dirty fix to test the idea.
> >
> > Short instruction: unpack archive, open the project in Beremiz and click
> > build button. As a result in the project directory 'build' directory
> > will be created with a firmware.elf file inside.
> >
> > --
> > Best regards,
> > Andrey Skvortsov
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Beremiz-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beremiz-devel
> >
> >

> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
We needed logging and debug, so RAM usage is critical issue for us.

среда, 25 октября 2017 г. пользователь написал:

> On 17-10-25 15:59, [hidden email] wrote:
>> Hi All!
>>
>> On AVR there is only a few kilobytes of RAM, so int and double (doube is
>> 32bits on AVR with AVR-libc) are the bigest problem!
> Why is it the bigest problem?
> I've used float on AVR without an issue.
> Sure, RAM/FLASH/CPU resources are pretty limited.
> But if you don't need debugging and logging functionality.
> That should be enough to implement some logic.
>
>
>> 2017-10-24 19:41 GMT+05:00 <[hidden email]>:
>>
>> > Hi Viacheslav,
>> >
>> > On 17-10-24 16:25, [hidden email] wrote:
>> > > I'm wondering how to correctly compile the sources using avr-gcc?
>> > What have you tried so far?
>> >
>> > > I need minimal working example (makefile and changes in the generated
>> > source code).
>> >
>> > matiec C library has some problems with compilation for 8bit
>> > microcontroller. int is 16bits on AVR. I've attached patch that is
>> > necessary to apply to matiec for that. Most likely some other problems
>> > may appear later.
>> >
>> > Mario, do you care about AVR support?
>> > I think it'd be nice to have Arduino out-of-the-box
>> > support in Beremiz.
>> >
>> >
>> > I've attached very simple Beremiz project that compiles IEC program
>> > using avr-gcc. It's missing avr hardware handling (I've mocked this in
>> > main_avr.c).
>> >
>> > In attached Beremiz project I placed already patched header file from
>> > matiec in project_files directory and it overrides matiec's original file
>> > using include path (see CFLAGS in the Makefile). Don't do this in
>> > production, it's just quick and dirty fix to test the idea.
>> >
>> > Short instruction: unpack archive, open the project in Beremiz and click
>> > build button. As a result in the project directory 'build' directory
>> > will be created with a firmware.elf file inside.
>> >
>> > --
>> > Best regards,
>> > Andrey Skvortsov
>> >
>> > ------------------------------------------------------------
>> > ------------------
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > _______________________________________________
>> > Beremiz-devel mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/beremiz-devel
>> >
>> >
>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>> _______________________________________________
>> Beremiz-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/beremiz-devel
>
>
> --
> Best regards,
> Andrey Skvortsov
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list

On 17-10-25 18:46, [hidden email] wrote:
> We needed logging and debug, so RAM usage is critical issue for us.

Paul, I've never meant, that YAPLC should use AVR.
ARM is a good choice. For the same reason as you we use ARM instead of
AVR in our development.

If someone wants to try run generated by matiec PLC code on AVR-based device,
why not. I looked at footprint. It's not that bad.


> среда, 25 октября 2017 г. пользователь написал:
> > On 17-10-25 15:59, [hidden email] wrote:
> >> Hi All!
> >>
> >> On AVR there is only a few kilobytes of RAM, so int and double (doube is
> >> 32bits on AVR with AVR-libc) are the bigest problem!
> > Why is it the bigest problem?
> > I've used float on AVR without an issue.
> > Sure, RAM/FLASH/CPU resources are pretty limited.
> > But if you don't need debugging and logging functionality.
> > That should be enough to implement some logic.
> >
> >
> >> 2017-10-24 19:41 GMT+05:00 <[hidden email]>:
> >>
> >> > Hi Viacheslav,
> >> >
> >> > On 17-10-24 16:25, [hidden email] wrote:
> >> > > I'm wondering how to correctly compile the sources using avr-gcc?
> >> > What have you tried so far?
> >> >
> >> > > I need minimal working example (makefile and changes in the generated
> >> > source code).
> >> >
> >> > matiec C library has some problems with compilation for 8bit
> >> > microcontroller. int is 16bits on AVR. I've attached patch that is
> >> > necessary to apply to matiec for that. Most likely some other problems
> >> > may appear later.
> >> >
> >> > Mario, do you care about AVR support?
> >> > I think it'd be nice to have Arduino out-of-the-box
> >> > support in Beremiz.
> >> >
> >> >
> >> > I've attached very simple Beremiz project that compiles IEC program
> >> > using avr-gcc. It's missing avr hardware handling (I've mocked this in
> >> > main_avr.c).
> >> >
> >> > In attached Beremiz project I placed already patched header file from
> >> > matiec in project_files directory and it overrides matiec's original
> file
> >> > using include path (see CFLAGS in the Makefile). Don't do this in
> >> > production, it's just quick and dirty fix to test the idea.
> >> >
> >> > Short instruction: unpack archive, open the project in Beremiz and
> click
> >> > build button. As a result in the project directory 'build' directory
> >> > will be created with a firmware.elf file inside.
> >> >
> >> > --
> >> > Best regards,
> >> > Andrey Skvortsov
> >> >
> >> > ------------------------------------------------------------
> >> > ------------------
> >> > Check out the vibrant tech community on one of the world's most
> >> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> > _______________________________________________
> >> > Beremiz-devel mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/beremiz-devel
> >> >
> >> >
> >
> >>
> ------------------------------------------------------------------------------
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >
> >> _______________________________________________
> >> Beremiz-devel mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/beremiz-devel
> >
> >
> > --
> > Best regards,
> > Andrey Skvortsov
> >

> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Hi, Andrey!

  On the other hand I didn't mean that AVR is totaly garbage. I just highligthed some problems which may rise on AVR.
BTW, AVR with external RAM may be used if one wants debug and logging support.

Best regards,
Paul Beltyukov

2017-10-25 18:56 GMT+05:00 <[hidden email]>:

On 17-10-25 18:46, [hidden email] wrote:
> We needed logging and debug, so RAM usage is critical issue for us.

Paul, I've never meant, that YAPLC should use AVR.
ARM is a good choice. For the same reason as you we use ARM instead of
AVR in our development.

If someone wants to try run generated by matiec PLC code on AVR-based device,
why not. I looked at footprint. It's not that bad.


> среда, 25 октября 2017 г. пользователь написал:
> > On 17-10-25 15:59, [hidden email] wrote:
> >> Hi All!
> >>
> >> On AVR there is only a few kilobytes of RAM, so int and double (doube is
> >> 32bits on AVR with AVR-libc) are the bigest problem!
> > Why is it the bigest problem?
> > I've used float on AVR without an issue.
> > Sure, RAM/FLASH/CPU resources are pretty limited.
> > But if you don't need debugging and logging functionality.
> > That should be enough to implement some logic.
> >
> >
> >> 2017-10-24 19:41 GMT+05:00 <[hidden email]>:
> >>
> >> > Hi Viacheslav,
> >> >
> >> > On 17-10-24 16:25, [hidden email] wrote:
> >> > > I'm wondering how to correctly compile the sources using avr-gcc?
> >> > What have you tried so far?
> >> >
> >> > > I need minimal working example (makefile and changes in the generated
> >> > source code).
> >> >
> >> > matiec C library has some problems with compilation for 8bit
> >> > microcontroller. int is 16bits on AVR. I've attached patch that is
> >> > necessary to apply to matiec for that. Most likely some other problems
> >> > may appear later.
> >> >
> >> > Mario, do you care about AVR support?
> >> > I think it'd be nice to have Arduino out-of-the-box
> >> > support in Beremiz.
> >> >
> >> >
> >> > I've attached very simple Beremiz project that compiles IEC program
> >> > using avr-gcc. It's missing avr hardware handling (I've mocked this in
> >> > main_avr.c).
> >> >
> >> > In attached Beremiz project I placed already patched header file from
> >> > matiec in project_files directory and it overrides matiec's original
> file
> >> > using include path (see CFLAGS in the Makefile). Don't do this in
> >> > production, it's just quick and dirty fix to test the idea.
> >> >
> >> > Short instruction: unpack archive, open the project in Beremiz and
> click
> >> > build button. As a result in the project directory 'build' directory
> >> > will be created with a firmware.elf file inside.
> >> >
> >> > --
> >> > Best regards,
> >> > Andrey Skvortsov
> >> >
> >> > ------------------------------------------------------------
> >> > ------------------
> >> > Check out the vibrant tech community on one of the world's most
> >> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >> > _______________________________________________
> >> > Beremiz-devel mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/beremiz-devel
> >> >
> >> >
> >
> >>
> ------------------------------------------------------------------------------
> >> Check out the vibrant tech community on one of the world's most
> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >
> >> _______________________________________________
> >> Beremiz-devel mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/beremiz-devel
> >
> >
> > --
> > Best regards,
> > Andrey Skvortsov
> >

> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


--
Best regards,
Andrey Skvortsov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
In reply to this post by Beremiz-Devel mailing list
TARGET_LOGGING_DISABLE not working.

make: Entering directory `/d/Проекты/beremiz/test/build'
*** all done ***
avr-gcc -mmcu=atmega8 -O0 -DTARGET_DEBUG_DISABLE -DTARGET_LOGGING_DISABLE -DTARGET_EXT_SYNC_DISABLE -I../project_files -I"C:/Program Files (x86)/Beremiz/matiec/lib/C" -ffunction-sections -fdata-sections plc_main.c plc_debugger.c config.c resource1.c ../project_files/main_avr.c -o firmware.elf  -nodefaultlibs -Wl,--gc-section -lgcc -lc
plc_main.c:117:13: error: size of array 'LogBuff' is too large
 static char LogBuff[LOG_LEVELS][LOG_BUFFER_SIZE] LOG_BUFFER_ATTRS;
             ^
make: *** [all] Error 1

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
On 17-10-27 21:03, [hidden email] wrote:

> TARGET_LOGGING_DISABLE not working.
>
> make: Entering directory `/d/Проекты/beremiz/test/build'
> *** all done ***
> avr-gcc -mmcu=atmega8 -O0 -DTARGET_DEBUG_DISABLE -DTARGET_LOGGING_DISABLE -DTARGET_EXT_SYNC_DISABLE -I../project_files -I"C:/Program Files (x86)/Beremiz/matiec/lib/C" -ffunction-sections -fdata-sections plc_main.c plc_debugger.c config.c resource1.c ../project_files/main_avr.c -o firmware.elf  -nodefaultlibs -Wl,--gc-section -lgcc -lc
> plc_main.c:117:13: error: size of array 'LogBuff' is too large
>  static char LogBuff[LOG_LEVELS][LOG_BUFFER_SIZE] LOG_BUFFER_ATTRS;
>              ^
> make: *** [all] Error 1
>
Apparently you use not the latest Beremiz. I don't have such problem.

TARGET_LOGGING_DISABLE should work.
https://bitbucket.org/skvorl/beremiz/src/e5ddbaf756cb16471538634b7253c7af8c77c393/targets/plc_main_tail.c?at=default&fileviewer=file-view-default


--
Best regards,
Andrey Skvortsov



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
And how to get the latest Beremiz?  I have 24168e52fc2b (from the Beremiz-1.2-rc1 installer). When I copied sources from
 here https://bitbucket.org/skvorl/beremiz/downloads/ to the install dir everything has broken down. IDE no longer starts.

Is there any instructions for windows user? (maximum transparent)

Viacheslav

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Hi Viacheslav,

On 17-10-28 10:20, [hidden email] wrote:
> And how to get the latest Beremiz?  I have 24168e52fc2b (from the Beremiz-1.2-rc1 installer). When I copied sources from
>  here https://bitbucket.org/skvorl/beremiz/downloads/ to the install dir everything has broken down. IDE no longer starts.
Beremiz-1.2-rc1 installer is now almost a year old. It missing
zeroconf dependency needed for latest Beremiz.

There is wiki article how to install missing dependencies on
Beremiz-1.2-rc1. [1]

And I posted recently on the mailing list in discussion with Xiao link
to updated installer with all dependencies included. [2]


If you take notes during you AVR investigations, you can write them
into Beremiz community wiki [3]. So other people benefit from your
research as well.

1. https://bitbucket.org/skvorl/beremiz/wiki/How%20to%20install%20Zeroconf%20on%20Windows%20using%20pip
2. https://cloud.woelkli.com/s/Wa7G5uvmqArkyoI
3. https://bitbucket.org/skvorl/beremiz/wiki/Home

> Is there any instructions for windows user? (maximum transparent)
>
> Viacheslav


--
Best regards,
Andrey Skvortsov



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Now it works, thank you. I'll make some experiments with Arduino Mega2560 board.

As for other people. It's difficult for me to write in English and use the mailing list for communication. It easier to write to the forum as I did it with OpenPLC.

Viacheslav

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
I changed build order and now use my own makefile (for avr-gcc 4.9.2 from Arduino SDK).

Now I have 3 questions:

1. What should be in the main_avr.c file? Where I can read about this?
2. How to attach (declare) avr input and output pins to the plc project?
3. How to add external functions (for st)?

Viacheslav

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

build.log (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Another problem.

I loaded hex file to my Arduino board and run debugger. As I see __init() declared in plc_main.c, but there is no code who called _init() on avr (!)

The first command is jump to __init() and nothing works after that of course - return to space.

I think this is compiler behavior because __init is reserved name for the startup code and I don't know how to avoid this.

Viacheslav

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
This described here: http://www.nongnu.org/avr-libc/user-manual/mem_sections.html

.init0: Weakly bound to __init(). If user defines __init(), it will be jumped into immediately after a reset.

_it will be jumped into immediately after a reset_

This is a dead end I think.

Vischeslav

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Hi Vischeslav,

On 17-10-28 21:52, [hidden email] wrote:
> This described here: http://www.nongnu.org/avr-libc/user-manual/mem_sections.html
>
> .init0: Weakly bound to __init(). If user defines __init(), it will be jumped into immediately after a reset.
>
> _it will be jumped into immediately after a reset_
>
> This is a dead end I think.
Dead end? What's problem?
It's open source. Change the name of the function and see whether it
fixes your problem.

And __init() should be called from main_avr like __run() to make
it work. I forgot to add it and I see I commented out __run() in my example.


--
Best regards,
Andrey Skvortsov



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Ok :)

I changed __init(...) to __begin() in plc_main_head.c. Now it works and start point is main again.
I made my own timer and check intervals using Proteus and Arduino board too. It works!

Also I add another task, program (ST) and resource.

Now I'm ready to make some blink example.

Viacheslav.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
I have a simple ST program:

void PROGRAM0_init__(PROGRAM0 *data__, BOOL retain) {
  __INIT_VAR(data__->BFIRSTCYCLE,__BOOL_LITERAL(TRUE),retain)
  TON_init__(&data__->T1,retain);
  __INIT_LOCATED(BOOL,__QX0_1,data__->OUT0,retain)
  __INIT_LOCATED_VALUE(data__->OUT0,__BOOL_LITERAL(FALSE))
}

// Code part
void PROGRAM0_body__(PROGRAM0 *data__) {
  // Initialise TEMP variables

  if (__GET_VAR(data__->BFIRSTCYCLE,)) {
    __SET_VAR(data__->,BFIRSTCYCLE,,__BOOL_LITERAL(FALSE));
  };
  __SET_VAR(data__->T1.,IN,,!(__GET_VAR(data__->T1.Q,)));
  __SET_VAR(data__->T1.,PT,,__time_to_timespec(1, 0, 1, 0, 0, 0));
  TON_body__(&data__->T1);
  if (__GET_VAR(data__->T1.Q,)) {
    __SET_LOCATED(data__->,OUT0,,!(__GET_LOCATED(data__->OUT0,)));
  };

  goto __end;

__end:
  return;
} // PROGRAM0_body__()

Where the data__->OUT0 is stored into __QX0_1 variable? How to properly declare and work with addressed variables in my main.c?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
Hi Viacheslav,

On 17-10-29 10:24, [hidden email] wrote:

> I have a simple ST program:
>
> void PROGRAM0_init__(PROGRAM0 *data__, BOOL retain) {
>   __INIT_VAR(data__->BFIRSTCYCLE,__BOOL_LITERAL(TRUE),retain)
>   TON_init__(&data__->T1,retain);
>   __INIT_LOCATED(BOOL,__QX0_1,data__->OUT0,retain)
>   __INIT_LOCATED_VALUE(data__->OUT0,__BOOL_LITERAL(FALSE))
> }
>
> // Code part
> void PROGRAM0_body__(PROGRAM0 *data__) {
>   // Initialise TEMP variables
>
>   if (__GET_VAR(data__->BFIRSTCYCLE,)) {
>     __SET_VAR(data__->,BFIRSTCYCLE,,__BOOL_LITERAL(FALSE));
>   };
>   __SET_VAR(data__->T1.,IN,,!(__GET_VAR(data__->T1.Q,)));
>   __SET_VAR(data__->T1.,PT,,__time_to_timespec(1, 0, 1, 0, 0, 0));
>   TON_body__(&data__->T1);
>   if (__GET_VAR(data__->T1.Q,)) {
>     __SET_LOCATED(data__->,OUT0,,!(__GET_LOCATED(data__->OUT0,)));
>   };
>
>   goto __end;
>
> __end:
>   return;
> } // PROGRAM0_body__()
>
> Where the data__->OUT0 is stored into __QX0_1 variable? How to properly declare and work with addressed variables in my main.c?
To bind PLC program with external variables is done by using IEC
addresses. Such variables called located. To do that correctly you need to
write Beremiz extension in Python. Don't worry Python is easy. If you
know C++ (as I see you already do), then you will be pretty
comfortable with Python.

The purpuse of extension is:
- to give user interface to configure some settings (if needed,
user can set direction of IO, select type of sensor connected to
analog input, configure analog output PWM frequency, set device
address on the bus and so on);
- to generate C code with located variables declaration (__QX0_1,  __QX0_1 is a pointer to actual data).
- to generate corresponding C code to bind PLC program with external
  variables (that copies values to/from external variables from/into located
  variable __QX0_1);
- add library with specific POUs, so they can be used by PLC user (if needed);
- to generate code needed to drive external functionality (if needed,
  This can be used to drive bus, handle protocol or make some
  other service work).


Beremiz has several extension already:
- c_ext (to write C code in Beremiz);
- py_ext (to use Python with PLC program, working only for
  Python-capable runtime);
- svgui (to create web interface using SVG);
- wxglade_hmi (to create native HMI using wxPython);
- canfestival (CANOpen protocol support).



All extensions are registered in features.py (see catalog variable).
Every extension has four C callbacks:
__init_XXXXX     - called before starting PLC program
__cleanup_XXXXX  - called after finishing PLC program
__retrieve_XXXXX - called before every PLC cycle (get values of input variables)
__publish_XXXXX  - called after every PLC cycle (set valous of output variables)

Here are python methods you most likely will need to implement:
- def CTNGenerate_C(self, buildpath, locations) generates C code
- def GetVariableLocationTree(self) defines located variables exported
  by this extension. These variables will be shown in browse dialog in
  Beremiz, when you select address for located variable.

You can look at the c_ext (C extension), it does not much. Only couple
of small python files. It only generates C code and doesn't have any
located variables.

How to use located variables you can can look at Modbus examples from
Mario [1].

These basic ideas are described in the article
"Open international IEC-61131 standard compliant programming languages
for computation systems based on Russian Sparc architecture
microprocessors" (Russian) written by I. Baranov, А. Glukhov.

You most likely have already read it as other articles about
Beremiz, that are linked on Beremiz website [2] in 'Collected
documents' section.

I understand that it's probably too much information at once for you.
I'd recommend you to experiment with using C extension first to have
idea how located variables work and how they can be implemented.
I've attached example for SoftPLC (GNU/Linux, Windows) to show you
basic concepts.

1. https://bitbucket.org/mjsousa/beremiz/src/c1298e7ffe3a3079ffa1e3e3fdc4548b2213bc04/modbus/modbus.py?at=default&fileviewer=file-view-default
2. http://www.beremiz.org/doc

--
Best regards,
Andrey Skvortsov



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

located_variables.tar.xz (1K) Download Attachment
signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Build sources using avr-gcc

Beremiz-Devel mailing list
...

> These basic ideas are described in the article
> "Open international IEC-61131 standard compliant programming languages
> for computation systems based on Russian Sparc architecture
> microprocessors" (Russian) written by I. Baranov, А. Glukhov.

Function name are changed now, by ideas still the same.

> You most likely have already read it as other articles about
> Beremiz, that are linked on Beremiz website [2] in 'Collected
> documents' section.


...

--
Best regards,
Andrey Skvortsov



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
12