<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2021-06-20T23:03:14+00:00</updated><id>/feed.xml</id><title type="html">My personal notes</title><subtitle>Mikhail Anisimov's personal notes. Mostly about system and embedded programming.</subtitle><entry><title type="html">Mess</title><link href="/jekyll/update/2020/11/27/mess.html" rel="alternate" type="text/html" title="Mess" /><published>2020-11-27T08:00:00+00:00</published><updated>2020-11-27T08:00:00+00:00</updated><id>/jekyll/update/2020/11/27/mess</id><content type="html" xml:base="/jekyll/update/2020/11/27/mess.html">&lt;h1 id=&quot;tools-to-study-later&quot;&gt;Tools to study later:&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;clang-format

lizard - code complexity
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">Tools to study later:</summary></entry><entry><title type="html">Emacs</title><link href="/jekyll/update/2020/11/19/emacs.html" rel="alternate" type="text/html" title="Emacs" /><published>2020-11-19T14:23:00+00:00</published><updated>2020-11-19T14:23:00+00:00</updated><id>/jekyll/update/2020/11/19/emacs</id><content type="html" xml:base="/jekyll/update/2020/11/19/emacs.html">&lt;p&gt;Toggle comment:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;M-;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;My config files:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/files/blank-mode.el&quot;&gt;blank mode&lt;/a&gt;
&lt;a href=&quot;/files/init.el&quot;&gt;init&lt;/a&gt;
&lt;a href=&quot;/files/emacs&quot;&gt;emacs&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">Toggle comment:</summary></entry><entry><title type="html">Raspberry Pi</title><link href="/jekyll/update/2020/11/15/raspberrypi.html" rel="alternate" type="text/html" title="Raspberry Pi" /><published>2020-11-15T11:09:00+00:00</published><updated>2020-11-15T11:09:00+00:00</updated><id>/jekyll/update/2020/11/15/raspberrypi</id><content type="html" xml:base="/jekyll/update/2020/11/15/raspberrypi.html">&lt;h1 id=&quot;this-post-is-about-raspberry-pi-model-b&quot;&gt;This post is about Raspberry Pi Model B+.&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/
https://www.valvers.com/open-software/raspberry-pi/bare-metal-programming-in-c-part-1/
https://azeria-labs.com/emulate-raspberry-pi-with-qemu/
https://wiki.qemu.org/Documentation/Platforms/ARM
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;qemu&quot;&gt;QEMU:&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./qemu-system-arm -s -S -m 512 -M raspi1ap -serial stdio -kernel /home/mih/projects/Raspberry/bare-metal-pi/output/rasppi.elf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;interrupts&quot;&gt;Interrupts:&lt;/h1&gt;

&lt;p&gt;Interrupt vectors are not loaded by bootloader, because they are at 0x00000000, and bootloader loads kernel image to 0x00008000. Vectors must be copied to 0x0 at runtime.&lt;/p&gt;

&lt;p&gt;QEMU behaves differently and doesn’t have this issue. It copies .text section of the elf file, which contains address information and can serve as the source of the interrupt vectors table.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://www.valvers.com/open-software/raspberry-pi/bare-metal-programming-in-c-part-4/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">This post is about Raspberry Pi Model B+.</summary></entry><entry><title type="html">QEMU, ARM and two smoking barrels.</title><link href="/jekyll/update/2020/11/05/qemu_arm.html" rel="alternate" type="text/html" title="QEMU, ARM and two smoking barrels." /><published>2020-11-05T13:23:00+00:00</published><updated>2020-11-05T13:23:00+00:00</updated><id>/jekyll/update/2020/11/05/qemu_arm</id><content type="html" xml:base="/jekyll/update/2020/11/05/qemu_arm.html">&lt;h2 id=&quot;static-and-dynamic-libraries&quot;&gt;Static and dynamic libraries&lt;/h2&gt;

&lt;p&gt;As I understood, QEMU (user-space QEMU, e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu-arm&lt;/code&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu-user&lt;/code&gt; package) requires dynamicaly linked libraries for the target architecture installed on the host.&lt;/p&gt;

&lt;p&gt;There is possibility to link all libraries statically and run it with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu-arm-static&lt;/code&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu-user-static&lt;/code&gt; debian package.&lt;/p&gt;

&lt;p&gt;gcc flag &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-static&lt;/code&gt; is used to make statically linked binary.&lt;/p&gt;

&lt;h2 id=&quot;cross-compilation&quot;&gt;Cross compilation&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;arm-linux-gnueabi-gcc-8 -g3 -static mess.c -march=armv7 -o mess

aarch64-linux-gnu-gcc -g3 -static mess.c -mcpu=cortex-a53 -o mess
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;debugging&quot;&gt;Debugging&lt;/h2&gt;

&lt;p&gt;Start process on the cortex-a7 emulator and open GDB server on port 1234:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;qemu-arm-static -g 1234 mess -cpu cortex-a7

qemu-aarch64-static -g 1234 mess -cpu cortex-a53
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Attach gdb:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gdb-multiarch

&amp;gt; file mess
&amp;gt; target remote localhost:1234
&amp;gt; b main
&amp;gt; c
&amp;gt; next
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">Static and dynamic libraries</summary></entry><entry><title type="html">Jekyll</title><link href="/jekyll/update/2020/10/02/Jekyll.html" rel="alternate" type="text/html" title="Jekyll" /><published>2020-10-02T17:02:00+00:00</published><updated>2020-10-02T17:02:00+00:00</updated><id>/jekyll/update/2020/10/02/Jekyll</id><content type="html" xml:base="/jekyll/update/2020/10/02/Jekyll.html">&lt;p&gt;Build locally:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; bundle exec jekyll serve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After gem file chnaged:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; bundle update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">Build locally:</summary></entry><entry><title type="html">Tools Installation</title><link href="/jekyll/update/2020/10/02/tools_installation.html" rel="alternate" type="text/html" title="Tools Installation" /><published>2020-10-02T17:02:00+00:00</published><updated>2020-10-02T17:02:00+00:00</updated><id>/jekyll/update/2020/10/02/tools_installation</id><content type="html" xml:base="/jekyll/update/2020/10/02/tools_installation.html">&lt;h2 id=&quot;linux&quot;&gt;Linux&lt;/h2&gt;
&lt;h1 id=&quot;meld&quot;&gt;Meld&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;/files/meld-compare.py&quot;&gt;Caja extension&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;caja-mate-desktop&quot;&gt;Caja (MATE desktop):&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://www.giuspen.com/nautilus-pyextensions/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Put here:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/home/mih/.local/share/caja-python/extensions
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After changes:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;killall caja
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;windows&quot;&gt;Windows&lt;/h2&gt;
&lt;h1 id=&quot;meld-1&quot;&gt;Meld&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;http://meldmerge.org/
https://sourceforge.net/projects/diff-ext/files/Binaries/1.9.1/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">Linux Meld Caja extension</summary></entry><entry><title type="html">GDB cheat sheet</title><link href="/jekyll/update/2020/10/01/GDB.html" rel="alternate" type="text/html" title="GDB cheat sheet" /><published>2020-10-01T17:02:00+00:00</published><updated>2020-10-01T17:02:00+00:00</updated><id>/jekyll/update/2020/10/01/GDB</id><content type="html" xml:base="/jekyll/update/2020/10/01/GDB.html">&lt;p&gt;Load symbols from file (mess):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; file mess
Reading symbols from mess...done.
&amp;gt; target exec mess
&amp;gt; b main
&amp;gt; r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Renesas simulator:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; file rx52n.elf
&amp;gt; target sim
&amp;gt; load
&amp;gt; b main
&amp;gt; r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Script from file:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gdb -x mess.gdb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Script from file (CLI):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; source mess_gdb.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Python API for scripts (https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html#Python-API)&lt;/p&gt;

&lt;p&gt;Pause running process:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; [CTRL+C]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;TUI:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; [CTRL+x+a]
&amp;gt; layout asm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Print:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; p/x $x30 - hex
&amp;gt; p/t $x30 - binary
&amp;gt; p/d $x30 - decimal
&amp;gt; display/x $x30 - print after each gdb stop
&amp;gt; i r x30
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">Load symbols from file (mess):</summary></entry><entry><title type="html">Welcome to Jekyll!</title><link href="/jekyll/update/2020/05/09/welcome-to-jekyll.html" rel="alternate" type="text/html" title="Welcome to Jekyll!" /><published>2020-05-09T21:09:58+00:00</published><updated>2020-05-09T21:09:58+00:00</updated><id>/jekyll/update/2020/05/09/welcome-to-jekyll</id><content type="html" xml:base="/jekyll/update/2020/05/09/welcome-to-jekyll.html">&lt;p&gt;You’ll find this post in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt;, which launches a web server and auto-regenerates your site when a file is updated.&lt;/p&gt;

&lt;p&gt;Jekyll requires blog post files to be named according to the following format:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YEAR-MONTH-DAY-title.MARKUP&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YEAR&lt;/code&gt; is a four-digit number, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MONTH&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAY&lt;/code&gt; are both two-digit numbers, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MARKUP&lt;/code&gt; is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.&lt;/p&gt;

&lt;p&gt;Jekyll also offers powerful support for code snippets:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hi, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Tom'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#=&amp;gt; prints 'Hi, Tom' to STDOUT.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Check out the &lt;a href=&quot;https://jekyllrb.com/docs/home&quot;&gt;Jekyll docs&lt;/a&gt; for more info on how to get the most out of Jekyll. File all bugs/feature requests at &lt;a href=&quot;https://github.com/jekyll/jekyll&quot;&gt;Jekyll’s GitHub repo&lt;/a&gt;. If you have questions, you can ask them on &lt;a href=&quot;https://talk.jekyllrb.com/&quot;&gt;Jekyll Talk&lt;/a&gt;.&lt;/p&gt;</content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html">You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.</summary></entry></feed>