Table of Contents
Linux on Sharp Brain
I have much interest in this kind of devices. The Sharp Brain is electronic dictionary for Japanese people to learn English. But it's kind of computer. Some time ago I bought six of them. Since I do not understand Japanese at all, and everything about these devices is described only in Japanese, here I will describe the essentials of how to run and use the GNU/Linux system. I will also try to find out what can be done with the device and software.
Presentation of running Linux on Sharp brain devices can be found here (english translation) and original (Japanese) here.
Build
You will need Linux Computer or Virtual Machine with Debian 10 (Buster) or Ubuntu 20.04 LTS. Keep note i will use build configuration for Sharp Brain PW-SA2 (3rd generation model) in this tutorial.
Install the required packages to make your system as build host:
sudo apt install build-essential bison flex libncurses5-dev gcc-arm-linux-gnueabi debootstrap qemu-user-static \ gcc-arm-linux-gnueabihf libssl-dev bc lzop qemu-user-static kpartx
Clone the repository to your machine:
git clone --recursive https://github.com/brain-hackers/buildbrain.git
Prepare the build configuration:
cd buildbrain make udefconfig-sh2 # you can use udefconfig-sh3 if your model is SH3 or so
Now build the boot loader:
make ubuild make nkbin-maker make nk.bin
Build Linux distribution:
make ldefconfig # generates Linux .config make lbuild # builds Linux kernel make aptcache # this is the last command in current terminal it stays in the background
As you missed my last # comment, you have to leave last command running in the current terminal and open new terminal or tab.
You can add your own debian packages to the default install by editing file os-brainux/setup_brainux.sh at line 80 you can put something like:
apt install -y dialog sudo \ libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev \ xserver-xorg xserver-xorg-video-fbdev xserver-xorg-dev xserver-xorg-input-evdev xinput-calibrator xorg-dev x11-apps xi> openbox obconf jwm \ weston xwayland \ bash tmux vim htop \ midori pcmanfm lxterminal xterm gnome-terminal fbterm uim-fep uim-anthy fonts-noto-cjk \ dbus udev alsa-utils usbutils iw fake-hwclock systemd-timesyncd\ build-essential flex bison pkg-config autotools-dev libtool autoconf automake device-tree-compiler mc \ python3 python3-dev python3-setuptools python3-wheel python3-pip python3-smbus \ resolvconf net-tools ssh openssh-server openssh-client avahi-daemon wget git \ network-manager zip neofetch sl python3-numpy ipython3 netsurf-gtk fcitx-anthy \ neofetch net-tools # your packages
When continue with building the distribution: make brainux
Now after you have finished making the Linux distribution move to the next section..
Setup MicroSD Card
NOTE! This procedure will erase the contents of the SD card. Always make a backup before doing this.
NOTE2! If your Linux distribution automatically mounts the MicroSD card, then make sure to unmount it before proceeding..
umount /dev/sdb1 # where your sd is located
Install gparted in your system:
sudo apt install gparted
Launch gparted:
sudo gparted
Change disk to your MicroSD card
Delete all partitions on the MicroSD card..
Create a FAT32 partition of about 100MB. For my setup i will use 2GB FAT32 partition, because i have 32GB MicroSD card and it's a lot of space.
The rest of the space we will use for the EXT4 file system (For Linux).
Now the MicroSD card file systems layout should look like this:
Click Apply All Operations.
Install
Mount file systems from newly created MicroSD card:
mkdir /mnt/sd{1,2} mount /dev/sdb1 /mnt/sd1 # FAT32 mount /dev/sdb2 /mnt/sd2 # EXT4
Copy Linux distribution to EXT4 partition:
sudo cp -ar ./brainux/* /mnt/sd2/
Copy Linux Kernel files to FAT32 partition:
cp linux-brain/arch/arm/boot/zImage /mnt/sd1/ cp linux-brain/arch/arm/boot/dts/imx28-pwsh2.dtb /mnt/sd1
The imx28-pwsh2.dtb depends on the model you have. You can use (pwsh1,pwsh2,pwsh3,pwsh4,pwsh5,pwsh6,pwsh7).
Of course you can copy them all:
cp linux-brain/arch/arm/boot/dts/imx28-pwsh{1,2,3,4,5,6,7}.dtb /mnt/sd1/
Now, there is no longer need to load Linux from Windows CE environment, it can be loaded directly when the device is booting by nk.bin.
Copy bootloader files:
cp u-boot-brain/u-boot.sb /mnt/sd1/ cp u-boot-brain/u-boot.bin /mnt/sd1/
So please Copy nk.bin to /mnt/sd1/(`ed[a-z]{2}[0-9]exe.bin`) filename for the specific model in this table.. Mine is SX2:
cp nk.bin /mnt/sd1/EDSA2EXE.BIN
Model | File name |
---|---|
PW-G5300 | EDNA3EXE.BIN |
PW-Sx1 | EDSA1EXE.BIN |
PW-Sx2 | EDSA2EXE.BIN |
PW-Sx3 | EDSA3EXE.BIN |
PW-Sx4 | EDSH4EXE.BIN |
PW-Sx5 | EDSA5EXE.BIN |
PW-Sx6 | EDSA6EXE.BIN |
PW-Sx7 | EDSA7EXE.BIN |
Umount the MicroSD card partitions:
umount /dev/sdb{1,2}
Now you are ready to run
Run
Insert MicroSD card to the Sharp Brain and reset device. Then prompted for the username/password use these:
user:brain
Keyboard Layout
Swap
dd if=/dev/zero of=/swapfile bs=1M count=256 # 256MB Swap file mkswap /swapfile swapon /swapfile echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
MicroUSB OTG Cables
Brainux defaults to the USB controller acting as a host. With an OTG cable you can connect any device you like. Brain itself doesn't have the ability to supply his VBUS (5V), so you'll need to use an OTG cable that can be powered separately.
USB Ethernet
Just by connecting a PC that can connect to the Internet and Brain, you can go out to the Internet from Brain and SSH in both directions between the PC and Brain. No need to worry about running out of battery. By default, Brain's USB controller acts as a host, so it cannot act as a device. There are way to switch the operating mode of the controller: using a tool called brain-config.
sudo brain-config sudo reboot
Internet Sharing script for Linux machine
- wlx74da38f5c024 → wifi interface or interface where internet is provided
- usb0 → is the usb cable connected to the sharp brain
#!/bin/sh iptables --table nat -A POSTROUTING --out-interface wlx74da38f5c024 -j MASQUERADE iptables -A FORWARD --in-interface wlx74da38f5c024 -j ACCEPT echo 1 > /proc/sys/net/ipv4/ip_forward ifconfig usb0 down ifconfig usb0 192.168.7.1 ifconfig usb0 up dnsmasq -d -i usb0 \ --filterwin2k -p0 --dhcp-range=192.168.7.2,192.168.7.20 \ -O 3,192.168.7.1 -O 6,1.1.1.1 --log-dhcp --server=8.8.8.8 --server=8.8.4.4 \ --dhcp-lease-max=253 --dhcp-authoritative
Save it to brain.sh and provide executable permissions:
chmod +x brain.sh
When ready to share internet to the Sharp brain, just execute it:
./brain.sh
Internet Sharing on Windows/Mac machine
Read auto translated tutorial here
Dosbox under Brainux
You should add dosbox package when building brainux from scratch.. See the build section of this tutorial.
export SDL_NOMOUSE=1 dosbox
Some buttons are not binded correctly, i'm working on the solution right now.
Same big parts of this tutorial where translated from the original Japanese wiki about the Sharp Brain.
Greetings are flying out to brain-hackers