1. WxEuphoria on ARM

Matt,

I've been using wxEuphoria on my ARM platform but I'm having trouble capturing mouse events. Since I had to cross-compile wxWidgets as well, I tried running one of the sample programs that captures mouse events and it works fine on my device. Here is the snippet of what their code looks like:

void BombsCanvas::OnMouseEvent(wxMouseEvent& event) 
{ 
    const int gridWidth = m_game->GetWidth(); 
    const int gridHeight = m_game->GetHeight(); 
 
    wxCoord fx, fy; 
    event.GetPosition(&fx, &fy); 
.... 

Now looking in wxEuphoria.cpp we have the following which seems perfectly reasonable:

object WXEUAPI  mouse_event_position(intptr_t event) 
{ 
        s1_ptr pos = NewS1(2); 
        wxMouseEvent * e = (wxMouseEvent*) event; 
        pos->base[1] = e->GetX(); 
        pos->base[2] = e->GetY(); 
        return MAKE_SEQ( pos ); 
} 

But anytime my wxEuphoria progam tries to get the position of a mouse event, I get a segementation fault. GDB returns the following:

0x4024edfc in wxMouseEvent::GetX() const () from /usr/lib/libwxeu.so.16 
0x4024edfc <_ZNK12wxMouseEvent4GetXEv+20>:    ldr   r3,   [r3, #36] 

Any thoughts on what the difference could be? I see that wxEuphoria uses a different wxMouseEvent procedure than the example ( GetX() vs. GetPosition() ), but neither method works on my device.

Thanks in advance,
Ira

new topic     » topic index » view message » categorize

2. Re: WxEuphoria on ARM

Ira:

I don't use WxEuphoria but I see a possible problem; take a look at

event.GetPosition(&fx, &fy)

Note that the parameters for GetPosition are addresses of x and y

segementation faults are usually cause by passing bad pointers.

new topic     » goto parent     » topic index » view message » categorize

3. Re: WxEuphoria on ARM

BRyan,

Thanks for the reply! To clarify the problem:

The first snippet which uses event.GetPosition(&fx, &fy) is from a wxWidgets demo program and does work on my ARM platform.

The second snippet which uses e->GetX() is from the wxEuphoria source code and does not work, crashing with segmentation faults.

wxWidgets provides several ways to access the mouse position for a wxMouseEvent but these methods do not work inside of wxEuphoria programs for some reason. Could there be a problem with the type conversion for some reason?

wxMouseEvent * e = (wxMouseEvent*) event 

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

4. Re: WxEuphoria on ARM

Jerome said...

BRyan,

Thanks for the reply! To clarify the problem:

The first snippet which uses event.GetPosition(&fx, &fy) is from a wxWidgets demo program and does work on my ARM platform.

The second snippet which uses e->GetX() is from the wxEuphoria source code and does not work, crashing with segmentation faults.

wxWidgets provides several ways to access the mouse position for a wxMouseEvent but these methods do not work inside of wxEuphoria programs for some reason. Could there be a problem with the type conversion for some reason?

wxMouseEvent * e = (wxMouseEvent*) event 

Thanks,
Ira

I have no idea what I am talking about here. However, from ARM9 onwards ARM uses the Harvard architecture (as opposed to the von Neumann one we are used to).

This being the case, I would not be suprised to find out that some special porting effort is required to get wxEuphoria to run on ARM. (For example, http://www.nongnu.org/avr-libc/user-manual/porting.html#iar_porting_flash says that C was not designed for Harvard architectures.)

Keep in mind, I have no idea what I'm talking about here.

new topic     » goto parent     » topic index » view message » categorize

5. Re: WxEuphoria on ARM

Jerome said...

Any thoughts on what the difference could be? I see that wxEuphoria uses a different wxMouseEvent procedure than the example ( GetX() vs. GetPosition() ), but neither method works on my device.

It doesn't make sense to me why one would break and the other work. Try changing the wxEuphoria code to:

object WXEUAPI  mouse_event_position(intptr_t event) 
{ 
        s1_ptr pos = NewS1(2); 
        wxMouseEvent * e = (wxMouseEvent*) event; 
        e->getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

That code should be equivalent. Maybe that's what you already tried. The only quirk I'm really aware of is the problems with reading unaligned data. I wouldn't have thought it would be an issue here. Alternatively, you could try:

object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
        s1_ptr pos = NewS1(2); 
        event->getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

This breaks my convention that allows easy automatic wrapping, but maybe it will fix whatever weirdness you're running into with this function.

Matt

new topic     » goto parent     » topic index » view message » categorize

6. Re: WxEuphoria on ARM

jimcbrown said...

I would not be suprised to find out that some special porting effort is required to get wxEuphoria to run on ARM. (For example, http://www.nongnu.org/avr-libc/user-manual/porting.html#iar_porting_flash says that C was not designed for Harvard architectures.)

I still have a lot to learn about ARM but since Euphoria and wxWidgets cross-compile nicely, I was hoping wxEuphoria wouldn't be too much of a stretch.

mattlewis said...
object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
        s1_ptr pos = NewS1(2); 
        event->getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

Unfortunately I'm still getting segmentation faults. I'm sure there is a key point I'm overlooking; I'll try to hunt it down!

Is there any interest in using Euphoria on ARM platforms, especially with the Raspberrypi (http://www.raspberrypi.org/ , http://openeuphoria.org/forum/116139.wc#116139) coming out soon?

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

7. Re: WxEuphoria on ARM

Yes

I'm interested in using Euphoria under ARM

hopefully it should be doable to compile
android for the PI.

a combination of PI + android + Euphoria would
make a nice dev target.

I would like to have the option of Euphoria running
against a shared library to save disk space for the PI,
instead of all binaries being statically linked.

i did have some shell script for v3 of Euphoria that would
link against the eu.a library compiled as a .so/.dll

feature request ?

maybe a new keyword

 
--// NOW 
--// automatically compiles and links statically 
include std/math.e 
 
--// ADDITIONAL 
--// function/procedure syntax check interface only 
--// similar to 'C' includes to check function signatures 
--// 
--// then link against command line -leui -leui-std  
--// 
--// where 
--// 
--//    -leui      = libeui.[so|dll]     from eu.a 
--//    -leui-std  = libeui-std.[so|dll] from std/*.e 
import std/math.e 


ras

new topic     » goto parent     » topic index » view message » categorize

8. Re: WxEuphoria on ARM

raseu said...

I would like to have the option of Euphoria running
against a shared library to save disk space for the PI,
instead of all binaries being statically linked.

i did have some shell script for v3 of Euphoria that would
link against the eu.a library compiled as a .so/.dll

Yes, I've done this in the past. The sizes were pretty small, so it never made much difference on a PC, but I could see this being important for a mobile device.

Matt

new topic     » goto parent     » topic index » view message » categorize

9. Re: WxEuphoria on ARM

Jerome said...
jimcbrown said...

I would not be suprised to find out that some special porting effort is required to get wxEuphoria to run on ARM. (For example, http://www.nongnu.org/avr-libc/user-manual/porting.html#iar_porting_flash says that C was not designed for Harvard architectures.)

I still have a lot to learn about ARM but since Euphoria and wxWidgets cross-compile nicely, I was hoping wxEuphoria wouldn't be too much of a stretch.

mattlewis said...
object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
        s1_ptr pos = NewS1(2); 
        event->getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

Unfortunately I'm still getting segmentation faults. I'm sure there is a key point I'm overlooking; I'll try to hunt it down!

Is there any interest in using Euphoria on ARM platforms, especially with the Raspberrypi (http://www.raspberrypi.org/ , http://openeuphoria.org/forum/116139.wc#116139) coming out soon?

Thanks,
Ira

I sent a post a few month ago about compiling euphoria on my Efika netbook. But I had a problem running some of the examples program that comes with euphoria. At the time someone suggested some solution but I didn't take the time to look at it. I would be happy to use euphoria on my Efika but I won't spend time trying to debug the source code. I'm waiting for a stable and working euphhoria for ARM platform. Until then I stick to C programming.

Jacques

new topic     » goto parent     » topic index » view message » categorize

10. Re: WxEuphoria on ARM

jimcbrown said...
Jerome said...

BRyan,

Thanks for the reply! To clarify the problem:

The first snippet which uses event.GetPosition(&fx, &fy) is from a wxWidgets demo program and does work on my ARM platform.

The second snippet which uses e->GetX() is from the wxEuphoria source code and does not work, crashing with segmentation faults.

wxWidgets provides several ways to access the mouse position for a wxMouseEvent but these methods do not work inside of wxEuphoria programs for some reason. Could there be a problem with the type conversion for some reason?

wxMouseEvent * e = (wxMouseEvent*) event 

Thanks,
Ira

I have no idea what I am talking about here. However, from ARM9 onwards ARM uses the Harvard architecture (as opposed to the von Neumann one we are used to).

This being the case, I would not be suprised to find out that some special porting effort is required to get wxEuphoria to run on ARM. (For example, http://www.nongnu.org/avr-libc/user-manual/porting.html#iar_porting_flash says that C was not designed for Harvard architectures.)

Keep in mind, I have no idea what I'm talking about here.

ARM as always been Harvard architecture and ARM9 is not new it is in fact a classic core. And as for C language, there is many C compilers that work with Harvard architecture microcontroller. I program Microchip PIC which are Harvard architecture too and there is many C compilers for PIC.

Jacques

new topic     » goto parent     » topic index » view message » categorize

11. Re: WxEuphoria on ARM

Jacques said...

I sent a post a few month ago about compiling euphoria on my Efika netbook. But I had a problem running some of the examples program that comes with euphoria. .... I'm waiting for a stable and working euphhoria for ARM platform.

I believe that last time you were having a problem with "missing magic". I've noticed that this happens to me when I use different cross-compilers for my ARM system. Can you post information about the compiler on your Efika notebook?

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

12. Re: WxEuphoria on ARM

Jerome said...
Jacques said...

I sent a post a few month ago about compiling euphoria on my Efika netbook. But I had a problem running some of the examples program that comes with euphoria. .... I'm waiting for a stable and working euphhoria for ARM platform.

I believe that last time you were having a problem with "missing magic". I've noticed that this happens to me when I use different cross-compilers for my ARM system. Can you post information about the compiler on your Efika notebook?

Thanks,
Ira

On Efika gcc report version 4.4.5

Jacques

new topic     » goto parent     » topic index » view message » categorize

13. Re: WxEuphoria on ARM

I've been using CodeSourcery toolchains for ARM.

>> sb2 -t armel gcc --version 
>>    arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2011.03-41) 4.5.2 

I'll grab the same version gcc crosscompiler and play with that.

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

14. Re: WxEuphoria on ARM

Jerome said...
mattlewis said...
object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
        s1_ptr pos = NewS1(2); 
        event->getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

Unfortunately I'm still getting segmentation faults. I'm sure there is a key point I'm overlooking; I'll try to hunt it down!

Actually, looking at this message http://openeuphoria.org/forum/m/116226.wc

Jerome said...
mattlewis said...

I seem to recall very similar errors happening. I believe that ARM processors require 16 byte alignment or something. We've probably either missed doing so somewhere or had a regression.

Yes, I use to get this illegal instruction when we first started:

0x002ff9b4 in decompress (c=251) at be_decompress.c:75  
75        d = (double)*(float *)string_ptr;  

Which was fixed with:

float f;  
d = (double)*(float*)memcpy((void*)&f, (void*)string_ptr, 4);  

Jacques, for your illegal instruction, can you give this a try?

... 
//--d= *(double *)string_ptr;  
memcpy(&d, (double *)string_ptr, 8); 
... 

Thanks,
Ira

I wonder if this would fix it:

object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
	wxCoord fx, fy; 
        event->getPosition( &fx, &fy ); 
        s1_ptr pos = NewS1(2); 
	memcpy(pos->base + 1, &fx, sizeof(wxCoord)); 
	memcpy(pos->base + 2, &fy, sizeof(wxCoord)); 
        return MAKE_SEQ( pos ); 
} 

That is, using memcpy() to get around the alignment issues which cause the illegal instructions/segmentation fault errors.

Or try memmove() :

object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
	wxCoord fx, fy; 
        event->getPosition( &fx, &fy ); 
        s1_ptr pos = NewS1(2); 
	memmove(pos->base + 1, &fx, sizeof(wxCoord)); 
	memmove(pos->base + 2, &fy, sizeof(wxCoord)); 
        return MAKE_SEQ( pos ); 
} 
Jerome said...

Is there any interest in using Euphoria on ARM platforms, especially with the Raspberrypi (http://www.raspberrypi.org/ , http://openeuphoria.org/forum/116139.wc#116139) coming out soon?

Thanks,
Ira

Yes, definitely. I have it running also, although I haven't set up wxWidgets or wxEuphoria.

new topic     » goto parent     » topic index » view message » categorize

15. Re: WxEuphoria on ARM

jimcbrown said...

I wonder if this would fix it:

object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
	wxCoord fx, fy; 
        event->getPosition( &fx, &fy ); 
        s1_ptr pos = NewS1(2); 
	memcpy(pos->base + 1, &fx, sizeof(wxCoord)); 
	memcpy(pos->base + 2, &fy, sizeof(wxCoord)); 
        return MAKE_SEQ( pos ); 
} 

That is, using memcpy() to get around the alignment issues which cause the illegal instructions/segmentation fault errors.

Or try memmove() ...

Thanks for looking into this again! Unfortunately, I get the segmentation fault when calling the member function GetPosition of wxMouseEvent. I wasn't able to find a solution. In the mean time I've been using C+ + and wxFormBuilder. In this way the code for the GUI and the boiler plate C+ + stuff is generated for me; you just need to fill in your code to handle events.

I'd be curious to know if you have any issues with wxEuphoria on your Nook Color. I also plan on trying it on the Raspberry Pi for another data point.

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

16. Re: WxEuphoria on ARM

Jerome said...
jimcbrown said...

I wonder if this would fix it:

object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
	wxCoord fx, fy; 
        event->getPosition( &fx, &fy ); 
        s1_ptr pos = NewS1(2); 
	memcpy(pos->base + 1, &fx, sizeof(wxCoord)); 
	memcpy(pos->base + 2, &fy, sizeof(wxCoord)); 
        return MAKE_SEQ( pos ); 
} 

That is, using memcpy() to get around the alignment issues which cause the illegal instructions/segmentation fault errors.

Or try memmove() ...

Thanks for looking into this again! Unfortunately, I get the segmentation fault when calling the member function GetPosition of wxMouseEvent.

Hmm. Looking at the original post, the code that worked was

void BombsCanvas::OnMouseEvent(wxMouseEvent& event) 
{ 
    const int gridWidth = m_game->GetWidth(); 
    const int gridHeight = m_game->GetHeight(); 
 
    wxCoord fx, fy; 
    event.GetPosition(&fx, &fy); 
.... 

So event is being passed by reference, rather than as a pointer.

Officially, though, dealing with C++ pass by reference in C uses pointers, and a guide for doing it on ARM does it the same way (the only difference I can see is the addition of 'const' for the C side declaration). http://infocenter.arm.com/help/topic/com.arm.doc.dui0203j/Cacjfjei.html#Babegiff

I wonder if it is crashing on the deference of event, or on the actual call to getPosition after the dereference is made. This code breaks up the two:

object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
	wxMouseEvent wme = *event; 
        s1_ptr pos = NewS1(2); 
        wme.getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

This code tries to do it as a reference instead of a pointer (it should not make a difference, though, but it might be worth trying out for completeness's sake).

object WXEUAPI  mouse_event_position(wxMouseEvent event&) 
{ 
        s1_ptr pos = NewS1(2); 
        event.getPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 
Jerome said...

I wasn't able to find a solution. In the mean time I've been using C+ + and wxFormBuilder. In this way the code for the GUI and the boiler plate C+ + stuff is generated for me; you just need to fill in your code to handle events.

I'd be curious to know if you have any issues with wxEuphoria on your Nook Color. I also plan on trying it on the Raspberry Pi for another data point.

Thanks,
Ira

I haven't tried wxEuphoria on here yet. I'm not sure I have C installed (and if not, if I'll have enough space to install it). I definitely don't have wxWidgets installed, but since this is Ubuntu I should just be able to use apt-get to install it painlessly.

new topic     » goto parent     » topic index » view message » categorize

17. Re: WxEuphoria on ARM

jimcbrown said...

Officially, though, dealing with C++ pass by reference in C uses pointers, and a guide for doing it on ARM does it the same way (the only difference I can see is the addition of 'const' for the C side declaration). http://infocenter.arm.com/help/topic/com.arm.doc.dui0203j/Cacjfjei.html#Babegiff

Good to know, thanks!

jimcbrown said...
object WXEUAPI  mouse_event_position(wxMouseEvent *event) 
{ 
	wxMouseEvent wme = *event; 
        s1_ptr pos = NewS1(2); 
        wme.GetPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

It looks like it is crashing on the dereference of the event; I get the following in gdb:

Program received signal SIGEGV, Segmentation fault. 
0x40da70c0 in wxEvent::wxEvent(wxEvent const&) () 
 from libwx_base-2.8.so.0 

jimcbrown said...
object WXEUAPI  mouse_event_position(wxMouseEvent event&) 
{ 
        s1_ptr pos = NewS1(2); 
        event.GetPosition( pos->base + 1, pos->base + 2 ); 
        return MAKE_SEQ( pos ); 
} 

This one crashes on the GetPosition:

Program received signal SIGEGV, Segmentation fault. 
0x40650418 in wxMouseEvent::GetPosition(int*, int*) const () 
 from libwxeu.so.16 

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu