1. 程式人生 > >嵌入式 Linux ARM ADS ADHOC C C++ PLC 微控制器

嵌入式 Linux ARM ADS ADHOC C C++ PLC 微控制器

  ramdisk 製作:

1: 核心支援:
其中主要修改3項,如下:
①、修改Bootoptions
Default kernel command string  這一項我設為空,讓bootloader(u-boot,vivi)傳入。

②、選上 Float point emulation ->
[ * ] NWFE math emnulaiton

③、修改Driver device  ->
  Block device ->
(4096)Default RAM disk size (kbytes)
改4096為8192

2:以下是摘自網上的,

製作空的ramdisk:
# dd if=/dev/zero of=ramdisk bs=1k count=8000
   在本地目錄下出現一個rmdisk的塊檔案
# losetup /dev/loop2 ramdisk
# mkfs.ext2 /dev/loop2
掛載ramdisk至/mnt下
# mount -t ext2 /dev/loop2 /mnt
㈢.準備lib庫檔案
# cd /mnt
# mkdir lib
# cd  /usr/local/arm/3.4.1/arm-linux/lib
# for file in libc libcrypt libdl libm libpthread libresolv libutil
> do
> cp $file-*.so /mnt/lib
> cp -d $file.so.[*0-9] /mnt/lib
> done
# cp -d ld*.so* /mnt/lib


㈣.複製busybox檔案至ramdisk中:
# cp –rf  /busybox-1.2.2.1 <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> /_install/* /mnt/
這樣在ramdisk中就有:sbin linuxrc bin
㈤.
# umount /dev/loop2
# losetup -d /dev/loop2
# gzip -9  ramdisk

這樣ramdisk.gz就製作好了。
# cp ramdisk.gz /tftpboot

基本上我也是如法炮製, 不過我是直接拿上次nfs啟動的檔案系統的內容全部拷貝到這裡,
注意拷貝連結檔案時要加上引數-d, 同時參閱了hh bbs上的說要
在ramdisk中建立console和null即可
cd /dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3

同時我的檔名字叫做today.ramfs.gz

試驗: 在uboot中設定
setenv bootargs "console=ttySAC0 initrd=0x30800000,0x440000 root=/dev/ram init=/linuxrc"

setenv bootargs "console=ttySAC0 initrd=0x30800000,0x440000 root=/dev/rd/0 init=/linuxrc"
按Document/initrd.txt中說如果採用devfs,則應使用root=/dev/rd/0, 如不採用,則用/dev/ram  ,結果反覆試驗了一下, 兩個效果是一樣的。
uboot==>tftp 30008000 zImage;tftp 30800000 today.ramfs.gz;go 30008000

發現:Uncompressing Linux......................................................................
就不動了, 查看了一下,核心沒什麼問題, 由昨天做nfs檔案系統記起來了linuxrc檔案, 一看是一個shell指令碼,
就把busybox生成的linuxrc拷貝過來,覆蓋掉。

                                                                                       
U-Boot 1.1.4 (Jan 13 2007 - 18:54:16)
                                                                                       
U-Boot code: 33F80000 -> 33F9DA78  BSS: -> 33FA20E8
RAM Configuration:
Bank #0: 30000000 64 MB
Nor Flash: 512 kB
Nand Flash:    64 MB
                                                                                       
In:    serial
Out:   serial
Err:   serial
hujun2410=> tftp 30008000 zImage;tftp 30800000 today.ramfs.gz;go 30008000
TFTP from server 59.69.74.87; our IP address is 59.69.75.186
Filename 'zImage'.
Load address: 0x30008000
Loading: #################################################################
        #################################################################
        #################################################################
        #################################################################
done
Bytes transferred = 1326596 (143e04 hex)
TFTP from server 59.69.74.87; our IP address is 59.69.75.186
Filename 'today.ramfs.gz'.
Load address: 0x30800000
Loading: #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        ###################################
done
Bytes transferred = 2839962 (2b559a hex)
## Starting application at 0x30008000 ...
Uncompressing Linux......................................................................Linux version 2.6.14 ([email protected]) (gcc version 3.4.1) #12 Sun Jan 14 13:16:14 EST 27CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
Machine: SMDK2410
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: "console=ttySAC0 initrd=0x30800000,0x2b308e root=/dev/ram init=/lin"irq: clearing pending ext status 00000800
irq: clearing <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> subpending status 00000002
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 59292KB available (2090K code, 462K data, 112K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
softlockup thread 0 started up.
Freeing initrd memory: 2764K
NET: Registered protocol family 16
USB Control, (c) 2006 sbc2410
S3C2410: Initialising architecture
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
NetWinder Floating Point Emulator V0.97 (double precision)
devfs: 2004-01-31 Richard Gooch ([email protected])
devfs: devfs_debug: 0x0
devfs: boot_options: 0x1
Initializing Cryptographic API
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
Console: switching to colour frame buffer device 80x25
fb0: Virtual frame buffer device, using 1024K of video memory
S3C2410 RTC, (c) 2004 Simtec Electronics
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
nbd: registered device at major 43
usbcore: registered new driver ub
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
pSMDK2410_ETH_IO=0x11000000,vSMDK2410_ETH_IO=0xe0000000
eth0: CS8900A rev E at 0xe0000300 irq=52, no eeprom , addr: 08: 0:3E:26:0A:5B
NFTL driver: nftlcore.c $Revision: 1.97 $, nftlmount.c $Revision: 1.40 $
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 2.6.14 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
RAMDISK: Compressed image found at block 0
RAMDISK: incomplete write (-28 != 32768) 4194304
RAMDISK: ran out of compressed data
invalid compressed format (err=1)
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "" or unknown-block(2,0)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

出現上面情況,查閱資料才知道是因為沒有修改
Driver device  ->
  Block device ->
(4096)Default RAM disk size (kbytes)
改4096為8192


NET: Registered protocol family 1
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Mounted devfs on /dev
                                                                                                 
Please press Enter to activate this console.
                                                                                                 
                                                                                                 
BusyBox v1.2.1 (2007.01.13-23:04+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
                                                                                                 
[[email protected] /]# ls
bin      etc      lib      mnt      sbin     usr
dev      hello    linuxrc  proc     tmp      var
[[email protected] /]# ./hello
hello,world
[[email protected] /]# ping www.baidu.com
ping: www.baidu.com: Unknown host
[[email protected] /]# ifconfig
[[email protected] /]# mount
devfs on /dev type devfs (rw)
/dev/root.old on / type ext2 (rw,nogrpid)
none on /dev type devfs (rw)
none on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
tmpfs on /dev/shm type tmpfs (rw)


這裡不知為何ping www.baidu.com 不通, 而
[[email protected] myuboot]# cd /public/today_ramfs/
[[email protected] today_ramfs]# ls
fs/  today.ramfs.gz
[[email protected] today_ramfs]# ls fs/
[[email protected] today_ramfs]# gunzip today.ramfs.gz
[[email protected] today_ramfs]# mount -o loop today.ramfs   fs/
[[email protected] today_ramfs]# cd fs
[[email protected] fs]# ls
bin/  dev/  etc/  hello*  lib/  [email protected]  mnt/  proc/  sbin/  tmp/  usr/  var/
[[email protected] fs]# ls lib
ld-2.3.2.so*        [email protected]                libpthread.so        [email protected]
[email protected]      [email protected]              [email protected]     [email protected]
libc-2.3.2.so*      libnss_dns-2.3.2.so*    libpthread.so_orig   libstdc++.so.6.0.1*
libcrypt-2.3.2.so*  [email protected]          libresolv-2.3.2.so*  libutil-2.3.2.so*
[email protected]        [email protected]        [email protected]        [email protected]
[email protected]      libnss_files-2.3.2.so*  [email protected]      [email protected]
libc.so             [email protected]        librt-2.3.2.so*      yaffs.o*
[email protected]          [email protected]      [email protected]
libm-2.3.2.so*      libpthread-0.10.so*     [email protected]
[[email protected] fs]# ls /public/myroot_nfs/lib/         這裡是NFS檔案系統的lib
ld-2.3.2.so*        [email protected]                libpthread.so        [email protected]
[email protected]      [email protected]              [email protected]     [email protected]
libc-2.3.2.so*      libnss_dns-2.3.2.so*    libpthread.so_orig   libstdc++.so.6.0.1*
libcrypt-2.3.2.so*  [email protected]          libresolv-2.3.2.so*  libutil-2.3.2.so*
[email protected]        [email protected]        [email protected]        [email protected]
[email protected]      libnss_files-2.3.2.so*  [email protected]      [email protected]
libc.so             [email protected]        librt-2.3.2.so*      yaffs.o*
[email protected]          libnss_files.so.[email protected]      [email protected]
libm-2.3.2.so*      libpthread-0.10.so*     [email protected]
[[email protected] fs]#

庫是一樣的,resolve.txt 中也指定了nameserver,為何不解析呢?

試了一下,telnet到板子也是可以的。ftp也可以。
[[email protected] /]# wget  ftp://59.69.74.87/hello.txt
Connecting to 59.69.74.87[59.69.74.87]:21
hello.txt            100% |*****************************|    21    --:--:-- ETA
[[email protected] /]#


我的問題是:
1: 用指令碼寫的linuxrc 也就是一句話 ,內容是
exec /sbin/init
和 用 busybox 生成的linuxrc 有何不同?

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

2: 為何 ping www.baidu.com   不解析域名, 不要說我沒有加相應的庫哦?
剛剛試過NFSRoot時:
IP-Config: Complete:
     device=eth0, addr=59.69.74.199, mask=255.0.0.0, gw=59.69.74.1,
    host=matrix4, domain=, nis-domain=arm9.net,
    bootserver=59.69.74.87, rootserver=59.69.74.87, rootpath=
Looking up port of RPC 100003/2 on 59.69.74.87
Looking up port of RPC 100005/1 on 59.69.74.87
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 112K
                                                                                                 
Please press Enter to activate this console.
                                                                                                 
                                                                                                 
BusyBox v1.2.1 (2007.01.13-23:04+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
                                                                                                 
[[email protected] /]# ping www.baidu.com
PING www.a.shifen.com (211.94.144.100): 56 data bytes
                                                                                                 
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss

相關推薦

嵌入式 Linux ARM ADS ADHOC C C++ PLC 微控制器

  ramdisk 製作: 1: 核心支援: 其中主要修改3項,如下:①、修改BootoptionsDefault kernel command string  這一項我設為空,讓bootloader(u-boot,vivi)傳入。②、選上 Float point emul

嵌入式linux開發面試題解析——C語言部分

 1、編寫統計一個數二進位制表示中有多少個1的函式         int count_bit1(int m)         {      int count = 0;      while(m)      {      m = m & (m-

嵌入式 linux arm Qt支援jpg格式的圖片

嵌入式 linux arm 嵌入式 arm Qt支援jpg格式的圖片 arm開發板上,Qt預設支援png格式的圖片,對於jpg格式的圖片,沒有預設支援,若需支援jpg格式的圖片,需要作如下操作: 1

嵌入式linux/ARM/2440/6410視訊教程》

http://www.xuexi111.com/jiaocheng/shipin/31458.html 嵌入式Linux作為一個系統學科,具有知識點多,知識難度大,實踐操作性強等特點,很多躊躇滿志的同學最終倒在了學習嵌入式Linux的道路上,絕大部分也是因為沒有掌握嵌入式

嵌入式Linux+ARMARM體系結構與程式設計(ARM概述)

ARM體系結構與程式設計 本文章記錄一些看《ARM體系結構與程式設計》這一本書的記錄; 個人覺得,學習ARM體系時,不需要死記硬背,只要把某些關鍵的大致記住,比如ARM暫存器(通用暫存器、PC、LR、

eclipse 遠端圖形化除錯嵌入式linux c arm(beaglebone black),解決常見除錯問題

1. eclipse遠端除錯的具體配置: 參考該網頁上的視訊http://www.eeboard.com/bbs/thread-15454-1-3.html (國外以小哥做的,講的非常詳細) 2. eclipse debug的具體設定說明: (對於遠端除錯的細節說明,防止

eclipse c +jre開發環境的建立(嵌入式linux,64位ubuntu,32位arm板)

1.64位ubuntu安裝使用32位交叉編譯器arm-2010.09需要注意的問題 在使用之前先安裝cross compiler,系統為ubuntu64位系統,安裝之前用的32位的arm-2010.09,該編譯器只能編譯32位程式,因此還需安裝32位的庫,可參考:http://www.o

嵌入式 Linux C 修煉手冊

target 十六 http left 動態內存分配 進行 rgb con str 以下博文是博主根據狄泰軟件學院的嵌入式C語言課程進階剖析視頻培訓教程的內容總結而來,加上自己對 C 語言的理解所整理出來的。C 語言是最基礎的語言,學好 C 語言有助於我們以

嵌入式LInuxC語言提升篇---Skr Skr Up Up

任務 開發者 三目運算 關鍵字const 此外 mat 庫函數 linu 限制 嵌入式C語言提升 致敬:每一個奮鬥的人! Up Up UpC語言常見編譯錯誤1.預處理錯誤 -E 1-1 找不到源文件錯誤 自己定義頭文件 使用 “xxx.

高質量嵌入式Linux C程式設計 第二章 資料 學習筆記

一、什麼是資料型別? 資料型別包含兩方面的內容,資料的表示和對資料加工的操作。資料的全部可能表示構成資料型別的值的集合,資料全部合理的操作構成資料型別的操作集合。 二、什麼是變數? 其值在作用域內可以改變的量稱為變數。一個變數應該有一個自己的名字,在記憶體中佔據

高質量嵌入式Linux C程式設計 第三章 運算子、表示式學習

一、運算子有哪幾類? (1)算數運算子:+、-、*、/、%、++、–七種 (2)關係運算符:>、<、==、>=、<=、!=六種 (3)邏輯運算子:&&、||、!三種 (4)位操作運算子:&、|、~、^、<&l

高質量嵌入式Linux C程式設計 第四章 語句 學習

一、語句從流程的角度可以分為幾種 三種基本結構:順序結構、分支結構、迴圈結構 二、空語句有什麼作用 (1)純粹消耗CPU時間,起到延時作用 (2)為了程式的結構清楚,可讀性好,以後擴充新功能方便。 三、 表示式語句的構成 表示式語句由表示式加上;號構成 四、布

基於mini2440嵌入式linux上整合一套Domoticz智慧家居系統(七)交叉編譯paho.mqtt.embedded-c庫和嵌入式linux樣例程式

本篇將把paho.mqtt.embedded-c官方的原始碼交叉編譯成資料包封裝庫和應用程式兩部分,並把樣例應用程式在mini2440上執行。 一、首先編譯MQTT協議包封裝庫: 解壓paho.mqtt.embedded-c-master.zip之後,進入目

通過共享資料夾高效除錯ARMLinuxC/C++程式

       這是一篇部落格主要講如何使用windows和Ubuntu虛擬機器聯合高效除錯ARM上linux的C/C++專案,是在做ARM上linux的C/C++應用程式開發的小總結。 開發環境 系統:        Windows 10 Pro 64位        U

基於mini2440嵌入式linux上整合一套Domoticz智慧家居系統(四)交叉編譯OpenSSL、c-ares、e2fsprogs和mosquitto

本篇主旨是編譯安裝mosquitto,其他的庫是它的依賴庫。後面我們交叉編譯的程式都將放置在主機的”/usr/local/arm/”目錄中,以區別主機本地的應用程式。 我的mimi2440的根檔案系統是PC端VMWare上linux中的nfs,這樣比較容易除錯

嵌入式Linux開發常用C語言標準庫函式

推薦兩個網站: http://www.cplusplus.com/ 各大語言基礎入門必備網站 菜鳥教程:http://www.runoob.com/ 標準輸入/輸出類函式 scanf() http://www.runoob.com/cprogramming/c-functio

嵌入式Linux C程式設計】linux檔案程式設計

系統呼叫是作業系統提供給使用者的一組“特殊”介面,使用者程式可以通過這些介面來獲得核心提供的服務。使用者程式為什麼不可以直接呼叫核心?系統呼叫可以保護核心。使用者程式在使用者空間中操作使用者資料,不允許訪問核心空間資料,也無法呼叫核心函式。使用者程式設計介面API在使用者空間

Android 執行 C/C++程式 (使用 arm-linux-gcc 交叉編譯環境)

這個其實就是個人的一個小小的興趣,用C/C++寫一個小程式放在Android的系統中,然後用Java寫一個Android的UI程式來呼叫這個C/C++的程式。這裡總結了實現這個功能的一些步驟和遇到的問題。蠻有意思的。 這裡參考了下面兩篇博文,主要是關於搭建arm-lin

嵌入式 Linux C如何列印64bit的longlong整型int64_t

64位無符號整型列印方式: #include<stdio.h>  unsigned long long ll=0x9102928374747474;  void main()  {          printf("**************\n");

嵌入式Linux C程式設計學習之路(十三)——標準IO之gets,puts,fprintf,sprintf,fgetc,fputc

1. gets & puts //是行快取的讀寫函式 char *gets(char*s); int puts(constchar *s); gets 與fgets的區別: Ø  gets()不能指定快取的長度,這樣就可能造成快取越界(如若該行長於快取長度