I haven't tested yet but on other devices I usually start programs from the serial console or SSH just by adding CLI arguments like this:
FRAMEBUFFER=/dev/fb1 <some command>
I haven't tested yet but on other devices I usually start programs from the serial console or SSH just by adding CLI arguments like this:
FRAMEBUFFER=/dev/fb1 <some command>
The mDNS service aka Zeroconf aka Avahi aka Bonjour is already enabled on the device, so if you have the client tools installed on your PC you can connect in SSH using the .local address like this:
ssh root@M5Core135.local
M5Core135 is the default hostname.
@mgrouch said in CoreMP135 Debian image:
I’m considering buying that CoreMP135 and
I need to make sure I will be able to use CAN Bus interfaces, i2c, uart, USB, Bluetooth, RS485, Both Ethernets and WiFi, as well as
touchscreen of CoreMP135 with the Debian image provided.
AFAIK there is no wifi/BT on this device. Dual ethernet works using the available Debian image though. That image has some defects but I guess this is being sorted out.
You can now build your own image (see post above) but I haven't tried that yet.
When it boots, does it boot into some kind of framebuffer LVGL GUI on 2” touchscreen?
Is there code example how to do that?
If that can help: I recently posted on how to develop Python apps in GTK or QT, using the frame buffer with Xorg/Openbox.
This is roughly the approach I have used for developing on Raspberry PI and other SBCs.
The touch screen work without problem for me.
Hello,
TL;DR: my goal is to develop a GUI application in Python for the MP135, using QT or GTK.
I would like to share the following notes after testing the MP135 for a few days. Hopefully, they can be useful to others, but I would welcome any comments (or criticism).
I have used the Debian Bookworm image (M5_CoreMP135_debian12_20240515), which can be found here.
NB: after burning the image to a SD card, don’t forget to extend the partition. This is easy to do with Gparted as shown below.
I have used a 8 Gb SD card, and the image takes about 1 Gb. Besides, you will need some free space to install a few big packages :)
The final result is a GTK app running in Openbox.
At the moment, I run applications as root user. This is something I would rather avoid in the future. Probably, a few things can be improved as well.
I have used a computer running Linux, so the instructions will be slightly different for Windows users.
You can use a PC with a free USB port as power source for the MP135 and serial console. NB: if the USB port does not deliver enough power, try another.
After one minute, the serial console should be ready, probably mounted under /dev/ttyACM0 but that may vary from one PC to another.
You can run this command before plugging in the device to see the name assigned to the USB serial console on your computer:
sudo dmesg -wT
Example:
[Wed May 29 20:48:54 2024] usb 1-4: new high-speed USB device number 5 using xhci_hcd
[Wed May 29 20:48:54 2024] usb 1-4: New USB device found, idVendor=0525, idProduct=a4a7, bcdDevice= 5.15
[Wed May 29 20:48:54 2024] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed May 29 20:48:54 2024] usb 1-4: Product: Gadget Serial v2.4
[Wed May 29 20:48:54 2024] usb 1-4: Manufacturer: Linux 5.15.118 with 49000000.usb-otg
[Wed May 29 20:48:54 2024] cdc_acm 1-4:2.0: ttyACM0: USB ACM device
[Wed May 29 20:48:54 2024] usbcore: registered new interface driver cdc_acm
[Wed May 29 20:48:54 2024] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
Here we can see that the device name is ttyACM0.
You can now access the console using Minicom or GNU Screen eg.:
screen /dev/ttyACM0 115200
When using the serial console you can adjust the terminal width to fill up your screen, in my case the right dimensions are like this:
stty rows 41 cols 190
Add an entry in: /etc/hosts like this:
127.0.0.1 M5Core135
As per the docs:
In the new version of debian image, the root login permission is turned off by default.
Create a new user, you can use the adduser command for that and possibly usermod after, to put the user in additional groups.
Install MDNS aka zeroconf aka Avahi:
apt install avahi-daemon
Then you can log in to the device over SSH with a .local address instead of IP address eg:
ssh root@M5Core135.local
Before going further, it is a good idea to make sure that the hardware is recognized by Linux and all necessary drivers are loaded.
These commands can be used to test the display using the frame buffer:
(as root)
# write random pixels
cat /dev/urandom > /dev/fb1
# display the M5Stack logo
FRAMEBUFFER=/dev/fb1 fbv /usr/local/m5stack/logo.jpg
apt install libts-bin
apt install evtest
Then:
export TSLIB_FBDEVICE=/dev/fb1
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CONFFILE=/etc/ts.conf
Then you can run the following commands to test the pointer:
ts_test
ts_calibrate
evtest /dev/input/event0
Install:
apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox
NB: I have not found a better way to start X on the LCD screen. For instance:
FRAMEBUFFER=/dev/fb1 startx
still outputs on the external screen instead of the built-in LCD.
My workaround is as follows:
Create a config file with following contents in /usr/share/X11/xorg.conf.d/99-fbdev.conf containing the following:
Section "Device"
Identifier "MP135"
Driver "fbdev"
Option "fbdev" "/dev/fb1"
EndSection
apt install xterm
apt install python3
We current don't use QT5 but to install it:
apt install qtbase5-dev qt5-qmake qtbase5-dev-tools
apt install python3-pyqt5
Install GTK4 on Debian:
apt install libgtk-4-dev
apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0
This is an example of GTK application (hello world).
Code borrowed from the GTK docs. Create file: /root/gtk_demo.py
import sys
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import GLib, Gtk
class MyApplication(Gtk.Application):
def __init__(self):
super().__init__(application_id="com.example.MyGtkApplication")
GLib.set_application_name('My Gtk Application')
def do_activate(self):
window = Gtk.ApplicationWindow(application=self, title="Hello World")
window.present()
app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
Add this line in file /etc/xdg/openbox/autostart
/usr/bin/python3 /root/gtk_demo.py &
Now run startx from the console – the GTK app should appear after a while.
To run the app on startup, add this line at the end of file /etc/rc.local
startx
# or startx -- -nocursor to hide the mouse cursor
Reboot the device to test.
THE END
On a side note and not sure this is a related issue, but I can't seem to shut down the device cleanly. I have tried: shutdown, poweroff, halt and the device always reboots instead of shutting down.
I am currently writing an Ansible playbook to automate the customization of my device, and some things like setting the time zone don't work for the reason described above. Hopefully this can get fixed soon.
I am also working on the LCD screen, as I would prefer to use Python rather than the proposed C environment.