Friday, February 20, 2015

Cerberus Alpha: Remastering the OS to Load the Program on Boot (Part 1)

Building a new iso for TinyCore was really easy enough, so the first thing I experimented with was adjusting boot behavior to what I wanted. The default option that I wanted was that Tiny Core would boot directly into a root command line interview. This is done using the boot code tinycore superuser. In ezremaster I made the mistake of entering only "superuser" instead of the whole phrase. With that fixed and the boot behavior working as desired, I set out to have the program run automatically. This proved quite the challenge.

When ezremaster creates the new OS for the .iso, it builds the actual folders that will go into the iso into a directory called "extract." Inside this is the actual system folders that will be extracted when the iso boots, such as /opt /etc and so on. What I did at first was to copy cerba.sh into the /extract/opt and modify bootlocal.sh with a line to start the script. Although later on I would need to start the script later in the boot process, this was not a problem yet. Modifying things this way caused the iso that was created to be "corrupt" and it would not boot at all.

Earlier in the project I had been able to modify the boot options by opening the iso and changing /boot/isolinux/isolinux,cfg, so I tried editing files inside the already built iso and rebuilding it with MagicISO. Specifically I went into /boot/core.gz/core.cpio where /opt is located. This idea didn't completely break the iso, but on boot I would get the errors "/boot/core.gz not found" (when core.gz was not named perfectly) or an error stating that there was a kernel panic.

After much searching I never found information on how to do what I wanted correctly. Fortunately, I eventually found the solution in ezremaster. In ezremaster there is an option to integrate backed up user data into the iso. Originally I didn't think this would work, but when I tried using this it did actually work. Here are the steps I had to follow to use this feature correctly to produce the iso with both the custom /opt data and :
Place cerba.sh in /opt of the running system
  • Edit /opt/bootlocal.sh to start /opt/cerba.sh (*)
  • In TinyCore's Control Panel, backup /opt/ as mydata.tgz somewhere
  • Use /mnt/sr0 (mounted CD) as base iso
  • Load mydata.tgz into ezremaster
  • Load extensions using "Extract TCZ in to initrd" option and "Run TCZ startup scripts in chroot now"
    • bash
    • nano
    • ncurses-utils
    • ntfs-3g (*)
  • Build the iso
* Later the correct place to boot from would be /etc/profile.d/cerba.sh and ntfs-3g was discovered to be needed

With all this work done, I finally had a working iso and it was correctly running cerba.sh from bootlocal.sh. Unfortunately, as it turns out, this was far too early in the boot sequence.

Friday, February 13, 2015

Cerberus Alpha: Tuning the OS for the Program

By now (version 0.B perhaps?) I had a mostly functioning program and it was time to set to work implementing it into the boot sequence. I implemented a function to try to mount all hard drives (still needs work, more on that later) and turned the main menu into a function of its own.

Everything was not working correctly yet and one of the first problems was that the Bourne Shell (#!/bin/sh) was not correctly interpreting the script. Since this script was written to be interpreted by Bash I changed the 1st line to #!/bin/bash. I then had to install the bash interpreter itself and from then on it worked. Fortunately, Tiny core has a very simple and easy way to install programs from the desktop. As a result of installing bash, ncurses was also installed as a dependency which I like because I'm a fairly big fan of ncurses based programs (wavemon and nano to name a couple).

Speaking of nano, that was the next thing that I installed. Personally, I can't really stand vi. In my opinion, nano is much easier to use and I like emacs too. I know some people really love vi and vim, so don't let me stop you. I wouldn't really need a text editor in the final version, but since I was still working on it I decided to leave it in. It doesn't add a lot of time to the boot process or the .iso size, so I think I will leave it in permanently in case anyone using the CD could use a text editor. A good text editor.

Oddly, there was a single command in my script that was giving the interpreter trouble still, tput. I was using tput to print out a warning in reverse-red text, but it was giving me an error. It turns out that for tput to function it requires ncurses-utils to be installed. Well, ncurses-utils is not very large and it looks like practically the only thing it does is for tput, so I installed it. I ended up taking out this warning later so I may actually get rid of ncurses-utils altogether, but for now it stays in.

At this point I'd like to mention that I had to install ezremaster in order to remaster the OS. Technically I didn't need it to do the remaster, but it was a great deal of help. Actually, whoever created ezremaster should really be commended. Once I understood how to use it correctly, it actually made remastering an EZ and painless task. I did not leave it installed in the final .iso, because there is no need for it.

Around this time I started working on actually getting the program to run at the correct time, which I eventually did, but much later on I ran into another problem which called for a new program to be installed. When I had everything working perfectly, or so I thought, I burned the .iso to a CD and gave it a shot in a PC at home. It came back with errors telling me the file system was read only. After much investigating, I discovered that TinyCore does not support writing to NTFS file systems out of the box. I guess I must be spoiled by working with such "bloated" Linux distros as Slitaz and Lucid Puppy. Anyway, I found that the program I needed was ntfs-3g. With this installed, it was working well again. One cause of the problem was that I mistakenly formatted my 3 hard drives (in VMWare) as FAT32 instead of NTFS.

Friday, February 6, 2015

Cerberus Alpha: Tuning the program for the OS

The first challenge that I ran into was with the nifty little line drawing characters that I used to make the menu boxes look nice. Writing the program for the first time I copied the box drawing characters off of the wikipedia page about them. This worked fine in testing, but when running the program for the first time in Tiny Core the boxes looked like fuzz and when editing the program it was like garbled text. It turns out that the terminal emulator (aterm) that runs from the desktop in Tiny Core does not support the UTF-8 characters I was using. I found a workaround that looks like this:

echo -e "\e(0lqqqqqqqqqqq\e(BMenu:\e(0qqqqqqqqqqqqqqqqk\e(B"
echo -e "\e(0x\e(B Enter 1: Simple Install        \e(0x\e(B"
echo -e "\e(0x\e(B Enter 2: Full Install          \e(0x\e(B"
echo -e "\e(0x\e(B Enter 3: Simple Uninstall      \e(0x\e(B"
echo -e "\e(0x\e(B Enter 4: Thorough Uninstall    \e(0x\e(B"
echo -e "\e(0x\e(B Enter q: to quit to terminal   \e(0x\e(B"
echo -e "\e(0x\e(B Enter r: to reboot             \e(0x\e(B"
echo -e "\e(0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj\e(B"
Although it looks a bit like crap in the code, it did actually render very well when running. It uses the escape character \e(0 to begin inputting text in alternate characters and \e(B to end this input mode. This change worked for the terminal emulator aterm, but later on when I was running the program from the command line without X the problem reared its ugly head again. I reverted the menu section code back to what it was originally (actually I rewrote it a bit more carefully) and once again it gave the desired printout. Technically, if you rerun the program from aterm it will still give ugly looking output. Hopefully at some point I will get around to writing a check for what environment the program is running from to fix this issue. Here is what the menu looks like, at least when it works right:

┌───────────Menu:────────────────┐
│ Enter 1: Simple Install        │
│ Enter 2: Full Install          │
│ Enter 3: Simple Uninstall      │
│ Enter 4: Thorough Uninstall    │
│ Enter 5: Replace sethc instead │
│ Enter q: to quit to terminal   │
│ Enter r: to reboot             │
└────────────────────────────────┘
You might by now notice the "replace sethc instead" option in the program has no "uninstall" function. This was intended for Windows XP as an alternate method. It works, but there are already much better programs out there designed to do the same thing for XP. It could be used as a last resort for Windows 8 too though, so I will try to get around to adding the option to undo it.

Tuesday, February 3, 2015

HP 8116A Review

Last week I reviewed the HP 8904A and this week I am reviewing the HP 8116A that I got with it. There is a bit more information out there regarding this model, but I felt like I would give my opinion on it anyway.



The front panel above is darker and not like any other test equipment that I have. It may be similar to other HP equipment of the same vintage, but I haven't seen any examples myself. Four main controls for settings are large rocker switches. The left three control the displayed digits (up / down) while the fourth controls "range" (essentially orders of magnitude). I think these buttons are quite neat and they are very intuitive and fast to use. One minor drawback is that there is no way to direct input a particular setting, but I don't think there are enough digits for that to really be a frustration. Also, if these keys were below the individual digits it would be just a little clearer what digit you are changing. Buttons under the LED display select what parameter you are adjusting.

The first thing that is immediately striking that I noticed about the HP 8116A is the absolutely gorgeous board inside the unit. Before I even opened the case I saw the thick golden traces shining through the vent holes in the bottom.



What a thing of beauty. You can see on the bottom of the lower board that there are plenty of nice big traces that are gold plated. I'm not sure whether the traces are exposed (no solder mask) and got plated during an immersion process or if they were plated and then coated with a very thin solder mask. Consider that a missed opportunity that I didn't get out my DMM and test the continuity to find out. It is certainly unusual to see a board like this that is not part of an RF section now.



Below is the top board which also has gold traces. It seems that it may have some interior layers. The layout and routing is very professional and most likely done with computer aid. I have not taken the time to catalog all the ICs, but I would guess were may be looking at a processor, some RAM and other peripherals. Although it might be the front panel controller as well since the ribbon cable goes directly to the front panel and the generator circuitry is likely to be on the bottom board.



Performance-wise the HP 8116A is presented as a 0-50MHz function generator. It can produce sine, triangle, square and pulses and can modulate its output as AM, FM or PWM. It also has some nice trigger and gating options as well as the ability to be used as a VCO.



As the modulation was one of the main features I was interested in using it for, I was happy that it produces a nice clean modulation throughout its range up to 50MHz. It produced 100% with a 5 V (amplitude) 10 kHz signal (above) and will go beyond 100% modulation if you want it to. That was a source of some confusion as the manual states that 100% modulation should be achieved at 5 Volt amplitude (the setting was 2.5 V amp.), but I believe that comes from the fact that the HP 8904A I was using as a modulating signal produces 5 V amplitude terminated into 50 ohms, but 5 V peak when terminated into high impedance. It should also be able to produce DSBSC with +2.5 V / -7.5 V modulating signal, but I was not able to produce enough DC offset for this with the HP 8904A.



As far as frequency accuracy goes, I think it is "pretty good" although it requires a fair bit of warmup time (typical for test equipment of this vintage). To be fair, I don't know whether the HP 8116A or my spectrum analyzer is out of calibration, but I think its accuracy is good without being necessarily absolutely precise. It seems to be off by about the same value so it may just need a calibration.



Its spectral performance is good and going through various wave shapes and looking at their spectra works out like an exercise in academic procedure. All the harmonics are where you'd expect them for sine, square, triangle and so on.






Above you can see a large amount of ringing in the scope shots, this is due to the lack of a good 50-ohm  termination on the oscilloscope and not indicative of the actual function generator performance. In my opinion it has very good performance, even producing square waves, well up into its operating range as shown below.

50 kHz square wave (left), 25 MHz square wave (right)

The HP 8116A can produce its waveforms with some fair DC offset and (using the duty cycle setting) can produce skewed triangle or sine waveforms (not necessarily a common feature with modern function generators). Below is an example of using the gate input to produce "bursts" of 50 MHz sine wave.



Below are some examples of the unit performing FM modulation that I could not find a place to fit anywhere else. It seems to be very stable, but I am not sure how to judge the "quality" of its FM modulation. I also tested the PWM and VCO functions and they worked well, but do not make for very interesting pictures.



Taken all together, I am very pleased with its performance. It doesn't have the convenience of a modern instrument or the ability to produce arbitrary waveforms. With a calibration, though, I think it would still contend as a useful piece to have around and I am certainly happy to have found it.