Project

General

Profile

Kernel loading module problems MityDSP and FPGA configuration

Added by Silvano Bertoldo about 6 years ago

Hello everybody.

I am Silvano Bertoldo, I mainly work on the software side of MityDSP and I have a big problem about the linux kernel I am not able to solve. I am very grateful if you can support me or forward the present email to a someone who can help me.
In the following I am going to explain what we have already did and what we would like to do, together with the problem.

The first step was to control 1 chip with the SPI bus, To do this, we first modified the standard file "baseboard-indoustrialio.c" with our settings and we decided that our chips was controlled with SPI 1. Then we recompiled the kernel and when we installed it on the Mity and it works perfectly. We had 1 chip, working on SPI, with its Chip Select (CS) and its own Chip Enabled programmed on a specific GPIO.
Attached you can find our modified baseboard file as "our_baserboard-industrialio_1chip.c". Note that we use the CAN_CS_N as chip select and the spi_mcp2515_config struct even if the name are not correct for our chip, because we would like to modify the least possible the configuration file.
We made also some successfull attempts to program the FPGA, without doing anything different than the following istruction reported in the wiki:
insmod /lib/modules/3.2.0/extra/fpga_ctrl.ko
echo "1" > /sys/devices/fpga_ctrl/cmd # configure the FPGA driver to reset the module
echo "2" > /sys/devices/fpga_ctrl/cmd # configure the FPGA driver to program the FPGA
cat [my_fpga_image.bin] > /sys/devices/fpga_ctrl/image # write the FPGA configuration to the FPGA
The second step was to control 2 chip with the same SPI bus and, of course, 2 different CS. To do this, we modified a second time the beaseboard file with our settings. Then we recompiled the kernel and when we installed in on the Mity it apparently seams to work good. Attached you can fine our second modified baseboard file as "our_baseboard-industrialio_2chip.c".
I also set the following string of parameters in uboot:
setenv bootargs mem=96M console=ttyS1,115200n8 mtdparts=nand:128M(rootfs),-(userfs) root=/dev/mtdblock0 rw,noatime rootfstype=jffs2 ip=none
Both the chips were properly managed.

Here come the problems: we would like to control also the FPGA in our project togehther with the 2 chips, but with the kernel version compiled with the file "our_baseboard-industrialio_2chip.c", during the start up of the system, it fails to start "Load Kernel Module" (as reported in the attached file FailedLoadKernelModuleStartup.png). That is a big problem because according to what reported in the wiki section "FPGA Core Device Drivers" (https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/FPGA_Core_Device_Drivers) you are told to install the module fpga_ctrl.ko, as we made before. If the module cannot be loaded we cannot work with the FPGA. Any suggestion why it appens?
I also tried to load the system load module utility from command line, as reported in numerous site searching on the web. It fails also in this case as reported in the screenshot FailedLoadKernelModuleStartupCommandLine.png.

Carefully reading the section "FPGA SPI Core Example" in the page related to FPGA core drivers, I noted that we need to add some lines to the baseboard file. Is it mandatory also in our case, before recompiling the kernel?

Any suggestion to solve out problems?

Thank you so much in advance.

Best regards.

Silvano


Replies (13)

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Jonathan Cormier about 6 years ago

Its hard to tell from those error messages whats going on but have you tried recompiling the kernel modules when you made changes to the kernel?

See https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/FPGA_Core_Device_Drivers

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

I report before that I recompile the kernel every time I made a modificatuon on the baseboard file.
In fact the link you report me is cited by me in my first message.
Maybe there is something wrong in the file or in the compiling.
Could someone help me?
Thanks.

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Bob Duke about 6 years ago

Hi Silvano,

Jon was referring to the kernel modules explicitly. The modules need to be installed in your target root filesystem (/lib/$kernelversion) after you copy over the kernel.

The page you reviewed, does mention this, but it's important to confirm that the modules you've compiled are the modules that are being loaded.
https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/FPGA_Core_Device_Drivers

What happens when you try to load the modules with insmod?

root@mityomapl138:~# insmod fpga_ctrl.ko
root@mityomapl138:~# insmod fpga_spi.ko

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

Dear Bob,

when I try to load the modules with "insmod fpga_ctrl.ko" I get an error with "Function non implemented" as explanation.
I also found on internet that the insmod error message is caused by either a kernel lacking module support or an incompatible version of modutils/module-init-tools with your kernel.
I never made modification in other file than the baseboard.industrialio.c.

Thanks.

Silvano

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Michael Williamson about 6 years ago

Hi,

Can you please capture the entire boot up on the console to a text file and set it over?

Or at least run "uname -a" and report the results?

-Mike

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

Dear all,

attached you can find a text (LinuxLoading.txt) file where I captured the entire boot together with the screenshot where "Failed" occurs (FailuresLoadingKernel.png).
I also run "uname -a" and the results are in the text file "unamea.txt".

When I run the command "insmod fpga_ctrl.ko" I get:
"insmod: error inserting 'fpga_ctrl.ko': -1 Function not implemented".

As suggested in the boot if I run "systemctl status systemd-modules-load.service" I get:
"Loaded: loaded (/lib/systemd/system/systemd-modules-load.service; static)
Active: failed (Result: exit-code) since Sat, 01 Jan 2000 00:00:08 +0000; 6h ago
Process: 985 ExecStart=/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE)
CGroup: name=systemd:/system/systemd-modules-load.service"

In the directory "/lib/modules/3.2.0/extra" I have the following files:
ads7843.ko fpga_ctrl.ko fpga_i2c.ko fpga_uart.ko
cmemk.ko fpga_dcmctlr.ko fpga_lcdctlr.ko
dsplinkk.ko fpga_gpio.ko fpga_pwm.ko
edmak.ko fpga_hdlc.ko fpga_spi.ko

I would like also to communicate I tried two times to recompile the kernel but the errors always occur.

Thanks for the support.

Silvano

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Michael Williamson about 6 years ago

Hello,

We have many customers able to load and run modules with the MityDSP-L138, it's not obvious what the issue is here. I am suspicious that there may have been a problem with the filesystem installation / update (either the modules install or with the FLASH process).

I see you are booting out of NAND flash and you are getting a CRC error in the boot log.

How did you install the filesystem and the modules? Which filesystem reference image did you use? The NAND JFFS2 image has to be padded with 0xFF's out to a multiple of 0x800 bytes when flashing, did you do this?

-Mike

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

Dear Michael,

let me know if my way of working is right:
1) I wrote my own baseboard-industrialio.c file as reported in the firts post of this discussion.
2) I recompiled the kernel as reported in https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Linux_Kernel
3) I built my drivers using:
root@buildmachine> make C /path/to/my/kernel M=`pwd` ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi modules
root@buildmachine> make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- INSTALL_MOD_PATH=/path/to/my/target/rootfs modules_install
4) I tr ied to use the compiled kernel and the remote filesystem using:
tftp 0xC0700000 [MYADDRESS]:[KERNEL BIN]
setenv bootargs ${bootargsbase} root=/dev/nfs nfsroot=[MYADDRESS]:/home/mitydsp/nfs ip=${ipaddr} ip=192.168.1.44:192.168.1.1::255.255.255.0::eth0:off
bootm 0xC0700000
In this way the system works good for what concern everything but not concerning the installation of module because it fails as reported before.
Then I tried to istalla the kernel on SPI-FLASH and also to flash filesystem on the NAND.
It has the same behavior as before. It does not load the module.
We cannot undestand the errors.

Best.

Silvano

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Michael Williamson about 6 years ago

Did you also rebuild the FPGA drivers? They are not in-tree in the kernel git repository. They are located in the board support package in the MityDSP Developer's Kit.

Let's start with this:

On the build machine:

root@buildmachine> cd $MDK/sw/ARM/linux/drivers/fpga
root@buildmachine> make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- -C /path/to/linuxkernelsrc M=`pwd` modules

This should build a fpga_ctrl.ko module. Copy this over to your target machine at /home/root or somewhere.

On the target, try to load the module directly using:

root@target> insmod /home/root/fpga_ctrl.ko 

If that works you can move/copy the modules to the /lib/modules/3.2.0/extra and run a "depmod -a".

Let me know if this works?

Can you do a find /lib/modules > moduledir.txt and post it as well?

-Mike

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

Dear Michael,

I tried to run the command you told me. Everything was ok until I copied the fpga_ctrl file on the target machine as you can see in the attached file fpga_ctrl_ontarget.png.
But when I run the "insmod" command I got what reported in the attached file fpg_ctrl_insmod.png.
Attached you also have the moduledir.txt file as requested.

As I got a lot of CRC errors, here are some other question:
1 My .jffs2 file is about 21 MB (22070432 bytes) which corresponds to 0x150C4A0. To copy the filesystem on the target I use the following commands, right?
u-Boot> mw.b 0xC2000000 0xFF 0x06000000
u-Boot> tftp 0xC2000000 myserver:/path/to/root_filesystem.jffs2
u-Boot> nand erase 0 0x8000000
u-Boot> nand write.jffs2 C2000000 0 0x<rounded_filesize>
2 In my case is 0 0x<rounded_filesize>=0x150E000 right? Or can you give me the right <rounded_filesize> in order to avoid CRC errors?
3 Are the following boot parameters right?
setenv bootargs mem=96M console=ttyS1,115200n8 mtdparts=nand:128M(rootfs),-(userfs) root=/dev/mtdblock0 rw,noatime rootfstype=jffs2 ip=none
saveenv

Thanks.

Silvano

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

Dear all

As I got a lot of CRC errors, here are some question:
1 My .jffs2 file is about 21 MB (22070432 bytes) which corresponds to 0x150C4A0. To copy the filesystem on the target I use the following commands, right?
u-Boot> mw.b 0xC2000000 0xFF 0x06000000
u-Boot> tftp 0xC2000000 myserver:/path/to/root_filesystem.jffs2
u-Boot> nand erase 0 0x8000000
u-Boot> nand write.jffs2 C2000000 0 0x<rounded_filesize>
2 In my case is 0 0x<rounded_filesize>=0x150E000 right? Or can you give me the right <rounded_filesize> in order to avoid CRC errors?
3 Are the following boot parameters right?
setenv bootargs mem=96M console=ttyS1,115200n8 mtdparts=nand:128M(rootfs),-(userfs) root=/dev/mtdblock0 rw,noatime rootfstype=jffs2 ip=none
saveenv

Anybody can tell me if I am right?

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Michael Williamson about 6 years ago

The filessize should be rounded to 0x800 bytes, which I think should be 0x150C800, not 0x150E000.

-Mike

RE: Kernel loading module problems MityDSP and FPGA configuration - Added by Silvano Bertoldo about 6 years ago

I have corrected all the CRC error rounding the filesize parameters to the correct values.
I have also recompiled the kernel modifyind a little our configuration baseboard-industrialio.c file beacuse we noticed that there was one error in the definition of the SPI devices.
I have restored both the kernel and the file system image on the mitydsp and now it works as expected.
It works but I do not why exactly, beacuse I apparently have not modified anything concerning the kernel.
When I write:
"insmod fpga_ctrl.ko"
It works without error.
For the moment it is ok like that.
Thanks.

    (1-13/13)
    Add picture from clipboard (Maximum size: 500 MB)