您尚未登录。

楼主 #1 2019-03-10 15:42:12

ArcherEmiya
会员
注册时间: 2019-03-10
已发帖子: 6
积分: 6

licheepi nano 移植SDL2运行程序报Illegal instruction

按照licheepinaono的指导手册编译好了UBOOT,使用buildroot自带的编译器编译了主线linux和rootfs,将SDL编译好的lib下得文件拷到了nano的跟文件系统、/usr/lib下,交叉编译了一个测试程序,就是初始化一下SDL就退出了。运行的时候提示Illegal instruction,同样编译了helloworld是可以运行的,应该不是编译器问题,文件系统和内核都是用的这个编译器,现在搞不清楚问题出在哪,linux菜鸟一个,请教大神建议。

SDL配置
./configure --prefix=/home/yuan/work/SDL2-2.0.9/SDLlib --disable-video-nanox \
                    --disable-video-qtopia \
            --disable-video-photon \
            --disable-video-direct \
            --disable-video-ggi \
            --disable-video-svga \
            --disable-video-aalib \
            --disable-video-dummy \
            --disable-video-dga \
            --enable-video-fbcon \
            --disable-arts \
            --disable-esd \
            --disable-alsa \
            --disable-video-x11 \
            --disable-nasm \
            --disable-debug \
            --disable-joystick-amigaos \
            --disable-joystick-beos \
            --disable-joystick-bsd \
            --disable-joystick-darwin \
            --disable-joystick-dc \
            --disable-joystick-linux \
            --disable-joystick-macos \
            --disable-joystick-mint \
            --disable-joystick-win32 \
            --disable-joystick \
            --disable-input-tslib \
            --host=arm-none-linux-gnueabi \
            --build=i386

程序编译
arm-none-linux-gnueabi-gcc -I/home/yuan/work/SDL2-2.0.9/SDLlib/include -L/home/yuan/work/SDL2-2.0.9/SDLlib/lib main.c -o main -lSDL2

离线

#2 2019-03-10 15:46:38

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

你用哪个编译器?





离线

楼主 #3 2019-03-11 07:57:17

ArcherEmiya
会员
注册时间: 2019-03-10
已发帖子: 6
积分: 6

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

回大神,我又检查了一遍编译链工具,发现之前是从buildroot的dl文件夹里面拷出来的arm-none-linux-gnueabi-2014.5,现在我直接换成了buildroot里面output/host下的编译好的工具链,这样编译的程序不再报非法指令了,又出现新问题了,运行显示一张BMP图片的程序,提示初始化失败,没有设备。Could not initialize SDL - No available video device。又不知道问题出在哪边了,唉

离线

#4 2019-03-11 08:23:16

超级萌新
会员
注册时间: 2018-05-04
已发帖子: 408
积分: 407

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

你跑的是 buildroot 生成的程序?具体是哪个程序?

离线

楼主 #5 2019-03-31 10:00:07

ArcherEmiya
会员
注册时间: 2019-03-10
已发帖子: 6
积分: 6

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

超级萌新 说:

你跑的是 buildroot 生成的程序?具体是哪个程序?

不是buildroot生成的程序,是网上找的一段测试程序

#include "SDL2/SDL.h"
#include <stdio.h>

const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int init();
int loadMedia();
void close();

SDL_Window* gWindow = NULL;
SDL_Surface* gScreenSurface = NULL;
SDL_Surface* gHelloWorld = NULL;

int init()
{
    int success = 1;

    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
        success = 0;
    }
    else
    {
        gWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
        if( gWindow == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
            success = 0;
        }
        else
        {
            gScreenSurface = SDL_GetWindowSurface( gWindow );
        }
    }

    return success;
}

int loadMedia()
{
    int success = 1;

    gHelloWorld = SDL_LoadBMP( "/usr/hello_world.bmp" );
    if( gHelloWorld == NULL )
    {
        printf( "Unable to load image %s! SDL Error: %s\n", "hello_world.bmp", SDL_GetError() );
        success = 0;
    }

    return success;
}

void close()
{
    SDL_FreeSurface( gHelloWorld );
    gHelloWorld = NULL;

    SDL_DestroyWindow( gWindow );
    gWindow = NULL;

    SDL_Quit();
}

int main( int argc, char* args[] )
{
    if( !init() )
    {
        printf( "Failed to initialize!\n" );
    }
    else
    {
        if( !loadMedia() )
        {
            printf( "Failed to load media!\n" );
        }
        else
        {
            SDL_BlitSurface( gHelloWorld, NULL, gScreenSurface, NULL );
           
            SDL_UpdateWindowSurface( gWindow );

            SDL_Delay( 2000 );
        }
    }

    close();

    return 0;
}

初始化SDL阶段就报错退出了。我就将交叉编译的SDL2库的lib文件拷到了板子的/usr/lib下,然后测试程序和bmp图片放在了/usr下

离线

#6 2019-03-31 10:36:33

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

http://sdl.beuc.net/sdl.wiki/SDL_envvars

#SDL_VIDEODRIVER=fbcon ./test





离线

楼主 #7 2019-03-31 13:32:01

ArcherEmiya
会员
注册时间: 2019-03-10
已发帖子: 6
积分: 6

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

晕哥 说:

http://sdl.beuc.net/sdl.wiki/SDL_envvars

#SDL_VIDEODRIVER=fbcon ./test

现在又显示SDL could not initialize! SDL_Error: fbcon not available
Failed to initialize!

我把SDL_FBDEV也设置了/dev/fb0

离线

#8 2019-03-31 15:23:54

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

刚刚下载 最新的 SDL 2.0 代码仔细研究, 发现居然没有 fbcon,

后来一番操作之后,  确认只有 1.2 版本才有 fbcon,

你用的应该是 2.0, 下载一个 1.2 版本再试一试.





离线

楼主 #9 2019-03-31 16:11:24

ArcherEmiya
会员
注册时间: 2019-03-10
已发帖子: 6
积分: 6

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

晕哥 说:

刚刚下载 最新的 SDL 2.0 代码仔细研究, 发现居然没有 fbcon,

后来一番操作之后,  确认只有 1.2 版本才有 fbcon,

你用的应该是 2.0, 下载一个 1.2 版本再试一试.

谢谢晕哥,换了1.2.15的立马就出图像了,之前搞的晕死了,多谢大神

离线

#10 2019-03-31 16:14:22

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

哈, 解决就好,  日后有空过来持续挖坑.





离线

#11 2019-06-19 13:23:22

Jmhh247
会员
注册时间: 2018-12-21
已发帖子: 262
积分: 262

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

不带你们这样玩的啊, 晕哥,SDL2还是要填坑的!!!


我用buildroot2017制作根文件系统,就是这荔枝派教程帖子里 https://whycan.cn/t_561.html ,目的是想用用ffplay。


所以选中ffmpeg和ffplay编译,因为ffplay需要SDL2支持,所以buildroot自动选中了SDL2。

buildroot编译成功后测试:ffplay xx.mp4

也是提示:Could not initialize SDL - No available video device。



一翻搜索,说是SDL2需要directfb。

buildroot选中directfb,继续编译测试。

设置export SDL_VIDEODRIVER=directfb,运行ffplay,显示:

Could not initialize SDL - directfb not available
(Did you set the DISPLAY variable?)


后面怎么破。。。

离线

#12 2019-06-19 13:53:20

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

ffplay 或许也支持 fbdev

https://www.ffmpeg.org/ffmpeg-devices.html

4.4.2 Examples
Play a file on framebuffer device /dev/fb0. Required pixel format depends on current framebuffer settings.

ffmpeg -re -i INPUT -c:v rawvideo -pix_fmt bgra -f fbdev /dev/fb0





离线

#13 2019-06-19 14:12:07

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

https://whycan.cn/t_1356.html#p6702

我这个勾选 directfb 之后, cairo 就可以跑了。





离线

#14 2019-06-19 16:29:43

Jmhh247
会员
注册时间: 2018-12-21
已发帖子: 262
积分: 262

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

晕哥 说:

https://whycan.cn/t_1356.html#p6702

我这个勾选 directfb 之后, cairo 就可以跑了。


这能说明directfb正常工作了吧,看帖子里你用的是SDL1。。。


晕哥,编译后,directfb需要怎么配置吗,就是那个directfbrc文件,还是免配置直接运行的

离线

#15 2019-06-19 17:07:43

nuvoton
会员
注册时间: 2019-06-17
已发帖子: 59
积分: 59

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

应该是免配置的, 因为搜到的 ubuntu sdl2 ffplay 只要安装 sdl2 & directfb 包就可以跑。

或者你在这个地方跟踪进去, 看是什么原因导致错误:

directfb not available

离线

#16 2019-06-25 10:16:40

Jmhh247
会员
注册时间: 2018-12-21
已发帖子: 262
积分: 262

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

nuvoton 说:

应该是免配置的, 因为搜到的 ubuntu sdl2 ffplay 只要安装 sdl2 & directfb 包就可以跑。

或者你在这个地方跟踪进去, 看是什么原因导致错误:

directfb not available


从源码看还是video驱动的问题,有时间继续看看:

    /* Select the proper video driver */
    index = 0;
    video = NULL;
    if (driver_name == NULL) {
        driver_name = SDL_getenv("SDL_VIDEODRIVER");
    }
    if (driver_name != NULL) {
        for (i = 0; bootstrap[i]; ++i) {
            if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
                if (bootstrap[i]->available()) {
                    video = bootstrap[i]->create(index);
                    break;
                }
            }
        }
    } else {
        for (i = 0; bootstrap[i]; ++i) {
            if (bootstrap[i]->available()) {
                video = bootstrap[i]->create(index);
                if (video != NULL) {
                    break;
                }
            }
        }
    }
    if (video == NULL) {
        if (driver_name) {
            return SDL_SetError("%s not available", driver_name);
        }
        return SDL_SetError("No available video device");
    }

离线

#17 2019-08-04 22:04:18

qinxiongxu
会员
注册时间: 2018-12-13
已发帖子: 88
积分: 80.5

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

请问下楼主编译有没遇到说找不到链接库lpuse,lpulse_simple的问题?我已经手动ln到/usr/lib/目录下面了这2个so库,但交叉编译还是报错说找不到的问题,请问楼主是怎么解决的?谢谢!
/mnt/sdc/f1c100s/C600/C600_Linux/out/sunivw1p1/linux/common/buildroot/external-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lpulse-simple
/mnt/sdc/f1c100s/C600/C600_Linux/out/sunivw1p1/linux/common/buildroot/external-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lpulse

离线

#18 2019-08-04 22:07:13

qinxiongxu
会员
注册时间: 2018-12-13
已发帖子: 88
积分: 80.5

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

晕哥 说:

你用哪个编译器?

请问晕哥有没遇交叉编译SDL1.2.15时,编译器无法连接到libpulse.so和libpulse_simple.so这2个库的问题?

离线

#19 2019-08-05 08:18:04

jimmy
会员
注册时间: 2017-10-29
已发帖子: 316
积分: 315

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

pulse 貌似 buildroot 集成了吧, 整合进去就可以了。

离线

#20 2020-08-21 13:47:00

jkl
会员
注册时间: 2019-11-18
已发帖子: 251
积分: 139.5

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

Jmhh247 说:

从源码看还是video驱动的问题,有时间继续看看:

    /* Select the proper video driver */
    index = 0;
    video = NULL;
    if (driver_name == NULL) {
        driver_name = SDL_getenv("SDL_VIDEODRIVER");
    }
    if (driver_name != NULL) {
        for (i = 0; bootstrap[i]; ++i) {
            if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
                if (bootstrap[i]->available()) {
                    video = bootstrap[i]->create(index);
                    break;
                }
            }
        }
    } else {
        for (i = 0; bootstrap[i]; ++i) {
            if (bootstrap[i]->available()) {
                video = bootstrap[i]->create(index);
                if (video != NULL) {
                    break;
                }
            }
        }
    }
    if (video == NULL) {
        if (driver_name) {
            return SDL_SetError("%s not available", driver_name);
        }
        return SDL_SetError("No available video device");
    }

你好,请问一下,您的这个问题最后解决了吗?我现在遇到跟您一样的问题

最近编辑记录 jkl (2020-08-21 13:47:49)

离线

#21 2023-04-17 17:58:31

simitel
会员
注册时间: 2023-04-17
已发帖子: 1
积分: 1

Re: licheepi nano 移植SDL2运行程序报Illegal instruction

我在SDL2+DirectFB跑通了简单的SDL2的例子。
当然不是在全志SOC的平台上。

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn