Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault #21

Open
RickSeiden opened this issue Apr 21, 2021 · 7 comments
Open

Segmentation Fault #21

RickSeiden opened this issue Apr 21, 2021 · 7 comments

Comments

@RickSeiden
Copy link

Hello,

I'm using a Pi Zero W with a generic ili9340 display. I've got it wired as per your instructions in the README.md. I followed the directions that you have labeled just for the Raspberry Pi and did not receive any errors. during setup/compiling. When everything was done I ran:

./demo

from the Raspberry-ili9340spi directory and received the following error:

Your TFT resolution is 240 x 320.
Your TFT offsetx is 0.
Your TFT offsety is 0.
Segmentation fault

I looked through the issues and saw a recommendation to someone to use bmc2835 1.6.4, so I used the only Raspberry Pi instructions to use 1.64 instead. I still receive the same error.

Thank you

@nopnop2002
Copy link
Owner

I don't have Pi Zero W.
Do you have some other Pi?

@RickSeiden
Copy link
Author

Actually, I was just trying it out on a Pi 3 B, although I just swapped the SD card and didn't do a fresh install. I ended up with the same result.

@nopnop2002
Copy link
Owner

OK
Change some code of demo.c & try.

    // You can change font file
    FontxFile fx32G[2];
    FontxFile fx24G[2];
    FontxFile fx16G[2];
    Fontx_init(fx32G,"./fontx/ILGH32XB.FNT","./fontx/ILGZ32XB.FNT"); // 16x32Dot Gothic
    Fontx_init(fx24G,"./fontx/ILGH24XB.FNT","./fontx/ILGZ24XB.FNT"); // 12x24Dot Gothic
    Fontx_init(fx16G,"./fontx/ILGH16XB.FNT","./fontx/ILGZ16XB.FNT"); // 8x16Dot Gothic
    printf("pass1\n");

    FontxFile fx32M[2];
    FontxFile fx24M[2];
    FontxFile fx16M[2];
    Fontx_init(fx32M,"./fontx/ILMH32XF.FNT","./fontx/ILMZ32XF.FNT"); // 16x32Dot Mincyo
    Fontx_init(fx24M,"./fontx/ILMH24XF.FNT","./fontx/ILMZ24XF.FNT"); // 12x24Dot Mincyo
    Fontx_init(fx16M,"./fontx/ILMH16XB.FNT","./fontx/ILMZ16XF.FNT"); // 8x16Dot Mincyo
    printf("pass2\n");

    lcdInit(screenWidth, screenHeight, offsetx, offsety);
    printf("pass3\n");
    lcdReset();
    printf("pass4\n");
    lcdSetup();
    printf("pass5\n");

@RickSeiden
Copy link
Author

Hello

I have not made any changes to tft.config.

I hade already put in some debugging code in demo.c. I only made changes to the main function.

int main(int argc, char **argv)
{
    int i;
    int screenWidth = 0;
    int screenHeight = 0;
    int offsetx = 0;
    int offsety = 0;
    char dir[128];
    char cpath[128];

printf("argv[0]=%s\n",argv[0]);
    strcpy(dir, argv[0]);
    for(i=strlen(dir);i>0;i--) {
        if (dir[i-1] == '/') {
          dir[i] = 0;
          break;
        } // end if
    } // end for
printf("dir=%s\n",dir);
    strcpy(cpath,dir);
    strcat(cpath,"tft.conf");
printf("cpath=%s\n",cpath);
    if (ReadTFTConfig(cpath, &screenWidth, &screenHeight, &offsetx, &offsety) == 0) {
        printf("%s Not found\n",cpath);
        return 0;
    }
printf("ReadTFTConfig:screenWidth=%d height=%d\n",screenWidth, screenHeight);
    printf("Your TFT resolution is %d x %d.\n",screenWidth, screenHeight);
    printf("Your TFT offsetx    is %d.\n",offsetx);
    printf("Your TFT offsety    is %d.\n",offsety);


    // You can change font file
printf("fontx 0");
    FontxFile fx32G[2];
printf("fontx 1");
    FontxFile fx24G[2];
    FontxFile fx16G[2];
    Fontx_init(fx32G,"./fontx/ILGH32XB.FNT","./fontx/ILGZ32XB.FNT"); // 16x32Dot Gothic
    Fontx_init(fx24G,"./fontx/ILGH24XB.FNT","./fontx/ILGZ24XB.FNT"); // 12x24Dot Gothic
    Fontx_init(fx16G,"./fontx/ILGH16XB.FNT","./fontx/ILGZ16XB.FNT"); // 8x16Dot Gothic
printf("fontx 2");

This is what I get when I compile and run it:

argv[0]=./demo
dir=./
cpath=./tft.conf
width=240 height=320
ReadTFTConfig:screenWidth=240 height=320
Your TFT resolution is 240 x 320.
Your TFT offsetx    is 0.
Your TFT offsety    is 0.
Segmentation fault

It's weird because the first statement after the printf that outputs my offsety is just another printf, and I never see the output from that.

@RickSeiden
Copy link
Author

Hello again,

I started with a fresh install of the latest version of Raspberry PI OS, did sudo apt-get update, sudo apt-get upgrade and then followed the Rapsberry Pi only instructions. I did have to run sudo apt-get install git half way through, but other than that, I ran everything as the instructions indicated. I still get the segmentation fault error.

@RickSeiden
Copy link
Author

I figured it out. I was running

./demo

When I run

sudo ./demo

it works fine. So it's a permissions issue.

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 22, 2021

Older OS don't require permissions.

There may be a bug in the latest OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants