zhemao / sockit_test

Figuring out the Arrow SoCKit
11 stars 10 forks source link

SoCKit just froze when writing to delay_ctrl module #3

Open ngzh opened 8 years ago

ngzh commented 8 years ago

First thing first I have to say that I really enjoy reading the "Exploring the Arrow SoCKit" series even before I got a real SoCKit.

Problem: SoCKit will just froze after performing a single write to delay_ctrl address. It is the same for both user space blinker program and the blinker kernel module.

Envirnoment: I've been using the exact quartus project/blinker userspace program/blinker kernel module in this repo. (I'm using Quartus II 15.0 instead of 13.1 for qsys in 13.1 does not work on my ubuntu, but I'll try to make it work).

sockit_test.rbf works fine, led and button just work as expected.

The kernel I use here is the same kernel mentioned in the second part of the series. As for rootfs I got an ubuntu-core but it should be irrelevant here I think.

Something I know:

# tail -f /var/log/kern.log

to capture some log before the froze but the system just froze before any log show up. Do I need to adjust log level here?

Any hint/suggestion on debugging this problem will be helpful!

zhemao commented 8 years ago

The kernel module has always been somewhat problematic. Could you first try using the blinker_us program, which does the writes from userspace? If that doesn't work, I'll have more suggestions.

ngzh commented 8 years ago

User space program will cause a freeze right after a write attempt.

If I comment out the line with an arrow below, there won't be a freeze.

       ....
        /* get the delay_ctrl peripheral's base address */
        blink_mem = (unsigned char *) (bridge_map + BLINK_OFFSET);

        /* write the value */
     => //*blink_mem = value;

        if (munmap(bridge_map, PAGE_SIZE) < 0) {
                perror("munmap");
                goto cleanup;
        }
        ....

If not, after the write to delay_ctrl, all console become irresponsible, including the one on the uart-usb port and the one on the ssh. ping SoCKit and it won't respond either, so I guess the entire linux system just froze. (The led and button are still normal at this point)

zhemao commented 8 years ago

Sorry it took so long to get back to you. Have you made sure that the lightweight HPS to FPGA bridge is activated?

ngzh commented 8 years ago

Yeah I can assure that it has been enabled, the action which froze the board should be the write avalon action only. Memory mapping does not harm both with userspace program or a kernel module.

It's been so long since the last time I play with the board, just for the reason that I have neither whole bunch of time nor the vast amount of knowledge in the hardware and embedded software field. A friend of mine told me that last year he just got it through, using the system image provided by terASIC, plus the instructions in you post. He ended up made himself a PWM generator, which is almost identical to the delay_ctrl module described in post 3 and 4, yet only with the userspace approach since he didn't setup a kernel dev env. I may pay him a visit someday and if with some luck, we may figure it out and help update the post series.

Have to say that what I enjoyed most is the =Warning! Here there be dragons!= part. -.-