您尚未登录。

#1 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » Modbus TCP通信问题! » 2020-11-19 17:18:11

我用调试模式测试了下,发现NUC977的ModbusServer 正常,提供服务中,但是NUC977客户端却一直提示请求超时,
服务器调试日志

Waiting for a indication...
<0D><32><00><00><00><06><01><03><00><00><00><18>
[0D][32][00][00][00][33][01][03][30][00][00][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><33><00><00><00><06><01><03><00><00><00><18>
[0D][33][00][00][00][33][01][03][30][00][00][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][73][16][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><34><00><00><00><06><01><03><00><00><00><18>
[0D][34][00][00][00][33][01][03][30][00][00][73][17][73][17][73][17][73][17][73][17][73][17][73][16][73][16][73][16][73][16][73][16][73][16][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><35><00><00><00><06><01><03><00><00><00><18>
[0D][35][00][00][00][33][01][03][30][00][00][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><36><00><00><00><06><01><03><00><00><00><18>
[0D][36][00][00][00][33][01][03][30][00][00][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><37><00><00><00><06><01><03><00><00><00><18>
[0D][37][00][00][00][33][01][03][30][00][00][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><38><00><00><00><06><01><03><00><00><00><18>
[0D][38][00][00][00][33][01][03][30][00][00][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...
<0D><39><00><00><00><06><01><03><00><00><00><18>
[0D][39][00][00][00][33][01][03][30][00][00][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][73][27][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]
ERROR Broken pipe
Waiting for a indication...

ERROR Broken pipe 是由于NUC977的Modbus客户端连接出错导致的,正常响应客户端为ModbusPoll软件(PC模拟软件)的结果。
客户端调试记录

[00][05][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][06][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][07][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][08][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][09][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][0A][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][0B][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select
Read hold rigister 120.
[00][0C][00][00][00][06][01][03][00][00][00][18]
Waiting for a confirmation...
ERROR Connection timed out: select

!!!!!怀疑会不是是nuc977的网卡配置有问题
Modbus的代码应该没问题,因为对PLC以及PC端的模拟软件都做过交叉测试,都可以正确收发数据。

#2 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » Modbus TCP通信问题! » 2020-11-19 14:04:17

smartcar 说:

有没有试过抓包,看用你的client和plc client,数据包的收发有没有区别?

使用调试模式看一下结果么 ? 我看Libmodbus有一个调试模式,ModbusPoll中间有一个traffic monitor。你的意思是使用这两个对比一下,看接收到的数据包之间有没有差别么 ?

#3 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » Modbus TCP通信问题! » 2020-11-19 13:09:13

thy442156388
回复: 4

本人最近尝试使用NUC977与PLC之间进行通信, 测试PC端使用模拟软件,Modbus Poll和Modbus Slave测试,但是发现一个奇怪的问题:
1. PLC作为Server,NUC977作为Client,同时Modbus Poll检测通信结果,可以通信;
2. NUC977作为Server,PLC作为Client,同时Modbus Poll检测通信结果,可以通信;
3. Nuc977作为Server,另一个NUC977作为Client,作为Client的NUC977读取不到数据,但是Modbus Poll可以正确读取到结果,通信失败。
想请教一下有没有使用过libmodbus的大神,给点建议,这中间哪里出了问题??附上NUC977的Modbus代码。
PS:PLC和PC模拟测均是使用很久的厂家提供代码,应该不存在问题。
Server端代码

void *modbusTcp_process(void *arg)
{
    uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
    int master_socket;
    int rc;
    fd_set refset;
    fd_set rdset;
    /* Maximum file descriptor number */
    int fdmax;

    ctx = modbus_new_tcp("192.168.150.159", 502);
    printf("Modbus Context Created OK!\n");
    mb_mapping = modbus_mapping_new(MODBUS_MAX_READ_BITS, 
                                    MODBUS_MAX_WRITE_BITS,
                                    MODBUS_MAX_READ_REGISTERS, 
                                    MODBUS_MAX_WRITE_REGISTERS);
    if (mb_mapping == NULL)
    {
        fprintf(stderr, "Failed to allocate the mapping: %s\n",
                modbus_strerror(errno));
        modbus_free(ctx);
        exit(-1);
    }

    server_socket = modbus_tcp_listen(ctx, NB_CONNECTION);
    if (server_socket == -1)
    {
        fprintf(stderr, "Unable to listen TCP connection\n");
        modbus_free(ctx);
        exit(-1);
    }

    signal(SIGINT, close_sigint);

    /* Clear the reference set of socket */
    FD_ZERO(&refset);
    /* Add the server socket */
    FD_SET(server_socket, &refset);

    /* Keep track of the max file descriptor */
    fdmax = server_socket;

    for (;;)
    {
        rdset = refset;
        
        if (select(fdmax + 1, &rdset, NULL, NULL, NULL) == -1)
        {
            perror("Server select() failure.");
            close_sigint(1);
        }

        /* Run through the existing connections looking for data to be
            * read */
        for (master_socket = 0; master_socket <= fdmax; master_socket++)
        {

            if (!FD_ISSET(master_socket, &rdset))
            {
                continue;
            }

            if (master_socket == server_socket)
            {
                /* A client is asking a new connection */
                socklen_t addrlen;
                struct sockaddr_in clientaddr;
                int newfd;

                /* Handle new connections */
                addrlen = sizeof(clientaddr);
                memset(&clientaddr, 0, sizeof(clientaddr));
                newfd = accept(server_socket, (struct sockaddr *)&clientaddr, &addrlen);
                if (newfd == -1)
                {
                    perror("Server accept() error");
                }
                else
                {
                    FD_SET(newfd, &refset);

                    if (newfd > fdmax)
                    {
                        /* Keep track of the maximum */
                        fdmax = newfd;
                    }
                    printf("New connection from %s:%d on socket %d\n",
                           inet_ntoa(clientaddr.sin_addr), clientaddr.sin_port, newfd);
                }
            }
            else
            {
                modbus_set_socket(ctx, master_socket);
                rc = modbus_receive(ctx, query);
                if (rc > 0)
                {
                    update_modbusmapping(mb_mapping);
                    modbus_reply(ctx, query, rc, mb_mapping);
                }
                else if (rc == -1)
                {
                    /* This example server in ended on connection closing or
                        * any errors. */
                    printf("Connection closed on socket %d\n", master_socket);
                    close(master_socket);

                    /* Remove from reference set */
                    FD_CLR(master_socket, &refset);

                    if (master_socket == fdmax)
                    {
                        fdmax--;
                    }
                }
            }
        }
    }
}

Client端代码

void *modbusTcp_process(void *arg){
	modbus_t *ctx;

    char index = 0;
    float fl1;
	int i=0;
    /* TCP 127.0.0.1 port 502*/
    ctx = modbus_new_tcp("192.168.150.159", 502);
	if (modbus_set_slave(ctx, 1) == -1)
    {
        fprintf(stderr, "Invalid slave ID\n");
        modbus_free(ctx);
        exit(-1);
    }
    if (modbus_connect(ctx) == -1)
    {
        fprintf(stderr, "Modbus connect failed: %s\n",
                modbus_strerror(errno));
        modbus_free(ctx);
        exit(-1);
    }
	while(1){
		modbus_read_registers(ctx, WT_START_ADDR, 
			24, modbusDataBuf);
		printf("Read hold rigister %d.\n",sizeof(modbusDataBuf));
		//ModbudDataPrase(modbusDataBuf);
		ModbusReceived = 1;
		//debug_LoadData_print();
		for(i=0;i<12;i++)
			printf("modbusDataBuf%d %7d\n",i,modbusDataBuf[i]);

        index++;
	}

    /*turn off connect*/
    modbus_close(ctx);
    modbus_free(ctx);
}

#4 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » linux下使用socket can收发数据帧丢失情况。 » 2020-09-30 11:23:53

另外补充一下,后面做了时间测定,在CAN在1M的速度下,收发18帧数据时间不到2ms,在一个调度时间片内应该是可以完成。我遇到的问题是调试手段不到位的原因。

#5 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977定时器,定时时间不精准。 » 2020-09-30 11:19:32

我的测试结果,显示在Linux应用层可能是由于任务调度的原因,每次执行的时间是不一样的,但是同样一段程序的执行时间大体一致。上面的配置是1ms的配置。误差都在1ms之内,对于我的项目来说暂时可以接受。

#6 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977定时器,定时时间不精准。 » 2020-09-28 11:53:00

thy442156388
回复: 2

最近项目中需要时用nuc970内部定时器来对程序运行时间做精确计时。需要精度至少到0.1ms。但是我按照如下代码测试nuc970的定时器发现同样程序, 每次测试出来的运行时间是不一样的。求教这是为什么 ?linux系统调度的原因么?

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/select.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "nuc970-etimer.h"

int main(int argc, char **argv){
    int fd_timer;
    int ret,j=0,cnt;
    int ii,jj,kk;
    char *dev = "/dev/etimer0";
    int timeout = 1000;  // base : 1ms 
    fd_timer = open(dev,O_RDWR);
    if(fd_timer < 0)
        printf("open etimer error\n");
    ioctl(fd_timer, ETMR_IOC_CLKHXT, NULL);
    ioctl(fd_timer, ETMR_IOC_PERIODIC, &timeout); 
    for(j=0;j<20;j++){
        read(fd_timer, &cnt, sizeof(cnt));
        printf("startime = %u\n",cnt);
        /*测试运行代码*/
        for(ii=0;ii<100;ii++)    
            for(jj = 0; jj < 200; jj++);            
                
        read(fd_timer, &cnt, sizeof(cnt));
        printf("endtime  = %u\n\n",cnt);
    }
    
    ioctl(fd_timer, ETMR_IOC_STOP, NULL);
    
}

运行结果如下

startime = 1
endtime  = 4

startime = 8
endtime  = 12

startime = 15
endtime  = 19

startime = 20
endtime  = 21

startime = 22
endtime  = 23

startime = 24
endtime  = 25

startime = 26
endtime  = 27

startime = 28
endtime  = 29

startime = 30
endtime  = 31

startime = 32
endtime  = 33

startime = 34
endtime  = 35

startime = 36
endtime  = 37

startime = 38
endtime  = 40

startime = 44
endtime  = 48

startime = 49
endtime  = 50

startime = 51
endtime  = 52

startime = 53
endtime  = 54

startime = 55
endtime  = 56

startime = 57
endtime  = 58

startime = 59
endtime  = 60

#8 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » linux下使用socket can收发数据帧丢失情况。 » 2020-09-27 18:07:00

下午我这边仔细检查了一下,发现是串口速率过慢的问题,CAN配置的是1M速率, 每一帧数据都打出来的情况下,串口的数据丢失了。导致我认为是CAN接收丢帧。
后面将程序输出信息重定向到文件当中,分析发现没有丢帧现象。

#9 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » linux下使用socket can收发数据帧丢失情况。 » 2020-09-27 10:37:26

thy442156388
回复: 3

我们最近做CAN收发的时发现,nuc977在linux下读取can帧的时候有丢帧现象。
我们另外一头连接的是PLC设备,该设备能够保证在20ms内发送9帧数据,但是我们在nuc977上接收的时候发现出现丢帧。你们遇到过这个问题么?
我用周立功USBCAN检测了,可以确保PLC设备能够在20ms内发送出来9帧数据。

#11 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » RAMFS 启动失败 » 2019-10-30 17:42:36

补充一下,原本之前的板子中的Uboot程序下载了同样的内核和文件系统就可以正常启动。 但是现在对于U-boot的二进制文件的内核版本不太清楚。这个是我们当初的交接问题。  所以个人感觉问题可能出在u-boot上

#12 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » RAMFS 启动失败 » 2019-10-30 17:39:38

我感觉ramfs和内核镜像应该没问题? 那这个问题出在哪里啊 ?应该怎么解决?@晕哥

#13 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » RAMFS 启动失败 » 2019-10-30 17:38:41

这个问题会和U-boot有关么? 我们之前同事交接给我的时候有两个U-boot的二进制文件,其中一个下载到板子上能启动,但是不解串口线的话会卡在uboot跳转到内核的那个阶段(Hit any key to stop to autoboot),这里的问题好像是我们的串口接收引脚和硬件都没有配置上啦导致电平不确定。但是接上串口可以正常启动。
第二个Uboot二进制文件下载进来就会报这个再ramfs解压错误。

#14 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » RAMFS 启动失败 » 2019-10-30 16:37:22

thy442156388
回复: 6
regulator_init_complete: incomplete constraints, leaving LDO2 on
regulator_init_complete: incomplete constraints, leaving LDO1 on
ata1: SATA link down (SStatus 0 SControl 300)
regulator_init_complete: incomplete constraints, leaving VDCDC3 on
regulator_init_complete: incomplete constraints, leaving VDCDC2 on
regulator_init_complete: incomplete constraints, leaving VDCDC1 on
davinci_emac_probe: using random MAC addr: 5a:60:e9:a5:c5:19
mmc0: new high speed SDHC card at address 0002
mmcblk0: mmc0:0002 SD16G 14.9 GiB 
 mmcblk0:
emac-mii: probed
omap_rtc omap_rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)

RAMDISK: gzip image found at block 0
uncompression error
VFS: Mounted root (ext2 filesystem) on device 1:0.
Freeing init memory: 148K
EXT2-fs (ram0): error: ext2_check_page: bad entry in directory #3841: : rec_len is smaller than minimal - offset=2048, inode=0, rec_len=0, name_len=0
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
Backtrace: 
[<c0031708>] (dump_backtrace+0x0/0x114) from [<c030155c>] (dump_stack+0x18/0x1c)
 r7:00000000 r6:00000000 r5:00000000 r4:c042e310
[<c0301544>] (dump_stack+0x0/0x1c) from [<c03015c4>] (panic+0x64/0x140)
[<c0301560>] (panic+0x0/0x140) from [<c002d628>] (init_post+0x100/0x134)
 r3:c781fedc r2:00000000 r1:c781fedc r0:c0397c1f
[<c002d528>] (init_post+0x0/0x134) from [<c00084e8>] (kernel_init+0x110/0x14c)
 r5:00000000 r4:c042dae0
[<c00083d8>] (kernel_init+0x0/0x14c) from [<c0044c88>] (do_exit+0x0/0x5ec)
 r5:00000000 r4:00000000

如上所示的错误代码,麻烦懂的大佬看一下是哪里出现了问题

#15 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » 请教关于内存的压力测试问题。 » 2019-09-03 12:07:04

好的 那我尝试下这个软件。感觉这个软件做测试挺全面的啊,谢谢晕哥啦

#16 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » 请教关于内存的压力测试问题。 » 2019-09-03 10:55:52

sysbench这个工具,是不是我需要重新编译到我的开发板中去 ?我在网上查到一个工具叫memtester 昨天打算用这个测试

#17 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » 请教关于内存的压力测试问题。 » 2019-09-02 18:25:39

thy442156388
回复: 5

今天我们的开办板又有DRR2内存芯片已经不生产了,所以同事尝试焊接了新的DDR2芯片。同事给我提出一个要求,要求我对与这个新的DDR2内存芯片做压力测试,我想请问下版主,有没有现成的内存压力测试工具? 这具体要怎么做啊 ? 我以前没有这方面的经验。

#18 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » CANopen实践 » 2019-06-27 19:16:18

thy442156388
回复: 2

最近工作是,用nuc977做canopen从站来和beckhoff(倍福)PLC设备通信,但是最近看canopen的原理,但是没找到合适的CANopen例程,向请教下论坛的大神们,有米有可以提供的实际案例 。

#19 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 18:01:50

我检查了和之前编译的出来的文件系统在/etc/init.d和/etc/profile.d路径下的文件一样,这个文件系统是可以被NFS正确引导启动的。

#21 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 17:47:41

我用buildroot做的文件系统,init.d文件夹下的启动脚本和我之前的有点不一样啊
是这样四个名字的脚本
S01logging  S20urandom  S40network  rcK  rcS

#24 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 17:38:20

ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci_nuc970_probe() - name: nuc970-ehci
nuc970-ehci nuc970-ehci: Nuvoton NUC970/N9H30 EHCI Host Controller
nuc970-ehci nuc970-ehci: new USB bus registered, assigned bus number 1
nuc970-ehci nuc970-ehci: irq 23, io mem 0xb0005000
nuc970-ehci nuc970-ehci: USB 2.0 started, EHCI 0.95
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
nuc970-ohci nuc970-ohci: Nuvoton NUC970/N9H30 OHCI Host Controller
nuc970-ohci nuc970-ohci: new USB bus registered, assigned bus number 2
nuc970-ohci nuc970-ohci: irq 24, io mem 0xb0007000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
cpuidle: using governor ladder
TCP: cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
jffs2: Empty flash at 0x003d7f54 ends at 0x003d8000
VFS: Mounted root (jffs2 filesystem) on device 31:1.
devtmpfs: mounted
Freeing unused kernel memory: 124K
devpts: called with bogus options
Starting logging: OK
Initializing random number generator... done.
Starting network: OK

现在卡在这里了 ,这个问题出在那里啊。串口能输入数据,是不是应该写开机脚本了?

#25 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 16:23:42

我找到了 修改过来了 现在jffs2 是挂载上去了,但是给我提示这个

can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
jffs2: Empty flash at 0x00347ffc ends at 0x00348000
jffs2: Empty flash at 0x00357ffc ends at 0x00358000
jffs2: Empty flash at 0x00367ffc ends at 0x00368000
jffs2: Empty flash at 0x00377ffc ends at 0x00378000
jffs2: Empty flash at 0x00387ffc ends at 0x00388000
jffs2: Empty flash at 0x00397ffc ends at 0x00398000
jffs2: Empty flash at 0x003a7ffc ends at 0x003a8000
jffs2: Empty flash at 0x003b7ffc ends at 0x003b8000
jffs2: Empty flash at 0x003c7ffc ends at 0x003c8000
jffs2: Empty flash at 0x003d7f54 ends at 0x003d8000
VFS: Mounted root (jffs2 filesystem) on device 31:1.
devtmpfs: mounted
Freeing unused kernel memory: 124K
mount: you must be root
mkdir: can't create directory '/dev/pts': Permission denied
mkdir: can't create directory '/dev/shm': Permission denied
mount: you must be root
hostname: sethostname: Operation not permitted
Starting logging: OK
Initializing random number generator... done.
Starting network: RTNETLINK answers: Operation not permitted
RTNETLINK answers: Operation not permitted
FAIL
can't open /dev/console: Permission denied
can't open /dev/console: Permission denied
can't open /dev/console: Permission denied
can't open /dev/console: Permission denied
can't open /dev/console: Permission denied

#26 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 16:02:55

jffs2: Perhaps the file system was created with the wrong erase size?
jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0013f000: 0xae23 instead
jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0013f004: 0x213a instead
jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0013f008: 0x03f7 instead
jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0013f00c: 0xab7f instead

现在给我提示这个错误
如果出现这个错误是不是我在制作jffs2文件系统镜像的时候,擦除数据大小设置的有问题

#27 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 16:01:18

我是用的新唐的内核 没有用这个设备树,那我需要下载最新的Linux内核去编译么 ?

#28 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 12:46:35

这里是不是还要修改新唐内核代码关于SPI-FLASH的驱动部分。

#29 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-05 11:28:23

我之前一直怀疑是烧录地址,和我的MTD分区表没对上的结果。

#31 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-04 16:52:17

winbond 这个我不太懂。啥意思啊 但是是一个SPI—FLASH没错。

#32 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc977的jffs2文件系统移植问题 » 2019-03-04 12:46:26

thy442156388
回复: 28

最近在做nuc977文件系统的移植问题,在jffs2文件系统启动上出现了问题 。启动日志如下,不能正确挂载jffs2文件系统。

SF: Detected W25Q128 with page size 4 KiB, total 16 MiB
## Booting kernel from Legacy Image at 00007fc0 ...
   Image Name:   
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4080640 Bytes = 3.9 MiB
   Load Address: 00007fc0
   Entry Point:  00008000
   Verifying Checksum ... OK
SF: Detected W25Q128 with page size 4 KiB, total 16 MiB
SF: DeviceBooting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.10.108 (cookie@NtrGoldWind) (gcc version 4.9.4 (Buildroot 2018.02.8) ) #2 PREEMPT Fri Mar 1 12:45:16 CST 2019
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: NUC970
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock1 rootfstype=jffs2 rootflags=inband-tags console=ttyS0 rdinit=/sbin/init 
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60680k/60680k available, 4856k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc0395eec   (3640 kB)
      .init : 0xc0396000 - 0xc03b5740   ( 126 kB)
      .data : 0xc03b6000 - 0xc03ec400   ( 217 kB)
       .bss : 0xc03ec400 - 0xc0421ac4   ( 214 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
NR_IRQS:625
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 4294967286ms
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Initializing cgroup subsys perf_event
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc02d99f0 - 0xc02d9a2c
devtmpfs: initialized
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 118
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
nuc970-uart.0: ttyS0 at I/O 0x0 (irq = 36) is a NUC970
brd: module loaded
nuc970-spi0 nuc970-spi0: master is unqueued, this is deprecated
m25p80: Enable Dual Read Mode
m25p80 spi0.0: w25q128 (16384 Kbytes)
Creating 2 MTD partitions on "m25p80":
0x000000000000-0x000000800000 : "kernel"
0x000000800000-0x000001000000 : "rootfs"
CAN device driver interface
nuc970-can0 nuc970-can0: nuc970_can0_platform device registered (regs=f800b000, irq=58)
libphy: nuc970_rmii0: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci_nuc970_probe() - name: nuc970-ehci
nuc970-ehci nuc970-ehci: Nuvoton NUC970/N9H30 EHCI Host Controller
nuc970-ehci nuc970-ehci: new USB bus registered, assigned bus number 1
nuc970-ehci nuc970-ehci: irq 23, io mem 0xb0005000
nuc970-ehci nuc970-ehci: USB 2.0 started, EHCI 0.95
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
nuc970-ohci nuc970-ohci: Nuvoton NUC970/N9H30 OHCI Host Controller
nuc970-ohci nuc970-ohci: new USB bus registered, assigned bus number 2
nuc970-ohci nuc970-ohci: irq 24, io mem 0xb0007000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
cpuidle: using governor ladder
TCP: cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
List of all partitions:
No filesystem could mount root, tried:  jffs2
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
CPU: 0 PID: 1 Comm: swapper Not tainted 3.10.108 #2
Backtrace: 
[<c001213c>] (dump_backtrace+0x0/0x108) from [<c001234c>] (show_stack+0x18/0x1c)
 r6:00008000 r5:c03b0ef0 r4:c38a5000 r3:00000000
[<c0012334>] (show_stack+0x0/0x1c) from [<c02d6af4>] (dump_stack+0x20/0x28)
[<c02d6ad4>] (dump_stack+0x0/0x28) from [<c02d4aa0>] (panic+0xa0/0x1f4)
[<c02d4a00>] (panic+0x0/0x1f4) from [<c03970c0>] (mount_block_root+0x234/0x27c)
 r3:c3843ea8 r2:00000020 r1:c3843ea8 r0:c034d0d0
 r7:c034d138
[<c0396e8c>] (mount_block_root+0x0/0x27c) from [<c03972f0>] (mount_root+0xec/0x114)
[<c0397204>] (mount_root+0x0/0x114) from [<c0397478>] (prepare_namespace+0x160/0x1c0)
 r8:c03ec400 r7:0000005b r6:c03b0ef0 r5:c03b0ef0 r4:c03ec460
[<c0397318>] (prepare_namespace+0x0/0x1c0) from [<c0396c3c>] (kernel_init_freeable+0x1d8/0x224)
 r6:c03ec400 r5:00000008 r4:c03b5738
[<c0396a64>] (kernel_init_freeable+0x0/0x224) from [<c02d4420>] (kernel_init+0x10/0x158)
[<c02d4410>] (kernel_init+0x0/0x158) from [<c000ee98>] (ret_from_fork+0x14/0x3c)
 r5:c02d4410 r4:00000000

我的uboot启动参数设置如下:

baudrate=115200
bootargs=noinitrd root=/dev/mtdblock1 rootfstype=jffs2 rootflags=inband-tags console=ttyS0 rdinit=/sbin/init 
bootcmd=sf probe 0 240000000; sf read 0x7fc0 0x200000 0x8a0000;bootm 0x7fc0
bootdelay=3
ethact=emac
ethaddr=00:00:00:11:66:88
stderr=serial
stdin=serial
stdout=serial

制作jffs2的命令如下:

mkfs.jffs2 -r target -o images/k2rootfs.jffs2 -n -l

使用的是W25Q128  SPI-FLASH芯片16M大小。
这个问题是不是出在jffs2文件系统的制作方面了

#33 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » 关于嵌入式系统的存储器选择问题 » 2019-01-24 17:15:25

也是,只是之前看资料,开发板的过程中,都是1G,2G这样的大内存,现在工作中,只给了这么小,觉得老板好抠.就特别想问下.
如果是这样的话,我还需要对文件下系统好好裁剪一下.

#34 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » 关于嵌入式系统的存储器选择问题 » 2019-01-24 17:05:29

3. 最疑惑的问题,公司选用nuc977芯片 内存是64M,但是却只配置了一个16M的SPIFLASH? 这样合理么?
这个问题呢 ?

#35 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » 关于嵌入式系统的存储器选择问题 » 2019-01-24 16:20:33

thy442156388
回复: 4

本人刚参加工作,接触嵌入式开发工作,之前接触过一些嵌入式看过国嵌的教程视频 ,在FLASH选型上有些疑问:
1. Nor-Flash和NAND-Flash如何选择? 现在大多数解决方案是如何选择的?
2. 大小方面应该如何选择? (这个应该看具体应用是么?,成本考量?)
3. 最疑惑的问题,公司选用nuc977芯片 内存是64M,但是却只配置了一个16M的SPIFLASH? 这样合理么?

#36 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-14 12:23:16

代码修改之后在nuc972 和我的nuc977 上均通过测试.
应该就是这样,让一份错误的代码传播了这么久.最后给大家一个建议,内核代码,固件驱动最好找官方的,如果直接使用官方的,我就不会被这个问题困扰这么久.

#37 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-11 12:53:06

通过了,但是这个问题出在哪里呢? 我沟通新唐的人,他们官方的代码时没有问题的。 我的内核代码是在百度云上下载的,坑的我好苦啊。我在mcuzone购买的板子,配套的固件库中的内核代码也是错误的,估计这个问题要坑很多人。

#38 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-11 12:20:38

要真的是这样,我要哭死, 一个月纠结这个问题,帮他们排查错误了 。。就是在PI3和PI4上测试出来。

#39 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-11 12:12:26

 
#if defined (CONFIG_NUC970_CAN0_PB)
                pinctrl = devm_pinctrl_get_select(&pdev->dev, "can0-PB");
        #elif defined (CONFIG_NUC970_CAN0_PH)
                pinctrl = devm_pinctrl_get_select(&pdev->dev, "can0-PH");
        #elif defined (CONFIG_NUC970_CAN0_PI)
                pinctrl = devm_pinctrl_get_select(&pdev->dev, "can0-PH");
        #endif

我查看了新唐的内核代码关于nuc970的配置代码,第三个define中,是不是写错了啊
应该是pinctrl = devm_pinctrl_get_select(&pdev->dev, "can0-PI");吧

#41 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-11 10:45:33

还是我应该向新唐报告BUG ? 因为我内核配置了PI3和PI4 为CAN0 的引脚

#42 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-11 10:34:28

读取出来了, 数据为0x00000000,功能作为通用IO了,那现在我就要在Linux下,一个裸机的程序么 ?

#43 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-10 19:04:15

又回来请教了,这个问题困扰我快一个月了,目前又了很大的进展,问题是这样。目前我的板子是nuc977DK62Y(这里强调一下是因为市场上都是972的开发板),内核代码使用的是新唐的官方代码。

我们已经制作出了板子,PI3和PI4上连接了CAN收发器。但是在PI3和PI4上却不能正常进行CAN通信。
我重新找了一个nuc977最小系统板,经过配置之后,发现在PB10和PB11上能够正常收发,修改内核配置之后配置到PI3和PI4上却又不行了。 

官方提示我,查看是否配置了NANDflash,cmos sensor等,我们自己制作的板子只有SPI-FLASH,我查看内核也没有配置NAND-FLASH支持。这种情况下我的问题出在哪里啊 ?附上新唐的关于PI3和PI4的引脚功能说明
007vJL53ly1fz1p0qky06j30gs0er0tu.jpg

#45 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2019-01-02 15:33:42

求助晕哥,我们的板子是自己做的,到目前位置,CAN还是不能正常通讯,我项请问下晕哥,有没有合适的功能相对齐全的nuc977开发板,给我推荐一下 ,我打算购买两块,测试CAN先确定我的软件没有问题,在让我们的硬件团队处理硬件问题。

#46 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-18 22:20:26

晕哥 说:

写得很棒,继续加油!


以后没事翻翻,就会感叹,想不到当年我如此厉害

万一后续技术更新换代,被人一做都是一键搞定得,那不就是尴尬啦,
哈哈哈
开玩笑得,自己做过的东西记录下,怕后期遗忘,如果做熟练了,还可以考虑自动化脚本啊想buildroot就很厉害啊。一起加油

#47 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-18 21:51:53

如果之后有人使用的,这里我整理了一个我编译buildroot的过程的博文。分享给大家,持续更新中。。
另外很感谢晕哥给与的指导
http://cookiedemo.ml/2018/12/14/buildro … %E4%BD%9C/

#48 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-18 16:33:32

晕哥 说:

这个问题最好还是通过代理商找原厂问下, 估计玩这个组合 NUC97x + Linux + CAN
即使有人玩,也不一定分享出来了。

好,我继续找一下解决方案,做出来了,我来分享把。

#49 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-18 14:33:28

我查看了我内核编译选项,里面勾选了CAN bit-timing calculationbit-timing。 但是我使用命令

[root@XXXXX ~] # ip link set can0 type can bitrate 125000 triple-sampling on
RTNETLINK answers: Operation not supported

我怎么老感觉是驱动的问题, 内核我也使用新的工具链编译过了。

#50 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-18 13:22:50

开发板还是不能正常进行CAN通信.
IP命令打开can0时会报错:

# ip link set can0 up
nuc970-can0 nuc970-can0 can0: bit-timing not yet defined
nuc970-can0 nuc970-can0 can0: failed to open can device
RTNETLINK answers: Invalid argument

ip命令can0接口详细信息如下

# ip -detail link show can0
2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state STOPPED (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 0 sample-point 0.000
          tq 0 prop-seg 0 phase-seg1 0 phase-seg2 0 sjw 0
          nuc970_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
          clock 75000000numtxqueues 0

晕哥求教,这种问题是哪里出错了,是nuc970驱动的问题么 ?我是不是应该朝着驱动这个方向看

#51 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-18 10:31:13

我又测试了下,使用buildroot编译的工具链能够正常的去编译成功IProuter2命令包。

#52 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-17 20:44:18

没有在之前新唐给的rootfs上不能运行,用buildroot制作出来的文件系统就能够正常运行的,另外我使用的是ouput/image/rootfs.tar 解包作为根文件系统的,你说的那个目录output/target下有个很大的说明:说这个不是你的根文件系统,我就没用。稍后几天我会整理一个博文供大家分享。
回到正题,现在ip命令,canutil相关命令可以正常使用了。但是开发板还是不能正常进行CAN通信.
IP命令打开can0时会报错:

# ip link set can0 up
nuc970-can0 nuc970-can0 can0: bit-timing not yet defined
nuc970-can0 nuc970-can0 can0: failed to open can device
RTNETLINK answers: Invalid argument

ip命令can0接口详细信息如下

# ip -detail link show can0
2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state STOPPED (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 0 sample-point 0.000
          tq 0 prop-seg 0 phase-seg1 0 phase-seg2 0 sjw 0
          nuc970_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
          clock 75000000numtxqueues 0

#53 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-17 18:59:23

我使用buildroot编译完成之后的工具链来编译我的程序,但是下载到开发板中不能够正确执行啊 。这个是什么问题啊

#54 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-17 11:38:54

还有一个问题,所以重新编译工具链算是一个解决办法么 ?

#55 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-17 11:36:00

关于buildroot的编译过程晕哥有没有合适nuc970 的参考博客啊。我这里配置的一头雾水,toolchains选择,内核版本选择,如何兼容3.10内核,都是问题,头大。

#56 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-17 10:50:01

晕哥 说:

嗯,刚刚试了一下,配置好BR2_PACKAGE_IPROUTE2=y

很容易就生成成功了:

root@ubuntu:/opt/buildroot-2018.08.2# find output/target/ |grep ip
output/target/sbin/iptunnel
output/target/sbin/iplink
output/target/sbin/ipneigh
output/target/sbin/iprule
output/target/sbin/ip
output/target/sbin/ipaddr
output/target/sbin/iproute
output/target/etc/iproute2
output/target/etc/iproute2/nl_protos
output/target/etc/iproute2/rt_dsfield
output/target/etc/iproute2/rt_protos
output/target/etc/iproute2/bpf_pinning
output/target/etc/iproute2/group
output/target/etc/iproute2/ematch_map
output/target/etc/iproute2/rt_tables
output/target/etc/iproute2/rt_scopes
output/target/etc/iproute2/rt_realms
output/target/usr/lib/ts/skip.so
output/target/usr/share/udhcpc/default.script
output/target/usr/share/udhcpc/default.script.d
output/target/usr/bin/unzip
output/target/usr/bin/bunzip2
output/target/usr/bin/ipcs
output/target/usr/bin/ipcrm
output/target/bin/gzip
output/target/bin/pipe_progress
output/target/bin/gunzip

好的 我尝试一下,本来我都准备重新编译一个交叉工具链,可能是新唐的交叉工具链带的软件库版本低的问题。所iprouter2编译不通过。

#57 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-13 21:25:35

晕哥 说:
thy442156388 说:
晕哥 说:

这个我查看源码别人源码里面是由这个头文件包含的,宏定义也是有的,编译之后提示,宏重复定义了,但是仍然找不到setn()函数。这个是不是交叉编译器的问题啊

也有这种可能,c库是不是uclibc?

这个应该怎么查看啊?

#58 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-13 21:11:45

晕哥 说:

http://man7.org/linux/man-pages/man2/setns.2.html

修改 ipnetns.c,

添加两行:

#define _GNU_SOURCE             /* See feature_test_macros(7) */
#include <sched.h>

这个我查看源码别人源码里面是由这个头文件包含的,宏定义也是有的,编译之后提示,宏重复定义了,但是仍然找不到setn()函数。这个是不是交叉编译器的问题啊

#59 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-13 18:47:27

晕哥 说:

https://blog.csdn.net/horotororensu/article/details/78251865
http://www.mcuzone.com/BBS/read.php?tid=10909

ifconfig can0 down //关闭can0,以便配置
ip link set can0 up type can bitrate 250000 //设置can0波特率
ip -details link show can0 //显示can0信息

没有玩过linux下的can, 楼主看下上面两个链接有没有参考价值。

我按照两个博文上的提示去编译ip命令,老是不能通过,目前出现的问题为

cookie@Cookie ~/Downloads/iproute2-3.6.0 % make CC=arm-linux-gcc
make[1]: Entering directory '/home/cookie/Downloads/iproute2-3.6.0/lib'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/cookie/Downloads/iproute2-3.6.0/lib'
make[1]: Entering directory '/home/cookie/Downloads/iproute2-3.6.0/ip'
arm-linux-gcc -Wall -Wstrict-prototypes -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -DHAVE_SETNS   -c -o ipnetns.o ipnetns.c
ipnetns.c: In function ‘netns_exec’:
ipnetns.c:146:2: warning: implicit declaration of function ‘setns’ [-Wimplicit-function-declaration]
  if (setns(netns, CLONE_NEWNET) < 0) {
  ^
arm-linux-gcc -Wl,-export-dynamic  ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o rtm_map.o iptunnel.o ip6tunnel.o tunnel.o ipneigh.o ipntable.o iplink.o ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o iplink_vlan.o link_veth.o link_gre.o iplink_can.o iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o ../lib/libnetlink.a ../lib/libutil.a  -lresolv ../lib/libnetlink.a ../lib/libutil.a -ldl -o ip
../lib/libutil.a(utils.o): In function `format_host':
utils.c:(.text+0x10d0): warning: gethostbyaddr is obsolescent, use getaddrinfo() instead.
ipnetns.o: In function `netns_exec':
ipnetns.c:(.text+0x58): undefined reference to `setns'
collect2: error: ld returned 1 exit status
make[1]: *** [<builtin>: ip] Error 1
make[1]: Leaving directory '/home/cookie/Downloads/iproute2-3.6.0/ip'
make: *** [Makefile:48: all] Error 2

你们有遇到这个问题了,我没有查到相关的setns的库啊 ‘

#60 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-11 10:00:57

晕哥 说:

https://blog.csdn.net/horotororensu/article/details/78251865
http://www.mcuzone.com/BBS/read.php?tid=10909

ifconfig can0 down //关闭can0,以便配置
ip link set can0 up type can bitrate 250000 //设置can0波特率
ip -details link show can0 //显示can0信息

没有玩过linux下的can, 楼主看下上面两个链接有没有参考价值。

我的linux启动之后shell里不支持ip link set can0 up type can bitrate 250000 这个命令,提示是不支持type选项. 这样的话是不是我还需要重新编译busybox啊

#61 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-10 23:12:29

basicdev 说:

没有玩过linux下的can,我记得新唐的开发手册有提到如何使用

能厚脸皮请问一下,您说的官方手册是哪个文件啊或者pdf啥的啊?
我上面贴的代码是官方bsp包中的代码,然后配置是按照<<nuc970 LInux BSP 用户手册.pdf>>去设置,但是结果不是很理想.虚心求教

#62 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970 linux下CAN通信测试问题 » 2018-12-10 22:20:47

thy442156388
回复: 45

最近工作需要,领导要求测试nuc977开发板上的CAN模块测试工作,之前听说过CAN通信,但是实际上没有操作过,所以有些东西是欠缺的.目前在做CAN口通信测试时遇到问题,所以再次后脸皮回到论坛请教.
问题如下: linux系统下CAN接口数据收发遇到问题:
1.linux内核对于can支持配置如下

 --- >CAN bus subsystem support                                                  
        <*>   Raw CAN Protocol (raw access with CAN-ID filtering)                    
        <*>   Broadcast Manager CAN Protocol (with content filtering)               
        <*>   CAN Gateway/Router (with netlink configuration)                         
              CAN Device Drivers  --->                                               
                      --- NUC970 CAN0/CAN1 devices                                                   
                      [*]   NUC970 CAN0 support                                                    
                      [*]     Enable CAN0 wake-up function                                           
                              NUC970 CAN0 pin selection (Tx:PI4, Rx:PI3)  --->                      
                      [*]   NUC970 CAN1 support                                                     
                      [*]     Enable CAN1 wake-up function                                         
                              NUC970 CAN1 pin selection (Tx:PH15, Rx:PH14)  ---> 

使用的是官方bsp固件包中 nu970bsp/applications/demo/CAN/main.c 修改之后的文件,这里我只修改了main函数,实现一个一直发生数据的功能.
因此这里我只粘贴我的main函数吧(main函数之前的内容没有修改)

int main(int argc, char **argv)
{
	struct can_frame frame;
	struct can_frame Rx_frame;
	struct ifreq ifr;
	struct sockaddr_can addr;
	
	int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
	int dlc = 8;
	int can0_fd, ret, i, rtr = 0, extended = 0;
	int j;
	int ret1;
	int Rx_cnt = 0;

	can_set_bitrate("can0", 5000);
	can_do_start("can0");
    strcpy(ifr.ifr_name, "can0");
		
	can0_fd = socket(family, type, proto);
	if (can0_fd < 0)
	{
		printf("ERROR");
		return 1;
	}

	addr.can_family = family;

	if (ioctl(can0_fd, SIOCGIFINDEX, &ifr) < 0)
	{
		printf("ERROR");
		return 1;
	}

	addr.can_ifindex = ifr.ifr_ifindex;
	if (bind(can0_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
	{
		printf("ERROR");
		return 1;
	}
		
	
	
	for(i = 0; i < dlc; i++)
	{
		frame.data[i] = Rx_cnt%34 + i;
		Rx_frame.data[i] = 0;
	}

	frame.can_id = 0x100;
	frame.can_dlc = dlc;

	if (extended)
	{
		frame.can_id &= CAN_EFF_MASK;
		frame.can_id |= CAN_EFF_FLAG;
	} 
	else
	{
		frame.can_id &= CAN_SFF_MASK;
	}

	if (rtr)
		frame.can_id |= CAN_RTR_FLAG;
	
	printf("\n CAN0 transfer id: %d", frame.can_id);
	printf("\n CAN0 transfer dlc: %d", frame.can_dlc);
	printf("\n CAN0 transfer Data:\n");
	for (i = 0; i < frame.can_dlc; i++)
		printf(" 0x%02x", frame.data[i]);
	printf("\n");

	ret1 = 0;
	for(;;){
		
		for(i = 0; i < dlc; i++)
		{
			frame.data[i] = Rx_cnt%34 + i;
			Rx_frame.data[i] = 0;
		}

		ret = write(can0_fd, &frame, sizeof(frame));
		if (ret == -1)
		{
			printf("write error !! \n");
		}
		printf("\n CAN0 transfer Data:\t");
		for (i = 0; i < frame.can_dlc; i++)
			printf(" 0x%02x", frame.data[i]);
		Rx_cnt++;
		printf("\t Rx: %d \n", Rx_cnt);
	}
	
	can_do_stop("can0"); 

        
	return 0;
}

编译完成之后在linux下测试,数据不能正确发送.
(这里给之后看的人一些提示, nuvoton官方bsp中的rootfs的命令很简化,很多命令不全,需要自己重新编译busybox来获得更多的命令及其参数设置等)
之后有查阅资料,要求使用ip命令来开启can0设备,结果出错.希望晕哥给点提示.
错误提示如下:

~ # ip link set can0 up
nuc970-can0 nuc970-can0 can0: bit-timing not yet defined
nuc970-can0 nuc970-can0 can0: failed to open can device
ip: ioctl 0x8914 failed: Invalid argument

#63 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 17:29:31

问题解决了,nfs协议默认使用UDP协议连接,掉包严重,需要指定NFS使用TCP协议来连接。这里需要更改的是在nfsroot加上tcp选项,添加之后的bootargs参数类似这样

bootargs=noinitrd console=ttyS0,115200n8 root=/dev/nfs rw rdinit=/linuxrc nfsroot=10.0.20.78:/home/cookie/nuc970bsp/rootfs,nfsvers=3,nolock,tcp

评估板的网卡型号为ICplus PHYs,这个掉包严重的问题和这个网卡有关么 ?
最后非常感谢晕哥的耐心指导。不甚感激

#64 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 17:09:42

我的nfs配置文件/etc/exports 中配置如下,这里会不会和linux版本有关,我开发机是Ubuntu18.04的64位机。安装的是nfs-kernel-service软件包。

/home/cookie/nuc970bsp/rootfs *(rw,sync,no_subtree_check)

#65 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 17:01:04

依然挂载不上去,现在感觉可能是我这边的服务器配置有问题,串口启动代码如下

## Booting kernel from Legacy Image at 00007fc0 ...
   Image Name:   
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4451904 Bytes = 4.2 MiB
   Load Address: 00007fc0
   Entry Point:  00008000
   Verifying Checksum ... OK
SF: Detected W25Q128 with page size 4 KiB, total 16 MiB
SF: DeviceBooting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.10.101 (cookie@cookie-HP) (gcc version 4.8.4 (GCC) ) #13 PREEMPT Wed Oct 24 14:44:15 CST 2018
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: NUC970
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd console=ttyS0,115200n8 root=/dev/nfs rw rdinit=/linuxrc nfsroot=10.0.20.78:/home/cookie/nuc970bsp/rootfs,nfsvers=3 ip=10.0.20.195:10.0.20.78:10.0.20.254:255.255.255.0::eth0:off
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60316k/60316k available, 5220k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
      .text : 0xc0008000 - 0xc03e6f04   (3964 kB)
      .init : 0xc03e7000 - 0xc0409680   ( 138 kB)
      .data : 0xc040a000 - 0xc0446e40   ( 244 kB)
       .bss : 0xc0446e40 - 0xc047da60   ( 220 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
NR_IRQS:625
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 4294967286ms
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Initializing cgroup subsys perf_event
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc0359d38 - 0xc0359d74
devtmpfs: initialized
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Switching to clocksource nuc970-timer1
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
nfs4filelayout_init: NFSv4 File Layout Driver Registering...
msgmni has been set to 117
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
nuc970-uart.0: ttyS0 at I/O 0x0 (irq = 36) is a NUC970
brd: module loaded
nuc970 mtd nand driver version: 20160331
NAND device: Manufacturer ID: 0xad, Chip ID: 0xf1 (Hynix NAND 128MiB 3,3V 8-bit), 128MiB, page size: 2048, OOB size: 64
SYSTEM: USE     BCH_T4 HWECC algorithm(SMRA     size: 64, Parity number:32 bytes)
EXECUTE: USE BCH_T4     HWECC algorithm(SMRA size: 64, Parity number:32 bytes)
USE     BCH_T4 HWECC algorithm(Parity number:32 bytes)
Bad block table found at page 65472, version 0x01
Bad block table found at page 65408, version 0x01
Creating 3 MTD partitions on "nand0":
0x000000000000-0x000000200000 : "u-boot"
0x000000200000-0x000001600000 : "Kernel"
0x000001600000-0x000008000000 : "user"
fmi-sm: registered successfully! mtdid=nand0
libphy: nuc970_rmii0: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
nuc970-ehci nuc970-ehci: Nuvoton NUC970 EHCI Host Controller
nuc970-ehci nuc970-ehci: new USB bus registered, assigned bus number 1
nuc970-ehci nuc970-ehci: irq 23, io mem 0xb0005000
nuc970-ehci nuc970-ehci: USB 2.0 started, EHCI 0.95
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
nuc970-ohci nuc970-ohci: Nuvoton NUC970 OHCI Host Controller
nuc970-ohci nuc970-ohci: new USB bus registered, assigned bus number 2
nuc970-ohci nuc970-ohci: irq 24, io mem 0xb0007000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
ipip: IPv4 over IPv4 tunneling driver
gre: GRE over IPv4 demultiplexor driver
ip_gre: GRE over IPv4 tunneling driver
TCP: cubic registered
NET: Registered protocol family 10
sit: IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
Key type dns_resolver registered
nuc970-emac0 nuc970-emac0: eth0 is OPENED
IP-Config: Complete:
     device=eth0, hwaddr=08:00:27:00:01:92, ipaddr=10.0.20.195, mask=255.255.255.0, gw=10.0.20.254
     host=10.0.20.195, domain=, nis-domain=(none)
     bootserver=10.0.20.78, rootserver=10.0.20.78, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:11.
devtmpfs: mounted
Freeing unused kernel memory: 136K (c03e7000 - c0409000)
nfs: server 10.0.20.78 not responding, still trying
nfs: server 10.0.20.78 not responding, still trying
nfs: server 10.0.20.78 OK
nfs: server 10.0.20.78 not responding, still trying
nfs: server 10.0.20.78 not responding, still trying

#66 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 16:50:47

启动过程串口输出是这样的

## Booting kernel from Legacy Image at 00007fc0 ...
   Image Name:   
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4451904 Bytes = 4.2 MiB
   Load Address: 00007fc0
   Entry Point:  00008000
   Verifying Checksum ... OK
SF: Detected W25Q128 with page size 4 KiB, total 16 MiB
SF: DeviceBooting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.10.101 (cookie@cookie-HP) (gcc version 4.8.4 (GCC) ) #13 PREEMPT Wed Oct 24 14:44:15 CST 2018
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: NUC970
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd console=ttyS0,115200n8 root=/dev/nfs rw rdinit=/linuxrc nfsroot=10.0.20.78:/home/cookie/nuc970bsp/rootfs ip=10.0.20.195:10.0.20.78:10.0.20.254:255.255.255.0::eth0:off
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60316k/60316k available, 5220k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
      .text : 0xc0008000 - 0xc03e6f04   (3964 kB)
      .init : 0xc03e7000 - 0xc0409680   ( 138 kB)
      .data : 0xc040a000 - 0xc0446e40   ( 244 kB)
       .bss : 0xc0446e40 - 0xc047da60   ( 220 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
NR_IRQS:625
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 4294967286ms
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Initializing cgroup subsys perf_event
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc0359d38 - 0xc0359d74
devtmpfs: initialized
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Switching to clocksource nuc970-timer1
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
nfs4filelayout_init: NFSv4 File Layout Driver Registering...
msgmni has been set to 117
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
nuc970-uart.0: ttyS0 at I/O 0x0 (irq = 36) is a NUC970
brd: module loaded
nuc970 mtd nand driver version: 20160331
NAND device: Manufacturer ID: 0xad, Chip ID: 0xf1 (Hynix NAND 128MiB 3,3V 8-bit), 128MiB, page size: 2048, OOB size: 64
SYSTEM: USE     BCH_T4 HWECC algorithm(SMRA     size: 64, Parity number:32 bytes)
EXECUTE: USE BCH_T4     HWECC algorithm(SMRA size: 64, Parity number:32 bytes)
USE     BCH_T4 HWECC algorithm(Parity number:32 bytes)
Bad block table found at page 65472, version 0x01
Bad block table found at page 65408, version 0x01
Creating 3 MTD partitions on "nand0":
0x000000000000-0x000000200000 : "u-boot"
0x000000200000-0x000001600000 : "Kernel"
0x000001600000-0x000008000000 : "user"
fmi-sm: registered successfully! mtdid=nand0
libphy: nuc970_rmii0: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
nuc970-ehci nuc970-ehci: Nuvoton NUC970 EHCI Host Controller
nuc970-ehci nuc970-ehci: new USB bus registered, assigned bus number 1
nuc970-ehci nuc970-ehci: irq 23, io mem 0xb0005000
nuc970-ehci nuc970-ehci: USB 2.0 started, EHCI 0.95
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
nuc970-ohci nuc970-ohci: Nuvoton NUC970 OHCI Host Controller
nuc970-ohci nuc970-ohci: new USB bus registered, assigned bus number 2
nuc970-ohci nuc970-ohci: irq 24, io mem 0xb0007000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
ipip: IPv4 over IPv4 tunneling driver
gre: GRE over IPv4 demultiplexor driver
ip_gre: GRE over IPv4 tunneling driver
TCP: cubic registered
NET: Registered protocol family 10
sit: IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
Key type dns_resolver registered
nuc970-emac0 nuc970-emac0: eth0 is OPENED
IP-Config: Complete:
     device=eth0, hwaddr=08:00:27:00:01:92, ipaddr=10.0.20.195, mask=255.255.255.0, gw=10.0.20.254
     host=10.0.20.195, domain=, nis-domain=(none)
     bootserver=10.0.20.78, rootserver=10.0.20.78, rootpath=
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
1f00            2048 mtdblock0  (driver?)
1f01           20480 mtdblock1  (driver?)
1f02          108544 mtdblock2  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
CPU: 0 PID: 1 Comm: swapper Not tainted 3.10.101 #13
Backtrace: 
[<c0011dc4>] (dump_backtrace+0x0/0x10c) from [<c0011f60>] (show_stack+0x18/0x1c)
 r6:c0404eac r5:00008000 r4:c03b7e8c r3:00000000
[<c0011f48>] (show_stack+0x0/0x1c) from [<c0356c98>] (dump_stack+0x20/0x28)
[<c0356c78>] (dump_stack+0x0/0x28) from [<c0354894>] (panic+0xa4/0x1fc)
[<c03547f0>] (panic+0x0/0x1fc) from [<c03e81dc>] (mount_block_root+0x1c4/0x270)
 r3:00000001 r2:00000000 r1:c3843ea0 r0:c03b7e8c
 r7:c03b7ef4
[<c03e8018>] (mount_block_root+0x0/0x270) from [<c03e8470>] (mount_root+0xec/0x114)
[<c03e8384>] (mount_root+0x0/0x114) from [<c03e85f8>] (prepare_namespace+0x160/0x1c0)
 r8:00000069 r7:c0404e8c r6:c0404eac r5:c0404eac r4:c0446ea0
[<c03e8498>] (prepare_namespace+0x0/0x1c0) from [<c03e7dd0>] (kernel_init_freeable+0x1f8/0x240)
 r6:c03e74c8 r5:c0404e84 r4:00000007
[<c03e7bd8>] (kernel_init_freeable+0x0/0x240) from [<c03541f0>] (kernel_init+0x10/0x158)
[<c03541e0>] (kernel_init+0x0/0x158) from [<c000eb98>] (ret_from_fork+0x14/0x3c)
 r5:c03541e0 r4:00000000

#67 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 16:37:44

是的NFS作为根文件系统,不能够进入shell,错误提示和一楼代码一样。uboot网络功能正常,能够正常ping通服务器地址,下面是我的uboot环境变量设置。

baudrate=115200
bootargs11=noinitrd root=/dev/nfs nfsroot=10.0.20.78:/home/cookie/nuc970bsp/rootfs ip=10.0.20.83:10.0.20.78:10.0.20.254:255.255.255.0::eth0:off console=ttyS0,115200n8 rdinit=/sbin/init 
bootargs=noinitrd console=ttyS0,115200n8 root=/dev/nfs rw rdinit=/linuxrc nfsroot=10.0.20.78:/home/cookie/nuc970bsp/rootfs ip=10.0.20.195:10.0.20.78:10.0.20.254:255.255.255.0::eth0:off
bootcmd=nboot 0x7fc0 0 0x200000;bootm 0x7fc0
bootdelay=3
ethact=emac
ethaddr=00:00:00:11:66:88
ipaddr=10.0.20.196
netmask=255.255.255.0
rootpath=/home/cookie/nuc970bsp/rootfs
serverip=10.0.20.78
stderr=serial
stdin=serial
stdout=serial

#68 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 15:45:59

现在yaffs2文件系统的nfs能够挂在上去了,在制作文件系统的时候在busybox中的mount命令配置里,官方给的默认配置mount没有给配置挂载nfs的功能,重新配置制作的文件系统可以挂载nfs,但是开发板的启动挂载仍然不行。

#69 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-24 15:09:12

晕哥 说:

这个难说, 你不能确认网络没有问题吧?你也不能确定NFS服务器一定没有问题吧?

所以还是按照我前面说的方法,
通过其它根文件系统启动到shell,
1. 设置好NUC97x的ip地址, ping NFS服务器, 可以发现NUC97x网络配置,硬件等有没有问题。
2. 手动 mount NFS 服务器到本地目录, 可以判断服务器是否正常。

上面都可以之后再配置 u-boot/kernel的 bootargs,设置一楼那些NFS 根文件系统参数,
这样从NFS启动就问题不大了,
如果有问题,也可以排除很多问题了。

我按你说的做了测试,但是新的问题又来了,我烧写了yaffs2文件系统的方式来启动开发板,但是在yaffs2文件系统下仍然不能够挂在nfs。我在我的另外一台电脑的ubunutu虚拟机中测试是可以挂在nfs的。

#70 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-21 22:35:24

内核系统配置是采用新唐给的linux3.10的内核,然后使用nuc972_defconfig。在这个基础上
取消了General setup--》中的Initial RAM filesystem and RAM disk support ,
配置了Networking support---》中的networking options 中的IP:kernel level autoconfiguration;
         File system---》下 network file system nfs client 所有选项
          File system---》下 network file system 下的 root file system on nfs

这样的内核配置有问题么 ?

#71 Re: Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-21 22:21:16

晕哥 说:

看错误提示是nfs根文件系统没有挂载上, 现在要排除问题:

1. 确认你的 nfs server 能不能被其它linux挂载上?
2. NUC97x使用别的根文件让系统能进入shell, 手动 mount nfs 文件系统,看是否出错.

那这个和busybox 编译的命令有关系么 ?我再看busybox编译配置的时候,印象中mount有一个选项要配置是否支持nfs挂载。是不是自己制作的别的根文件系统再编译busybox 的时候应该加上这个选项。

#72 Nuvoton N32905/N32926/NUC972/N9H20/N9H26/N9H30 » nuc970评估版nfs启动失败的问题 » 2018-10-21 22:11:47

thy442156388
回复: 35

最近因工作需要,目前做nuc970 开发板nfs启动的实验,但是现在nfs挂载不上。
开发板启动给出的错误为

usbcore: registered new interface driver usb-storage
TCP: cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
[color#ff0000]
nuc970-emac0 nuc970-emac0: eth0 is OPENED
IP-Config: Complete:
     device=eth0, hwaddr=08:00:27:00:01:92, ipaddr=10.0.20.81, mask=255.255.255.0, gw=10.0.20.254
     host=10.0.20.81, domain=, nis-domain=(none)
     bootserver=10.0.20.78, rootserver=10.0.20.78, rootpath=
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
CPU: 0 PID: 1 Comm: swapper Not tainted 3.10.101 #3
[/color]
Backtrace: 
[<c0011f24>] (dump_backtrace+0x0/0x10c) from [<c0012138>] (show_stack+0x18/0x1c)
 r6:c03fd8d0 r5:00008000 r4:c03977a8 r3:00000000
[<c0012120>] (show_stack+0x0/0x1c) from [<c031a1c8>] (dump_stack+0x20/0x28)
[<c031a1a8>] (dump_stack+0x0/0x28) from [<c0317db4>] (panic+0xa4/0x1f8)
[<c0317d10>] (panic+0x0/0x1f8) from [<c03e2054>] (mount_block_root+0x1c4/0x270)
 r3:00000030 r2:00000000 r1:c3843ea0 r0:c03977a8
 r7:c0397810
[<c03e1e90>] (mount_block_root+0x0/0x270) from [<c03e22e8>] (mount_root+0xec/0x114)
[<c03e21fc>] (mount_root+0x0/0x114) from [<c03e2470>] (prepare_namespace+0x160/0x1c0)
 r8:c03fd8a8 r7:c043b5a0 r6:c03fd8d0 r5:c03fd8d0 r4:c043b600
[<c03e2310>] (prepare_namespace+0x0/0x1c0) from [<c03e1c48>] (kernel_init_freeable+0x1d8/0x220)
 r6:c043b5a0 r5:00000007 r4:c0402114
[<c03e1a70>] (kernel_init_freeable+0x0/0x220) from [<c0317710>] (kernel_init+0x10/0x158)
[<c0317700>] (kernel_init+0x0/0x158) from [<c000ecf8>] (ret_from_fork+0x14/0x3c)
 r5:c0317700 r4:00000000

开发板的启动命令如下

mem=64M console=ttyS0,115200n8 root=/dev/nfs rw rdinit=/sbin/init mtdparts=nand0:16M(boot)ro,-(rootfs) nfsroot=10.0.20.78:/home/cookie/nuc970bsp/rootfs ip=10.0.20.81:10.0.20.78:10.0.20.254:255.255.255.0::eth0:off

内核配置了配置了IP支持,nfs客户端支持,root filesystem on nfs.
开发的Linux主机上配置了nfs,同时再另一台电脑上用虚拟机测试能够正确挂载nfs。
但是目前启动不了。求论坛大神给小弟一点指导。google上查询了很多方法但是都不行。

页脚

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

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