Меnu:


Our telephone. The Nokia N900 is still fully operational until today-2023 (this article began to be written in 2022), and we hope that it will continue to function for many more years (as long as the operators allow it, since each time they try to turn off the old cellular networks and focus only on new ones like 5G), although migration to another phone with GNU/Linux and keyboard seems inevitable in the near future, or when the N900 stops working (such as stops connecting to the cellular network easily).

From failed boot in maemo-leste to failed boot in Archlinux

Maemo users have observed how the N900 no longer has major updates for several years ago. Some of the Maemo users decided to undertake the upgrade and be able to run the current Linux kernel on the Nokia N900 phone. This is how the maemoleste project began.


https://maemo-leste.github.io/
https://leste.maemo.org/A33-TurboX-Twister
chroot-chroot-pendant

What the maemo-leste guys are doing is amazing, we watch them from a distance. As users of the traditional N900 aka freemantle, we always wondered what it would be like to run Maemo on a desktop, since we managed to run it on QEMU in the past. Arrival of the SBCs. When SBCs started appearing, these devices and maemo(thanks kotczarny) users helped us to be able of having a chroot for compiling packages on the SBC which we can then run without a problem on the Nokia N900 phone (without using Scratchbox on x86).

The chroot for the Nokia N900 freemantle reminded us of our old question 'what would it be like to run maemo-leste on an SBC?', so we decided to buy an EMMC module with a microSD adapter, and decided to install maemo-leste there. After having managed to create a bootable image with the help of the guys at maemo-leste, we dd to the emmc+adapter, we were anxious to see how the X and Hildon would appear on the HDMI screen, but nothing happened, just a kernel message which said that it could not mount the / (root).

,---- [ error-message-when-booting-kernel ]
| sunxi-mmc 1c0f000.mmc: send stop command failed
`----

Photo of the emmc connected to the adapter and a microSD at the bottom:






What happened?. We didn't get out of our astonishment, this should work without any problem. We left it there and started using the emmc+adapter only as a USB stick (this is a waste, since there are cheaper 64 Gb USB sticks). And we stayed like that for a long time. You can imagine how disappointed we were that day.

When time allowed, we decided to put only Archlinux-armv7 and not maemo-leste in the emmc+adapter and it failed again with archlinux-armv7 just as it failed when trying to run maemo-leste previously. Investigating we managed to find similar cases.

As trying to boot Archlinux failed to boot either, and the error was the same as what we initially had when we tried to boot maemo-leste. It was obvious that it was not a maemo-leste problem, but rather a problem for the kernel to recognize the emmc+adapter properly. I spend quite a lot of time (months). Until we tried again and got a successful boot.

To achieve successful boot it was necessary to put a change in the dts that allowed us to boot Archlinux. Up to there all good. So what do we do now? We try again to put maemo-leste?.

diff -u /tmp/sun8i-h3-orangepi-pc_5139.dts /tmp/sun8i-h3-orangepi-pc.dts
--- /tmp/sun8i-h3-orangepi-pc_5139.dts  2023-07-14 18:46:10.840974161 +0000
+++ /tmp/sun8i-h3-orangepi-pc.dts       2023-07-14 18:46:35.404384580 +0000
@@ -174,12 +174,13 @@
                        status = "okay";
                        #address-cells = <0x01>;
                        #size-cells = <0x00>;
-                       compatible = "allwinner,sun7i-a20-mmc";
+                       compatible = "allwinner,sun7i-a20-mmc\0allwinner,sun50i-h5-emmc";
                        clocks = <0x03 0x16 0x03 0x47 0x03 0x49 0x03 0x48>;
                        clock-names = "ahb\0mmc\0output\0sample";
                        vmmc-supply = <0x0b>;
                        bus-width = <0x04>;
                        cd-gpios = <0x0c 0x05 0x06 0x01>;
+                       no-1-8-v;
                        phandle = <0x3e>;
                };

Diff finished.  Fri Jul 14 18:47:04 2023

Shall we try again maemo-leste?

After thinking about it for a few months, the answer is NO, since the emmc+adapter works as an external disk for the SBCs, and we can boot either on an orange-pi-pc SBC as well as on an orange-pi-plus-2e SBC. All that space, which is 4 times larger than what comes in orange-pi-plus-2e (its emmc is only 16GB), helps us a lot, allows us to compile the kernel, or other packages in a second SBC and not in our SBC which is always on. It also helps us to have a backup of our machine that is always on.

Additionally, it should be noted, regarding the statement 'that with the same microSD|SD|USB-pendrive you can boot different devices', in this case opipc, opiplus2e, A721, for this to be possible it is only necessary to change the binary of the u-boot, the u-boot is the bootloader for SBCs. In the case of x86 machines, the u-boot is the equivalent of the BIOS.

The maemo-leste is still a pending task. We will try maemo-leste in the future. But that future is not so close, it can take several months and even years, it depends a lot on our availability of time more than our desire.

Archlinux on Topwise A721 tablet

Time passes and we arrive at kernel 5.13, which enables dtb for the Topwise A721 tablet. Which we have on hand. To run Archlinux on the tablet, first we put the u-boot version suitable for the tablet and then we make the same modification that we did to boot the opipc to the dtb of the Topwise A721 tablet and it should boot with the emmc+adapter. What can go wrong? Nothing. TRUE?. Patches for the u-boot were shared by Pascal Roeleven.

,---- [ got-same-error-as-before-when-trying-booting-topwise-a721 ]
| sunxi-mmc 1c0f000.mmc: send stop command failed
`----

Photo of the emmc with the adapter connected to the Topwise A721 tablet:



Like when trying to boot Topwise A721 tablet with Archlinux it 'Did not Boot', and the error was the same as we had before when we tried to boot Archlinux on opipc. We did an emergency kernel patch and the tablet booted. The tablet would boot, but it took a long time to boot when checking with our friends on the irc channel linux-sunxi(thanks apritzel). They gave us a tip to increase speed. The tip was to change the frequency of the microSD reader. We applied the tip and it started to boot faster. And also by applying the tip we were able to get rid of our emergency patch.

diff -u /tmp/sun4i-a10-topwise-a721_as-was.dts /tmp/sun4i-a10-topwise-a721.dts
--- /tmp/sun4i-a10-topwise-a721_as-was.dts      2022-06-29 22:35:52.000000000 +0000
+++ /tmp/sun4i-a10-topwise-a721.dts     2023-07-04 01:39:32.000000000 +0000
@@ -413,7 +413,9 @@
                        #address-cells = <0x01>;
                        #size-cells = <0x00>;
                        vmmc-supply = <0x17>;
+                       max-frequency = <0x2625a00>;
                        bus-width = <0x04>;
                        cd-gpios = <0x18 0x07 0x01 0x01>;
+                       no-1-8-v;
                        phandle = <0x49>;
                };

Diff finished.  Fri Jul 14 18:51:00 2023

So apart from the tip (change the frequency) it was necessary to put an option in the dtb that would tell the kernel that the microSD reader (hardware) does not support the 1.8 voltage.

U-boot version installed on Topwise A721 tablet:

U-Boot SPL 2021.07-dirty (Nov 19 2021 - 00:54:34 +0000)


https://www.denx.de/project/u-boot/

Pascal Roeleven patch:


https://disk.yandex.com/d/jfzosuFG8gl4pg

u-boot (binary):


https://disk.yandex.com/d/Yu1li8NL89lfsQ

Android version installed on tablet

We share a photo of Topwise A721 tablet with Archlinux emmc+adapter and Onboard keyboard. Great isn't it? Let's also remember that this tablet came with Android 4.04 and in the past we have migrated it to 4.1.1 and we believe that it would be possible with the help of our friends at h3droid to bring it up to 4.4.0. That would be interesting, right?




kernel problem when turning off the tablet

There is a problem when turning off the Topwise A721 tablet, it does not turn off completely, so you have to press the on/off button for about 10s, so that it turns off the tablet completely (now that if you have the oscilloscope at the hand, the oscilloscope would help You). This inconvenience is already resolved in kernel 6.1. But when we try to boot the tablet with kernel 6.1. The tablet failed to boot. We haven't had enough time to debug this issue properly yet.

Link to the thread of the mailing list, where the reason for not turning off the tablet properly was discussed:


https://lore.kernel.org/linux-sunxi/9f8a0fc3-1d9a-b271-3c26-4f7373b8a3e9@gmail.com/

Topwise A721 tablet connected with a bluetooth keyboard (see photo rmail below):




video playback

Tell You guys that with mainline kernel and mesa-3d package the playback of a Video on the Topwise A721 tablet is not possible, since there is a de-synchronization between the audio and the image. The friends of maemo-leste DID manage to play a video using maemo-leste on a tablet with an A33 chip, the Topwise A721 has the A10 chip, however both tablets share the same mali-400 GPU. The command they used in that video was mpv with the '-vo=gpu' option. We have tried to find the mentioned video again without success, as we wanted to try such option on the Topwise A721 tablet with Archlinux and the emmc+adapter.

adding bluetooth adapter to the tablet (Improvement)

Let's remember that this tablet doesn't have a bluetooth adapter included by default (But now that we have GNU/Linux installed we just put an adapter and we already add bluetooth to the table. How nice it is).

Actually, apart from connecting the bluetooth adapter to the only Usb port of the tablet, we have a script that starts the bluetooth service and also creates a NAP network, besides that in the onehandmenu (which starts by default when turning on the tablet) there is a command to connect to our bluetooth keyboard in case the Topwise A721 tablet was not the last bluetooth device this keyboard connected to.

script that configures the bluetooth dongle:

#!/bin/sh

# check bnap
if ! btmgmt info | grep '0 items' > /dev/null 2>&1 && ! ip addr show  | grep pan0  > /dev/null 2>&1; then
    MYIP=10.1.24.1 # also on above (ip see mybr on bashrc)
    pactl unload-module module-bluetooth-discover; pactl load-module module-bluetooth-discover # check pactl is available
    sudo brctl addbr pan0; sudo brctl setfd pan0 0; sudo brctl stp pan0 off; sudo ip addr add $MYIP/24 dev pan0; sudo ip link set pan0 up
    sudo systemctl start bluetooth # bt on systemctl should not be enabled
    echo -e "power on" | bluetoothctl
    # below is manual not enabled
    systemctl --user start peru-nap-bt-network.service
    MYIP2=$(echo $MYIP | awk -F '.' '{printf("%d.%d.%d.%d", $1, $2, $3,0)}') # also on above (ip see mybr on bashrc)
    sudo bash -c "echo 1  > /proc/sys/net/ipv4/ip_forward"
    sudo iptables -t nat -A POSTROUTING -s $MYIP2/24 -j MASQUERADE
    # doing manually by now, 4 receiving files. should be an automatic way on systemd
    sudo sed -i -e 's/ExecStart=\/usr\/lib\/bluetooth\/obexd$/ExecStart=\/usr\/lib\/bluetooth\/obexd -a/g' /usr/lib/systemd/user/obex.service #for always receiving files
    systemctl --user start obex #{/usr/lib/systemd/user/obex.service; ~/.config/systemd/}
    #sh ~/manual_autostart.sh; # try to work with this on .config/openbox/autostart.sh
    # rm some lines (@worstCase next startup dnsmasq would be ok) {this is just 4 headless}
    #sudo sed -i '/interface=w/,$d' /etc/dnsmasq.conf
else
    if ! btmgmt info | grep '0 items' > /dev/null 2>&1 && ip addr show  | grep pan0  > /dev/null 2>&1; then
        sudo systemctl start bluetooth # bt on systemctl should not be enabled
        echo -e "power on" | bluetoothctl
        # below is manual not enabled
        systemctl --user start peru-nap-bt-network.service
    fi
fi

Since the Topwise A721 tablet was not intended to be used with an emmc+adapter , and the microSD input comes at the bottom of the device, we couldn't rest the tablet on a flat surface like the one where we took the picture, so to be able to rest the tablet on a flat surface, we need to rotate it, when physically rotating the tablet, we also need to rotate the video displayed on the LCD screen of the tablet.

To invert the video of the tablet it is necessary to execute the following command:

~ $ xrandr -o 2; xinput set-prop "generic ft5x06 (91)" 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1;

As in the Nokia N800, we could listen to music, be in chats and also write emails. We can do the same with the Topwise A721 tablet. But when trying it we realized that we need to activate the audio first.

Command to activate the audio, which is deactivated by default.

~ $ amixer -c0 cset numid=17 1; amixer -c0 cset numid=15 1; amixer -c0 cset numid=1 50;

Photo of Nokia N900 and Topwise A721 tablet side by side.




about tablet buttons

We made a driver using libevdev, but it didn't work properly, we'll share it with you anyway, it could serve as a reference.

Proof of concept of the driver for the buttons of the Topwise A721 tablet:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <libevdev.h>
// cc -I /usr/include/libevdev-1.0/libevdev/ -o remapping_touch.out -l evdev
int main (int argc, char **argv) {
  struct libevdev *dev = NULL;
  char buf[256];
  char text[8];
  int fd;
  int rc = 1;
  int flag_tracking_sequential, flag_position_value, flag_touch_one, flag_x_value, flag_tracking_minus_one; //flag_touch_zero
  int x_val;

  sprintf (text, "%s", argv[1]);
  strncpy (buf, "/dev/input/event", 16);
  buf [16] = text[0];
  buf [17] = 0;
  fprintf (stdout, "%s", buf);
  fd = open (buf, O_RDONLY|O_NONBLOCK);
  rc = libevdev_new_from_fd(fd, &dev);
  if (rc < 0) {
    fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
    exit(1);
  }
  printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
  printf("Input device ID: bus %#x vendor %#x product %#x\n",
         libevdev_get_id_bustype(dev),
         libevdev_get_id_vendor(dev),
         libevdev_get_id_product(dev));
  flag_tracking_sequential = flag_position_value = flag_touch_one = flag_x_value = flag_tracking_minus_one = 0;
  do {
    struct input_event ev;
    rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
    if (rc == 0) {
      if (ev.type == 3 && ev.code == 57 && ev.value > 0) {
        flag_tracking_sequential = 1;
      }
      if (flag_tracking_sequential && ev.type == 3 && ev.code == 53 ) {
        flag_position_value = 1;
        x_val = ev.value;
      } // the second time button is pressed, NO x_position comes, so for now change button
      if (flag_position_value && ev.type == 1 && ev.code == 330 && ev.value == 1 ) {
        flag_touch_one = 1;
      }

      if (flag_touch_one && ev.type == 3 && ev.code == 0 && ev.value == x_val ) {
        flag_x_value = 1;
      }

      if (flag_x_value && ev.type == 3 && ev.code == 57 && ev.value == -1) {
        flag_tracking_minus_one = 1;
      }
      if (flag_tracking_minus_one && ev.type == 1 && ev.code == 330 && ev.value == 0 ) {
        if (x_val > 699)
            system ("xdotool key Alt+F3");
        flag_tracking_sequential = flag_position_value = flag_touch_one = flag_x_value = flag_tracking_minus_one = 0;
      }
      if ( (ev.type == 3 && ev.code == 54) || (ev.type == 3 && ev.code == 1) ) {
        flag_tracking_sequential = flag_position_value = flag_touch_one = flag_x_value = flag_tracking_minus_one = 0;
      }
    }
    usleep(250 * 1000);// a quarter second {1000 *250}
  } while (rc == 1 || rc == 0 || rc == -EAGAIN);
} //main

some photos of some of our applications running on the tablet

Photo of the OneHandMenu application:



Timeline Photo:



Faena Photo:



lyricus-mode Photo on emacs tui:



lyricus-mode Photo on emacs X-frame:



Picture of rmail and an mbox file:



Conclusion

Why and for what we have done this experiment, what could be the utility in the future? In our case we could use the tablet to make demos of our products. products.

In addition to the fact that we are reusing a product that would fall into disuse, which I imagine many people no longer use and have abandoned at home, if they have not already been sent for recycling. This is how we help ourselves as a society not to generate so much garbage. Although with Android it is still possible to use this tablet with RadioDroid for listening to music streams.

almost forgot: on successful boot using fel-mode

We at kipuamutay have also had success using fel-mode to boot the opipc SBC using a USB-connected external drive.

Last change: 18.07.2023 16:00

blog comments powered by Disqus