Sunday, March 23, 2025

Raspberry Pi running BASIC

Earlier on this blog, I posted something about the BASIC language on Linux. 

It turns out that all the tools mentioned in this posting are available on Raspberry Pi computers too. In fact, BWBASIC, FreeBasic and Geany work in the exact same way.


Raspberry Pi zram swap

Raspberry Pi computers may not always have the best amount of RAM available. For small embedded applications, this is just perfect, no precious ram wasted by remaining empty.
However, depending on the application, more memory might be required. The fallback would be virtual memory. In big server installations, swap is not even a topic. However, if an SD-card is were the files live on, SWAP is somewhat out of the picture.

If CPU power is not an issue, ZRAM might be a solution of the RAM-shortage of an RPi-application. 
While my RPi500 has plenty of RAM, I installed ZRAM anyways.
This is what my present memory situation looks like:

               total        used        free      shared  buff/cache   available
Mem:         8131616      835544     6173708      103560     1315828     7296072
Swap:        4270584           0     4270584

NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.9G   4K   80B   12K       4 [SWAP]

NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition 3.9G   0B  100
/var/swap  file      200M   0B   -2

And yes, the RPi500 is equipped with 8GB of RAM and 4 CPU cores. 
Presently I would not know how to fill up all the memory available to me.

Raspberry Pi 500 USB boot

There seems very little information on the internet on the Raspberry Pi 500. I love the RPi400, so, how could I resist to purchase an RPi500? I got the whole package, including mouse, PSU and the book.

The RPi500 comes preinstalled with a micro-SD, no surprise here. I am not a big fan of running my OS on SD-cards. So, I ordered a USB3 to SATA adapter to go with the 500. Of course my intention was to use an SSD in this setup. However, I was curious if the RPi500 could handle an spiny-disk-device. And yes, it can. Here is what I did:

Boot the RPi500 with the SD-card. Use the tool "SD Card Copier" to copy the contents of a Seagate Expansion external USB3 HDD. Surprise surprise, it worked. Once the SD-card was copied to the HDD, I shut down the RPi500 and removed the SD-card. Switching back on booted right away from the hard-drive. Of course a spiny disk does not provide a very snappy experience, but it worked. The SPi500 was able to supply the spiny disk, however, the temperature of the keyboard-computer was slightly elevated; not to an alarming level, however noticeable. 

While I call the exercise a success, I went back to the original plan and replaced the HDD with a (Kingston) SSD drive. This was done by simply using the "SD Card Copier" to copy the HDD content to the SSD.
The RPi500 runs a lot cooler and snappier now, who would have though?

Contrary to the actions one had to perform with the Raspberry Pi 4 generations, not strange commands are needed to boot the RPi5 generation using USB devices.

Friday, February 28, 2025

BASIC on Linux

Who does not remember the good old times when all (home) computers came with BASIC. To recreate the good old time feeling, BASIC had to be back on my Linux systems.

I figured out a combination of bwbasic and FreeBasic

The Bywater BASIC interpreter offers an interactive environment, similar to GW-BASIC. With a tiny trick, bwbasic can be used in a batch mode directly from shell. The "trick" being using the SYSTEM or QUIT statement at the end of the code, rather than the END statement. Here is an example:

10 for i=0 to 10
20 gosub 100
30 next
40 ?
50 system
100 ? i;
110 return

Line numbers are not necessary, however, line numbers allow to edit the code in the bwbasics interactive environment.

Sometimes, one might want to compile a program. In comes the FreeBasic compiler. It is important to point out that bwbasic and FreeBasic are not 100% compatible. I order successfully compile code as displayed above, one needs to the a "-lang" option. I found "fbc -lang qb [filename]" to work fine.
Another remark, while SYSTEM and QUIT are equivalents under bwbasic, fbc does understand SYSTEM, but not QUIT.

One interesting comparison is the performance of the interpreter and the compiled code.

Interpreter:
$ time bwbasic count.bas
Bywater BASIC Interpreter/Shell, version 2.20 patch level 2
Copyright (c) 1993, Ted A. Campbell
Copyright (c) 1995-1997, Jon B. Volkoff

 0 1 2 3 4 5 6 7 8 9 10

real 0m0.007s
user 0m0.003s
sys 0m0.004s

Compiled code:
$ time ./count
 0 1 2 3 4 5 6 7 8 9 10

real 0m0.038s
user 0m0.005s
sys 0m0.007s

When using the interpreter, the first 4 lines of the output are not controllable by the user of bwbasic. However, a very simple trick with the stream editor gets rid of the problem. It does not even cost a lot of extra time. This way, the output can be piped to yet another program. Have a look:
$ time bwbasic count.bas | sed 1,4d
 0 1 2 3 4 5 6 7 8 9 10


real 0m0.013s
user 0m0.005s
sys 0m0.018s


There is yet another program I want to push into the mix, Geany. This IDE integrates perfectly with the FreeBasic compiler. Just be sure to add the "-lang qb" to the Build Commands. Click Build -> Set Build Commands. The "Compile" Command would therefore look like this: fbc -lang qb -w all "%f"
Geany also supports "Run" Commands. Making use od the stream editor as above, the command looks like this: bwbasic "%f" | sed 1,4d Obviously, this run option won't function on interactive programs... just saying.

Dell Wyse 5070 Linux setup

In my previous post. I discussed the use of a Dell Wyse 5060 thing client. There is a better option, which meanwhile made it into my collection, the Dell Wyse 5070. 

The version I got is equipped with a 16GB onboard eMMC device, which is big enough for a small Linux installation. My joice fell on Xubuntu Minimal. With some additional software installed, 48% of the eMMC drive are used, roughly 6.5GB.

To keep things simple, I am using an external 2TB USB3 HDD. This disk is partitioned into a Linux swap and an ext4 partition. The ext4 partition serves as home-drive.

Swapping over USB3 is certainly not ideal. However, with only 4GB RAM, swap is desireable. In order to improve on the swap situation, zram takes care of part of the virtual memory. The total virtual memory is now 4GB (HDD) + 1.8GB (zram).


Sunday, August 28, 2022

Dell Wyse 5060 Thin Client

OMG, it has been over a year since I posted last... I am so sorry! The COVID-19 situation gave me some sort of reluctance, in which I indulged, watching other folks' work. My Raspberry Pi projects were quiet too. I simply tried to focus on growing a business... Has that worked? Maybe!

Anyway, for my business, I figured that my (t)rusty old dual core Celeron NUC was not cutting it any longer. I like the NUC, but, it might do better service to me as an Owncloud server or something alike. So, in replacing my authoring workstation, I was looking for silent (!) alternatives. When I was employed, many years ago, I was given a "thin client" to connect with the company's servers. This thing was fully passively cooled and silent but butt ugly.  Not sure what brand it was, and this is not important either.

So, in recall of what the silence during my thin client usage was, I started researching on a suitable thin client for my own business. The distinction here is that there is no intention to use the thin client as intended by the manufacturer. The original plan was to replace my (t)rusty old NUC, with something more silent and more powerful.

The research of tech and availability got me to the Dell Wyse range, in particular the 5060 model. And here is why:

  • accessible BIOS (password "Fireport") with USB boot option
  • quad core AMD 64bit CPU up to 2.4 GHz
  • 2 SODIMM sockets (one populated with a 4 GB card)
  • 8 GB SATA SSD module (internal connector)
  • 4 USB2 ports
  • 2 USB3 ports
On top, there is an internal connector for a wlan card. 

Hence, this thing should be pretty decent as a Linux workplace PC. In fact, I am writing this article on this particular piece of kit.

However, there is of course no free lunch, so, there was some work to be done before arriving at this workstation.
First of all, 8 GB of storage night be enough to run Puppy Linux, or distributions alike, however, more serious work will ask for a heavier distro. I am a long time user of Linux Mint, as this is what I was intending to use on this machine. Linux Mint does not install on 8 GB storage however.
This might look like a big problem, but it isn't, promised!

First, I want to give you an overview what the thin client looks in it's original state...
DELL WYSE 5060

Now that we has established how the thin client looks with the covers removed, lets have a look at the guts.
SATA SSD module

installed SODIMM module

SODIMM module removed, showing 2nd slot below

I had a 2GB SODIMM module in my junk box, so, I dropped it in. The original 4 GB module is now in slot 0, while the spare 2 GB module is in slot 1. While this may not be a big deal, every little bit of (gratis) RAM helps.
2 SODIMM slots used

The more interesting mod is of course to purpose the the SATA slot. 8 GB might be something, but more might be something better.

It just so happened that I had a 240 GB Sandisk SATA SSD in one of my junk boxes. It previously served a Raspberry Pi 4 but was not presently in use. There are other SSDs in my junk box, however, it is important to point out that the PCB of the Sandisk SSDs are particularly small. Have a look:
SanDisk SSD plus 240 GB
Now, lets compare that to the SSD module of the Wyse 5060...
On the left: 8 GB SSD module, on the right: 240 GB SSD
It is obvious that the Sandisk PCB is a little bit larger than the one of the original 8 GB SSD, However, it is not large enough to pose a real problem.
First of all, there is a screw and a respective terminal right in the middle of the original SSD. For electrical reasons, this has to be covered (by some electrical tape).


When installing the Sandisk SSD, some additional measures are needed to prevent electrical problem. In particular the EM-shield of the of RAM section might interfere with the larger SSD pcb. In order to overcome this problem, pliers might be required to bend the EM-shield such to no longer interfere/touch the SSD pcb.
Sandisk 240 GB SSD pcb installed
I will spare you a picture how I secured the SSD with just a strip of electrical tape.

This was a weekend project, i.e. just a few hours old. Still, I think this is a very worthy project to do. Inexpensive (if you are patient enough) and pretty rewarding in the results in my view.

I am running this with Linux Mint 20.3 and I am very pleased. I wish to point out that tweaking of the CPU frequencies might improve your experience.

Sunday, April 4, 2021

Raspberry Pi 400 Document Scanning with Canon LiDE 30

My RPi400 evolves more and more into my daily driver for my office activities. Here and there I got paper documents to share, so I needed to scan those, for sending them as PDFs around the world.

Many year ago, I purchased a Canon LiDE 30 USB scanner. This scanner is powered by the USB connection only. Until today, I used this particular scanner on a powered USB hub, thinking the power draw would be to great for the RPi400.
Well, I was wrong. Today, I hooked the scanner up to one of the USB3 ports of the RPi400 directly and the scanner worked perfectly.

If you wonder, the Canon LiDE 30 is supported up to Windows Vista 32bit or Mac OS X 10.5 (Leopard) and won't work on anything more modern than that in Microsoft or Apple environments.
However, we are in good luck with linux and the "sane" environment. 
On Raspberry Pi linux systems, XSane is available. To my surprise, the RPi400 delivers sufficient current on the USB3 connectors to power my Canon LiDE 30 scanner.