【NUC972】LINUX移植笔记:(1)移植笔记

【NUC972】LINUX移植笔记:(1)移植笔记

宿主机 : 虚拟机 Ubuntu 16.04 LTS / X86
开发板: NUC972
LINUX内核: 3.10.x
交叉编译器: arm-linux-uclibcgnueabi-gcc 4.3.4
日期: 2018-2-9 10:58:04
作者: SY


简介

开发板使用全然电子的 NUC972 ,他们在新唐官方的基础上移植了大部分的功能。但是驱动仍然存在问题,触摸屏不能使用。还有提供的 QT 不支持软键盘等。


编译器

全然电子提供的编译器 arm-linux-uclibcgnueabi-gcc 4.3.4 可以正常编译。后来尝试使用 arm-none-linux-gnueabi-gcc 4.8.3 同样可以正常编译内核、文件系统等,后续将使用该编译器!


驱动

触摸屏

官方提供的是四线制电阻触摸屏驱动,而开发板使用的是电容触摸屏,触摸屏 ICFT5206 ,主机与触摸屏 IC 使用 I2C 方式通信。根据全然电子的描述,当使用硬件 i2C 高速通讯时会死机,因此通过任意使用两个 GPIO 模拟 I2C 时序。

引脚

对于 FT5206 ,我们重点关注下面引脚:

  • SDA —–> NUC970_PG9
  • SCL —–> NUC970_PG2
  • INT —–> NUC970_PG3

Menuconfig

Device Drivers  ---> 
    Input device support  ---> 
        [*]   Touchscreens  ---> 
            <*>   Ft5X06 I2C Touchscreen
        < >   Input NUC970 ADC  ---> 

arch/arm/mach-nuc970/dev.c

#ifdef CONFIG_I2C_ALGOBIT
static struct i2c_board_info __initdata nuc970_i2c_clients2[] =
{
#ifdef CONFIG_TOUCHSCREEN_FT5X06
{
        I2C_BOARD_INFO("ft5x06-ts", 0x38),
        .irq=(IRQ_GPIO_START+0xc3), //PG3
},
#endif
};

static struct i2c_gpio_platform_data i2c_gpio_adapter_data = {
    .sda_pin = NUC970_PG9,
    .scl_pin = NUC970_PG2,
    .udelay = 5,
    .timeout = 100,
    .sda_is_open_drain = 0,   //not support open drain mode
    .scl_is_open_drain = 0,   //not support open drain mode
};

static struct platform_device i2c_gpio = {
    .name = "i2c-gpio",
    .id = 2,
    .dev = {
        .platform_data = &i2c_gpio_adapter_data,
    },
};

#endif

static struct platform_device *nuc970_public_dev[] __initdata = {
#ifdef CONFIG_I2C_ALGOBIT
    &i2c_gpio,
#endif
}

void __init nuc970_platform_init(struct platform_device **device, int size)
{
    platform_add_devices(nuc970_public_dev, ARRAY_SIZE(nuc970_public_dev));
#ifdef CONFIG_GPIO_NUC970
#ifdef CONFIG_I2C_ALGOBIT
    i2c_register_board_info(2, nuc970_i2c_clients2, sizeof(nuc970_i2c_clients2)/sizeof(struct i2c_board_info));
#endif
#endif
}

烧录测试

==kzalloc=
==request_irq=
==input_allocate_device=
input: ft5x06-ts as /devices/virtual/input/input0
[FST] Firmware version = 0x00
==probe over =
i2c-gpio i2c-gpio.2: using pins 201 (SDA) and 194 (SCL)

根据输出信息,在 /dev/input/event0 生成了节点。而且 I2C 工作正常,但是读取芯片的 ID 始终错误,怀疑是干扰问题。通过连接示波器查看 I2C 的波形,发现即使不使用 I2C 收发数据,甚至不初始化 GPIOI2C-DATA 引脚始终有非常多的不规则的脉冲。

通过卸载其他驱动的方式来排除,发现只要不使用 LCDI2C 即可工作正常。

查看 nuc970fb_probe ,发现只要注释掉 p = devm_pinctrl_get_select(&pdev->dev, “lcd-16bit”); I2C 工作正常,查找关键字 lcd-16bit ,找到:

driver/pinctrl/pinctrl-nuc970.c

static const struct pinctrl_map nuc970_pinmap[] = {
    {
        .dev_name = "nuc970-lcd",
        .name = "lcd-16bit",
        .type = PIN_MAP_TYPE_MUX_GROUP,
        .ctrl_dev_name = "pinctrl-nuc970",
        .data.mux.function = "lcd0",
        .data.mux.group = "lcd0_grp",
    },
}   

说明 lcd 属于 lcd0_grp 组。

static const struct nuc970_pinctrl_group nuc970_pinctrl_groups[] = {    
    {
        .name = "lcd0_grp",
        .pins = lcd_0_pins,
        .num_pins = ARRAY_SIZE(lcd_0_pins),
        .func = 0x2,
    },
}

找到相关引脚

const struct pinctrl_pin_desc nuc970_pins[] = {
    PINCTRL_PIN(0x66, "PG6"),
    PINCTRL_PIN(0x67, "PG7"),
    PINCTRL_PIN(0x68, "PG8"),
    PINCTRL_PIN(0x69, "PG9"),
};
static const unsigned lcd_0_pins[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                                0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
                                0x66, 0x67, 0x68, 0x69}; // 16 bit mode

正好 PG9 包含在其中!去掉 0X69 后,再次测试 LCDI2C 均工作正常!

==kzalloc=
==request_irq=
==input_allocate_device=
input: ft5x06-ts as /devices/virtual/input/input0
[FST] Firmware version = 0x13
==probe over =
i2c-gpio i2c-gpio.2: using pins 201 (SDA) and 194 (SCL)

回头来看,其实内核早已做出提示:一开始烧录时提示:

Please Check GPIOG09's multi-function = 0x2

当时不懂什么意思,直接将提示注释掉了,现在看来大有深意啊!

lcd0_grp 中正是配置了 .func = 0x2


LCD

LCD 使用的是 AT070TN92 屏,分辨率:800X480 ,支持 RGB888 格式,从硬件连接上,只使用了 16 位数据总线,因此格式为 RGB565


控制台

LCD 上使用控制台界面

/etc/inittab

添加下面内容:

tty0::askfirst:-/bin/sh

去除 LCD 控制台光标

drivers/video/console/fbcon.c

1333 static void fbcon_cursor(struct vc_data *vc, int mode)
1334 {
1335     return;
1336 }

按钮

去掉不用的按钮。

Device Drivers  --->
    Input device support  --->  
        [*]   Keyboards  ---> 
            < >   GPIO Buttons

QT

添加触摸屏

/etc/profile

export  QWS_MOUSE_PROTO="Tslib:/dev/input/event0"

添加鼠标

/etc/profile

export  QWS_MOUSE_PROTO="MouseMan:/dev/input/mouse1"

添加触摸屏和鼠标

/etc/profile

export  QWS_MOUSE_PROTO="Tslib:/dev/input/event0 MouseMan:/dev/input/mouse1"

添加 USB 键盘

export  QWS_KEYBOARD="USB:/dev/input/event1"

支持键盘鼠标热插拔

QT5.5.1 嵌入式平台 鼠标键盘不能热插拔问题解决(一)

/etc/profile

echo "/sbin/mdev" > /proc/sys/kernel/hotplug

在开机的情况下,插入键盘鼠标,只要重启应用程序即可识别!

添加虚拟键盘

QT SYSZUXpinyin 开源输入法移植

源文件名:syszuxpinyin1.0.tar.gz

将文件拷贝到 Linux ,使用 qtcreator 打开,使用交叉编译器编译后,生成:

libSYSZUXpinyin.so
libSYSZUXpinyin.so.1
libSYSZUXpinyin.so.1.0
libSYSZUXpinyin.so.1.0.0

文件拷贝到 QT 库目录

root@ubuntu:/opt/SYSZUXpinyin/build-syszuxpinyin-Linux-Release# cp libsyszuxpinyin.so* /usr/local/Trolltech97x/QtEmbedded-4.8.5/lib/

文件拷贝到开发板 QT 库目录

root@ubuntu:/opt/SYSZUXpinyin/build-syszuxpinyin-Linux-Release# cp libsyszuxpinyin.so* /opt/fs/rootfs/usr/qt/lib/

新建自己的项目,打开 .pro 文件

QMAKE_LIBS += -lsyszuxpinyin

SYSZUXpinyin 源码中的 syszuxpinyin.ui syszuxim.h syszuxpinyin.h 拷贝到工程目录,并添加到工程中!

在需要用到输入法的源文件中添加:

#include "syszuxpinyin.h"
#include "syszuxim.h"

启动输入法

QWSInputMethod* im = new SyszuxIM;
QWSServer::setCurrentInputMethod(im);

当出现输入框时,点击即可跳转到输入法界面!

改进

原来的输入法,点击 enter 按钮,将输入 enter 字符串,我们希望点击 enter 直接退出输入法!修改源码:

syszuxpinyin.cpp

void SyszuxPinyin::buttonClickResponse(int gemfield)
{
    if(gemfield==1)
    {
        selectHanziPre();
        return;
    }
    else if(gemfield==10)
    {
        selectHanziNext();
        return;
    }
    else if(gemfield<10)
    {
        lineEdit_window->insert(button_vector.at(gemfield-1)->text());
        lineEdit_pinyin->clear();
        clearString();
        return;
    }
    else if(gemfield==23)
    {
        deleteString();
        return;
    }
    else if(gemfield==59)
    {
         changeLowerUpper();
         return;
    }

    else if ((gemfield>10 && gemfield<=60 && (gemfield!=48)))
    {
        if(lower_upper)
            event=new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,syszux_upper_letter[gemfield-11]);
        else
            event=new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,syszux_lower_letter[gemfield-11]);
    }
    else if(gemfield==61)
    {
        changeInputMethod();
        return;
    }
    else if ((gemfield == 62) || (gemfield == 48))
    {
        affirmString();
        return;
    }
    else if(gemfield>62)
    {
        switch(gemfield)
        {
        case 63:
            event=new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier);
            break;
        case 64:
            event=new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
            break;
        case 65:
            event=new QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier);
            break;
        case 66:
            event=new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
            break;
        }
    }
    if(input_method)
    {
        lineEdit_pinyin->setFocus();
        QApplication::sendEvent(focusWidget(),event);
        matching(lineEdit_pinyin->text());
    }
    else
    {
        lineEdit_window->setFocus();
        QApplication::sendEvent(focusWidget(),event);
    }
}

其中 48 表示字符 enter !

支持中文

默认输入法只支持英文输入,如果需要中文输入法,首先需要安装中文字库,QT 默认的中文字库为 unifont

main.cpp

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    /* Support Chinese */
    QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
}

对于程序中使用中文的地方,比如设置标题文本,需要:

#include 

/* Load virtual keyboard */
QWSInputMethod* im = new SyszuxIM;
QWSServer::setCurrentInputMethod(im);

QTextCodec *textCh = QTextCodec::codecForName("UTF-8");
this->setWindowTitle(textCh->toUnicode("QT 示例程序"));

启动程序需要使用:

$ [root@NUC972:/]# /usr/local/app/gdb -qws -font unifont

一般安装的字体是 wenquanyi ,也可以这么启动

[root@NUC972:/]# /usr/local/app/gdb -qws -font wenquanyi

根文件系统

busybox

从官网下载 busybox ,文件名:busybox-1.22.1.tar.bz2

Makefile

190 ARCH ?= arm
191 ARCH ?= $(SUBARCH)

menuconfig

Busybox Settings  --->
    General Configuration  --->  
        [*] Don't use /usr
    Build Options  --->     
        [*] Build BusyBox as a static binary (no shared libs)
        (arm-linux-) Cross compiler prefix
    Archival Utilities  --->
        [*] tar, rpm, modprobe etc understand .Z data
Archival Utilities  --->
    [*] tar, rpm, modprobe etc understand .Z data

下面开始编译

$ make
coreutils/touch.c: In function 'touch_main':
coreutils/touch.c:172: error: 'lutimes' undeclared (first use in this function)
coreutils/touch.c:172: error: (Each undeclared identifier is reported only once
coreutils/touch.c:172: error: for each function it appears in.)
scripts/Makefile.build:197: recipe for target 'coreutils/touch.o' failed
make[1]: *** [coreutils/touch.o] Error 1
Makefile:743: recipe for target 'coreutils' failed
make: *** [coreutils] Error 2

进入 menuconfig

Coreutils  --->
    [] touch (5.8 kb)

继续编译

$ make
miscutils/nandwrite.c: In function 'dump_bad':
miscutils/nandwrite.c:64: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c:68: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c:71: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c:72: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c:74: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c:64: warning: unused variable 'buf'

进入 menuconfig

Miscellaneous Utilities  ---> 
    [ ] nandwrite                                                     
    [ ] nanddump

继续编译

$ make
miscutils/ubi_tools.c:67:26: error: mtd/ubi-user.h: No such file or directory
miscutils/ubi_tools.c: In function 'ubi_tools_main':
miscutils/ubi_tools.c:106: error: 'UBI_DEV_NUM_AUTO' undeclared (first use in this function)
miscutils/ubi_tools.c:106: error: (Each undeclared identifier is reported only once

进入 menuconfig

Miscellaneous Utilities  ---> 
    [ ] ubiattach                                                                
    [ ] ubidetach                                                         
    [ ] ubimkvol                                                     
    [ ] ubirmvol                                               
    [ ] ubirsvol                                            
    [ ] ubiupdatevol 

继续编译

$ make
Trying libraries: crypt m
 Library crypt is not needed, excluding it
 Library m is needed, can't exclude it (yet)
Final link with: m
  DOC     busybox.pod
  DOC     BusyBox.txt
  DOC     busybox.1
  DOC     BusyBox.html  

安装

root@ubuntu:/opt/busybox-1.22.1# make install
--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
--------------------------------------------------

【TINY4412】LINUX移植笔记:(2)BusyBox制作最小文件系统


以太网

打开网卡

/etc/profile

ifconfig eth0 up

自动获取IP

menuconfig

[*] Networking support  --->
    Networking options  ---> 
        [*]   IP: kernel level autoconfiguration
            [*]     IP: DHCP support 
            [*]     IP: BOOTP support
            [*]     IP: RARP support 
    [*] Network packet filtering framework (Netfilter)  ---> 
    [*]   Advanced netfilter configuration 

烧录程序,编写脚本

/usr/share/udhcpc/default.script

#!/bin/sh

# udhcpc script edited by Tim Riker 
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
case "$1" in
        deconfig)
                /sbin/ifconfig $interface 0.0.0.0
                ;;
        renew|bound)
                /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
                if [ -n "$router" ] ; then
                        echo "deleting routers"
                        while route del default gw 0.0.0.0 dev $interface ; do
                                :
                        done
                        for i in $router ; do
                                route add default gw $i dev $interface
                        done
                fi
                echo -n > $RESOLV_CONF
                [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
                for i in $dns ; do
                        echo adding dns $i
                        echo nameserver $i >> $RESOLV_CONF
                done
                ;;
esac

exit 0

执行:

~ # chmod 755 /usr/share/udhcpc/default.script
~ # udhcpc
udhcpc (v1.22.1) started
Sending discover...
Sending select for 192.168.0.42...
Lease of 192.168.0.42 obtained, lease time 604800
deleting routers
route: ioctl 0x890c failed: No such process
adding dns 192.168.0.1

开发板的 IP 地址为 192.168.0.42

~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:00:01:92  
          inet addr:192.168.0.42  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:981 errors:0 dropped:82 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:312634 (305.3 KiB)  TX bytes:1368 (1.3 KiB)

~ # ping 192.168.0.73
PING 192.168.0.73 (192.168.0.73): 56 data bytes
64 bytes from 192.168.0.73: seq=0 ttl=128 time=3.059 ms
64 bytes from 192.168.0.73: seq=1 ttl=128 time=0.733 ms
64 bytes from 192.168.0.73: seq=2 ttl=128 time=0.741 ms

嵌入式linux通过DHCP自动获取IP地址实现


文件系统

NFS网络文件系统

主机端

【TINY4412】LINUX移植笔记:(12)NFS网络文件系统

menuconfig

File systems  --->
    [*] Network File Systems  ---> 
        <*>   NFS client support
        [*]   Root file system on NFS 

U-BOOT

U-Boot> setenv serverip 192.168.0.74
U-Boot> setenv ipaddr 192.168.0.128
U-Boot> setenv netmask 255.255.255.0

U-Boot> setenv bootcmd tftpboot 0x7fc0 uImage.bin\; bootm 0x7fc0
U-Boot> setenv bootargs init=/linuxrc root=/dev/nfs nfsroot=192.168.0.74:/opt/fs/rootfs,nolock rw ip=dhcp earlyprintk console=ttyS0,115200n8 mem=64M
U-Boot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0xe0000 -- 100% complete.
Writing to Nand... done

设置上述参数的目的:

开发板进入 U-BOOT 后,将自己的 IP 设置为 192.168.0.128 ,使用 TFTP 协议接收主机端 uImage.bin 文件,将文件存储于 0x7fc0 开始的内存地址。然后跳转到该地址执行!

menuconfig

Boot options  --->
    Kernel command line type (Use bootloader kernel arguments if available)  ---> 

设置上述参数表示,如果 U-BOOT 设置 bootargs ,将使用该参数,并忽略 linux 内核中设置的参数!

下面我们来解析 bootargs

  • init=/linuxrc:首先执行的初始化程序

  • nfsroot=192.168.0.74:/opt/fs/rootfs:表示主机端 ip 地址及根文件系统所在目录

  • ip=dhcp:开发板的 ip 地址使用 dhcp 自动获取

  • console=ttyS0,115200n8:控制台设备为 ttyS0 ,也就是串口

  • mem=64M:内存大小为64M

挂载根文件系统到SD卡

【TINY4412】LINUX移植笔记:(14)SD卡分区、格式化

【TINY4412】LINUX移植笔记:(15)SD卡启动Linux内核

U-BOOT

U-Boot> setenv bootargs noinitrd root=/dev/mmcblk0p1 rw rootfstype=ext4 console=ttyS0,115200n8 init=/linuxrc rootwait mem=64M
U-Boot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0xe0000 -- 100% complete.
Writing to Nand... done

下面解释:

  • noinitrd:不使用 initrd 文件系统
  • root=/dev/mmcblk0p1:文件系统挂载到 mmcblk0p1 设备的第一个分区上面,该设备正是 SD
  • rootfstype=ext4:根文件系统类型为 ext4
  • rootwait:必须添加!否则提示找不到设备 mmcblk0p1

技巧

查看中断

# cat /proc/interrupts 
           CPU0       
 13:          0         -  nuc970-lcd
 15:          0         -  nuc970rtc
 16:      50430         -  nuc970-timer0
 23:          2         -  ehci_hcd:usb1
 24:          0         -  ohci_hcd:usb2
 27:         38         -  mmc0
 29:          1         -  nuc970-udc
 33:          0         -  nuc970-jpeg
 36:       3114         -  ttyS0
451:        601  GPIO-IRQ  ft5x06_ts
Err:          0
  • 451 代表中断号,451 转换为 16 进制为 0x01C3
  • 601 代表在 CPU0 上响应中断的次数

中断号:通过查看文档 NUC970 Linux BSP 使用手冊.pdf

GPIO 驅動程序將NUC970系列芯片的 GPIO口, 從GPIOA~GPIOJ 每組IO都保留32個號
碼, 所以GPIOA編號0x000~0x01F, GPIOB編號0x020~0x03F, GPIOC編號0x040~0x05F,
GPIOD編號0x060~0x07F, GPIOE編號0x080~0x09F, GPIOF編號0x0A0~0x0BF, GPIOG編
號 0x0C0~0x0DF, GPIOH 編 號 0x0E0~0x0FF, GPIOI 編 號 0x100~0x11F, GPIOJ 編 號
0x120~0x13F.

找到定义 #define IRQ_GPIO_START NUC970_IRQ(NUC970_IRQ(0x100))

可以推出:PG3 –> 0x100 + 0xC3 = 0x1C3

Debugfs

Menuconfig

Kernel hacking  ---> 
    -*- Debug Filesystem

烧录后,进入控制台

/etc/profile

mount -t debugfs none /sys/kernel/debug/
ln -s /sys/kernel/debug /

这样,开机后自动挂在 debugfs 到目录 /

~ # ls
Settings    dev         lib         mnt         sys         var
bin         etc         linuxrc     proc        tmp
debug       gdb         lost+found  sbin        usr
~ # cd debug/
/sys/kernel/debug # ls
bdi             extfrag         ieee80211       pinctrl
clk             gpio            memblock        sched_features
dma_buf         hid             mmc0            usb

debugfs mount point

GPIO

打印 GPIO 信息

/sys/kernel/debug # cat gpio 
GPIOs 0-319, platform/nuc970-gpio, nuc970_gpio_port:
 gpio-194 (scl                 ) in  hi
 gpio-201 (sda                 ) in  hi

/dev/mem

/dev/mem 用于访问设备物理地址,查看寄存器数值。

为了防止应用程序任意修改物理地址空间数据

/sys/kernel/debug # cat /dev/mem 
Program cat tried to access /dev/mem between 0->1000.
cat: read error: Operation not permitted

可以看出根本不允许用户读取!我们调试阶段做出以下修改:

menuconfig

Kernel hacking  ---> 
    [] Filter access to /dev/mem

解除访问限制,这样就可以访问整个处理器地址空间。

使用 cat 这种方式打印的数据都是乱码,一般的访问方式是在应用程序中,使用 mmap 映射一段物理地址空间到用户空间。

自动挂载SD卡

Linux下实现U盘、SD卡自动挂载功能

添加内容

/etc/init.d/rcS

echo /sbin/mdev > /proc/sys/kernel/hotplug 

新建文件

/etc/mdev.conf

sd[a-z][0-9]      0:0 666        @(/etc/hotplug/insert.sh $MDEV $SUBSYSTEM)
sd[a-z]           0:0 666        $(/etc/hotplug/remove.sh $MDEV $SUBSYSTEM)
ub[a-z][0-9]      0:0 666        @(/etc/hotplug/insert.sh $MDEV $SUBSYSTEM)
ub[a-z]           0:0 666        $(/etc/hotplug/remove.sh $MDEV $SUBSYSTEM)
mmcblk[0-9]p[0-9] 0:0 666        @(/etc/hotplug/insert.sh $MDEV $SUBSYSTEM)
mmcblk[0-9]       0:0 666        $(/etc/hotplug/remove.sh $MDEV $SUBSYSTEM)

/etc/hotplug/insert.sh

#! /bin/sh

if [ -n "$1" ] ; then
    if [ -b /dev/$1 ]; then

        if [ ! -d /mnt ]; then
            mkdir -p /mnt
        fi

        if [ ! -d /mnt/$1 ]; then
            mkdir -p /mnt/$1
        fi
             mount /dev/$1 /mnt/$1
if [ $? -ne 0 ]; then
    rm -rf /mnt/$1

        fi

    fi
fi

/etc/hotplug/remove.sh

MOUNTS=$(mount | grep $1 | cut -d' ' -f3)
umount $MOUNTS
rm -rf $MOUNTS

重启开发板,可以在 /mnt 目录下看到挂载的内容

设置命令行提示符

/etc/profile

USER="`id -un`"
LOGNAME=$USER
HOSTNAME='/bin/hostname'
/bin/hostname NUC972

PS1='[\u@\h:\w]# '

/etc/passwd

root:x:0:0:root:/root:/bin/sh

/etc/group

root:x:0:

/etc/shadow

root::12179:0:99999:7:::

用户登录

设置登录密码

[root@NUC972:~]# passwd root

/etc/inittab

::sysinit:/etc/init.d/rcS
::sysinit:-/bin/login
::respawn:-/bin/sh
#ttyS0::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r

关键是添加:::sysinit:-/bin/login


问题记录

问题

编译 Linux 内核时,输入 make menuconfig ,提示:

root@ubuntu:/opt/linux-3.10.x# make menuconfig
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
/opt/linux-3.10.x/scripts/kconfig/Makefile:199: recipe for target 'scripts/kconfig/dochecklxdialog' failed
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
Makefile:504: recipe for target 'menuconfig' failed

输入:

root@ubuntu:/opt/linux-3.10.x# apt-get install ncurses-devel
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ncurses-devel

解决

如何解決執行 make menuconfig 時…會遇到 recipe for target ‘scripts/kconfig/mconf.o’ failed

输入:

root@ubuntu:/opt/linux-3.10.x# apt-get install libncurses5-dev

问题

每次编译完内核,都会自动拷贝文件

解决

./arch/arm/boot/Makefile

cp $@   ../image/970image
zip ../image/970image.zip ../image/970image

去掉上述内容即可。

你可能感兴趣的:(NUC972,LINUX)