Paolo Amoroso's Journal

Tech projects, hobby programming, and geeky thoughts of Paolo Amoroso

ChromeOS 104 delivered the ability to access USB serial devices from Android, an option for controlling the Z80-MBC2 computer from an Android terminal emulator app.

I didn't realize chromeOS 104 improved the support for accessing USB serial devices also from web apps implementing the WebUSB API. On my Chromebox, version 104 is the first that enables controlling the Z80-MBC2 from the web. Here's a CP/M 3.0 session in a serial terminal emulator web app:

USB Web Serial terminal emulator web app running a Z80-MBC2 CP/M 3.0 session on chromeOS.

Up to chromeOS 104, web terminals failed to connect to the Z80-MBC2 as they didn't detect the USB device. With version 104 I tested the following terminal apps, most of which work:

These apps operate the same way. A connection button brings up a system dialog listing the serial devices, like the Z80-MBC2's CP2102 chip. Once connected, the apps behave like other terminal emulators.

Although useful as an additional option for controlling the Z80-MBC2 on chromeOS, these web terminals are experimental or basic apps, have limited functionality, and miss major features like XMODEM file transfer.

#z80mbc2 #sbc #Android #chromeOS

Discuss... Email | Reply @amoroso@fosstodon.org

I discontinued my old Blogger blog and, going forward, I'll post only to this new blog hosted at Write.as. After initially meaning to maintain both, I had been considering mothballing the old blog for months. The joy of using Write.as finally drove home I can't stand Blogger anymore.

#blogging

Discuss... Email | Reply @amoroso@fosstodon.org

I decided what to work on next on Suite8080, the suite of Intel 8080 Assembly cross-development tools I'm writing in Python. I'll add two features, the ability for the assembler to trim trailing uninitialized data and a macro assembler script.

Trimming uninitialized data

Consider this 8080 Assembly code, which declares a 1024 bytes uninitialized data area at the end of the program:

# . . .

data:        ds    1024
             end

For this ds directive, the Suite8080 assembler asm80 emits a sequence of 1024 null bytes at the end of the binary program. The executable file is thus longer and may be slower to load on the host system, typically CP/M.

The Digital Research CP/M assemblers, ASM.COM and MAC.COM, strip such trailing uninitialized data from binaries. After asking for feedback to r/asm, I decided to do the same with asm80. I should be able to implement this optimization by adding just one line of Python, so the feature is a low-hanging fruit.

Macro assembler

asm80 can accept source files from standard input, which makes it possible to combine the assembler with an external macro preprocessor to get a macro assembler. Thanks to its ubiquity, M4 is the clear choice for a preprocessor.

Assuming prog.asm is an 8080 Assembly source file containing M4 macros, this shell pipe can assemble it with asm80:

$ cat prog.asm | m4 | asm80 - -o prog.com

The - option accepts input from standard input and -o sets the file name of the output binary program.

The other Suite8080 feature I'm going to implement is a mac80 helper script in Python to wrap such a shell pipe and make assembling macro files more convenient. In other words, syntactic sugar wrapping asm80 and M4.

The script will use the Python subprocess module to set up the pipe, feed the proprocessed source to the assembler, and not much else.

#Suite8080 #Python

Discuss... Email | Reply @amoroso@fosstodon.org

The Python feed of my old blog Moonshots Beyond the Cloud has long been aggregated by Planet Python. But I'm no longer going to update that blog, so I removed the old feed from Planet Python and submitted the Python feed of my new blog, Paolo Amoroso's Journal.

#Python #blogging

Discuss... Email | Reply @amoroso@fosstodon.org

ChromeOS 104 landed on my Chromebox delivering a pleasant surprise, the ability to access serial USB devices from Android apps.

When I plugged the Z80-MBC2 Z80 homebrew computer into the Chromebox under chromeOS 104, the system popped up this notification allowing me to connect the device to Android or Linux, not just Linux as before:

chromeOS notification allowing to connect a Z80-MBC2 serial USB device to Linux or Android.

The notifcation confirms the detection of the Z80-MBC2's CP2102 chipset and says:

USB device detected

Open Settings to connect CP2102 USB to UART Bridge Controller to Linux or Android apps

Connect to Linux Connect to Android

I had long been looking forward to accessing the Z80-MBC2 from Android. I researched a great terminal emulator app, Serial USB Terminal, which can connect to serial USB devices, features basic ANSI support, and can transfer files via XMODEM. Although the app runs fine on the Chromebox, I never figured how to connect to the Z80-MBC2. It turns out it wasn't possible, until chromeOS 104.

Selecting the notification's option to connect to Android prompts to run Serial USB Terminal, optionally setting it as the default app for Android connections.

I interacted a bit with the Z80-MBC2 from the Android terminal emulator and it's usable. Here's what a CP/M 3.0 session looks like in the app in landscape tablet mode, the window layout that works best with a terminal:

Serial USB Terminal Android app running a Z80-MBC2 CP/M 3.0 session on chromeOS.

Input goes in a text field separate from the terminal output. It feels awkward on the desktop but natural on mobile devices with touch interfaces.

Serial USB Terminal's ANSI support seems limited or incomplete, but I haven't checked extensively.

I tried transferring a file via XMODEM from the terminal emulator to the Z80-MBC2 under CP/M 3.0. But, as with Crostini Linux, nothing happens and the XMODEM transfer doesn't work. More experimentation may provide clues on the XMODEM issue.

So far I haven't played with the Z80-MBC2 much from Android, but it's great to have another option for controlling the device.

#z80mbc2 #sbc #Android #chromeOS

Discuss... Email | Reply @amoroso@fosstodon.org

One reason I chose Write.as as my blogging platform is great support for technical writing with Markdown and MathJax.

I use Markdown all the time but haven't played with MathJax much, which I may need for some occasional simple math. So this post is a quick overview of how I write MathJax and what it renders like.

Editing and previewing MathJax

I love Write.as, but it has a few rough edges that introduce friction when writing MathJax.

There's no post preview and the only workaround, publishing an anonymous post and moving it to my blog when satisfied, doesn't render MathJax. This forces to go blind. Until a post shows up on the blog and I can fix any formatting issues, in the few minutes since publication and prior to the newsletter and the RSS feed entry going out.

I came up with an alternate workflow. I edit the math in the Interactive LaTeX Editor. This nice little tool supports MathJax, renders as I type, and has no ads.

Once the LaTeX source looks good, I copy the code from the LaTeX editor and paste it into the Write.as editor. If some LaTeX symbols have meaning in Markdown, such as _, *, and \, I have to go the extra step of escaping them with \.

At this point I'm ready to publish the post and tweak the math as described earlier.

MathJax examples

Time to kick the tires.

Let's start with some inline big \(O\) notation, say an algorithm that's \(O(n \ln n)\). I also throw in some binary numbers such as \(10010101_2\) and \(11010111_2\), and a simple calculation like \(2^{16} = 65536\).

Here is a displayed logical operation:

$$00000101_2 \wedge 00001100_2 \Rightarrow 00000100_2$$

The quadratic formula renders like this:

$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}$$

Finally, the standard deviation:

$$\sigma = \sqrt{ \frac{1}{N} \sum_{i=1}^N (x_i -\mu)^2}$$

#blogging

Discuss... Email | Reply @amoroso@fosstodon.org

On my Chromebox, XMODEM file transfer from Linux to the Z80-MBC2 is broken, but I've been trying with every new chromeOS version just in case an update delivers a fix. So far the transfer still doesn't work with chromeOS up to 104.

#z80mbc2 #sbc #chromeOS

Discuss... Email | Reply @amoroso@fosstodon.org

I'm reposting here some content I published elsewhere, such as this and this. My journal will be my primary blog, so I'm consolidating here some of my other material. Which is an opportunity to revisit, filter, and revise old content.

#blogging

Discuss... Email | Reply @amoroso@fosstodon.org

The conventional marketing wisdom is to emphasize product benefits rather than features.

Is it universally true? Are there products or customers for whom the features are more important than the benefits? Think for example of technical products such as tools or platforms for software developers.

I prefer to learn about the features because the benefits are too vague, focus on average users, and often feel unrealistic or patronizing. I wonder how representative I am.

The features let me figure the benefits that are important to me, which those promoting the product may not even think of.

If I know the product domain well, the features suggest the benefits I can get out of it. Or I may plan to use the product in ways the vendor didn't intend or anticipate in their benefits-oriented communication.

If you pitch a product to me, skip the benefits and talk features.

#misc

Discuss... Email | Reply @amoroso@fosstodon.org

It all started when I added a new Intel 8080 Assembly demo to Suite8080. Pushing the commit to the GitHub repo triggered a rebuild of the project documentation hosted on Read The Docs, which failed.

I maintain the Suite8080 documentation with Jupyter Book and publish it to Read The Docs with Sphinx as the backend.

Over the previous months, while my work on Suite8080 was on hold, some backward incompatible Jupyter Book update broke the Suite8080 documentation configuration. I had no idea what to do, so I opened a Read The Docs issue. After some troubleshooting with the help of Manuel Kaufmann, Benjamin Balder Bach contributed a Suite8080 pull request that fixed the issue.

Benjamin's patch has an additional advantage. I no longer have to manually edit conf.py to let sphinx.ext.autodoc discover the project's Python packages.

#Suite8080 #Python

Discuss... Email | Reply @amoroso@fosstodon.org

Enter your email to subscribe to updates.