Bug in builder for LM3 platform Re: IMPORTANT: new build system in master

classic Classic list List threaded Threaded
3 messages Options
scdr scdr
Reply | Threaded
Open this post in threaded view
|

Bug in builder for LM3 platform Re: IMPORTANT: new build system in master


Finally got eLua to compile using the new builder system.
Targeting LM3s8962 and LM4F120

One thing that was lost in transition to the new build system were the switches telling the compiler and
the assembler about the target CPU.  (-mcpu=cortex-m3 -mthumb )

I got it to compile by adding the following lines to build_elua.lua (right near the other tests for things like lualong ).

if bd.get_arch_of_cpu( comp.cpu ) == 'cortexm3' then addcf( { '-mcpu=cortex-m3', '-mthumb' }) dprint("CortexM3") end
if bd.get_arch_of_cpu( comp.cpu ) == 'cortexm4' then addcf( { '-mcpu=cortex-m4', '-mthumb' }) dprint("CortexM4") end

Not sure if this omission affects other cortex platforms as well.

Took me quite a while to figure out where to add these.
The old build system was a lot easier to add tweaks like this without having to hunt so much.
Would be good to make the code clearer for quick tweaking - making it more obvious where to insert or change compiler arguments, etc.
(No, I don't understand how the old builder worked, and I don't understand the new one either, and I shouldn't have to
just to build the program, or to tell the compiler the options I want used.)

---

One downside of the new build system, it seems to assume that all boards that use the same platform will also use the
same CPU architecture.  The LM4F120 (Stellaris/Tiva launchpad) is a cortex M4 processor, but it uses the
same libraries/platform as the LM3s.  I found the table in build_data.lua, which has the aforementioned assumption
built into it.  How do I add the LM4F120, making it use the LM3s platform, but tell the build system that it is a cortex m4 processor?
Some tweaking of build_data.lua should make it possible to handle this situation gracefully.

Hope this helps

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Bug in builder for LM3 platform Re: IMPORTANT: new build system in master

Hello,

On Fri, Jun 21, 2013 at 4:22 AM, <[hidden email]> wrote:

Finally got eLua to compile using the new builder system.
Targeting LM3s8962 and LM4F120

One thing that was lost in transition to the new build system were the switches telling the compiler and
the assembler about the target CPU.  (-mcpu=cortex-m3 -mthumb )

I got it to compile by adding the following lines to build_elua.lua (right near the other tests for things like lualong ).

if bd.get_arch_of_cpu( comp.cpu ) == 'cortexm3' then addcf( { '-mcpu=cortex-m3', '-mthumb' }) dprint("CortexM3") end
if bd.get_arch_of_cpu( comp.cpu ) == 'cortexm4' then addcf( { '-mcpu=cortex-m4', '-mthumb' }) dprint("CortexM4") end

I don't know how you're using the build system, but If I do this on master:

$ lua build_elua.lua board=ek-lm3s8962 disp_mode=all

I can see the '-mcpu=cortex-m3 -mthumb' flags in the compiler command line.
Support for STM32F4 is not on master yet; if you need it, check the stm32f4 branch. It will be merged to the master soon.


Not sure if this omission affects other cortex platforms as well.

Took me quite a while to figure out where to add these.
The old build system was a lot easier to add tweaks like this without having to hunt so much.
Would be good to make the code clearer for quick tweaking - making it more obvious where to insert or change compiler arguments, etc.

That is coming as a separate commit which deals with the build system refactoring. Soon.
 
(No, I don't understand how the old builder worked, and I don't understand the new one either, and I shouldn't have to
just to build the program, or to tell the compiler the options I want used.)

The compiler switches come from three places:

- build_elua.lua: various generic macros, libraries and include paths + configurator related switches
- build_data.lua: platform-specific compiler switches (but generic amongst all CPUs in that platform)
- src/platform/<platform>/conf.lua: CPU/board specific macros/includes/libraries. This is also where you add the platform/CPU/board specific files that you need.
 

---

One downside of the new build system, it seems to assume that all boards that use the same platform will also use the
same CPU architecture.  

This is the idea behind the concept of "platform", yes. This is intentional.The CPU _architecture_ is the same, but the actual architecture implementation can vary between various CPUs.
 
The LM4F120 (Stellaris/Tiva launchpad) is a cortex M4 processor, but it uses the
same libraries/platform as the LM3s.  I found the table in build_data.lua, which has the aforementioned assumption
built into it.  How do I add the LM4F120, making it use the LM3s platform, but tell the build system that it is a cortex m4 processor?
Some tweaking of build_data.lua should make it possible to handle this situation gracefully.

build_data.lua is generic. It doesn't know anything at all about platform libraries and platform specific files. This is the kind of stuff you specify in the platform's conf.lua files. Look for example at src/platform/lm3s/conf.lua.

Best,
Bogdan
 

Hope this helps

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
raman raman
Reply | Threaded
Open this post in threaded view
|

Re: Bug in builder for LM3 platform Re: IMPORTANT: new build system in master

In reply to this post by scdr

* I wrote this mail in the morning. I thought I posted this but I just saw
it and apparently I didn't. My apologies.

Hello,

> One thing that was lost in transition to the new build system were
> the switches telling the compiler and the assembler about the target
> CPU.  (-mcpu=cortex-m3 -mthumb )

It is not a bug. We simply don't have the `cpu' option anymore. You
now build the code base by specifying the `board' option. In your case
that would look like this:

./build_elua.lua board=ek-lm3s8962 prog

From another post:
"In other words, the old invocation 'scons cpu=<...>" doesn't work at
all anymore. This makes sense, since eLua is generally built to run on
a board, not a CPU."

Please check the documentation [1] for more information on this.

> Not sure if this omission affects other cortex platforms as well.

The build process is common for all targets. You specify `board'.

> One downside of the new build system, it seems to assume that
> all boards that use the same platform will also use the same CPU
> architecture. [...] has the aforementioned assumption built into it.

That is not true. eLua currently doesn't support any Cortex-M4 clone
for LM3S and hence you don't see a reference to arch=`cortexm4'
in the platform_list table (from build_data.lua) you mentioned.

> How do I add the LM4F120, making it use the LM3s platform, but tell
> the build system that it is a cortex m4 processor? Some tweaking of
> build_data.lua should make it possible to handle this situation
> gracefully.

Getting eLua to run on the LM4F120 involves a bit of work (assuming
you have the perquisites [2]). You will need to touch various files and
add a few.

1. You may start off with build_data.lua and add the your new cpu
under the lm3s entry and include reference to Cortex-M4 for the
architecture (but it isn't the real deal yet).

2. Touch lm3s/build_config.lua to include board specific details. This is
generally used to specify configuration which is not available on other
platforms/boards. For example: The OLED module is not available on
all LM3S targets. So, the macro `ENABLE_DISP' is only defined (-D on
gcc) for the boards that support it.

3. You must also include your device specific files (should be supplied
by TI) like device specific headers and other platform libraries in lm3s/
See lm3s/driverlib for an example; this will give you an idea.

3. Add your linker file (something like lm4f-120.ld) and hack lm3s/conf.lua
to include this by checking for your board. Include the path to your device
specific files and add other compiler specific options like -mcpu=cortex-m4
here.

4. Your must also add a new file for your board in boards/known. This
contains the build configuration for your board.

5. Hopefully, if everything goes well, you should be able to run eLua on
your LM4F Cortex-M4 board.

I would suggest that you look into the code [3] for the other LM3S cpus.
This might give you an idea on how to extend the same for your new
target.

Good luck! Have fun with your board.

Best,
Raman

Links:
[1]: http://www.eluaproject.net/doc/master/en_building.html
[2]: http://www.eluaproject.net/doc/v0.9/en_arch_newport.html
[3]: https://github.com/elua/elua/tree/master/src/platform/lm3s