溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

03-剛接觸開發(fā)板的準(zhǔn)備工作

發(fā)布時間:2020-02-28 02:06:21 來源:網(wǎng)絡(luò) 閱讀:1136 作者:少年不在了 欄目:系統(tǒng)運維

一、開發(fā)板接口接線工具

?開發(fā)板與PC機之間可以進行連接的接口通常有四個:串口、JTAG、USB、網(wǎng)絡(luò)接口。而如今在PC端是沒有JTAG或者接口的,因此可以使用轉(zhuǎn)接板轉(zhuǎn)換為并口或者USB口與PC段相連。
03-剛接觸開發(fā)板的準(zhǔn)備工作
?JTAG最初是用來對芯片進行測試的,JTAG測試允許多個器件通過JTAG接口串聯(lián)在一起,形成一個JTAG鏈,能實現(xiàn)對各個器件分別測試。如今,JTAG接口還常用于實現(xiàn)ISP(In-System Programmer,在系統(tǒng)編程),對FLASH等器件進行編程。在2440中,當(dāng)需要對NOR Flash進行燒寫時,就需要用到JTAG接口進行燒錄軟件,而當(dāng)軟件是要燒錄到NAND Flash時,使用串口與USB接口就可以操作。這里介紹NOR Flash、NAND Flah與SDRAAM的區(qū)別。
?ROM和RAM指的都是半導(dǎo)體存儲器,ROM是Read Only Memory的縮寫,RAM是Random Access Memory的縮寫。ROM在系統(tǒng)停止供電的時候仍然可以保持數(shù)據(jù),而RAM通常都是在掉電之后就丟失數(shù)據(jù),典型的RAM就是計算機的內(nèi)存。

芯片 特點
靜態(tài)RAM(Static RAM/SRAM),是目前讀寫最快的存儲設(shè)備,但是它也非常昂貴;
RAM 動態(tài)RAM(Dynamic RAM/DRAM),DRAM保留數(shù)據(jù)的時間很短,速度也比SRAM慢,但從價格上來說DRAM相比SRAM要便宜很多;
DDR RAM(Date-Rate RAM)也稱作DDR SDRAM(Synchronous Dynamic RAM),可以在一個時鐘讀寫兩次數(shù)據(jù),這樣就使得數(shù)據(jù)傳輸速度加倍。

?目前Flash主要有兩種NOR Flash和NADN Flash。NOR Flash的讀取和SDRAM的讀取是一樣,用戶可以直接運行裝載在NOR FLASH里面的代碼,這樣可以減少SRAM的容量從而節(jié)約了成本。NAND Flash沒有采取內(nèi)存的隨機讀取技術(shù),它的讀取是以一次讀取一塊的形式來進行的,通常是一次讀取512個字節(jié),采用這種技術(shù)的Flash比較廉價。用戶不能直接運行NAND Flash上的代碼,因此眾多NAND Flash的開發(fā)板除了使用NAND Flah以外,還有一塊小的NOR Flash來運行啟動代碼。
?在2440開發(fā)板中,通常將uboot燒寫在nor flash上作為引導(dǎo)程序,而linux kernel與根文件系統(tǒng)燒錄在nand flash上,而這些代碼會加載到SDRAM中運行。

二、在TQ2440中開發(fā)板程序的燒錄

?一個linux文件系統(tǒng)的構(gòu)成可分為硬件、bootloader、內(nèi)核、根文件系統(tǒng)四個層次。首先要想硬件可以工作工作,需要有bootloader引導(dǎo)程序,它設(shè)置硬件相關(guān)參數(shù)以及軟件變量,如設(shè)置中斷變量、關(guān)閉看門狗、初始化串口、時鐘等硬件參數(shù),設(shè)置堆棧等。要完成這些操作,那么UBOOT代碼就必須上電就能自動運行,通常將這些代碼燒錄在NOR Flash中,因為NAND Flash無法運行代碼,而linux kernel、 root filesystem則燒錄到nand flash中等待bootloader引導(dǎo)完成加載到SDRAM中運行。
1. 使用J-link燒寫u-boot到Nor Flash
?編譯uboot具體操作步驟為:
1、解壓u-boot1.1.6,進入解壓后的目錄
2、打補丁
3、使用arm-linux-gcc3.4.5編譯器編譯

book/home/test/1_bare_metal/1_test$ tar xjf u-boot-1.1.6.tar.bz2 
book/home/test/1_bare_metal/1_test$ cd u-boot-1.1.6/
book/home/test/1_bare_metal/1_test/u-boot-1.1.6$ patch -p1 < ../u-boot-1.1.6_jz2440.patch
book/home/test/1_bare_metal/1_test/u-boot-1.1.6$ arm-linux-gcc -v
Reading specs from /work/tools/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5/specs
Configured with: /work/tools/create_crosstools/crosstool-0.43/build/arm-linux/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/work/tools/gcc-3.4.5-glibc-2.3.6 --with-float=soft --with-headers=/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include --with-local-prefix=/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.5
book/home/test/1_bare_metal/1_test/u-boot-1.1.6$ make 100ask24x0_config
book/home/test/1_bare_metal/1_test/u-boot-1.1.6$ make 

燒寫uboot:
1、JLink 的 USB 口接到電腦上,JTAG 口用排線和開發(fā)板的 JTAG 口相連, 開發(fā)板設(shè)為 Nor Flash 啟動并上電。
2、啟動 J-Flash, 它在“Windows 開始菜單->所有程序->SEGGER”里面。
3、選擇菜單“File -> Open -> Open Project…”,打開光盤里的 s3c2440.jflash。
03-剛接觸開發(fā)板的準(zhǔn)備工作
4、選擇菜單“Target -> Connect”
03-剛接觸開發(fā)板的準(zhǔn)備工作
5、選擇菜單“File -> Open”,打開要燒寫的二進制文件,比如 u-boot.bin,并且在“Start address”里輸入 0。
6、選擇菜單“Target -> Auto”即可自動燒寫。
7、重啟開發(fā)板,啟動uboot。

##### 100ask Bootloader for OpenJTAG #####
[n] Download u-boot to Nand Flash
[o] Download u-boot to Nor Flash
[c] Re-scan Nor Flash
[u] Copy bootloader from nand to nor
[v] Copy bootloader from nor to nand
[k] Download Linux kernel uImage
[j] Download root_jffs2 image
[y] Download root_yaffs image
[d] Download to SDRAM & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the Nand Flash
[s] Set the boot parameters
[b] Boot the system
[r] Reboot u-boot
[q] Quit from menu
Enter your selection:

2. 使用DNW和串口工具CRT燒寫Linux內(nèi)核和根文件系統(tǒng)
編譯Linux內(nèi)核的步驟為:
1、解壓linux2.6.22,進入解壓后的目錄
2、打補丁
3、使用arm-linux-gcc3.4.5編譯器編譯

book/home/test/1_bare_metal/1_test$ tar xjf linux-2.6.22.6.tar.bz2 
book/home/test/1_bare_metal/1_test$ cd linux-2.6.22.6/
book/home/test/1_bare_metal/1_test/linux-2.6.22.6$ patch -p1 < ../linux-2.6.22.6_jz2440.patch

4、這里我是用的是TQ2440開發(fā)板,因此韋老師的linux內(nèi)核源碼不能直接使用在TQ2440開發(fā)板上,需要對LCD和DM9000兩個驅(qū)動程序進行修改。
將TQ2440源碼\drivers_and_test\17th_dm9000c\修改好的\dm9dev9000c.c復(fù)制到linux-2.6.22.6/drivers/net目錄下;
修改其Makefile:obj-$(CONFIG_DM9000) += dm9dev9000c.o #dm9000.o
將TQ2440源碼drivers_and_test\10th_lcd\4th\lcd.c復(fù)制到linux-2.6.22.6/drivers/video目錄下,并修改其Makefile:obj-$(CONFIG_FB_S3C2410) += lcd.o #s3c2410fb.o
5、修改config_ok為.config
book/home/test/1_bare_metal/1_test/linux-2.6.22.6$ cp config_ok .config
6、編譯make uImage,此事可能出現(xiàn)錯誤:

book/home/test/1_bare_metal/1_test/linux-2.6.22.6$ make uImage
Makefile:1449: *** mixed implicit and normal rules: deprecated syntax
/home/test/1_bare_metal/1_test/linux-2.6.22.6/Makefile:416: *** mixed implicit and normal rules: deprecated syntax
/home/test/1_bare_metal/1_test/linux-2.6.22.6/Makefile:1449: *** mixed implicit and normal rules: deprecated syntax
make[1]: *** No rule to make target 'silentoldconfig'。 停止。
  CHK     include/linux/version.h
make: *** No rule to make target 'include/config/auto.conf', needed by 'include/asm-arm/.arch'。 停止。

根據(jù)提示修改這兩行Makefile:
在makefile中將416行代碼:config %config: scripts_basic outputmakefile FORCE
改為:%config: scripts_basic outputmakefile FORCE
在makefile中將1449行代碼:/ %/: prepare scripts FORCE
改為:%/: prepare scripts FORCE
再次編譯,編譯成功。

    ...
UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-2.6.22.6
Created:      Fri Dec 29 20:05:44 2017
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1845828 Bytes = 1802.57 kB = 1.76 MB
Load Address: 0x30008000
Entry Point:  0x30008000
  Image arch/arm/boot/uImage is ready
book/home/test/1_bare_metal/1_test/linux-2.6.22.6$ 

7、在串口界面輸入k命令下載uImage,使用dnw下載數(shù)據(jù)。

##### 100ask Bootloader for OpenJTAG #####
[n] Download u-boot to Nand Flash
[o] Download u-boot to Nor Flash
[c] Re-scan Nor Flash
[u] Copy bootloader from nand to nor
[v] Copy bootloader from nor to nand
[k] Download Linux kernel uImage
[j] Download root_jffs2 image
[y] Download root_yaffs image
[d] Download to SDRAM & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the Nand Flash
[s] Set the boot parameters
[b] Boot the system
[r] Reboot u-boot
[q] Quit from menu
Enter your selection: k
USB host is connected. Waiting a download.

8、在串口界面輸入y命令下載根文件系統(tǒng),使用dnw下載數(shù)據(jù)。

##### 100ask Bootloader for OpenJTAG #####
[n] Download u-boot to Nand Flash
[o] Download u-boot to Nor Flash
[c] Re-scan Nor Flash
[u] Copy bootloader from nand to nor
[v] Copy bootloader from nor to nand
[k] Download Linux kernel uImage
[j] Download root_jffs2 image
[y] Download root_yaffs image
[d] Download to SDRAM & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the Nand Flash
[s] Set the boot parameters
[b] Boot the system
[r] Reboot u-boot
[q] Quit from menu
Enter your selection: y
USB host is connected. Waiting a download.

Now, Downloading [ADDRESS:30000000h,TOTAL:49769290]
RECEIVED FILE SIZE:49769290 (725KB/S, 67S)

NAND erase: device 0 offset 0x260000, size 0xfda0000
Erasing at 0xffa0000 --   3% complete.
OK

NAND write: device 0 offset 0x260000, size 0x2f76b40

Writing data at 0x3033800 --  13% complete.
 49769280 bytes written: OK

9、啟動開發(fā)板,查看效果。

Warning: firstuse finished 1
tsdev (compaq touchscreen emulation) is scheduled for removal.
See Documentation/feature-removal-schedule.txt for details.
Warning: TimeZone::data Can't create a valid data object for 'Europe/Oslo'
Warning: Unable to open /root/Settings/Categories.xml
Warning: could not register server

starting pid 772, tty '/dev/s3c2410_serial0': '/bin/sh'
# 
# ls
bin         lib         mnt         root        tmp
dev         linuxrc     opt         sbin        usr
etc         lost+found  proc        sys
# 

03-剛接觸開發(fā)板的準(zhǔn)備工作
3. 使用tftp網(wǎng)絡(luò)燒寫Linux內(nèi)核和根文件系統(tǒng)
?當(dāng)開發(fā)板中安裝好uboot后,還可以使用網(wǎng)絡(luò)tftf下載linux內(nèi)核與根文件系統(tǒng),此時當(dāng)tftp服務(wù)器為win7時,要保證開發(fā)板與PC機之間可以ping通。這里我采用開發(fā)板與PC機直接使用網(wǎng)線相連,PC機有線IP為192.168.2.20;開發(fā)板IP為192.168.2.10。

OpenJTAG> set ipaddr 192.168.2.10
OpenJTAG> set serverip 192.168.2.20
OpenJTAG> save
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
OpenJTAG> printenv
bootargs=noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
bootcmd=nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0
bootdelay=2
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
netmask=255.255.255.0
stdin=serial
stdout=serial
stderr=serial
mtdids=nand0=nandflash0
mtdparts=mtdparts=nandflash0:256k@0(bootloader),128k(params),2m(kernel),-(root)
partition=nand0,0
mtddevnum=0
mtddevname=bootloader
ipaddr=192.168.2.10
serverip=192.168.2.20

Environment size: 450/131068 bytes

03-剛接觸開發(fā)板的準(zhǔn)備工作
1、PC機tftp端設(shè)置,將需要下載的內(nèi)核與根文件系統(tǒng)放在服務(wù)器目錄下。
03-剛接觸開發(fā)板的準(zhǔn)備工作
2、開發(fā)板進入uboot命令行界面下載kernel:
tftp 30000000 uImage
mtdpart 查看分區(qū)信息
nand erase kernel
nand write.jffs2 30000000 kernel
3、下載根文件系統(tǒng)
tftp 30000000 fs_qtopia.yaffs2
nand erase root
nand write.yaffs 30000000 260000(root分區(qū)地址) 2fb6b40(大小)
4、開發(fā)板啟動效果:
03-剛接觸開發(fā)板的準(zhǔn)備工作
4. 使用NFS服務(wù)器掛載內(nèi)核和根文件系統(tǒng)
?使用NFS下載方法與tftp下載方式,大致相同,此時要確保開發(fā)板可以和虛擬機ubuntu能ping通。同時要設(shè)置虛擬機已經(jīng)開啟了nfs服務(wù),并設(shè)置了掛載點:

book~$  cat /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
/work/nfs_root  *(rw,sync,no_root_squash)      #掛載目錄

1、下載內(nèi)核
nfs 30000000 192.168.1.123:/work/nfs_root/uImage
nand erase kernel
nand write.jffs2 30000000 kernel
2、下載根文件系統(tǒng)
nfs 30000000 192.168.1.123:/work/nfs_root/fs_qtopia.yaffs2
nand erase root
nand write.yaffs 30000000 26000 2f76b40

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI