{"id":8843,"date":"2024-12-17T02:00:00","date_gmt":"2024-12-17T07:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=8843"},"modified":"2024-12-05T11:48:32","modified_gmt":"2024-12-05T16:48:32","slug":"set-up-an-embedded-system-with-freedos","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=8843","title":{"rendered":"Set up an embedded system with FreeDOS"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"8843\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>An <em>embedded system<\/em> is a computer system that is dedicated to running a single task. You might think of embedded systems as part of the \u201cInternet of Things\u201d (IoT) such as sensors or doorbell cameras. These kinds of embedded systems usually run on a version of Linux.<\/p>\n\n\n\n<p>But in days past, embedded systems ran on a custom proprietary platform, or they ran on DOS. Some of these DOS embedded systems systems still run today, including cash registers or advertising displays.<\/p>\n\n\n\n<p>Setting up an embedded system with FreeDOS requires defining a minimal DOS environment that runs just a single application. This is fairly straightforward if you are willing to do all the setup from the command line. All you need is a FreeDOS kernel, the application to run, and a <code>FDCONFIG.SYS<\/code> file that tells the kernel to run that application as a \u201cshell\u201d program.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install-a-minimal-system\">Install a minimal system<\/h2>\n\n\n\n<p>Let\u2019s simulate a dedicated FreeDOS system with the QEMU virtual machine, using a very small virtual disk. To reflect the limitations of an embedded system, let\u2019s use a disk that\u2019s only 10MB, which is <em>tiny<\/em> by today\u2019s standards, but quite large for what DOS needs.<\/p>\n\n\n\n<p>To create a small disk, use this <code>qemu-img<\/code> command to define a 10MB disk image:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-img create -f qcow2 disk.qcow2 10M\nFormatting 'disk.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10485760 lazy_refcounts=off refcount_bits=16<\/code><\/pre>\n\n\n\n<p>To prepare the disk for FreeDOS, we need to create a single partition on it. We can do that by booting the FreeDOS 1.3 distribution, which is available as a \u201clive CD.\u201d The \u201clive CD\u201d includes a bootable version of FreeDOS with a basic FreeDOS environment plus a few games. That\u2019s all we need to set up the disk for FreeDOS.<\/p>\n\n\n\n<p>Boot QEMU with the FreeDOS LiveCD and the 10MB virtual disk, using this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-system-i386 -enable-kvm -m 8 -hda disk.qcow2 -cdrom FD13LIVE.iso -boot order=d<\/code><\/pre>\n\n\n\n<p>QEMU requires that you define the virtual machine entirely from the command line, so that line includes several parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>-enable-kvm<\/strong> tells QEMU to use the kernel virtual machine support that\u2019s built into the Linux kernel<\/li>\n\n\n\n<li><strong>-m 8<\/strong> sets up the virtual machine with 8MB of memory<\/li>\n\n\n\n<li><strong>-hda<\/strong> sets up the disk image as the first hard drive<\/li>\n\n\n\n<li><strong>-cdrom<\/strong> uses the FD13LIVE.iso image as the CD-ROM<\/li>\n\n\n\n<li><strong>-boot order=d<\/strong> tells QEMU to boot from the CD-ROM (use <strong>c<\/strong> to boot from the hard disk, or <strong>a<\/strong> to boot from a floppy, or <strong>n<\/strong> to boot from a PXE server on the network)<\/li>\n<\/ul>\n\n\n\n<p>After you\u2019ve booted the FreeDOS 1.3 LiveCD, you should find yourself at a DOS prompt. Use the FreeDOS FDISK (\u201cfixed disk\u201d) program to partition the drive. Or, since this is a basic setup, we can let FDISK create the partition itself with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>D:\\&gt; fdisk \/mbr \/auto<\/code><\/pre>\n\n\n\n<p>This will automatically create a partition that spans the entire 10MB disk, and mark it active at the same time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"format-the-disk-and-make-it-bootable\">Format the disk and make it bootable<\/h2>\n\n\n\n<p>FreeDOS reads the disk partition information exactly <em>once<\/em>, at boot-time. So after making any changes to the disk, you need to reboot the system so FreeDOS will recognize the new partitions. Type <strong>reboot<\/strong> to restart the FreeDOS 1.3 LiveCD; you should find yourself back at a DOS prompt.<\/p>\n\n\n\n<p>The next step is to create a DOS filesystem on the new partition, and make it bootable by transferring the <em>system<\/em> files. The system files are a copy of the FreeDOS kernel and command shell (called FreeCOM), which is the minimum that FreeDOS needs to start up. The FreeDOS FORMAT program can do all of this in one step with this command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>D:\\&gt; format \/s C:<\/code><\/pre>\n\n\n\n<p>The <strong>\/s<\/strong> command line option tells FORMAT to transfer a copy of the system files.<\/p>\n\n\n\n<p>As part of formatting step, you\u2019ll need to enter a volume name for the disk. Volume names are purely informative to the user, and they help to identify the purpose of the disk. You can pick whatever label is meaningful to you; I named mine \u201cEMBED\u201d because this tiny disk will run an embedded system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install-the-embedded-application\">Install the embedded application<\/h2>\n\n\n\n<p>An embedded system runs a single application, so now you need to install the program you want to run on this dedicated FreeDOS system. As a demonstration, I\u2019ll make a copy of the Simple Senet game, which we include on the FreeDOS 1.3 LiveCD in the <code>D:\\GAMES\\SENET<\/code> directory as the SENET.EXE program. Copy it to the hard disk using the COPY command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>D:\\&gt; copy games\\senet\\senet.exe C:\\<\/code><\/pre>\n\n\n\n<p>This makes a copy of the Simple Senet game on the new disk, in the root directory (<code>C:\\<\/code>).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"run-the-embedded-application-at-boot-time\">Run the embedded application at boot-time<\/h2>\n\n\n\n<p>When FreeDOS boots up, the kernel immediately looks for the <code>FDCONFIG.SYS<\/code> file to find its system configuration information. (If this file does not exist, FreeDOS also looks for <code>CONFIG.SYS<\/code>, which is the file used by classic DOS systems.) The FreeDOS kernel uses several default values for some things, such as a default shell, but the FDCONFIG file lets you set your own values.<\/p>\n\n\n\n<p>Let\u2019s modify the FDCONFIG file to run the Simple Senet program at boot-time. To do that, create a <code>SHELL=<\/code> line that indicates the full path to the Simple Senet game. Since the freshly-formatted disk doesn\u2019t have an FDCONFIG file, and we only need to put one line into this file, we can use the ECHO command to make a new <code>SHELL=<\/code> line, with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>D:\\&gt; echo SHELL=C:\\senet.exe &gt; C:\\fdconfig.sys<\/code><\/pre>\n\n\n\n<p>When you\u2019re done, don\u2019t forget to exit FreeDOS and halt the virtual machine by typing <strong>shutdown<\/strong> at the prompt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"freedos-as-an-embedded-system\">FreeDOS as an embedded system<\/h2>\n\n\n\n<p>With the embedded system fully defined, we can now reboot the machine to run the embedded application. Running an embedded system usually requires only limited resources, so for this demonstration, we\u2019ll tweak the QEMU command line to only boot from the hard drive and not use the LiveCD at all:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-system-i386 -enable-kvm -m 8 -hda disk.qcow2 -boot order=c<\/code><\/pre>\n\n\n\n<p>When the FreeDOS kernel starts up, it reads the FDCONFIG file file for its startup parameters. Then it runs the shell specified by the <code>SHELL=<\/code> line. That runs the Simple Senet game automatically:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"434\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/12\/qemu-senet.png\" alt=\"\" class=\"wp-image-8844\"\/><figcaption class=\"wp-element-caption\">Running Simple Senet as an embedded application<\/figcaption><\/figure>\n\n\n\n<p>Congratulations! You\u2019ve created a new FreeDOS embedded system that runs the Simple Senet game at boot-time.<\/p>\n\n\n\n<p>However, there\u2019s one limitation here. Embedded systems do not usually need to exit back to a command prompt, so these dedicated applications don\u2019t usually allow the user to quit to DOS. If you manage to exit the embedded application, you\u2019ll likely see a \u201cBad or missing Command Interpreter\u201d prompt, where you\u2019ll need to enter the full path to a new shell. For a user-focused desktop system, this would be a problem. But on an embedded system that\u2019s dedicated to doing only one job, you should never need to exit anyway.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up an embedded system with FreeDOS requires defining a minimal DOS environment that runs just a single application.<\/p>\n","protected":false},"author":33,"featured_media":2803,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[340],"tags":[267],"class_list":["post-8843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-freedos","tag-freedos"],"modified_by":"Jim Hall","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/8843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8843"}],"version-history":[{"count":2,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/8843\/revisions"}],"predecessor-version":[{"id":8846,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/8843\/revisions\/8846"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/2803"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}