Juggling Partitions

I've been doing Inferno-related things with hardware other than the NanoNote recently, so I've only just looked at what I need to do next with the system I'm writing for it. There are three tasks I feel I need to address at some point so, before getting stuck in with more complicated things, I decided to take a look at them.

Mounting a FAT partition

I wanted to be able to import and export data on the microSD card from a Linux system without having to start up Inferno's emu and mount Plan 9 partitions containing kfs as the filing system. The main problem here was getting the automounter in LXQt to see the newly created FAT partition and mount it. After all, it normally mounts partitions automatically, especially when I don't want it to!

Whatever I tried, it just wouldn't see the new partition until I created one really close to the start of the microSD card. Since the NanoNote's bootloader expects a boot partition with an ext2 filing system at the start of the disk, this caused problems, so I ended up creating a small boot partition followed by the FAT partition. I was using cfdisk to do all this work and was surprised to find how much more awkward it is to use these days. Did someone strip out all the features at some point?

On the Inferno side of things, I struggled with getting the SD device to accept the partition information I was producing in the init script if more than one partition was being added to the /dev/sdM0/ctl file at once. I could, of course, just do the following but I wanted to be more selective:

disk/fdisk -p /dev/sdM0/data > /dev/sdM0/ctl

In the end, I just used code to select individual partitions and send them one at a time to the ctl file.

Handling kfs unmounting

Every time the init script mounts the partition on the device, I see a warning: kfs needs check. In my shutdown function, I send a message to kfs via a channel, telling it to sync. Then I unmount it. I thought that this would be enough to stop the warnings from occurring.

According to the kfs man page, it seems that I needed to add a adm/users file to the root of the filing system. With that done, kfs no longer complains at boot time. Well, it didn't the first time, anyway. Later reboots caused warnings again, so I may need to revisit this.

Shutdown and power up

My shutdown function works almost all the time. I think the times when it doesn't probably involves situations where I removed the microSD card before shutting down. In any case, that's not the problem at hand. The real problem is that the NanoNote won't power up again afterwards unless power is cut for 5-10 seconds. This means removing the battery, if used, or cutting the USB power supply — I have a useful cable with a switch for this purpose.

Really, the system isn't powered off when I shut it down. It goes into hibernate mode. Looking at the reference manual for the processor, I wasn't sure what I needed to do to get it to respond to a wake up signal, so I looked at the Linux 3.3.8 code for the JZ4740, and it turns out to be easier than expected: just set a couple of registers with numbers of RTC ticks to let the SoC know how long the wake up signal has to be before it will act on it.

The result is that I can power up (wake up) the system again after shutting it down. This should make it easier and quicker to test new code because I won't have to mess around with actually cutting the power and potentially corrupting the RTC value.


David Boddie
10 January 2022