万博网页版登陆页派论坛

QQ登录

只需一步,快速开始

查看: 6095|回复: 0
收起左侧

串口连接pcduino 进入到U-BOOT

[复制链接]
发表于 2013-5-18 23:33:14 | 显示全部楼层 |阅读模式
[p=26, null, left][color=#000][font=Arial]原文出处:[url=http://www.the-greathouses.net/blog/category/pcduino/]http://www.the-greathouses.net/blog/category/pcduino/[/url]   该文章主要讲述使用串口连接pcduino,然后再启动时进入到U-BOOT,修改U-BOO环境参数以使板子挂载SD卡的分区作为文件系统,原文作者使用dosfstools来设置SD卡分区的文件系统类型,使用rsync拷贝系统文件,另外由于U-boot环境参数修改后无法保存,原文作者修改了u-boot-sunxi使其能在pcduino中使用,使用该修改过的u-boot-sunxi可导出导入保存在nand中的环境参数。另外原文作者没有说明分区问题,本人在试验的时候使用自带的fdisk工具对SD进行分区。[/font][/color][/p]
[b]Part I[/b]
[p=26, null, left][color=#000][font=Arial]This evening I decided it was time to check out the boot loader and boot command options on the pcDuino. To access the serial port on the J5 debug port I used a[color=#ca00][url=https://www.sparkfun.com/products/9873]Sparkfun FTDI Basic Breakout-3.3v[/url][/color]— a simple to use logic level serial to USB interface. With the power off and the FTDI Basic disconnected from the computer, I connected the serial lines and ground.

[/font][/color][/p]
[b]Connections[/b]
[table]
[tr][td][b]pcDuiono J5 Pin[/b][/td][td][b]FTDI Basic[/b][/td][td][b]Description[/b][/td][/tr]
[tr][td]1 – RX[/td][td]3 – TXO[/td][td]pcDuino to FTDI serial data[/td][/tr]
[tr][td]2 – GND[/td][td]6 – GND[/td][td]common signal reference[/td][/tr]
[tr][td]3 – TX[/td][td]2 – RXI[/td][td]FTDI to pcDuino serial data[/td][/tr]
[/table][p=26, null, left][color=#000][font=Arial]After double checking the connections, I plugged the FTDI Basic into my Windows laptop computer. After confirming the port assignment, I used[color=#ca00][url=http://en.sourceforge.jp/projects/ttssh2/]TeraTerm[/url][/color] to open the serial port on my computer. The serial communication configuration needed to be set for 115200 Baud, 8-bit, No parity, 1 stop bit, no flow control, and the serial port assigned by Windows to the FTDI Basic.[/font][/color][/p]
[b]Power On and Boot[/b]
[p=26, null, left][color=#000][font=Arial]After applying power to the pcDuino, the bootloader ([color=#ca00][url=http://www.denx.de/wiki/U-Boot/]U-Boot[/url][/color]) startup sequence showed in the terminal window, followed by the familiar Linux boot messages as the kernel was loaded and Linux started. Surprisingly, at the end of the Linux boot, I was presented with a[b][i]root[/i][/b] prompt. Instead of presenting a login prompt, the debug port goes directly to a root shell. This I will need to change![/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit][  12.776652]Freeinginit memory:5108K  [/backcolor][/color]
[*][color=black][backcolor=inherit]/dev/nandd  [/backcolor][/color]
[*][color=black][backcolor=inherit]e2fsck1.42.7(21-Jan-2013)  [/backcolor][/color]
[*][color=black][backcolor=inherit]/dev/nandd:clean,60026/96000files,314839/384000blocks  [/backcolor][/color]
[*][color=black][backcolor=inherit][  12.837041]EXT3-fs(nandd):usinginternal journal  [/backcolor][/color]
[*][color=black][backcolor=inherit][  12.842051]kjournaldstarting.  Commitinterval5seconds  [/backcolor][/color]
[*][color=black][backcolor=inherit][  12.847559]EXT3-fs(nandd):mountedfilesystem withordereddata mode  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.098102]setto DVI mode  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.101848]get_hdmi_mode==DVI  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.140992]hostnameused greateststackdepth:5648bytes left  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.200950]hwclockused greateststackdepth:5592bytes left  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.253305]plymouthdused greateststackdepth:5208bytes left  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.262105]init:ureadahead main process(71)terminatedwith status5  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.685501]dfused greateststackdepth:5168bytes left  [/backcolor][/color]
[*][color=black][backcolor=inherit][  13.708732]grepused greateststackdepth:4960bytes left  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]*StartingNTP serverntpd                                                    Welcome to Linaro 12.11(GNU/Linux3.0.8+armv7l)  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]*Documentation:  [url=https://wiki.linaro.org/]https://wiki.linaro.org/[/url]  [/backcolor][/color]
[*][color=black][backcolor=inherit]                                                                        [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit][  20.106130]android_usb:alreadydisabled  [/backcolor][/color]
[*][color=black][backcolor=inherit]root@ubuntu:~#  [/backcolor][/color]
[/list][/font]


[b]U-Boot Fun[/b]
[p=26, null, left][color=#000][font=Arial]Now for the real reason I wanted to try this. Access to U-Boot and the boot command line.[/font][/color][/p][p=26, null, left][color=#000][font=Arial]In the serial terminal window, I rebooted the pcDuino…[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]root@ubuntu:~# shutdown -r now  [/backcolor][/color]
[*][color=black][backcolor=inherit]root@ubuntu:~#  [/backcolor][/color]
[*][color=black][backcolor=inherit]Broadcast message from root@ubuntu  [/backcolor][/color]
[*][color=black][backcolor=inherit]        (/dev/ttyS0)at19:14...  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]The systemisgoing down forrebootNOW!  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Askingall remainingprocessestoterminate...                        [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Allprocesses endedwithin1seconds....                              [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit]nm-dispatcher.action:Caughtsignal15,shutting down...  [/backcolor][/color]
[*][color=black][backcolor=inherit]nm-dispatcher.actionisconnectedfrom thesystembus,exiting.  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Deconfiguringnetwork interfaces...                                  [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Unmountingtemporary filesystems...                                  [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Deactivatingswap...                                                  [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Unmountinglocal filesystems...                                      [OK]  [/backcolor][/color]
[*][color=black][backcolor=inherit]umount:/run/lock:notmounted  [/backcolor][/color]
[*][color=black][backcolor=inherit]*Willnow restart  [/backcolor][/color]
[*][color=black][backcolor=inherit][  631.725545]Restartingsystem.  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]… and interrupted the U-Boot start up by pressing the space bar at the “Hit any key to stop autoboot” prompt.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]HELLO!BOOT0is starting!  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot0 version :1.5.0  [/backcolor][/color]
[*][color=black][backcolor=inherit]dram size =1024  [/backcolor][/color]
[*][color=black][backcolor=inherit]Succeed in opening nand flash.  [/backcolor][/color]
[*][color=black][backcolor=inherit]Succeed in reading Boot1 file head.  [/backcolor][/color]
[*][color=black][backcolor=inherit]The sizeofBoot1 is0x00056000.  [/backcolor][/color]
[*][color=black][backcolor=inherit]The filestoredin 0X00000000of block 2isperfect.  [/backcolor][/color]
[*][color=black][backcolor=inherit]Check is correct.  [/backcolor][/color]
[*][color=black][backcolor=inherit]Ready to disable icache.  [/backcolor][/color]
[*][color=black][backcolor=inherit]Succeed in loading Boot1.  [/backcolor][/color]
[*][color=black][backcolor=inherit]Jump to Boot1.  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.181]boot1 version: 1.5.0  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.181]pmu type =3  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.182]bat vol =0  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.213]axi:ahb:apb=3:2:2  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.213]set dcdc2=1400,clock=1008successed  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.215]key  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.227]no key found  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.227]flash init start  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.239]flash init finish  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.241]fs init ok  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.242]fattype FAT16  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.242]fs mount ok  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.247]script finish  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.249]power finish  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.257]BootMain start  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.257]0  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.272]usbdc_vol =4000,usbdc_cur =0  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.272]usbpc_vol =4000,usbpc_cur =0  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.275]init to usbpc  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.278]set pc  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.368]power_start=0x00000002  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.368]pre sys mode  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.368]startup status= -1  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.371]key value =0  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.374]unable to findrecovery_key key_maxvalue  [/backcolor][/color]
[*][color=black][backcolor=inherit][      0.382]test for multios boot withdisplay  [/backcolor][/color]
[*][color=black][backcolor=inherit][      1.006]show pic finish  [/backcolor][/color]
[*][color=black][backcolor=inherit][      1.006]load kernel start  [/backcolor][/color]
[*][color=black][backcolor=inherit][      1.024]load kernel successed  [/backcolor][/color]
[*][color=black][backcolor=inherit][      1.024]start address= 0x4a000000  [/backcolor][/color]
[*][color=black][backcolor=inherit][      1.026]power exit detect  [/backcolor][/color]
[*][color=black][backcolor=inherit][  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]U-Boot2011.09-rc1-svn62(Feb01 2013-22:20:45)AllwinnerTechnology  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]CPU:  SUNXIFamily  [/backcolor][/color]
[*][color=black][backcolor=inherit]Board:A10-EVB  [/backcolor][/color]
[*][color=black][backcolor=inherit]DRAM:  512MiB  [/backcolor][/color]
[*][color=black][backcolor=inherit]NAND:  1900MiB  [/backcolor][/color]
[*][color=black][backcolor=inherit]In:    serial  [/backcolor][/color]
[*][color=black][backcolor=inherit]Out:  serial  [/backcolor][/color]
[*][color=black][backcolor=inherit]Err:  serial  [/backcolor][/color]
[*][color=black][backcolor=inherit]--------fastbootpartitions--------  [/backcolor][/color]
[*][color=black][backcolor=inherit]-totalpartitions:5-  [/backcolor][/color]
[*][color=black][backcolor=inherit]-name-        -start-      -size-  [/backcolor][/color]
[*][color=black][backcolor=inherit]bootloader  :1000000      2000000  [/backcolor][/color]
[*][color=black][backcolor=inherit]env        :3000000      1000000  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot        :4000000      1000000  [/backcolor][/color]
[*][color=black][backcolor=inherit]rootfs      :5000000      5dc00000  [/backcolor][/color]
[*][color=black][backcolor=inherit]UDISK      :62c00000      14000000  [/backcolor][/color]
[*][color=black][backcolor=inherit]-----------------------------------  [/backcolor][/color]
[*][color=black][backcolor=inherit]no miscpartitionisfound  [/backcolor][/color]
[*][color=black][backcolor=inherit]Hit any key tostopautoboot:  0  [/backcolor][/color]
[*][color=black][backcolor=inherit]sunxi#  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]Greeted by the U-Boot prompt. No to check for what commands are available for modifying the environment using the[b][i]help[/i][/b] command.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sunxi#help  [/backcolor][/color]
[*][color=black][backcolor=inherit]?      -alias for 'help'  [/backcolor][/color]
[*][color=black][backcolor=inherit]base    -printor set address offset  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot    -bootdefault,i.e.,run'bootcmd'  [/backcolor][/color]
[*][color=black][backcolor=inherit]boota  -boota  -boot android bootimgfrommemory  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]bootd  -boot default,i.e.,run'bootcmd'  [/backcolor][/color]
[*][color=black][backcolor=inherit]bootm  -boot application imagefrommemory  [/backcolor][/color]
[*][color=black][backcolor=inherit]cmp    -memory compare  [/backcolor][/color]
[*][color=black][backcolor=inherit]cp      -memorycopy  [/backcolor][/color]
[*][color=black][backcolor=inherit]crc32  -checksum calculation  [/backcolor][/color]
[*][color=black][backcolor=inherit]env    -environmenthandling commands  [/backcolor][/color]
[*][color=black][backcolor=inherit]exit    -exitscript  [/backcolor][/color]
[*][color=black][backcolor=inherit]false  -donothing,unsuccessfully  [/backcolor][/color]
[*][color=black][backcolor=inherit]fastboot-fastboot-use USB Fastbootprotocol  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]fatdown-download data toados filesystem  [/backcolor][/color]
[*][color=black][backcolor=inherit]fatinfo-print information aboutfilesystem  [/backcolor][/color]
[*][color=black][backcolor=inherit]fatload-load binary filefromados filesystem  [/backcolor][/color]
[*][color=black][backcolor=inherit]fatls  -list files inadirectory(default/)  [/backcolor][/color]
[*][color=black][backcolor=inherit]go      -startapplication ataddress'addr'  [/backcolor][/color]
[*][color=black][backcolor=inherit]help    -printcommand description/usage  [/backcolor][/color]
[*][color=black][backcolor=inherit]key_test-Testthe keyvalueand dump key registers  [/backcolor][/color]
[*][color=black][backcolor=inherit]loop    -infiniteloop onaddressrange  [/backcolor][/color]
[*][color=black][backcolor=inherit]md      -memorydisplay  [/backcolor][/color]
[*][color=black][backcolor=inherit]mm      -memorymodify(auto-incrementingaddress)  [/backcolor][/color]
[*][color=black][backcolor=inherit]mmc    -MMC sub system  [/backcolor][/color]
[*][color=black][backcolor=inherit]mmcinfo-display MMC info  [/backcolor][/color]
[*][color=black][backcolor=inherit]mtest  -simple RAM read/writetest  [/backcolor][/color]
[*][color=black][backcolor=inherit]mw      -memorywrite(fill)  [/backcolor][/color]
[*][color=black][backcolor=inherit]nand    -NANDsub-system  [/backcolor][/color]
[*][color=black][backcolor=inherit]nboot  -boot from NANDdevice  [/backcolor][/color]
[*][color=black][backcolor=inherit]nm      -memorymodify(constantaddress)  [/backcolor][/color]
[*][color=black][backcolor=inherit]printenv-printenvironment variables  [/backcolor][/color]
[*][color=black][backcolor=inherit]reset  -Perform RESET ofthe CPU  [/backcolor][/color]
[*][color=black][backcolor=inherit]run    -run commands inan environment variable  [/backcolor][/color]
[*][color=black][backcolor=inherit]saveenv-save environment variablestopersistentstorage  [/backcolor][/color]
[*][color=black][backcolor=inherit]setenv  -setenvironment variables  [/backcolor][/color]
[*][color=black][backcolor=inherit]showvar-print local hushshellvariables  [/backcolor][/color]
[*][color=black][backcolor=inherit]sunxi_flash-sunxi_flashsub-system  [/backcolor][/color]
[*][color=black][backcolor=inherit]test    -minimaltest like/bin/sh  [/backcolor][/color]
[*][color=black][backcolor=inherit]true    -donothing,successfully  [/backcolor][/color]
[*][color=black][backcolor=inherit]version-print monitor,compilerandlinker version  [/backcolor][/color]
[*][color=black][backcolor=inherit]sunxi#  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]Current environment settings.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sunxi#env print  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot_fastboot=fastboot  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot_normal=fatloadnand00x48000000uImage;bootm0x48000000  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot_recovery=nandread40007800recovery;boota40007800  [/backcolor][/color]
[*][color=black][backcolor=inherit]bootargs=console=ttyS0,115200root=/dev/nanddinit=/initloglevel=8rootfstype=ext4rootwait  [/backcolor][/color]
[*][color=black][backcolor=inherit]bootcmd=runsetargsload1 boot_normal  [/backcolor][/color]
[*][color=black][backcolor=inherit]bootdelay=3  [/backcolor][/color]
[*][color=black][backcolor=inherit]console=ttyS0,115200  [/backcolor][/color]
[*][color=black][backcolor=inherit]fastboot_key_value_max=0x8  [/backcolor][/color]
[*][color=black][backcolor=inherit]fastboot_key_value_min=0x2  [/backcolor][/color]
[*][color=black][backcolor=inherit]init=/init  [/backcolor][/color]
[*][color=black][backcolor=inherit]load1=fatloadnand043000000evb.bin  [/backcolor][/color]
[*][color=black][backcolor=inherit]loglevel=8  [/backcolor][/color]
[*][color=black][backcolor=inherit]mmc_root=/dev/mmcblk0p7  [/backcolor][/color]
[*][color=black][backcolor=inherit]nand_root=/dev/nandd  [/backcolor][/color]
[*][color=black][backcolor=inherit]partitions=nanda@boot:nandb@rootfs:nandc@UDISK  [/backcolor][/color]
[*][color=black][backcolor=inherit]recovery_key_value_max=0x13  [/backcolor][/color]
[*][color=black][backcolor=inherit]recovery_key_value_min=0x10  [/backcolor][/color]
[*][color=black][backcolor=inherit]setargs=setenvbootargsconsole=${console}root=${nand_root}init=${init}loglevel=${loglevel}  [/backcolor][/color]
[*][color=black][backcolor=inherit]stderr=serial  [/backcolor][/color]
[*][color=black][backcolor=inherit]stdin=serial  [/backcolor][/color]
[*][color=black][backcolor=inherit]stdout=serial  [/backcolor][/color]
[*][color=black][backcolor=inherit]   [/backcolor][/color]
[*][color=black][backcolor=inherit]Environmentsize:749/131068bytes  [/backcolor][/color]
[*][color=black][backcolor=inherit]sunxi#  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]Interesting. By default, the A10 settins are loaded to memory from [i]evb.bin[/i] and the kernel is loaded from[i]uImage[/i] from the NAND flash[i]/boot[/i] partition. The default kernel command line sets[i]/root[/i] to the NAND flash root partition. Then off it goes.[/font][/color][/p]
[b]Part II[/b]

[p=26, null, left][color=#000][font=Arial]In [color=#ca00][url=http://www.the-greathouses.net/blog/2013/03/pcduino-u-boot-part-1/][b]Part 1[/b][/url][/color] I described connecting to the [color=#ca00][url=https://www.sparkfun.com/products/11712]pcDuino[/url][/color] serial port and accessing the U-Boot subsystem. With this access to the boot environment, the task of booting to a root file system other than the NAND flash looked promising.[/font][/color][/p]
[b]Configuring the SD Card[/b]
[p=26, null, left][color=#000][font=Arial]The pcDuino accepts a micro-SD card (I just refer to it as SD to save typing) for additional storage. It is best to partition and format the card with a Linux file system for use on the pcDuino.[b]If you are attempting this, the following steps will result in a loss of all data already on an SD card.[/b][/font][/color][/p][p=26, null, left][color=#000][font=Arial]For some of the steps below, additional software needed to be installed on the pcDuino. For formatting a DOS FAT partition, the[i]dosfstools[/i] package must be installed. For copying the files between filesystems, I use the[i]rsync[/i] package.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sudo apt-get update  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo apt-get install-ydosfstools  [/backcolor][/color]
[*][color=black][backcolor=inherit]suod apt-get install-yrsync  [/backcolor][/color]
[/list][/font]


[p=26, null, left][color=#000][font=Arial]First, the SD card must be inserted in the card slot and partitioned. By default, the pcDuino will attempt to automatically mount the SD card partitions, so these partitions must be unmounted after inserting the card. I’m lazy, so I just ask the system to unmount every thing accociated with the SD card slot. The redirection to [i]/dev/null[/i] is to avoid error messages I would just ignore.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]formin/dev/mmcblk0*;dosudo umount $m>/dev/null2>/dev/null;done  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]Next, the new partitions need defined. I set my card up with a small (16MB) FAT partition for future use as a[i]/boot[/i] file system, and used the remaining space for the root file system. The pcDuino desktop DiskManager allows the formatting to be done from from a graphical interface. Or, as I prefer, the fdisk command line application can be used.[/font][/color][/p][p=26, null, left][color=#000][font=Arial]Once the partitions are created, the file systems need to be created, mounted, and a copy of the existing operating system copied to the corresponding locations. For my configuration, the following commands were used to accomplish this task.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]mkfs.vfat/dev/mmcblk0p1  [/backcolor][/color]
[*][color=black][backcolor=inherit]mkfs.ext4/dev/mmcblk0p2  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]With the new file systems on the card, I needed to make certain they were not automatically mounted.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]formin/dev/mmcblk0*;dosudo umount $m>/dev/null2>/dev/null;done  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]Then, the file systems were copied. Starting with the [i]/boot[/i] partition[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sudo mount /dev/mmcblk0p1/mnt  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo mount /dev/nanda/boot  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo rsync -aqPx-H--numeric-ids/boot//mnt  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo umount /mnt  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo umount /boot  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]And the root [i]/[/i] file system[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sudo mount /dev/mmcblk0p2/mnt  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo rsync -aqPx-H--numeric-ids//mnt  [/backcolor][/color]
[*][color=black][backcolor=inherit]sudo umount /mnt  [/backcolor][/color]
[/list][/font]


[b]Testing the SD card image[/b]
[p=26, null, left][color=#000][font=Arial]To test, I rebooted the system with the serial debug output connected to my lap top as I described in[color=#ca00][url=http://www.the-greathouses.net/blog/2013/03/pcduino-u-boot-part-1/][b]Part 1[/b][/url][/color] and entered into the U-Boot command line. From the U-Boot prompt, I set the default root device to my root partition on the SD card and booted.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]setenv nand_root /dev/mmcblk0p2  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]After booting, it was necessary to check if the root [i]/[/i] was being used from the SD card.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]df-h  [/backcolor][/color]
[*][color=black][backcolor=inherit]Filesystem      Size  UsedAvailUse%Mountedon  [/backcolor][/color]
[*][color=black][backcolor=inherit]/dev/mmcblk0p2  15G  1.4G  13G  10%/  [/backcolor][/color]
[*][color=black][backcolor=inherit]...  [/backcolor][/color]
[/list][/font]


[p=26, null, left][color=#000][font=Arial][b]CONFIRMED:[/b] The pcDuino will boot to an alternate root file system. All that’s needed now is to make it permanent.[/font][/color][/p]
[b]Setting a permanent new root file system[/b]
[p=26, null, left][color=#000][font=Arial]Time to reboot the system and back into U-Boot to make the environment change permanent. The[i]saveenv[/i] command is used to permanently write environment changes to non-volatile storage. In the case of the pcDuino the environment is saved to a specific NAND flash area.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]setenv nand_root /dev/mmcblk0p2  [/backcolor][/color]
[*][color=black][backcolor=inherit]saveenv  [/backcolor][/color]
[*][color=black][backcolor=inherit]boot  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]No errors were displayed, and a check of the mounted file systems showed the SD card was being used for the root file system. Time for the critical test. Reboot without entering U-Boot to confirm the change is permanent.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sudo reboot  [/backcolor][/color]
[*][color=black][backcolor=inherit]...  [/backcolor][/color]
[*][color=black][backcolor=inherit]df-h  [/backcolor][/color]
[*][color=black][backcolor=inherit]Filesystem      Size  UsedAvailUse%Mountedon  [/backcolor][/color]
[*][color=black][backcolor=inherit]/dev/nandd      1.9G  1.2G  700M  63%/  [/backcolor][/color]
[*][color=black][backcolor=inherit]...  [/backcolor][/color]
[/list][/font]


[p=26, null, left][color=#000][font=Arial][b]FAILURE![/b] The changes are not persistent. The [i]saveenv[/i] did not work. No errors were displayed, but the environment was not updated.[/font][/color][/p]
[b]Postmortem[/b]
[p=26, null, left][color=#000][font=Arial]After a detailed investigation, I concluded the [i]saveenv[/i] was non-functional in the pcDuino U-Boot version. The NAND flash write routines are not present or operational. More details of the investigation into alternatives for controlling the boot process will be in [color=#ca00][url=http://www.the-greathouses.net/blog/2013/03/pcduino-u-boot-part-3/][b]Part 3[/b][/url][/color] and a workable solution will be presented. Stay tuned![/font][/color][/p]

[b]Part III[/b]

[p=26, null, left][color=#000][font=Arial]In [color=#ca00][url=http://www.the-greathouses.net/blog/2013/03/pcduino-u-boot-part-1/][b]Part 1[/b][/url][/color] and [color=#ca00][url=http://www.the-greathouses.net/blog/2013/03/pcduino-u-boot-part-2/][b]Part 2[/b][/url][/color] of this series of posts I outlined the attempts I have made at using U-Boot to control the booting of the pcDuino. Specifically, I have been trying to configure the second stage boot to be from my SD card instead of the on board NAND flash. Unfortunately, the U-Boot implementation as installed does not allow persistent setting of the environment for boot from an alternative interface. And the installed U-Boot does not support the newer[i]boot.scr[/i] or[i]uEnv.txt[/i] extensions. The newer U-Boot versions available on[color=#ca00][url=https://github.com/linux-sunxi/u-boot-sunxi/]linux-sunxi[/url][/color] are not compatible with the pcDuino. I also tried the[i]fw_printenv[/i] and[i]fw_setenv[/i] U-Boot tools, but they only work with /dev/mtdX NAND configurations. I was not able to find a ready made solution, so I had to roll my own.[/font][/color][/p]
[b]The U-Boot environment[/b]
[p=26, null, left][color=#000][font=Arial]The U-Boot environment is stored as simple list of strings in non-volatile memory with a 32-bit CRC added for validating the memory content. Typically, to modify the environment, a user will interrupt the boot process and access the U-Boot command line prompt. This can be made available on a serial port, or in some cases, on the main console. Once there is access to the U-Boot command line, it is only necessary to update the existing environment using[i]setenv[/i] and then save the updates back to non-volatile memory using [i]saveenv[/i]. For the pcDuino, the environment is stored in the NAND flash and should be updated with the new settings. The NAND flash update is not implemented. There are no error messages displayed, the environment is just not saved.[/font][/color][/p][p=26, null, left][color=#000][font=Arial]This led me to investigating where the environment is stored on the pcDuino. This was not hard to determine with a quick check of the pcDuino NAND file systems. The U-Boot environment is stored in the second NAND partition — /dev/nandb — as viewed from the Linux environment. Nothing special formatting is performed on the partition, it is treated as a raw data area, with the environment stored as 128K bytes of data starting at the beginning.[/font][/color][/p][p=26, null, left][color=#000][font=Arial]Now that I had the location of the environment, I thought should be able to use the default tools available with U-Boot to update this area. I proceeded to fetch the full source package for U-Boot from linux-sunxi and compiled the U-Boot tools without any problems. I then proceeded to try [i]fw_printenv[/i] to confirm access to the environment.[/font][/color][/p][p=26, null, left][color=#000][font=Arial]That’s when my problems started with the tools. First, I had to create a [i]fw_env.config[/i] file in the[i]/etc[/i] directory. No problem, I just copied the sample and tried again. Next problem… no[i]/dev/mtdX[/i] devices were found. That’s right. On the pcDuion, the NAND flash provides file system mapping via the[i]/dev/nandX[/i] devices. Should be a simple matter of updating the[i]/etc/fw_env.config[/i] file. Right? No. I updated the configuration, and tried again. This time I had a non-supported[i]ioctl[/i] error output from[i]fw_printenv[/i].[/font][/color][/p][p=26, null, left][color=#000][font=Arial]Time to look at the source code and find out how to make this work with the pcDuino. To make a long story short, the U-Boot supplied tools are centered around the[i]/dev/mtd[/i] NAND flash implementation. It would not be a simple matter to update them in a compatible manner for supporting the pcDuino. My decision was to create my own tools specifically for the pcDuino.[/font][/color][/p]
[b]U-Boot tools for pcDuino[/b]
[p=26, null, left][color=#000][font=Arial]After deciding I needed to write my own tools, I had a working prototype in less than 30 minutes. The most complicated portion of the code was calculating the CRC-32 and I was able to find existing code for that task. This was fine for me, but I knew there was additional interest in the pcDuino community. I added some error handling and default modes to the code and am making it available for general use.[b]Read the warning at the end of this post![/b][/font][/color][/p][p=26, null, left][color=#000][font=Arial]Here are the files for setting your environment on the pcDuino. Extract to a directory on your pcDuino and follow the instructions in the include README.txt file. I am distributing as a source package that you will need to compile on your system. I am assuming that anyone who wants to try this does have some basic Linux skills.[/font][/color][/p][p=26, null, left][color=#000][font=Arial]Download the file from here: [color=#ca00][url=http://www.the-greathouses.net/files/u-boot-pcduino-env.tgz]u-boot-pcduino-env.tgz[/url][/color][/font][/color][/p][p=26, null, left][color=#000][font=Arial]Quick instructions for downloading, installing, compiling and using from the command line.[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sudo apt-get install-ywget  [/backcolor][/color]
[*][color=black][backcolor=inherit]wget [url=http://www.the-greathouses.net/files/u-boot-pcduino-env.tgz]http://www.the-greathouses.net/files/u-boot-pcduino-env.tgz[/url]  [/backcolor][/color]
[*][color=black][backcolor=inherit]tar xzvfu-boot-pcduino-env.tgz  [/backcolor][/color]
[*][color=black][backcolor=inherit]cdu-boot-pcduino-env  [/backcolor][/color]
[*][color=black][backcolor=inherit]make  [/backcolor][/color]
[/list][/font]

[p=26, null, left][color=#000][font=Arial]After building the tools, you can run them from the build directory or install to /usr/local/bin using:[/font][/color][/p]
[font=Consolas,][color=silver][backcolor=rgb(248, 248, 248)][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]view plain[/url][/size][/backcolor][/color][color=#a0a0a0][backcolor=inherit][size=9px][url=http://blog.csdn.net/kaijiexue/article/details/8754261#]copy[/url][/size][/backcolor][/color]
[/size][/font][/backcolor][/color]

[list=1]
[*][color=black][backcolor=inherit]sudo make install  [/backcolor][/color]
[/list][/font]


[p=26, null, left][color=#000][font=Arial]Refer to my previous posting ([color=#ca00][url=http://www.the-greathouses.net/blog/2013/03/pcduino-u-boot-part-2/][b]Part 2[/b][/url][/color]) for setting up an SD card partition for use as your root partition.[/font][/color][/p]
[b][color=#ff00]WARNING[/color][/b]
[p=26, null, left][color=#000][font=Arial][b]ONLY TRY THE ABOVE IF YOU UNDERSTAND WHAT YOU ARE DOING. Connecting to the serial debug port has the potential to damage your pcDuino if your connections are incorrect. Changes to the U-Boot environment can render your pcDuino unbootable. YOU HAVE BEEN WARNED![/b][/font][/color][/p]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|万博网页版登陆页派论坛 ( 粤ICP备15075382号-1  

GMT+8, 2024-11-1 23:40 , Processed in 1.140625 second(s), 24 queries , Gzip On.

Powered by Shumeipai.net! X3.2

© 2001-2015 万博网页版登陆页派论坛安全联盟

快速回复 返回顶部 返回列表