<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Running Python GUI apps on CoreMP135 with Debian]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto"><strong>TL;DR</strong>: my goal is to develop a GUI application in Python for the MP135, using QT or GTK.</p>
<p dir="auto">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).</p>
<p dir="auto">I have used the <strong>Debian Bookworm</strong> image (M5_CoreMP135_debian12_20240515), which can be found <a href="https://docs.m5stack.com/en/guide/linux/coremp135/image" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">NB: after burning the image to a SD card, don’t forget to <strong>extend the partition</strong>. This is easy to do with Gparted as shown below.<br />
<img src="https://ibb.co/zSc3Vtk" alt="Gparted" class=" img-fluid img-markdown" /></p>
<p dir="auto">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 :)</p>
<p dir="auto">The final result is a <strong>GTK</strong> app running in <strong>Openbox</strong>.</p>
<p dir="auto">At the moment, I run applications as <strong>root</strong> user. This is something I would rather avoid in the future. Probably, a few things can be improved as well.</p>
<p dir="auto">I have used a computer running <strong>Linux</strong>, so the instructions will be slightly different for Windows users.</p>
<h1>Serial console</h1>
<p dir="auto">You can use a PC with a free USB port as <strong>power source</strong> for the MP135 and <strong>serial console</strong>. NB: if the USB port does not deliver enough power, try another.<br />
After one minute, the serial console should be ready, probably mounted under /dev/ttyACM0 but that may vary from one PC to another.</p>
<p dir="auto">You can run this command <em>before</em> plugging in the device to see the name assigned to the USB serial console on your computer:</p>
<pre><code>sudo dmesg -wT
</code></pre>
<p dir="auto">Example:</p>
<pre><code>[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
</code></pre>
<p dir="auto">Here we can see that the device name is ttyACM0.<br />
You can now access the console using Minicom or GNU Screen eg.:</p>
<pre><code>screen /dev/ttyACM0 115200
</code></pre>
<p dir="auto">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:</p>
<pre><code>stty rows 41 cols 190
</code></pre>
<h1>Configure hostname</h1>
<p dir="auto">Add an entry in: /etc/hosts like this:</p>
<pre><code>127.0.0.1       M5Core135
</code></pre>
<h1>SSH configuration</h1>
<p dir="auto">As per the <a href="https://docs.m5stack.com/en/guide/linux/coremp135/develop" target="_blank" rel="noopener noreferrer nofollow ugc">docs</a>:<br />
<em>In the new version of debian image, the root login permission is turned off by default.</em></p>
<p dir="auto">Create a new user, you can use the adduser command for that and possibly usermod after, to put the user in additional groups.</p>
<h1>Optional: MDNS</h1>
<p dir="auto">Install MDNS aka zeroconf aka Avahi:</p>
<pre><code>apt install avahi-daemon
</code></pre>
<p dir="auto">Then you can log in to the device over SSH with a .local address instead of IP address eg:</p>
<pre><code>ssh root@M5Core135.local
</code></pre>
<h1>Testing the LCD screen and the touch device</h1>
<p dir="auto">Before going further, it is a good idea to make sure that the hardware is recognized by Linux and all necessary drivers are loaded.</p>
<h2>LCD screen</h2>
<p dir="auto">These commands can be used to test the display using the frame buffer:<br />
(as root)</p>
<pre><code># write random pixels
cat /dev/urandom &gt; /dev/fb1

# display the M5Stack logo
FRAMEBUFFER=/dev/fb1 fbv /usr/local/m5stack/logo.jpg
</code></pre>
<h2>Touch device</h2>
<pre><code>apt install libts-bin
apt install evtest
</code></pre>
<p dir="auto">Then:</p>
<pre><code>export TSLIB_FBDEVICE=/dev/fb1
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CONFFILE=/etc/ts.conf
</code></pre>
<p dir="auto">Then you can run the following commands to test the pointer:</p>
<pre><code>ts_test

ts_calibrate

evtest /dev/input/event0
</code></pre>
<h1>Install Openbox</h1>
<p dir="auto">Install:</p>
<pre><code>apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox
</code></pre>
<h1>Force X to use fb1</h1>
<p dir="auto">NB: I have not found a better way to start X on the LCD screen. For instance:</p>
<pre><code>FRAMEBUFFER=/dev/fb1 startx
</code></pre>
<p dir="auto">still outputs on the external screen instead of the built-in LCD.<br />
My workaround is as follows:<br />
Create a config file with following contents in /usr/share/X11/xorg.conf.d/99-fbdev.conf containing the following:</p>
<pre><code>Section "Device"  
  Identifier "MP135"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection
</code></pre>
<h1>Create a sample Python app</h1>
<h2>Install some tools and dependencies</h2>
<pre><code>apt install xterm
</code></pre>
<h2>Install Python</h2>
<pre><code>apt install python3
</code></pre>
<h2>Install QT (optional)</h2>
<p dir="auto">We current don't use QT5 but to install it:</p>
<pre><code>apt install qtbase5-dev qt5-qmake qtbase5-dev-tools
apt install python3-pyqt5
</code></pre>
<h2>GTK</h2>
<p dir="auto">Install GTK4 on Debian:</p>
<pre><code>apt install libgtk-4-dev
apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0
</code></pre>
<h1>Create a test app</h1>
<p dir="auto">This is an example of GTK application (hello world).<br />
Code borrowed from the <a href="https://pygobject.gnome.org/getting_started.html#ubuntu-getting-started" target="_blank" rel="noopener noreferrer nofollow ugc">GTK docs</a>. Create file: /root/gtk_demo.py</p>
<pre><code>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)
</code></pre>
<p dir="auto">Add this line in file /etc/xdg/openbox/autostart</p>
<pre><code>/usr/bin/python3 /root/gtk_demo.py &amp;
</code></pre>
<p dir="auto">Now run startx from the console – the GTK app should appear after a while.</p>
<h1>Final steps</h1>
<p dir="auto">To run the app on startup, add this line at the end of file /etc/rc.local</p>
<pre><code>startx
# or startx -- -nocursor to hide the mouse cursor
</code></pre>
<p dir="auto">Reboot the device to test.</p>
<p dir="auto"><strong>THE END</strong></p>
]]></description><link>https://community.m5stack.com/topic/6513/running-python-gui-apps-on-coremp135-with-debian</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 23:51:07 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6513.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 May 2024 22:01:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Mon, 20 Jan 2025 06:03:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/19116">@EricB</a> said in <a href="/post/27946">Running Python GUI apps on CoreMP135 with Debian</a>:</p>
<blockquote>
<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/443">@ajb2k3</a><br />
Awesome demo ! thanks .<br />
Any advice on "softer" way to reload an updated GTK app ?</p>
<p dir="auto">been using "reboot" and "kill &lt;proces num&gt;"<br />
I haven't gotten that far yet, still working on backend information</p>
</blockquote>
]]></description><link>https://community.m5stack.com/post/27949</link><guid isPermaLink="true">https://community.m5stack.com/post/27949</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Mon, 20 Jan 2025 06:03:00 GMT</pubDate></item><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Sun, 19 Jan 2025 22:54:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/443">@ajb2k3</a><br />
Awesome demo ! thanks .<br />
Any advice on "softer" way to reload an updated GTK app ?</p>
<p dir="auto">been using "reboot" and "kill &lt;proces num&gt;"</p>
<p dir="auto">most of my experience on linux has been backend with CLI only ...<br />
otherwise ESP32 with micropython/circuitpython for display management</p>
<p dir="auto">Thx<br />
will certainly look for your facebook material</p>
]]></description><link>https://community.m5stack.com/post/27946</link><guid isPermaLink="true">https://community.m5stack.com/post/27946</guid><dc:creator><![CDATA[EricB]]></dc:creator><pubDate>Sun, 19 Jan 2025 22:54:49 GMT</pubDate></item><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Fri, 17 Jan 2025 16:41:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/19116">@EricB</a> if you are on Facebook you can find a free sample of my books as well as some write up on <a href="http://hackster.io" target="_blank" rel="noopener noreferrer nofollow ugc">hackster.io</a></p>
]]></description><link>https://community.m5stack.com/post/27930</link><guid isPermaLink="true">https://community.m5stack.com/post/27930</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Fri, 17 Jan 2025 16:41:01 GMT</pubDate></item><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Fri, 17 Jan 2025 13:43:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/443">@ajb2k3</a> You were darn right about not reading the instructions.<br />
I found them minutes after my post...<br />
I've been using pretty much all other M5 products for which I accessed from the "Store"/&lt;product&gt; --&gt; Documents link at the bottom</p>
<p dir="auto">Using the same link for MP135 doesn't bring the usefull link you mention :<br />
<a href="https://docs.m5stack.com/en/core/M5CoreMP135" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/core/M5CoreMP135</a></p>
<p dir="auto">THIS ONE should be added to the previous: <a href="https://docs.m5stack.com/en/guide/linux/coremp135/image" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/guide/linux/coremp135/image</a></p>
<p dir="auto">Thank you for feeding my addiction ! ...<br />
I am now officially sleep deprived !</p>
]]></description><link>https://community.m5stack.com/post/27927</link><guid isPermaLink="true">https://community.m5stack.com/post/27927</guid><dc:creator><![CDATA[EricB]]></dc:creator><pubDate>Fri, 17 Jan 2025 13:43:51 GMT</pubDate></item><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Thu, 16 Jan 2025 20:30:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/19116">@EricB</a> I'm going to have to Ask this but Did you read the instructions?<br />
I know I didn't and missed the command!</p>
<p dir="auto">In the root folder run :</p>
<pre><code>./user/local/m5stack/resize_mmc.sh
</code></pre>
]]></description><link>https://community.m5stack.com/post/27919</link><guid isPermaLink="true">https://community.m5stack.com/post/27919</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Thu, 16 Jan 2025 20:30:21 GMT</pubDate></item><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Thu, 16 Jan 2025 18:10:20 GMT]]></title><description><![CDATA[<p dir="auto">I am one of those other lame-Windows guys which can't run Gparted from a WSL ( access to raw disk )...</p>
<p dir="auto">Any advices on extending the partition just with the pre-mounted packages of the "images" found  with your link ?</p>
<p dir="auto">The 3x Debian builds do not even have 'parted' installed and executing apt-get update BEFORE extending the partiotion extension doesn't leave enough room to install parted ,,,<br />
I tried  a few times using fdisk directly but the result is always the same -&gt; bricked<br />
--&gt; mandatory BelenaEtcher  sdcard</p>
<blockquote>
<p dir="auto">fdisk -l  ( results )<br />
Device                     Start          End     Sectors  Size Type<br />
/dev/mmcblk0p1    34              200          167 83.5K Linux filesystem<br />
/dev/mmcblk0p2    201            367          167 83.5K Linux filesystem<br />
/dev/mmcblk0p3    368          3385        3018  1.5M Linux filesystem<br />
/dev/mmcblk0p4    3386        7481        4096    2M Linux filesystem<br />
/dev/mmcblk0p5    7482   2104633 2097152    1G Linux filesystem<br />
root@CoreMP135:~#</p>
</blockquote>
<p dir="auto">-deleted last partition ( p5 )</p>
<ul>
<li>created new parttion<br />
start @ 7482<br />
End   @ default much large value presented<br />
type  @ default</li>
<li>write  ( save )</li>
</ul>
<blockquote>
<p dir="auto">reboot</p>
</blockquote>
<p dir="auto">BRICKED !</p>
<p dir="auto">any advice ?<br />
So close ( but still so far .... ) to getting to start using my CoreMp135 !  :-)</p>
]]></description><link>https://community.m5stack.com/post/27918</link><guid isPermaLink="true">https://community.m5stack.com/post/27918</guid><dc:creator><![CDATA[EricB]]></dc:creator><pubDate>Thu, 16 Jan 2025 18:10:20 GMT</pubDate></item><item><title><![CDATA[Reply to Running Python GUI apps on CoreMP135 with Debian on Thu, 30 May 2024 04:35:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/114023">@prima</a> Thanks for this.</p>
]]></description><link>https://community.m5stack.com/post/25428</link><guid isPermaLink="true">https://community.m5stack.com/post/25428</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Thu, 30 May 2024 04:35:47 GMT</pubDate></item></channel></rss>