Updating DSO Quad firmware from a FreeBSD host

Back in January I received a DSO Quad portable oscilloscope. Here is some additional information on what the scope looks like to a FreeBSD desktop when trying to update the scope’s firmware.

Types of firmware

There are three main components of the DSO Quad’s “firmware” — FPGA code, SYStem code and APPlication code (the oscilloscope’s user-facing functionality). New APPlication code is of most interest to us end-users, and these are distributed as .hex files (binaries encoded for safe transfer via email, or other non 8-bit clean transports).

The current official Seeed Studio firmware for V2.6 DSO Quad is APP v2.53, SYS v1.52 and FPGA v2.61, with an active community working on enhanced alternative APPlications.

In normal use the DSO Quad’s USB port presents itself as a 2MByte USB drive. This is where screen captures are stored, among other things, for transfer to an external PC by a simple file copy operation. In order to upgrade the firmware (either using official or community developed binaries) the DSO Quad must be restarted in “bootloader” mode.

Bootloader mode

Bootloader mode is entered by powering-on the DSO Quad while holding button #1 (the button with the “play/pause” symbol). In this mode the USB port presents an entirely different, ~493 Kbyte MSDOS-formatted USB drive to your PC.

Updating APP firmware involves copying the appropriate .hex file onto this smaller drive and waiting a few seconds for the DSO Quad to detect the new file’s presence. The DSO Quad will then briefly cause the bootloader mode USB drive to disappear while it unpacks and installs the new firmware to Flash memory.

I’ve had success with the following steps under FreeBSD 8.2

# mount -t msdosfs /dev/da0 /mnt/ttt
# cp NEW_APP.HEX /mnt/ttt && sync && umount /mnt/ttt
    [...the DSO Quad then installs NEW_APP...]

Unmounting the drive immediately after copy/sync helps avoid having the FreeBSD kernel become confused when the DSO Quad “disappears” for a few seconds.

Booting APPlications

The DSO Quad’s Flash storage has room for four separate APPlications of 32Kbyte each. The DSO Quad defaults to booting APP1 when powered on. Booting into APP2, APP3 or APP4 is achieved by holding down button’s #2, #3, and #4 respectively while powering on the DSO Quad (the 2nd, 3rd and 4th from the “play/pause” button on top of the unit). Which slot an application resides in is specified during compilation of the image, and extracted from the .hex file that’s uploaded to the DSO Quad in bootloader mode.

More details under FreeBSD

When turned on as normal (using only the on/off slider switch) the DSO Quad boots up APP1 in the Flash, and presents the following activity on the USB port of my PC-BSD 8.2 desktop (which is based on FreeBSD 8.2):

               [...various from /var/log/messages...]
May 20 16:51:44 gjadesktop root: Unknown USB device: vendor 0x0483 product 0x5720 bus uhub5
May 20 16:51:44 gjadesktop kernel: ugen4.3: <STMicroelectronics> at usbus4
May 20 16:51:44 gjadesktop kernel: umass0: <ST Mass> on usbus4
May 20 16:51:44 gjadesktop kernel: umass0:  SCSI over Bulk-Only; quirks = 0x0000
May 20 16:51:45 gjadesktop kernel: umass0:3:0:-1: Attached to scbus3
May 20 16:51:45 gjadesktop kernel: da0 at umass-sim0 bus 0 scbus3 target 0 lun 0
May 20 16:51:45 gjadesktop kernel: da0: <Mini_DSO Flash Disk > Removable Direct Access SCSI-2 device
May 20 16:51:45 gjadesktop kernel: da0: 1.000MB/s transfers
May 20 16:51:45 gjadesktop kernel: da0: 2MB (4096 512 byte sectors: 64H 32S/T 2C)

Once the device has settled, usbconfig reveals:

[gja@gjadesktop]/home/gja(102)% usbconfig
         [..]
ugen4.3: <STM32 Mass Storage STMicroelectronics> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
[gja@gjadesktop]/home/gja(103)%

This is the 2MB MSDOS formatted drive the DSO Quad presents in normal operational mode. (My PCBSD 8.2 desktop detects the device as a drive named “MINIDSO”, which PC-BSD will happily automount if you ask it to.)

When turned on in bootloader mode the DSO Quad presents the following activity on the USB port of my PC-BSD 8.2 desktop:

[...various from /var/log/messages...]
May 20 17:09:27 gjadesktop root: Unknown USB device: vendor 0x0483 product 0x5720 bus uhub5
May 20 17:09:27 gjadesktop kernel: ugen4.3: <STMicroelectronics> at usbus4
May 20 17:09:27 gjadesktop kernel: umass0: <ST Mass> on usbus4
May 20 17:09:27 gjadesktop kernel: umass0: SCSI over Bulk-Only; quirks = 0x0000
May 20 17:09:28 gjadesktop kernel: umass0:3:0:-1: Attached to scbus3
May 20 17:09:28 gjadesktop kernel: da0 at umass-sim0 bus 0 scbus3 target 0 lun 0
May 20 17:09:28 gjadesktop kernel: da0: <Vertual DFU Disk > Removable Direct Access SCSI-2 device
May 20 17:09:28 gjadesktop kernel: da0: 1.000MB/s transfers
May 20 17:09:28 gjadesktop kernel: da0: 0MB (1024 512 byte sectors: 64H 32S/T 0C)

This is the ~493 Kbyte MSDOS-formatted USB drive used for transferring .hex files to the DSO Quad.

Example — installing a new APPlication

I had success with the following steps:

  • Mount bootloader’s msdosfs file system (which will appear empty)
  • Copy .hex file, then immediately ‘sync’ and unmount the file system
  • Reboot the DSO Quad

As an example I’ll install the Frequency Response app  from http://essentialscrap.com/dsoquad/freq.html (FREQ_APP.hex, which installs in the APP4 memory bank). First, mount the bootloader ‘drive’.

[gja@gjadesktop] /media# mount -t msdosfs /dev/da0 /mnt/ttt
[gja@gjadesktop] /media# df -h /mnt/ttt
Filesystem Size Used Avail Capacity Mounted on
/dev/da0 493K 1.0K 492K 0% /mnt/ttt
[gja@gjadesktop] /media# ll /mnt/ttt
total 0
[gja@gjadesktop] /media#

The drive is an empty 493Kbyte device. Now copy over the .hex file, sync and umount the device in rapid succession.

[gja@gjadesktop] /media# cp FREQ_APP.hex /mnt/ttt && sync && ls -al /mnt/ttt && umount /mnt/ttt
total 85
drwxr-xr-x 1 root wheel 16384 Jan 1 1980 .
drwxr-xr-x 13 root wheel 13 May 3 2011 ..
-rwxr-xr-x 1 root wheel 68832 May 20 17:11 freq_app.hex
[gja@gjadesktop] /media#

In a few seconds the DSO Quad ‘disconnects’ as a USB device, then reconnects itself again as the bootloader’s USB drive (ready to have another .hex file copied over).

At this point, rather than upload another .hex or .bin file, I simply reboot the DSO Quad while holding down button #4 and turning the unit back on again… the Frequency Response application starts successfully and the DSO Quad itself re-appears on the USB port as the 2MB USB drive seen when booting into ‘normal’ mode.

Yay!

Advertisements

One comment

  1. […] in January I received a DSO Quad portable oscilloscope., whose Flash storage has room for four separate APP(lications) of 32Kbyte each. The primary APP (in slot #1, and booted by default) is the manufacturer’s […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: