Wednesday, May 29, 2019

FreeDOS on AtomicPi

Atomic Pi can be a great platform to try other OSes, such as DOS, ReactOS, Minix.  Here we start with the oldest PC OS, DOS.  We will install FreeDOS to a microSD card.  We will use an old 256MB microSD card.

It appears that the easiest way to get a DOS disk image is to use VirtualBox, QEMU or Bochs.  We get the CDROM ISO file from freedos.org.  We'll use QEMU.  First, create a 200MB DOS disk,
qemu-img create dos.img 200M
Then run the emulator to boot from the ISO image,
 qemu-system-i386 -m 16 -k en-us -rtc base=localtime  -hda dos.img -cdrom FD12CD.iso -boot order=d
We proceed with installation.  We did a full installation, which took about 89MB.  Additionally packages can be installed by running fdimples.  Included on the CD are games, including a version DOOM clone, BOOM, which runs fine on QEMU.

We can mount the disk image in Linux,
 sudo mount -o loop,offset=32256 dos.img /mnt/dos/
The offset is necessary, because the DOS partition starts at sector 63.  We can write the disk image to the SD card
 dd if=/dev/loop0 of=/dev/sdb1
We install the DOS MBR by adding it as the second disk,
 qemu-system-i386 -hda dos.img -hdb /dev/sdb
and run `fdsik /mbr 2`.
After that, we can directly boot the SD card,
 qemu-system-i386 -hda /dev/sdb 
On an older PC with Intel Core2 Duo,  it boots directly with a USB uSD reader.  Or we can use GRUB chain-loading,
set root=(hd1,msdos1)
chainloader +1
boot
We added this as another menuentry to the grub.cfg file.

However, if we try chain-loading on Atomic Pi, we get the error message "invalid EFI file path".  The Atomic Pi BIOS cannot load the legacy MBR; and it may not provide the BIOS that DOS is depended on.  It does not seem to have the Compatibility Support Module to provide the legacy BIOS support.

Is it possible to have a BIOS compatibility layer?




Wednesday, May 8, 2019

Atomic Pi

At some point, there is bound to be a version of Pi with an Intel processor.  Atomic Pi is here for a similar price of $35.   It comes with Atom x5-Z8350, 2GB RAM, 16GB flash.  x5-Z8350 has a max TDP of 4W; with a large heat sink, it can run fanless.  (Compared with a similar performance Core 2 Duo T7200 of 34W max TDP.)  There is one USB 3 port; another USB 2 port does not has standard USB A connector.  A 26-pin I/O header has 2 UARTs and 6 GPIOs.  The audio circuitry is a little curious: a digital audio power amplifier and a microcontroller for two digital microphones.  For most part it appears superior to Raspberry Pi.

The board is about 260g.  It lacks a convenient power connector.  So the first thing is to solder a more standard 2mm power jack.
We need to connect a keyboard/mouse to the USB and a monitor to the HDMI connector.   Power up and we see the BIOS screen then the Lubuntu login screen.  The current draw is about 1.2A and does not seem to exceed 1.5A.  The board draws 0.1A after shutdown.  In the suspend mode, the board draws 0.4A.  We also need to attach antennas for WiFi and Bluetooth; both work fine.  At the BIOS splash screen, DEL key gets into the BIOS settings.  We set the date and time, which is back with CR2032 coin battery.

The preinstalled OS distribution is Ubuntu 18.04.1 LTS.   The python script for BNO055 (gyro, accel and mag) works. Run stress to load the CPU; the temperature only gets up to 55C (from 44C idle) with current draw about 1.6A.   The heatsink is only a little warm.  The video playing at the full screen is smooth.  Initially there is no audio through HDMI and the problem is solved by changing pulseaudio configuration (using instructions from the user forum).

I tried to boot from a uSD card, but it did not work.  It appears not to support legacy MBR boot.   We'll create UEFI boot partition and install efi bootloader,
grub-install --target=x86_64-efi --efi-directory=/mnt/ --bootloader-id=GRUB --boot-directory=/media/atomicpi/xxx/boot/ 
It was not able to find the config file initially; it was looking for it under ubuntu somehow.  So I put one there.  There is probably a way to specify it.  The uSD card had an Ubuntu 16.04 distribution, but it mostly worked here.  It did report some kernel driver issues and the HDMI audio driver did not load, apparently missing snd-hdmi-lpe-audio kernel module, which was not included in the 4.4.0 version of the kernel.  I upgraded the kernel to 4.15.0; now the audio driver was included.  But there seemed some problem starting pulseaudio.  In addition, a later version of gcc is required to compile the kernel module, i2c-gpio-custom.

We can also add the Linux system on the uSD to the default eMMC grub menu and boot into it.

The write speed to the uSD is 15.5MB/s and read speed is 29.1MB/s.

Run hardinfo benchmark; the results are: CPU Blowfish 6.60s, CPU CryptoHash 96.49MB/s, CPU Fibonacci 3.29s, CPU N-Queens 32.85s, FPU FFT 6.80s, FPU Raytracing 9.37s.  (Compared with Core 2 Duo Blowfish 10.7s, CryptoHash 155.50s, Fibonacci 4.86s, N-Queens 29.45s, FFT 4.46s, Raytracing 16.59s.)   According to PassMark CPU benchmarks, Z8350's average CPU mark is 1266 vs 1167 for T7200.

Next we'll test out the other connectors.

CN3 is the power button connector, unpopulated.  When the two pin shorted momentarily, it turns on the system or wakes up from suspend.

CN10 is the debug UART serial port (3.3V), /dev/ttyS0, which is the boot console, at 115,200 baud.  The AMI BIOS is also accessible here, so we do not have to connect a keyboard and a monitor, which is a great convenience.

Overall it is a very impressive board for the price.