1.ÒýÑÔ
ÔÚרÓõÄǶÈëʽ°å×ÓÔËÐÐ GNU/Linux ϵͳÒѾ±äµÃÔ½À´Ô½Á÷ÐС£Ò»¸öǶÈëʽ Linux ϵͳ´ÓÈí¼þµÄ½Ç¶È¿´Í¨³£¿ÉÒÔ·ÖΪËĸö²ã´Î,Èçͼ1-1Ëùʾ£º
(1)Òýµ¼³ÌÐò¡£°üÀ¨¹Ì»¯Ôڹ̼þ(firmware)ÖÐµÄ boot ´úÂë(¿ÉÑ¡)£¬ºÍ Boot Loader Á½´ó²¿·Ö¡£
(2)Linux Äںˡ£Õë¶ÔÓÚǶÈëʽ°å×ӵĶ¨ÖÆÄÚºËÒÔ¼°Äں˵ÄÆô¶¯²ÎÊý¡£
(3)Îļþϵͳ¡£°üÀ¨¸ùÎļþϵͳºÍ½¨Á¢ÓÚ Flash ÄÚ´æÉ豸֮ÉÏÎļþϵͳ¡£Í¨³£Óà ram disk À´×÷Ϊ¸ùÎļþϵͳ
(4)Óû§Ó¦ÓóÌÐò¡£Ìض¨ÓÚÓû§µÄÓ¦ÓóÌÐò¡£ÓÐʱÔÚÓû§Ó¦ÓóÌÐòºÍÄں˲ãÖ®¼ä¿ÉÄÜ»¹»á°üÀ¨Ò»¸öǶÈëʽͼÐÎÓû§½çÃæ¡£³£ÓõÄǶÈëʽ GUI ÓУºMicroWindows ºÍ MiniGUI ¡£
ÏÂÃæ¾ÍÔÚlinux-2.4.xÄÚºËÉÏÈçºÎÕýÈ·×éÖ¯¡¢Á¬½ÓÕ⼸¸ö²¿·ÖÀ´×Ô¶¯ÔËÐÐÓû§Ó¦ÓóÌÐò½øÐзÖÎö¡£
2.linuxµÄÆô¶¯¹ý³Ì
ÔÚϵͳ¸´Î»ºóÊ×ÏÈÔ¶ÐеijÌÐò¾ÍÊÇÒýµ¼³ÌÐò£¨Boot loader£©¡£ Òýµ¼³ÌÐò¿ÉÒÔ·ÅÔÚרÓõÄROMÖУ¬Ò²¿ÉÒÔºÍÄÚºËÓ°Ïñ¡¢ÎļþϵͳӰÏñ¹²ÓÃÉÁ´æоƬ»ò¹Ì̬ӲÅÌÈçÏÂͼËùʾ¡£Òýµ¼³ÌÐòÊ×ÏȸºÔð³õʼ»¯Ó²¼þÉ豸¡¢½¨Á¢ÄÚ´æ¿Õ¼äµÄÓ³Éäͼ£¬´Ó¶ø½«ÏµÍ³µÄÈíÓ²¼þ»·¾³´øµ½Ò»¸öºÏÊʵÄ״̬£¬ÒÔ±ãΪ×îÖÕµ÷ÓòÙ×÷ϵͳÄÚºË×¼±¸ºÃÕýÈ·µÄ»·¾³¡£UbootÊÇSourceforgeÉϵÄÒ»¸ö¿ªÔ´µÄÒýµ¼³ÌÐò£¬ÌṩÁ˶ÔPowerPC(MPC5xx¡¢MPC8xx¡¢MPC82x¡¢MPC7xx¡¢MP74xx¡¢4xx)¡¢ARM(ARM7¡¢ARM9¡¢StrongArm¡¢Xsacle)¡¢MIPS¡¢x86µÈ´¦ÀíÆ÷µÄÖ§³Ö¡£ÏÂÔØÕ¾µãÊÇhttp://sourceforge.net/projects/u-boot
U-bootÔÚARM9ϵͳÆô¶¯Á÷³Ì£º
1¡¢Ìøתµ½reset´úÂ루½«CPUÉèÖóÉSVC,ARM¹¤×÷ģʽ£¬SDRAM³õʼ»¯£©
2¡¢½«U-boot´úÂ뿽±´µ½RAM¿Õ¼ä¡£¿ÉÒÔµ÷ÓÃCº¯Êý
3¡¢µ÷Óóõʼ»¯º¯Êý
£¨CPU_init(),board_init(),interrupt_init(),serial_init()£©
4¡¢³õʼ»¯flashÉ豸
5¡¢³õʼ»¯ÏµÍ³ÄÚ´æ·ÖÅ亯Êý
6¡¢³õʼ»¯NANDÉ豸
7¡¢³õʼ»¯ÏÔʾÉ豸
8¡¢³õʼ»¯ÍøÂçÉ豸
9¡¢½øÈëÃüÁîÑ»·£¬½ÓÊÕÓû§´Ó´®¿Ú´«À´µÄÃüÁÈç¹ûÑÓʱ10ÃëÖÓÎÞÓû§²Ù×÷Ôò×Ô¶¯¼ÓÔØlinuxÄںˡ£Ê×ÏȽ«linuxÄÚºËÓ°Ïñ£¨kernel Image£©¿½±´µ½ram¿Õ¼ä£¬È»ºóÌøתµ½linuxÄں˴úÂëµÄµÚÒ»ÌõÖ¸Áî´¦£¬½«¿ØÖÆȨ½»¸ølinuxÄںˡ£
3. ¹Ò½Ó×Ô¼ºµÄǶÈëʽÎļþϵͳ
3.1. ǶÈëʽÎļþϵͳµÄ²ã´Î½á¹¹
ǶÈëʽÎļþϵͳµÄÈÎÎñÊǶÔÎļþ½øÐйÜÀí£¬Æ乤×÷°üÀ¨Ìṩ¶ÔÂß¼ÎļþµÄ²Ù×÷£¨°üÀ¨¼ìË÷¡¢ÐÂÔö¡¢Ð޸ġ¢É¾³ý¡¢¿½±´£©½Ó¿Ú£¬·½±ãÓû§²Ù×÷ÎļþºÍĿ¼¡£ÎļþϵͳÄÚ²¿£¬Ôò¸ù¾Ý´æ´¢É豸µÄÌص㣬ʹÓò»Í¬µÄÎļþ×é֯ģʽÀ´ÊµÏÖÎļþµÄÂß¼½á¹¹£¬±ÈÈç´Å´øÖÐʹÓõÄ˳ÐòÎļþÒÔ¼°´ó¶àÊý²Ù×÷ϵͳʹÓõÄÊ÷×´Îļþ¡£´ËÍâÎļþϵͳҲ¹ÜÀíÎļþµÄ°²È«ÐÔ¡¢ÍêÕûÐÔÒÔ¼°¶à½ø³Ì·ÃÎÊ¿ØÖÆ¡£Îļþϵͳ²»ÄÜʵÏÖ¶ÔÎïÀíÉ豸µÄÖ±½Ó¿ØÖÆ£¬¶ÔÎïÀíÉ豸µÄ·ÃÎÊÊÇͨ¹ýMTD/FTL²ãʵÏֵġ£MTD/FNL²ãÏòÉϽ«ÉÁ´æÉ豸³éÏó³ÉÂß¼É豸£¨Âß¼Ò³ÃæºÍ¿é£©£¬ÎªÎļþϵͳÌṩ¶ÔÎïÀíÉ豸²Ù×÷½Ó¿Ú£»ÏòÏÂʵÏÖ¶ÔÉÁ´æÉ豸µÄ¶Áд¡¢ÇåÁã¡¢ECCУÑéµÈ¹¤×÷¡£ÔÚlinuxϵͳÖÐʵÏÖÁ˶ÔÉÁ´æ²Ù×÷µÄµ×²ãº¯Êý¡£ÏÂͼ¸ø³öÁËÎļþϵͳµÄ²ã´Î¹Øϵ¡£
3.2. ¼¸ÖÖÕë¶ÔÉÁ´æµÄǶÈëʽÎļþϵͳµÄ±È½Ï
3.3. ¹Ò½ÓJFFS2Îļþϵͳ
(1) ÐÞ¸ÄÉ豸ºÅ
ÓÉÓÚROMÉ豸ºÍMTDBlockÉ豸µÄÖ÷É豸ºÅ£¨major£©¶¼ÊÇ31£¬ËùÒÔÈç¹ûÄã²»Ïë°ÑJFFS2×÷Ϊ¸ùÎļþϵͳµÄ»°£¬±ØÐëÐÞ¸ÄËûÃÇÖ®Ò»µÄmajor¡£Èç¹ûÄãÒªÐÞ¸ÄJFFS2µÄÉ豸major£¬ÔÚ/linux-2.4.x/include/linux/mtd/mtd.hÖаÑ
££define MTD_BLOCK_MAJOR 31
¸Ä³É
££define MTD_BLOCK_MAJOR 30
(2) ±àдMapsÎļþ
Ìí¼ÓÔÚflashÉϵÄmapÎļþ¡£ÔÚ/kernel/drivers/mtd/mapsÏÂÌí¼Óflash(Èçintel NORÐÍ28f128j3a)µÄmap¡£
(3) ½«ÅäÖüÓÈë/kernel/drivers/mtd/maps/Config.inÖÐ
dep_tristate ' CFI Flash device mapped on S3C2410' CONFIG_MTD_S3C2410 $CONFIG_MTD_CFI
(4) ÅäÖÃÄÚºËʹÆäÖ§³Öjffs2¡£
ÕâÀïÒªÌرð×¢ÒâMemory Technology Devices (MTD)µÄÑ¡ÏîÖ§³Ö¼°Æä×ÓÏî
RAM/ROM/Flash chip drivers --->
Mapping drivers for chip access --->
µÄÑ¡ÏîÖ§³Ö£»
»¹ÓÐFile systemsÏÂÑ¡ÏîÖ§³Ö¡£
¾ßÌåµÄÅäÖÃÑ¡ÔñÇë²Î¿¼¸½Â¼1
(5) ÖÆ×÷jffs2Ó³Ïó
Ê×ÏÈÈ¡µÃjffs2µÄÖÆ×÷¹¤¾ß£ºmkfs.jffs2£¨¿É´ÓÍøÉÏÈ¡µÃ£©
Ö´ÐÐÈçÏÂÃüÁî¼´¿ÉÉú³ÉËùÒªµÄÓ³Ïó£º
chmod 777 mkfs.jffs2 //È¡µÃmkfs.jffs2µÄÖ´ÐÐȨÏÞ£¬¼´mkfs.jffs2³ÉΪ¿ÉÖ´ÐÐÎļþ
./mkfs.jffs2 £d jffs2/ £o jffs2.img //Éú³Éjffs2ÎļþÓ³Ïó£¬ÆäÖÐĿ¼jffs2¿ÉÒÔÊÇÈÎÒâµÄĿ¼£¬ÕâÀïµÄjffs2ÊÇÎÒн¨µÄÒ»¸öĿ¼
(6) Jffs2µÄÏÂÔØ
ÉÕдÍêÒýµ¼³ÌÐò£¨boot loader£©¡¢ÄÚºËÓ°Ïñ£¨zImage£©¡¢¸ùÎļþϵͳ£¨ramdisk.image.gz£©Ö®ºó£¬½Ó×ÅÉÕдjffs2.img£¬¾ßÌåÉÕдÈçÏ£º
tftp 30800000 jffs2.img
fl 1800000 30800000 20000 £¨ÆäÖÐ20000¿É¸ù¾Ýjffs2µÄ´óСÊʵ±µ÷Õû£¬ÀíÂÛÉÏÖ»Òª±Èjffs2.imgÂÔ´ó¼´¿É£¬µ«ÒªÎª20000µÄÕûÊý±¶¡£1800000ÊÇJffs2ÔÚÉÁ´æÖеÄÆðʼλÖã¬3800000Êǽ«jffs2.imgÏÂÔص½ÄÚ´æÖеÄλÖã©
(7) ÔÚ¸ùÎļþϵͳÉÏ×Ô¶¯¹Ò½ÓJffs2
ÔÚramdisk.image.gzµÄmnt/etc/init.d/rc$ÎļþÖмÓÈëÈçÏÂÖ¸ÁîÒÔ±ãÆô¶¯Ê±×Ô¶¯¹ÒÔØjffs2Îļþϵͳ¡£
Mount £t jffs2 /dev/mtdblock/4 /mnt £¨ÆäÖеÄ/dev/mtdblock/4ÊÇflashÉϵÄjffs2·ÖÇø£©
4.Æô¶¯Óû§Ó¦ÓóÌÐò
ÔÚǶÈëʽӦÓÃϵͳÖÐ,ÍùÍù²»ÐèÒª½øÈëlinuxµÄ½çÃ棨ÃüÁîÐд°¿Ú»òͼÐÎ×ÀÃ棩£¬¶øÊÇÐèÒªÖ±½ÓÆô¶¯×¨ÓõÄÓû§³ÌÐò¡£ÏÂÃæ½éÉÜÒ»ÖÖʵÏÖ·½·¨¡£
ÔÚÖÆ×÷¸ùÎļþϵͳӰÏñ£¨ramdisk.image.gz£©Ç°ÔÚ¸ùĿ¼Ï´´½¨myprocĿ¼£¬½«MyAppÓ¦ÓóÌÐò¸´ÖƵ½´ËĿ¼Ï¡£ÔÚramdisk.image.gzµÄmnt/etc/init.d/rc$ÎļþÖмÓÈëÈçÏÂÖ¸ÁîÒÔ±ã×Ô¶¯Æô¶¯Óû§Ó¦ÓóÌÐòMyApp¡£
#cd /myproc£¨ ½øÈëmyprocĿ¼£©
££./MyApp
MyAppÊÇÒ»¸öСµÄÓ¦ÓóÌÐò£¬ËüµÄ´¦ÀíÁ÷³ÌÈçÏ£¨ÆäÖÐMystart¼Ù¶¨ÎªÓû§×îÖÕµÄÓ¦ÓóÌÐò£© £º
5. ×ܽá
Linux ÕýÔÚǶÈëʽ¿ª·¢ÁìÓòÎȲ½·¢Õ¹¡£ÒòΪ Linux »ùÓÚ GPL£¬ËùÒÔÈκζԽ« Linux ¶¨ÖÆÓÚ PDA¡¢ÕÆÉÏ»ú»òÕß¹¤¿ØÉ豸¸ÐÐËȤµÄÈ˶¼¿ÉÒÔ´ÓÒòÌØÍøÃâ·ÑÏÂÔØÆäÄں˺ÍÓ¦ÓóÌÐò£¬²¢¿ªÊ¼ÒÆÖ²»ò¿ª·¢¡£Ä¿Ç°Ðí¶à ÓÅÐãµÄLinux ϵͳ¿É¹©Óû§Ñ¡Ôñ¡£ËüÃÇ°üÀ¨ RTLinux£¨ÊµÊ± Linux£©¡¢uClinux£¨ÓÃÓÚ·Ç MMU É豸µÄ Linux£©¡¢Montavista Linux£¨ÓÃÓÚ ARM¡¢MIPS¡¢PPC µÄÉÌÓà Linux ·Ö·¢°æ£©¡¢ARM-Linux£¨ARM É쵀 Linux£©µÈ¡£ÀûÓÃÏÖÓеĴóÁ¿µÄ¹²Ïí×ÊÔ´£¬¹¹½¨×Ô¼ºµÄǶÈëʽlinuxƽ̨£¬¿ª·¢linuxÓ¦ÓÃÒѾÁÐÈëÐíÐí¶à¶à¹«Ë¾µÄ·¢Õ¹Õ½ÂÔÖ®ÖС£