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

"ls -l" raises usage fault #50

Open
akioolin opened this issue Oct 18, 2017 · 4 comments
Open

"ls -l" raises usage fault #50

akioolin opened this issue Oct 18, 2017 · 4 comments
Assignees
Labels

Comments

@akioolin
Copy link

akioolin commented Oct 18, 2017

hello, pikoRT developer:

Thank you for create this wonder land.

the following is how to generate the fault which i meet.

after OS boot sequence complete, the prompt will be displayed.
type the below 'ls' operation, will cause system hang up.

step 1. type 'ls'
step 2. type 'ls -l'
step 3. type 'ls'

the system will show the message like below:

#UsageFault

r0: 00000000 r1: 00003e73 r2: 00000002 r3: 00000014
r4: 00000008 r5: 200011f8 r6: 00000000 r7: 00003e73
r8: 00000002 r9: 00003688 r10: 20000f9c r11: 00000000
r12: 0000002d sp: 20028f90 lr: 000034a5 pc: 00002d82

EXC_RETURN: fffffff1
ufsr: 00000002 <INVSTATE>
-------------------------------------------------------------

-------------------------------------------------------------
#HardFault

r0: 00000000 r1: 00003e73 r2: 00000002 r3: 00000014
r4: 00000008 r5: 200011f8 r6: 00000000 r7: 00003e73
r8: 00000002 r9: 00003688 r10: 20000f9c r11: 00000000
r12: 0000002d sp: 20028f90 lr: 000034a5 pc: 00002d82

EXC_RETURN: fffffff1

for trying to understand the 'ls' command's flow, i try to add come code in the
below code piece.

    if (argc == 1)
        dir = opendir("/");  // FIXME: get current directory
    else {
        dir = opendir(argv[1]);
        printk("argv[1]=>%s, open %s\n", argv[1], (dir==NULL) ? "no dir":" done");
    }

    do {
        readdir_r(dir, &dirent, &result);
        if (result != NULL)
            printk("% 6d %s\n", dirent.d_ino, dirent.d_name);
    } while (result != NULL);
    closedir(dir);

the question is after step 3., the system will hang on. what is the root cause of this problem?
how to fix this problem?

Thank you very much.

BR,
Akio

@iankuan iankuan added the bug label Oct 19, 2017
@iankuan iankuan self-assigned this Oct 19, 2017
@iankuan iankuan changed the title "ls -l" cause hard fault "ls -l" cause usage fault Oct 19, 2017
@iankuan
Copy link
Member

iankuan commented Oct 19, 2017

Thank for your report. I confirmed that it's a bug.

By the way, I revised the subject of this issue. Hard fault occurred in this situation results from that system is unable to handle usage fault anymore.

@akioolin
Copy link
Author

Thank you very much.

Is this easy to solve?

if I want to add new command, micropython porting could be a good starting point or not?

@jserv jserv changed the title "ls -l" cause usage fault "ls -l" raises usage fault Oct 19, 2017
@iankuan
Copy link
Member

iankuan commented Oct 20, 2017

@akioolin , I answer this question, "Is this easy to solve", first. It might be easy to just fix this bug, but however, it's better to refactor shell command parser first.

Micropython porting is worked in place by @mlouielu. Please see #16 .

@manbing
Copy link

manbing commented Dec 17, 2017

Dear, piko-RT developer:
Excuse me, i am novice about ARM and OS.
May i ask some questions about this issue, Thank you very much.

For now piko-RT. this issue will output the below information


$ ls
     1 .
     1 ..
     2 dev
     3 proc
$ ls -l
$ ls
     1 .
     1 ..
     2 dev
     3 proc

 #UsageFault

 r0: 00000000    r1: 00003e52    r2: 00000002    r3: 00000014
 r4: 00000008    r5: 2000122c    r6: 00000000    r7: 00000002
 r8: 00003e52    r9: 00000000   r10: 00000000   r11: 00000000
r12: 00000000    sp: 20008f98    lr: 00003323    pc: 00002ce2

EXC_RETURN: fffffff1
      ufsr: 00000000

i know this issue is ls.c can't parse "ls -l".
but, i have the below problems.

  1. why the usage fault exception is trigger on third command "ls", not second command "ls -l"?
  2. i do not sure whether the ufsr has value when usage fault is triggering?
    In this case, ufsr does not have value. how Developer know the root cause?

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

No branches or pull requests

3 participants