{"id":769,"date":"2010-10-23T15:42:17","date_gmt":"2010-10-23T22:42:17","guid":{"rendered":"http:\/\/www.graphics-muse.org\/wp\/?p=769"},"modified":"2010-10-23T15:57:45","modified_gmt":"2010-10-23T22:57:45","slug":"beaglebox-understanding-the-boot-process-requirements","status":"publish","type":"post","link":"https:\/\/www.graphics-muse.org\/wp\/?p=769","title":{"rendered":"BeagleBox: understanding the boot process requirements"},"content":{"rendered":"<p>With a better understanding of what&#8217;s happening with the <a href=\"http:\/\/code.google.com\/p\/beagleboard\/wiki\/BeagleboardRevC3Validation\">Beagle Board validation images<\/a> I&#8217;ve started to redesign the boot process for <a href=\"https:\/\/www.graphics-muse.org\/wiki\/pmwiki.php?n=BeagleBox.BeagleBox\">BeagleBox<\/a>.\u00a0 First, the SD card will be partitioned with two partitions.\u00a0 The first is the <a href=\"http:\/\/code.google.com\/p\/beagleboard\/wiki\/LinuxBootDiskFormat\">FAT32 partition<\/a> to hold the kernel image, boot scripts and an initial ramdisk (initrd).\u00a0 The ramdisk will be extremely light weight &#8211; its only purpose is to allow a fast boot and pivot to the root file system on the second partition.\u00a0 We can even eliminate the initrd and boot directly to the second partition but that will require some experimentation to find which boots faster &#8211; with initrd or without.<\/p>\n<p>With only the kernel image, a small initrd and u-boot script the first partition on the SD card can be very small.\u00a0 Initial experiments show that 20MB should be plenty, leaving lots of space for the root file system.\u00a0 Even bumping that to 25MB just to be safe still leaves lots of room on a 1GB SD card, which is the maximum size specified in the <a href=\"https:\/\/www.graphics-muse.org\/wiki\/pmwiki.php?n=BeagleBox.Design#costs\">Design page on the wiki<\/a>.\u00a0 Note, however, that a FAT32 partition won&#8217;t format on a small partition so you may have to use FAT16.\u00a0 I just tried that and it works fine.<\/p>\n<p>The boot script is read by the bootloader, re: u-boot, in order to get configuration and commands to run.\u00a0 On the C4 board there is a u-boot installed in NAND flash from the factory (or whoever builds them).\u00a0 There is no need for the u-boot on the SD card unless we want to flash a new u-boot to NAND flash.\u00a0 The boot script provides the proper boot arguments that u-boot will pass to the Linux kernel.\u00a0 The kernel is stored on the first partition of the SD card and loaded into memory by u-boot.\u00a0 The proper way to deal with u-boot and x-loader updates is to create a separate SD card image that handles it automatically.\u00a0 The user just has to swap cards, reboot, and swap cards again to get the STB running again.<\/p>\n<p>The kernel will have only enough drivers compiled in to mount the root file system from the second partition on the SD card.\u00a0 That means the driver for the SD card and the ext2 filesystem. The root file system is formatted as ext2.\u00a0 Why ext2?\u00a0 Because journaling file systems would cause the SD card (re: flash memory) to be written too often, causing it to become worn out faster than it should.\u00a0 We don&#8217;t need journaling anyway.\u00a0 This isn&#8217;t a desktop.\u00a0 It&#8217;s a consumer device &#8211; a set top box.\u00a0 Also, reducing the number of drivers compiled into the kernel and moving the others to loadable modules in the root file system will mean the bootloader has a smaller file to copy from the SD card to memory at boot time &#8211; thus a faster boot.<\/p>\n<p>The root file system will contain everything needed to run the STB from user space, including applications and libraries.\u00a0 The build system already handles loadable modules installation to the root file system build thanks to the SGX library integration.\u00a0 Now there will be more loadable modules.\u00a0\u00a0 The reason a small initrd is used to pivot to the root file system is so u-boot doesn&#8217;t have to copy the root file system into memory.\u00a0 Such a copy operation takes a long time at boot time and also uses up DDR memory when we don&#8217;t have to do that.\u00a0 However, running the root file system off the SD card instead of out of memory means we need to make writeable files and directories on the root filesystem redirected to files and directories stored in ramdisks.\u00a0 Because of the limited write nature of flash memory we want to reduce the number of writes to the SD card as much as possible.\u00a0 That will require some special handling when it comes to user space configuration options, but we can deal with that later and within the context of the BUI (BeagleBox UI) project.\u00a0 The process for creating ramdisks and symlinking files and directories to them is covered by the validation images.\u00a0 See <a href=\"https:\/\/www.graphics-muse.org\/bugs\/index.php?do=details&amp;task_id=40\">FS#40<\/a> for details on use of the volatile.cache which will be integrated into the root file system build.<\/p>\n<p>I&#8217;ve already started implementing this process in the build system.\u00a0 I have an initrd build working and the boot script is written and integrated into the u-boot build.\u00a0 This will all be checked in a bit later after I&#8217;ve had some time make sure the updated build is producing a set of files (the pkg target does this) for installation on the SD card.\u00a0 One thing I wasn&#8217;t able to do was figure out how to use fakeroot to mount an ext image to copy in the files and create device files for the initrd.\u00a0 So that particular part of the build requires running as root.\u00a0 If we skip the initrd and simply use <em>root=\/dev\/mmcblk0p2<\/em> in the kernel boot arguments this would go away, so there is an argument for dropping the initrd even if it boots faster.\u00a0\u00a0 I&#8217;ll just have to experiment a bit to see what works best.\u00a0 Unless someone tells me how to make fakeroot do this for me.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With a better understanding of what&#8217;s happening with the Beagle Board validation images I&#8217;ve started to redesign the boot process for BeagleBox.\u00a0 First, the SD card will be partitioned with two partitions.\u00a0 The first is the FAT32 partition to hold the kernel image, boot scripts and an initial ramdisk (initrd).\u00a0 The ramdisk will be extremely [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[390,8,5,6],"tags":[381,443,454,399,456,450,457,451,449,453,452,435,455,411,442,348,393,398],"class_list":{"0":"post-769","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-beaglebox-hardware","7":"category-hardware","8":"category-linux","9":"category-software-development","10":"tag-beaglebox","11":"tag-boot-process","12":"tag-bootloader","13":"tag-bui","14":"tag-ddr","15":"tag-ext2-filesystem","16":"tag-fakeroot","17":"tag-fat32-partition","18":"tag-initial-ramdisk","19":"tag-journaling-file-systems","20":"tag-kernel-image","21":"tag-nand","22":"tag-pivot","23":"tag-root-filesystem","24":"tag-sd-card","25":"tag-set-top-box","26":"tag-sgx","27":"tag-stb","28":"czr-hentry"},"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pe9t8-cp","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=769"}],"version-history":[{"count":3,"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/769\/revisions"}],"predecessor-version":[{"id":771,"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/769\/revisions\/771"}],"wp:attachment":[{"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.graphics-muse.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}