<?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="https://kibihrchak.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kibihrchak.github.io/" rel="alternate" type="text/html" /><updated>2022-01-10T20:36:03+00:00</updated><id>https://kibihrchak.github.io/feed.xml</id><title type="html">Kibihrchak’s Best Webpage</title><subtitle>Articles on tech, embedded and stuff.</subtitle><author><name>Marko Oklobdžija</name></author><entry><title type="html">VS Code Remote Development</title><link href="https://kibihrchak.github.io/articles/2022/01/10/vscode-remote-development.html" rel="alternate" type="text/html" title="VS Code Remote Development" /><published>2022-01-10T00:00:00+00:00</published><updated>2022-01-10T00:00:00+00:00</updated><id>https://kibihrchak.github.io/articles/2022/01/10/vscode-remote-development</id><content type="html" xml:base="https://kibihrchak.github.io/articles/2022/01/10/vscode-remote-development.html">&lt;p&gt;When remote work is not enough.&lt;/p&gt;

&lt;h2 id=&quot;initial-encounter-with-vs-code-remote-development&quot;&gt;Initial Encounter with VS Code Remote Development&lt;/h2&gt;

&lt;p&gt;During the past week I gave &lt;a href=&quot;https://code.visualstudio.com/docs/remote/remote-overview&quot;&gt;VS Code Remote
Development&lt;/a&gt;
a try, mainly to see how it would work with a build environment set up
in a Docker container. Victim for this was &lt;a href=&quot;https://github.com/kibihrchak/kibihrchak.github.io&quot;&gt;this blog
repo&lt;/a&gt;, so the work
went in setting up an image with Jekyll/GitHub Pages, and feeding it
this repo’s content to inspect the locally generated output.&lt;/p&gt;

&lt;p&gt;First try went with using the Docker Desktop on the Windows host. But,
it appeared that running Docker Desktop relies on Hyper-V being enabled,
and that brought its own set of issues, &lt;a href=&quot;https://forums.virtualbox.org/viewtopic.php?t=90853&quot;&gt;in particular with
VirtualBox&lt;/a&gt;. With
that encountered, I’ve moved the Docker installation to the VirtualBox
Ubuntu VM with an idea to run VS Code there (better something than
nothing). But, as it happened, VS Code offers an option &lt;a href=&quot;https://code.visualstudio.com/docs/remote/containers#_open-a-folder-on-a-remote-ssh-host-in-a-container&quot;&gt;to remotely
connect to a container through
SSH&lt;/a&gt;.
This allowed me at the end to have the following setup which
surprisingly enough works without a hitch:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;VS Code runs on the Windows host.&lt;/li&gt;
  &lt;li&gt;It can SSH to the Ubuntu VirtualBox VM and open up workspaces there.&lt;/li&gt;
  &lt;li&gt;Furthermore, it can run a Docker container in the said VM and work
on a workspace inside of it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;common-development-interface&quot;&gt;Common Development Interface&lt;/h2&gt;

&lt;p&gt;The most significant benefit of this setup for me is the ability to use
the common development interface, but tailored to the peculiarities of
the particular project. This kind of setup before required either -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Doing the development on the same base system, which led to the
overlapping of development environment setups (needed software, VS
Code extensions), or&lt;/li&gt;
  &lt;li&gt;Having multiple instances of VS Code deployed in independent
development environments, which then required repeated base setup of
VS Code, and introduced an effort for keeping this base setup same
between all environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this remote development setup, it is possible to use the same,
&lt;em&gt;host-based&lt;/em&gt; instance of VS Code, and then have separate configurations
for each &lt;em&gt;independent&lt;/em&gt; development environment. First point allows for
the speed and convenience of doing the work from the host-based
interface, and not having to run the VS Code through virtual machine
instances. Second point means that the development environments are not
mashed together which complicates provisioning and gives opportunity for
environment collisions.&lt;/p&gt;

&lt;p&gt;In this vein, an ideal development setup for me should be looking
something like this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Have the base VS Code setup on the host system for host-related
projects (that is, text-based projects, or the software projects
intended to be ran on the host system).&lt;/li&gt;
  &lt;li&gt;For each non-host project, their build/test environment is set up in
an isolated fashion through Docker.&lt;/li&gt;
&lt;/ol&gt;</content><author><name>Marko Oklobdžija</name></author><category term="articles" /><category term="vs-code" /><category term="remote-development" /><category term="development-environment" /><summary type="html">When remote work is not enough.</summary></entry><entry><title type="html">Mobile Phone Cameras</title><link href="https://kibihrchak.github.io/articles/2021/11/13/mobile-phone-cameras.html" rel="alternate" type="text/html" title="Mobile Phone Cameras" /><published>2021-11-13T00:00:00+00:00</published><updated>2021-11-13T00:00:00+00:00</updated><id>https://kibihrchak.github.io/articles/2021/11/13/mobile-phone-cameras</id><content type="html" xml:base="https://kibihrchak.github.io/articles/2021/11/13/mobile-phone-cameras.html">&lt;p&gt;The best camera mode is the one you have on your phone.&lt;/p&gt;

&lt;h2 id=&quot;leveraging-computational-photography&quot;&gt;Leveraging Computational Photography&lt;/h2&gt;

&lt;p&gt;Some day ago I’ve listened to the &lt;a href=&quot;https://youtu.be/iXVdeYbgEvQ?t=1290&quot;&gt;MKBHD’s podcast on Pixel
6&lt;/a&gt; and heard about the new photo
modes introduced in this new lineup of Pixel phones. That got me
thinking on the overall development of mobile photography, and how it
managed to improve and get to the state where it is today.&lt;/p&gt;

&lt;p&gt;I mean, the mobile phone photography compared to the conventional one is
at a clear disadvantage when compared to the conventional one due to the
physical limitations on what you can fit in the mobile phone form
factor. This results in mobile phones having a &lt;a href=&quot;https://en.wikipedia.org/wiki/Image_sensor_format#Table_of_sensor_formats_and_sizes&quot;&gt;smaller sensor
size&lt;/a&gt;
and smaller equivalent aperture, and consequently resulting in photos
lacking depth of field and being noisier when compared to the
conventional camera counterpart ones, in addition to being limited to a
single focal length (there’s a &lt;a href=&quot;https://www.youtube.com/watch?v=hi_CkZ0sGAw&quot;&gt;great video explaining the senosr size
differences by Tony &amp;amp; Chelsea
Northrup&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So, what changed here that allowed us to move from potato cell phone
photos to what we have today? Sensor size and resolution increased
during time, alright, but aside from that two other things occured.
First one was brute-forcing the way around the fixed focal length
limitation by introducing multi-camera setup with each camera having its
own optics stack. But, what is more important to me here is the other
approach to achieving better photos, and that is through the
computational photography (CP), the ability to infer more information
about the photo and then improve it, either by computer vision, image
stacking, or sensor fusion.&lt;/p&gt;

&lt;p&gt;Here the current application examples that come to my mind are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The subject isolation, basically emulating depth of field of larger
lenses by blurring the “out-of-focus” image areas either by
recognizing the subject on the image, or &lt;a href=&quot;https://lux.camera/iphone-12-camera-review/&quot;&gt;using LIDAR to create a
scene depth map&lt;/a&gt;,&lt;/li&gt;
  &lt;li&gt;HDR, stacking different exposure photos of the same scene to achieve
the greater dynamic range,&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.androidauthority.com/what-is-night-mode-and-how-does-it-work-979590/&quot;&gt;Night&lt;/a&gt;
and &lt;a href=&quot;https://petapixel.com/2021/11/04/google-pixel-6-pro-astrophotography-review-stellar-results/&quot;&gt;astrophotography
modes&lt;/a&gt;
as a follow-up to the HDR,&lt;/li&gt;
  &lt;li&gt;Automated panoramic stitching, although in the recent years
ultrawide camera setups replaced this mode for getting the wide lens
camera shots,&lt;/li&gt;
  &lt;li&gt;Improved digital zoom, where instead of having only one photo,
&lt;a href=&quot;https://ai.googleblog.com/2018/10/see-better-and-further-with-super-res.html&quot;&gt;multiple photos are stacked to resolve additional detail from
digitally zoomed
photo&lt;/a&gt;,&lt;/li&gt;
  &lt;li&gt;Most recently, Pixel 6 introduced &lt;a href=&quot;https://youtu.be/Kp1P4S-WgvU?t=451&quot;&gt;motion photo
modes&lt;/a&gt; for getting the panning
and long exposure shots.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;camera-as-a-code&quot;&gt;Camera as a Code&lt;/h2&gt;

&lt;p&gt;One important aspect of the CP is that the resulting image content is
not determined anymore only by the raw captured data, but by what can be
extracted out of it, and what can be retrieved from other photos and
other sensors. Thus, it is subject to change as the processing
mechanisms gets updated, allowing for better photos or even further
modes.&lt;/p&gt;

&lt;p&gt;Ofc, the limiting factor here are the phone processing capabilities,
because if image processing takes too long it would deteriorate the user
experience. That’s the reason that new features &lt;a href=&quot;https://www.tomsguide.com/news/google-pixel-6-tensor-chip-what-it-is-and-why-its-a-big-deal&quot;&gt;require custom hardware
to keep them
going&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;computational-photography-is-cheating&quot;&gt;Computational Photography is Cheating&lt;/h2&gt;

&lt;p&gt;There’s one more thing to consider here, and that is that the CP can be
seen as a “cheating” when compared to the conventional photography,
basically producing image information that didn’t exist in the original
photo. The counter-argument here is that indeed the photo coming out of
a compact or DSLR was of better quality and could be used straightaway,
but still for getting the most of the photo some processing in post was
needed. That could have been eg. stitching the photos to get the
panoramic shot unattainable by the used lens setup, or pulling in
shadows/highlights to get a HDR look, or even retouching the photos to
remove the undesirable elements from the photo.&lt;/p&gt;

&lt;p&gt;Indeed, these operations as well as getting some kind of shots, like
action pan ones require more skill and effort and thus can be more
valued (putting your sweat into the photo), but from the technical
standpoint they differ not that much from what CP achieves, the only
difference being that these operations are done by hand and not by an
automated system.&lt;/p&gt;

&lt;h2 id=&quot;where-do-we-go-next&quot;&gt;Where Do We Go Next?&lt;/h2&gt;

&lt;p&gt;The initial incentive for CP came out of overcoming the limitations of
mobile phone camera setups, and trying to achieve something what could
be got from a conventional camera. I think that for consumer use we’ve
reached the stage where even the mid-range smartphones offer the
functionality set that covers most of the use cases and that making
progress there becomes less important.&lt;/p&gt;

&lt;p&gt;One non-CP direction would be to simplify the camera setup and try to
revert to a single-camera configuration with the aim to reduce the cost
and free up phone real estate. The most notable technologies there are -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Using the periscope camera setup allowing for horizontal stacking of
optic elements, and thus allowing longer focal lengths and even
&lt;a href=&quot;https://www.gsmarena.com/sony_xperia_1_iii-review-2287p5.php&quot;&gt;adjusting the focal
length&lt;/a&gt;,
and&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.theverge.com/2021/3/25/22350245/xiaomi-mi-mix-liquid-lens-autofocus-focal-length-camera&quot;&gt;Use of liquid
lenses&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As for the CP, the next step now could be assisting the photographer in
improving the photo content, either passively (composition assistance,
selecting the best shot out of the burst) or actively (image
retouching). Some examples would be -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Pixel 6 motion photo modes,&lt;/li&gt;
  &lt;li&gt;Pixel 6 &lt;a href=&quot;https://youtu.be/Kp1P4S-WgvU?t=204&quot;&gt;in-phone unwanted object
removal&lt;/a&gt;,&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=WmdABCNTNNE&quot;&gt;Galaxy S10 best shot
suggestion&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For now, these modes seem like a manufacturer’s gimmick made for the
phone to stand out among the competition, but like with HDR or night
mode or the rest, I would assume the proliferation into general use when
the technology settles in and the supporting hardware becomes more
widespread and universal and not vendor-specific.&lt;/p&gt;</content><author><name>Marko Oklobdžija</name></author><category term="articles" /><category term="camera" /><category term="photography" /><category term="mobile-phone" /><summary type="html">The best camera mode is the one you have on your phone.</summary></entry><entry><title type="html">Autonomous Driving Observations</title><link href="https://kibihrchak.github.io/articles/2021/10/30/autonomous-driving-observations.html" rel="alternate" type="text/html" title="Autonomous Driving Observations" /><published>2021-10-30T00:00:00+00:00</published><updated>2021-10-30T00:00:00+00:00</updated><id>https://kibihrchak.github.io/articles/2021/10/30/autonomous-driving-observations</id><content type="html" xml:base="https://kibihrchak.github.io/articles/2021/10/30/autonomous-driving-observations.html">&lt;p&gt;“Tap on the stars to rate your autonomous ride - ⭐⭐⭐⭐⭐”&lt;/p&gt;

&lt;h2 id=&quot;driving-instructor-to-an-autonomous-driving-system&quot;&gt;Driving Instructor to an Autonomous Driving System&lt;/h2&gt;

&lt;p&gt;While watching the Tesla FSD videos from &lt;a href=&quot;https://www.youtube.com/c/AIDRIVR&quot;&gt;AI
DRIVR&lt;/a&gt;, one thing about autonomous
driving caught my attention. My previous perception about autonomous
driving and &lt;a href=&quot;https://en.wikipedia.org/wiki/Self-driving_car#Levels_of_driving_automation&quot;&gt;its
categorization&lt;/a&gt;
was that -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Either car has full control over the driving and requires drivers
assistance when it cannot determine the correct course of action, or&lt;/li&gt;
  &lt;li&gt;That car automates only certain aspect of driving (eg. cruise
control), and leaves the rest to the human driver.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But one additional aspect that appeared really significant to me there
was having the ability to act like a driving instructor to the
autonomous driving system. This occured on several of the Tesla FSD
videos, where the human driver didn’t take control over the car from the
autonomous driving system, but rather gave it a hint what it could do.
Some examples seen there were - giving it a nudge when being stopped at
the intersection that it is safe to advance, or requesting the lane
change when the car seems unsure about doing it. Other things that come
to my mind and follow this suit would be keeping the steering wheel
while turning and thus saying to the car that it is turning too sharply,
or tapping the brake to tell the car to slow down, or tapping the
accelerator to tell the car that it is okay to take over another
vehicle.&lt;/p&gt;

&lt;p&gt;This whole “driving instructor” functionality to me seems like a really
good approach to bridge the gap while developing an autonomous system of
level 2 and above. The important thing is that the system still has the
ability to get the vehicle to a safe state if it is unable to perform
anymore, but the instructor thing allows for a partially done system to
still be usable. Then, with time as the system improves, driver’s
assistance would be required less and less. And, about the improvement,
this assistance aspect has a real value if the driving system behavior
is monitored and that data aggregated to improve the system.&lt;/p&gt;

&lt;h2 id=&quot;it-is-human-to-make-mistakes&quot;&gt;“It is Human to Make Mistakes”&lt;/h2&gt;

&lt;p&gt;Another noticeable thing while watching the videos, and something that
AI DRIVR has also mentioned on a couple of occassions is the ability of
the autonomous driving system to gracefully deal with mistakes. It is
one thing to detect that you in a mess and just freeze there and yepl
for hooman’s assistance, and other thing is to try to make things
better. Some examples of that would be -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Trying to move to the side of the road if there’s not enough room
for the vehicle from the opposite direction to pass.&lt;/li&gt;
  &lt;li&gt;Trying to claw your way through an intersection after selecting the
wrong turn lane.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These examples ride on the fact that other human drivers will be aware
of your mistake and that they will react to it, and not behave like
autonomous drones with preprogrammed paths. They give you some leeway
for it and not a middle finger, and even move aside themselves, or they
will react but will yield anyways like for the second example.&lt;/p&gt;</content><author><name>Marko Oklobdžija</name></author><category term="articles" /><category term="ai" /><category term="autonomous" /><category term="driving" /><summary type="html">“Tap on the stars to rate your autonomous ride - ⭐⭐⭐⭐⭐”</summary></entry><entry><title type="html">On Ideal Software Development Workflow</title><link href="https://kibihrchak.github.io/articles/2020/08/19/ideal-sw-dev-workflow.html" rel="alternate" type="text/html" title="On Ideal Software Development Workflow" /><published>2020-08-19T00:00:00+00:00</published><updated>2020-08-19T00:00:00+00:00</updated><id>https://kibihrchak.github.io/articles/2020/08/19/ideal-sw-dev-workflow</id><content type="html" xml:base="https://kibihrchak.github.io/articles/2020/08/19/ideal-sw-dev-workflow.html">&lt;p&gt;Is it possible to harness unicorns? But ideally.&lt;/p&gt;

&lt;h2 id=&quot;the-best-part-is-no-part&quot;&gt;“The Best Part Is No Part”&lt;/h2&gt;

&lt;p&gt;What got me thinking on this topic was the remark think repeated by Elon
Musk on several occasions, but most notably during &lt;a href=&quot;https://twitter.com/Erdayastronaut/status/1203840982497792005&quot;&gt;Starship
presentation last
year&lt;/a&gt;
that goes like -&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The best part is no part. The best process is no process. It weighs
  nothing. Costs nothing. Can’t go wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically, the way I see it is that everything that is shown as
unnecessary will encumber either the development process or the product,
and the product in the subsequent use.&lt;/p&gt;

&lt;p&gt;What is of interest here is the hidden cost in the development process
itself. As an end user, you can point at the product and state that this
or that may not be needed, but there’s that background effort invested
in realizing the product, which may have had its own “extra” unused
parts, removal of which could lead to faster development, better devised
product or just less burn out.&lt;/p&gt;

&lt;h2 id=&quot;ideal-software-development-workflow-&quot;&gt;Ideal Software Development Workflow 🦄&lt;/h2&gt;

&lt;p&gt;The question that comes here is, how to reach this ideal development
process? The common approach is minimization of most notable waste, eg.
what &lt;a href=&quot;http://minifesto.org/&quot;&gt;Minifesto&lt;/a&gt; proclaims. Other approach would
be to go from the idealistic development workflow, however unlike may it
seemed, then identify possible violations of it in the context of
current project and then select strategies or the workflow enhancements
to mitigate these violations.&lt;/p&gt;

&lt;p&gt;How would that look like? Ideal workflow eg. would be to:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Collect requirements in full, without any ambiguities, conflicts or
omissions.&lt;/li&gt;
  &lt;li&gt;Based on these requirements and preexisting knowledge, a complete
design of a system is devised, and pre-existing
tools/libraries/frameworks are selected so that they enhance
development and remove work duplication to the full.&lt;/li&gt;
  &lt;li&gt;In line with the product design, a support infrastructure for
development is identified, and a development infrastructure is set
up so that there is no need for further enhancements or changes.&lt;/li&gt;
  &lt;li&gt;Based on the given design, necessary missing software components are
created.&lt;/li&gt;
  &lt;li&gt;Newly created code is seamlessly and without conflicts integrated
with pre-existing software components.&lt;/li&gt;
  &lt;li&gt;Resulting software product is then integrated in the operation
environment without conflicts and issues.&lt;/li&gt;
  &lt;li&gt;Work done. Profit.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What may seem is that the given outline looks too naive. And, for the
majority of the projects it is. But, the core assumption holds, that &lt;em&gt;if
there are no violations to it, it would work&lt;/em&gt;. This is also relevant for
the steps perceived as omitted, like maintenance. If the product is
ideal, it would not require maintenance.&lt;/p&gt;

&lt;h2 id=&quot;dealing-with-complexity&quot;&gt;Dealing with Complexity&lt;/h2&gt;

&lt;p&gt;Onto the violations. What happens here is that due to the unaccounted
factors it is possible that the given ideal workflow will not satisfy
the project development needs. It may be due to the changing or
incomplete requirements, understanding of the system, lack of
preexisting knowledge in domain, or regarding the suitable
tools/frameworks/libraries. It may be due to the distributed nature of
development, where the synchronization issues between team members
appear.&lt;/p&gt;

&lt;p&gt;Whatever the reason, the idea is to see these factors as something that
the ideal development workflow is not prepared to address, and
mitigation strategies should be added to it in order to do so. Eg. in
case of a possibility of having incomplete requirements, mitigation
mechanisms could be creating the problem domain model and testing the
requirements on it, or creating a mock-up product for asserting the
requirements. In case of possible integration issues, interface
specification and incremental development may be the solution.&lt;/p&gt;

&lt;p&gt;The main idea behind this is to make &lt;em&gt;all ideal development workflow
violations visible&lt;/em&gt;, and to state mitigation strategies explicitly. This
way ideal workflow in combination with mitigation strategies becomes &lt;em&gt;a
verifiable minimal development workflow&lt;/em&gt; based on the current
understanding of the project.&lt;/p&gt;

&lt;p&gt;As a side benefit, purpose of development workflow tools/processes
becomes apparent with this, and they will not be seen as an externally
imposed hurdle. Also, this allows for building a certain “repository”,
or toolkit of useful tools to be applied in particular development
scenarios.&lt;/p&gt;

&lt;h2 id=&quot;what-about-real-world-application&quot;&gt;What About Real-World Application?&lt;/h2&gt;

&lt;p&gt;The final question is the applicability of this thought out approach?
Even Musk may say “The best process is no process”, but the feasibility
of keeping true to that word is what matters. Guess that the best way to
achieve it is:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;To have an extensive knowledge of tools at disposal (toolkit).&lt;/li&gt;
  &lt;li&gt;Do not over-anticipate the issues, but develop the mitigation on
fly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Further than that, useful real-world experience examples would be
beneficial.&lt;/p&gt;</content><author><name>Marko Oklobdžija</name></author><category term="articles" /><category term="development" /><category term="process" /><category term="workflow" /><category term="unicorns" /><summary type="html">Is it possible to harness unicorns? But ideally.</summary></entry><entry><title type="html">Line Length Limit</title><link href="https://kibihrchak.github.io/analysis/2020/07/29/line-length-limit.html" rel="alternate" type="text/html" title="Line Length Limit" /><published>2020-07-29T00:00:00+00:00</published><updated>2020-07-29T00:00:00+00:00</updated><id>https://kibihrchak.github.io/analysis/2020/07/29/line-length-limit</id><content type="html" xml:base="https://kibihrchak.github.io/analysis/2020/07/29/line-length-limit.html">&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;1   5    10   15   20   25   30   35   40   45   50   55   60   65   70   75
80   85   90   95   100  105  110  115  120
|...|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;

&lt;ol id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; id=&quot;markdown-toc-table-of-contents&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#version-history&quot; id=&quot;markdown-toc-version-history&quot;&gt;Version History&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#a-look-at-the-problem&quot; id=&quot;markdown-toc-a-look-at-the-problem&quot;&gt;A Look at The Problem&lt;/a&gt;    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#text-file-element-types&quot; id=&quot;markdown-toc-text-file-element-types&quot;&gt;Text File Element Types&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#text-operations&quot; id=&quot;markdown-toc-text-operations&quot;&gt;Text Operations&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#contributing-factors&quot; id=&quot;markdown-toc-contributing-factors&quot;&gt;Contributing Factors&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#making-a-cpl-limit-decision&quot; id=&quot;markdown-toc-making-a-cpl-limit-decision&quot;&gt;Making a CPL Limit Decision&lt;/a&gt;    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#factors&quot; id=&quot;markdown-toc-factors&quot;&gt;Factors&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#decision-examples&quot; id=&quot;markdown-toc-decision-examples&quot;&gt;Decision Examples&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#glossary&quot; id=&quot;markdown-toc-glossary&quot;&gt;Glossary&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#cpl-limit-examples&quot; id=&quot;markdown-toc-cpl-limit-examples&quot;&gt;CPL Limit Examples&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#resources&quot; id=&quot;markdown-toc-resources&quot;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;version-history&quot;&gt;Version History&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Date&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;2020-07-29&lt;/td&gt;
      &lt;td&gt;Initial version&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;Some time ago while looking through the Internets, &lt;a href=&quot;https://www.reddit.com/r/programming/comments/gt4wgn/linus_torvalds_on_80character_line_limit/&quot;&gt;a Reddit post on
Linus’ rant about 80CPL limit&lt;/a&gt; caught my attention.
The gist was that 80CPL is a thing of a past, and “more reasonable”
limit should become a norm, like 120CPL or so.&lt;/p&gt;

&lt;p&gt;This got me thinking on, what actually constitutes a justification for
“more reasonable” limit, or, should limit be imposed at all?&lt;/p&gt;

&lt;p&gt;This analysis tries to answer -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;If and when limiting line length for text files matters&lt;/li&gt;
  &lt;li&gt;Also in that context - What would be the appropriate line length
limit?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First part of this post is dedicated to the perceived origins of the
problem, and to describing the underlying problem domain. It is followed
next by a summary of relevant factors when choosing if and what CPL
limit to impose.&lt;/p&gt;

&lt;p&gt;Also, at the end there is some other useful information, like glossary
used for terms here (like CPL), some CPL limit examples, and a resource
list.&lt;/p&gt;

&lt;h2 id=&quot;a-look-at-the-problem&quot;&gt;A Look at The Problem&lt;/h2&gt;

&lt;p&gt;Trigger for delving into the topic are the statements in discussion
groups/blog posts like -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Pro banishing 80CPL:
    &lt;ul&gt;
      &lt;li&gt;120CPL is the magic number.&lt;/li&gt;
      &lt;li&gt;Why stick with 80CPL when we’re not using 80CPL screens? 4K/dual
monitor setup is a norm today.&lt;/li&gt;
      &lt;li&gt;80CPL makes code unnecessary long.&lt;/li&gt;
      &lt;li&gt;80CPL encourages naming abbreviation which reduces readability.&lt;/li&gt;
      &lt;li&gt;Line breaks limit use of line-based tools.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Pro sticking to 80CPL:
    &lt;ul&gt;
      &lt;li&gt;Diff viewers use is easier with lower limit.&lt;/li&gt;
      &lt;li&gt;80CPL supports easy side-by-side editing (if you don’t want to
accept word wrap).&lt;/li&gt;
      &lt;li&gt;80CPL supports easy font enlargement for presentation/video
recording.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important thing mentioning here is that the bulk of these examples
relate to code files, seeming to stem from code file lines becoming too
long, but CPL rules apply to document files, too. Still, these examples
may be used as a starting point to developing the view on the problem
domain. Based on them, following generalized use cases are derived -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Optimal CPL when writing code in a single-window IDE.&lt;/li&gt;
  &lt;li&gt;Optimal CPL when writing code and having to reference some other
location in source tree, in a multi side-by-side viewport setup.&lt;/li&gt;
  &lt;li&gt;Not being able to wrap long lines when performing code diff in
VS Code, GitHub, Bitbucket.&lt;/li&gt;
  &lt;li&gt;Issue with CPL limit - Grep expressions not working across multiple
lines.&lt;/li&gt;
  &lt;li&gt;Reading/modifying text files over limited-width terminal (embedded
system serial port, SSH).&lt;/li&gt;
  &lt;li&gt;Reading/modifying text in an atypical work environment (eg. on a
mobile phone via &lt;a href=&quot;https://github.com/gsantner/markor&quot;&gt;Markor&lt;/a&gt;).&lt;/li&gt;
  &lt;li&gt;Reading preformatted text in a browser (eg. source files or
discussion group posts).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;text-file-element-types&quot;&gt;Text File Element Types&lt;/h3&gt;

&lt;p&gt;What is of interest is that the treatment of text files should not
depend on the text file type per se, but it’s on the elements it
consists of. These elements determine the way text is read, the approach
on how it should be laid out, how it is accessed.&lt;/p&gt;

&lt;p&gt;Here, the identified text file elements are listed -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;File type&lt;/th&gt;
      &lt;th&gt;Element&lt;/th&gt;
      &lt;th&gt;Treatment&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Code&lt;/td&gt;
      &lt;td&gt;Source code&lt;/td&gt;
      &lt;td&gt;Code&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Code&lt;/td&gt;
      &lt;td&gt;Comment&lt;/td&gt;
      &lt;td&gt;Breakable text&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Document&lt;/td&gt;
      &lt;td&gt;Paragraph&lt;/td&gt;
      &lt;td&gt;Breakable text&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Document&lt;/td&gt;
      &lt;td&gt;Code block&lt;/td&gt;
      &lt;td&gt;Code&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Document&lt;/td&gt;
      &lt;td&gt;Code block comment&lt;/td&gt;
      &lt;td&gt;Breakable text&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Document&lt;/td&gt;
      &lt;td&gt;Table&lt;/td&gt;
      &lt;td&gt;Non-breakable text&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Document&lt;/td&gt;
      &lt;td&gt;Hyperlink&lt;/td&gt;
      &lt;td&gt;Non-breakable text&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Thing worth recapping here is that for a single text file, there may be
different rules, depending on the text file element, eg. document table
may have CPL limit but a document paragraph may have no CPL limit.&lt;/p&gt;

&lt;h3 id=&quot;text-operations&quot;&gt;Text Operations&lt;/h3&gt;

&lt;p&gt;Next what impacts the treatment is the way text is used. In this regard,
the following text operations are identified, as well as the tools that
may be used -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Operation&lt;/th&gt;
      &lt;th&gt;Example tools&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Navigation&lt;/td&gt;
      &lt;td&gt;Vim, Notepad&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inserting/modifying&lt;/td&gt;
      &lt;td&gt;Notepad, VS Code, Vim through terminal&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Reading&lt;/td&gt;
      &lt;td&gt;Terminal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;less&lt;/code&gt;, browser render, VS Code&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Comparison (diffing)&lt;/td&gt;
      &lt;td&gt;VS Code, GitHub/Bitbucket, terminal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;diff&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Searching&lt;/td&gt;
      &lt;td&gt;Terminal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Most appropriate text file element CPL limit depends on the operation,
but also on the tool employed, as well as the environment in which the
tool is used. Eg. diffing with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;diff&lt;/code&gt; produces valid result regardless
of CPL limit, where other tools do not have support for diff wrap and
require horizontal scrolling, &lt;em&gt;except&lt;/em&gt; if they do not use a sufficiently
wide viewport.&lt;/p&gt;

&lt;p&gt;This lead further to having a development environment determining, in
combination with CPL limits, feasibility of the given operations.
Development environment would consist out of -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Display(s) size (and orientation together with this).&lt;/li&gt;
  &lt;li&gt;Viewport size&lt;/li&gt;
  &lt;li&gt;Text editor:
    &lt;ol&gt;
      &lt;li&gt;Inherent operation model.&lt;/li&gt;
      &lt;li&gt;Configuration.&lt;/li&gt;
      &lt;li&gt;Reserved viewport space (eg. sidebar, scrollbars, minimap, line
numbers, diff prefix).&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;contributing-factors&quot;&gt;Contributing Factors&lt;/h3&gt;

&lt;p&gt;In addition to the operation and text operation environment, there are
some further side factors that may impact the usefulness of imposed CPL
limit rules.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;User base size - Single user vs. multiple users (with potentially
disjunctive development environments).&lt;/li&gt;
  &lt;li&gt;Tabs vs. spaces and tab indentation value.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;making-a-cpl-limit-decision&quot;&gt;Making a CPL Limit Decision&lt;/h2&gt;

&lt;h3 id=&quot;factors&quot;&gt;Factors&lt;/h3&gt;

&lt;p&gt;Here’s a piled up list of observed factors that may contribute to a
certain CPL limit decision.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Enforcing code writing style through CPL limit:
    &lt;ol&gt;
      &lt;li&gt;More concise variable names.&lt;/li&gt;
      &lt;li&gt;Local aliasing.&lt;/li&gt;
      &lt;li&gt;Condition nesting.&lt;/li&gt;
      &lt;li&gt;Long expressions rework (no sausage expressions).&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Cost of adhering to a CPL limit when creating/modifying text:
    &lt;ol&gt;
      &lt;li&gt;Having to break long statements when writing code.&lt;/li&gt;
      &lt;li&gt;Having to make document tables fit.&lt;/li&gt;
      &lt;li&gt;Switching to an atypical work environment which is not
configured/tailored to the imposed CPL limit (eg. editing files
on a mobile phone or Web UI).&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Readability:
    &lt;ol&gt;
      &lt;li&gt;Certain document line length range is optimal for reading
convenience.&lt;/li&gt;
      &lt;li&gt;Same holds to a certain degree for code.&lt;/li&gt;
      &lt;li&gt;Wrapping of long lines depend on the text editor, and may
produce unreadable output, eg. document tables or code.&lt;/li&gt;
      &lt;li&gt;If wrapping is not applied, then user need to perform horizontal
scrolling to read the text which breaks the flow. This is esp.
relevant to diffing. There:
        &lt;ol&gt;
          &lt;li&gt;VS Code, Gitk, GitHub, Bitbucket, TFS do not wrap diff.&lt;/li&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git diff&lt;/code&gt; wraps diff.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;For CPL limited text, if it is modified it may require
rewrapping which will introduce modifications to the otherwise
unmodified text. This may make diffing difficult.
        &lt;ol&gt;
          &lt;li&gt;On the other hand, this is also a case with a long
non-wrapped line.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;This depends on the indentation style and amount.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Flexibility:
    &lt;ol&gt;
      &lt;li&gt;CPL limit makes text rigid, and not able to adapt to the
environment at hand (eg. smaller mobile viewport), or
developer’s preferences.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Output reproducibility:
    &lt;ol&gt;
      &lt;li&gt;Specific line length, use of spaces instead of tabs, and no wrap
results in reproducible output. This ensures that everyone has
the same representation on the text file.&lt;/li&gt;
      &lt;li&gt;Long line wrapping depends on the viewport configuration, and
may change as the viewport is resized leading to different text
representation even for the same user.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Ambiguity:
    &lt;ol&gt;
      &lt;li&gt;There’s a certain expectation that each text line fits into one
displayed line. When this is broken due to line wrapping,
there’s a risk that user will interpret wrapped lines as new
text lines. This may result in the confusion when reading code
statements, or the interpretation how the markup document file
will be rendered.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Stimulating certain work environment:
    &lt;ol&gt;
      &lt;li&gt;Lower CPL limit stimulates use of narrower viewport, which
leaves horizontal space for other windows, or stimulates
multiple side-by-side viewport use.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Usability:
    &lt;ol&gt;
      &lt;li&gt;If document file paragraphs are not broken, this makes grep
search for more than a single word queries possible.&lt;/li&gt;
      &lt;li&gt;Large CPL limit may prove diffing difficult as the tools usually
don’t wrap text, so horizontal scrolling is needed.&lt;/li&gt;
      &lt;li&gt;Text wrapping may impede with normal workflow for some tools
(eg. Vim jk navigation).&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Development environment setup:
    &lt;ol&gt;
      &lt;li&gt;No CPL limit enforcement eases up setup.&lt;/li&gt;
      &lt;li&gt;Some environments even cannot be configured for the given CPL
limit (eg. mobile edit environment).&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;decision-examples&quot;&gt;Decision Examples&lt;/h3&gt;

&lt;p&gt;[TODO]&lt;/p&gt;

&lt;h2 id=&quot;glossary&quot;&gt;Glossary&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Term&lt;/th&gt;
      &lt;th&gt;Meaning&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Text file&lt;/td&gt;
      &lt;td&gt;Non-binary file containing readable text&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Code file&lt;/td&gt;
      &lt;td&gt;Text file containing source code&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Document file&lt;/td&gt;
      &lt;td&gt;Text file containing plaintext or markup text&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CPL rule&lt;/td&gt;
      &lt;td&gt;Requirements on text file line length&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CPL limit&lt;/td&gt;
      &lt;td&gt;Allowed number of characters per line&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Text editor&lt;/td&gt;
      &lt;td&gt;Tool for editing &lt;em&gt;or viewing&lt;/em&gt; a text file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Viewport&lt;/td&gt;
      &lt;td&gt;Screen area displaying text file content&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Word wrap&lt;/td&gt;
      &lt;td&gt;Text editor ability to break long line to fit viewport&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;cpl-limit-examples&quot;&gt;CPL Limit Examples&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;CPL&lt;/th&gt;
      &lt;th&gt;Note&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;70&lt;/td&gt;
      &lt;td&gt;Oracle’s Java Coding Convention - Documentation code examples&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;72&lt;/td&gt;
      &lt;td&gt;Python PEP 8 - Doctrings or comments&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;79&lt;/td&gt;
      &lt;td&gt;Python PEP 8 - Maximum&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;80&lt;/td&gt;
      &lt;td&gt;Punch cards and teletypes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;120&lt;/td&gt;
      &lt;td&gt;Widely accepted better-than-80CPL limit&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/programming/comments/gt4wgn/linus_torvalds_on_80character_line_limit/&quot;&gt;reddit_linus&lt;/a&gt; : Discussion on Linus’ post on line length limit.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://baymard.com/blog/line-length-readability&quot;&gt;baymard_line-length&lt;/a&gt; : Article on optimal length of text line.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://nickjanetakis.com/blog/80-characters-per-line-is-a-standard-worth-sticking-to-even-today&quot;&gt;nick_80cpl&lt;/a&gt; : Benefits of 80CPL with large monitors.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/578059/studies-on-optimal-code-width&quot;&gt;stack_optimal-width&lt;/a&gt; : (Lack of) info on studies on optimal code
width.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.python.org/dev/peps/pep-0008/#maximum-line-length&quot;&gt;python_pep8&lt;/a&gt; : Python Coding style guide - line length.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://softwareengineering.stackexchange.com/questions/148677/why-is-80-characters-the-standard-limit-for-code-width&quot;&gt;stack_80cpl&lt;/a&gt; : Origin of 80CPL limit.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.oracle.com/technetwork/java/codeconventions-150003.pdf&quot;&gt;oracle_java-code-conv&lt;/a&gt; : Oracle’s Java Coding Conventions - Check 4.1.&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Marko Oklobdžija</name></author><category term="analysis" /><category term="formatting" /><category term="code" /><category term="line-length" /><category term="wrap" /><category term="indentation" /><summary type="html">1 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 |...|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|....|</summary></entry><entry><title type="html">A Take on GCC Linux Cross-Compilation Compatibility</title><link href="https://kibihrchak.github.io/analysis/2020/05/25/take-on-linux-gcc-cc-comp.html" rel="alternate" type="text/html" title="A Take on GCC Linux Cross-Compilation Compatibility" /><published>2020-05-25T00:00:00+00:00</published><updated>2020-05-25T00:00:00+00:00</updated><id>https://kibihrchak.github.io/analysis/2020/05/25/take-on-linux-gcc-cc-comp</id><content type="html" xml:base="https://kibihrchak.github.io/analysis/2020/05/25/take-on-linux-gcc-cc-comp.html">&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;arm-linux-gnueabihf&lt;/code&gt;, almost usable for all ARM platforms.&lt;/p&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;

&lt;ol id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; id=&quot;markdown-toc-table-of-contents&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#version-history&quot; id=&quot;markdown-toc-version-history&quot;&gt;Version History&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#cross-compilation-101&quot; id=&quot;markdown-toc-cross-compilation-101&quot;&gt;Cross-Compilation 101&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#cross-compilation-parameters-and-compatibility&quot; id=&quot;markdown-toc-cross-compilation-parameters-and-compatibility&quot;&gt;Cross-Compilation Parameters and Compatibility&lt;/a&gt;    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#parameter-violation-effects&quot; id=&quot;markdown-toc-parameter-violation-effects&quot;&gt;Parameter Violation Effects&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#linux-shared-libraries&quot; id=&quot;markdown-toc-linux-shared-libraries&quot;&gt;Linux Shared Libraries&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#gcc&quot; id=&quot;markdown-toc-gcc&quot;&gt;GCC&lt;/a&gt;    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#cross-compilation-toolkit-components&quot; id=&quot;markdown-toc-cross-compilation-toolkit-components&quot;&gt;Cross-Compilation Toolkit Components&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#gcc-toolkit-build-process&quot; id=&quot;markdown-toc-gcc-toolkit-build-process&quot;&gt;GCC Toolkit Build Process&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#cross-compilation-toolkit-install-directory-contents&quot; id=&quot;markdown-toc-cross-compilation-toolkit-install-directory-contents&quot;&gt;Cross-Compilation Toolkit Install Directory Contents&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#potential-use-cases&quot; id=&quot;markdown-toc-potential-use-cases&quot;&gt;Potential Use Cases&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#resources&quot; id=&quot;markdown-toc-resources&quot;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;version-history&quot;&gt;Version History&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Date&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;2020-05-27&lt;/td&gt;
      &lt;td&gt;Initial bare-bones post&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;This topic started as a search for a more modern GCC version for
cross-compiling the programs for Raspbian, and then turned into an
all-out compatibility research on what it takes to cross-compile
software, and be sure it’s going to run without issues on the target
platform. The original topic got &lt;a href=&quot;/guides/2020/05/23/raspbian-cross-compile.html&quot;&gt;its own dedicated guide&lt;/a&gt;,
and the rest of stuff collected on cross-compilation compatibility got
slated for a dedicated analysis post, that is, this one.&lt;/p&gt;

&lt;p&gt;This is a look on what consists a cross-compiler toolkit for a Linux
target, what are its specifics, and as the subtitle says, why is a
cross-compiler tied to a particular target even if the toolkit name
prefix sounds generic enough so that it can cover a multitude of
platforms. And at last, why that sometimes may be the case.&lt;/p&gt;

&lt;p&gt;As a process to answer that question, here’s the outline of covered
topics -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;First there’s a refresher on cross-compilation&lt;/li&gt;
  &lt;li&gt;There’s a look on what are the relevant parameters for
cross-compilation&lt;/li&gt;
  &lt;li&gt;A look at what makes a shared libraries compatible&lt;/li&gt;
  &lt;li&gt;What is the GCC cross-compiler build process&lt;/li&gt;
  &lt;li&gt;What are the assumed pitfalls of cross-compilation toolkit use&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Cross compilation in a nutshell is a process of building code on one
machine that is to be executed on another (potentially incompatible)
machine.&lt;/p&gt;

&lt;p&gt;As this process considers using different machines (execution platforms,
that is), here’s a recap of these -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Machine&lt;/th&gt;
      &lt;th&gt;Purpose&lt;/th&gt;
      &lt;th&gt;Built artifact&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Build&lt;/td&gt;
      &lt;td&gt;Builds the compiler&lt;/td&gt;
      &lt;td&gt;Cross-compiler toolkit&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Host&lt;/td&gt;
      &lt;td&gt;Runs the compiler&lt;/td&gt;
      &lt;td&gt;Cross-compiled user program&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Target&lt;/td&gt;
      &lt;td&gt;Executes the compiled code&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;And here’s a recap of different build types and the corresponding
machines -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Build name/Machine&lt;/th&gt;
      &lt;th&gt;Build&lt;/th&gt;
      &lt;th&gt;Host&lt;/th&gt;
      &lt;th&gt;Target&lt;/th&gt;
      &lt;th&gt;Example&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Native&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;Local compilation&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Cross&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;B&lt;/td&gt;
      &lt;td&gt;For MCU target&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Cross-native&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;B&lt;/td&gt;
      &lt;td&gt;B&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Canadian cross&lt;/td&gt;
      &lt;td&gt;A&lt;/td&gt;
      &lt;td&gt;B&lt;/td&gt;
      &lt;td&gt;C&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;cross-compilation-parameters-and-compatibility&quot;&gt;Cross-Compilation Parameters and Compatibility&lt;/h2&gt;

&lt;p&gt;Here’s a summary of parameters relevant for creating a cross-compiler
toolkit. All parameters are related to a target machine.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Parameter&lt;/th&gt;
      &lt;th&gt;Example&lt;/th&gt;
      &lt;th&gt;Compatibility note&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;CPU architecture&lt;/td&gt;
      &lt;td&gt;ARM&lt;/td&gt;
      &lt;td&gt;Incompatible&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CPU architecture variant&lt;/td&gt;
      &lt;td&gt;ARMv6&lt;/td&gt;
      &lt;td&gt;Backward(1)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ABI&lt;/td&gt;
      &lt;td&gt;EABI&lt;/td&gt;
      &lt;td&gt;Variants inside ABI(2)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Object file format&lt;/td&gt;
      &lt;td&gt;ELF&lt;/td&gt;
      &lt;td&gt;Depends on format, linker&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;OS API&lt;/td&gt;
      &lt;td&gt;Linux API&lt;/td&gt;
      &lt;td&gt;Incompatible&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;OS API version&lt;/td&gt;
      &lt;td&gt;Linux API 3.2.0&lt;/td&gt;
      &lt;td&gt;Backward for Linux&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Standard C library&lt;/td&gt;
      &lt;td&gt;glibc, uclibc&lt;/td&gt;
      &lt;td&gt;Incompatible&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Standard C library version&lt;/td&gt;
      &lt;td&gt;glibc 2.28&lt;/td&gt;
      &lt;td&gt;Backward for glibc&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Compiler runtime library&lt;/td&gt;
      &lt;td&gt;libgcc&lt;/td&gt;
      &lt;td&gt;Incompatible&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Compiler RT library version&lt;/td&gt;
      &lt;td&gt;libgcc 7.0.0&lt;/td&gt;
      &lt;td&gt;Backward for libgcc&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Eg. for ARM AArch32, or x86 sans extensions.&lt;/li&gt;
  &lt;li&gt;Eg. EABI hard-float and soft-float variants are compatible between
themselves.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;parameter-violation-effects&quot;&gt;Parameter Violation Effects&lt;/h3&gt;

&lt;p&gt;Now, with knowledge what parameters are all involved when making a
cross-compiler, let’s see what are the potential effects of setting an
incorrect parameter value&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Parameter violation&lt;/th&gt;
      &lt;th&gt;Effect&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;CPU architecture&lt;/td&gt;
      &lt;td&gt;Code execution will crash&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CPU architecture variant&lt;/td&gt;
      &lt;td&gt;Crash on unsupported execution&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ABI&lt;/td&gt;
      &lt;td&gt;Crash on linked library call&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ABI&lt;/td&gt;
      &lt;td&gt;Crash on an OS system call&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Object file format&lt;/td&gt;
      &lt;td&gt;Linker/loader won’t accept the file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;OS API&lt;/td&gt;
      &lt;td&gt;Any system call will fail&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;OS API version&lt;/td&gt;
      &lt;td&gt;Unsupported system calls will fail&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Standard C library&lt;/td&gt;
      &lt;td&gt;Linking will fail&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Standard C library version&lt;/td&gt;
      &lt;td&gt;Linking will fail&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Compiler runtime library&lt;/td&gt;
      &lt;td&gt;Linking will fail&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Compiler RT library version&lt;/td&gt;
      &lt;td&gt;Linking will fail&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;linux-shared-libraries&quot;&gt;Linux Shared Libraries&lt;/h2&gt;

&lt;p&gt;Shared libraries in Linux go under three names -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Naming example&lt;/th&gt;
      &lt;th&gt;Note&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;soname&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libstdc++.so.6&lt;/code&gt;(1)&lt;/td&gt;
      &lt;td&gt;Symlink to real name&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Real name&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libstdc++.so.6.0.28&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Linker name&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libstdc++.so&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Symlink to latest soname&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Standard C libraries don’t start with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lib&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As for the shared library and their symbols versioning, here are the
notes -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Linker uses library represented with latest library (one represented
by linker name).&lt;/li&gt;
  &lt;li&gt;Version number specifies interface, and it’s possible to have
multiple sonames for different major library versions.&lt;/li&gt;
  &lt;li&gt;API inside library is also versioned, with newer libraries adding
API revisions, while keeping the old API. Example from
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libc-2.31.so&lt;/code&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;414: 00149b80  7039 FUNC    GLOBAL DEFAULT   16 glob64@GLIBC_2.2
415: 0014b900  7039 FUNC    GLOBAL DEFAULT   16 glob64@GLIBC_2.1
416: 000d1620  7039 FUNC    GLOBAL DEFAULT   16 glob64@@GLIBC_2.27
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;gcc&quot;&gt;GCC&lt;/h2&gt;

&lt;h3 id=&quot;cross-compilation-toolkit-components&quot;&gt;Cross-Compilation Toolkit Components&lt;/h3&gt;

&lt;p&gt;Here’s an overview of components, and how and where they’re gonna be
used -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Component&lt;/th&gt;
      &lt;th&gt;Use&lt;/th&gt;
      &lt;th&gt;Use location&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Binaries&lt;/td&gt;
      &lt;td&gt;Perform compilation, linking&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;C static libraries&lt;/td&gt;
      &lt;td&gt;Link with compiled program&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;C dynamic libraries&lt;/td&gt;
      &lt;td&gt;Link with compiled program&lt;/td&gt;
      &lt;td&gt;Target&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;C libraries headers&lt;/td&gt;
      &lt;td&gt;Program compilation&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Dynamic linker/loader&lt;/td&gt;
      &lt;td&gt;Load and link with dynamic libs&lt;/td&gt;
      &lt;td&gt;Target&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GCC static libraries&lt;/td&gt;
      &lt;td&gt;Link with compiled program&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GCC dynamic libraries&lt;/td&gt;
      &lt;td&gt;Link with compiled program&lt;/td&gt;
      &lt;td&gt;Target&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CRT object files&lt;/td&gt;
      &lt;td&gt;Program compilation&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GCC headers&lt;/td&gt;
      &lt;td&gt;Program compilation&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Linker scripts&lt;/td&gt;
      &lt;td&gt;Produce object file&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Documentation&lt;/td&gt;
      &lt;td&gt;Get to perform tasks&lt;/td&gt;
      &lt;td&gt;Host&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;gcc-toolkit-build-process&quot;&gt;GCC Toolkit Build Process&lt;/h3&gt;

&lt;p&gt;Build by steps -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Tool&lt;/th&gt;
      &lt;th&gt;Note&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Binutils&lt;/td&gt;
      &lt;td&gt;Linker and assembler most importantly&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GCC dependency libs&lt;/td&gt;
      &lt;td&gt;Needed for build-time calculations&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1st stage GCC&lt;/td&gt;
      &lt;td&gt;Static C only, no libc&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Libc&lt;/td&gt;
      &lt;td&gt;Build both dynamic linker/loader, and C library&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2nd stage GCC&lt;/td&gt;
      &lt;td&gt;Libgcc built here; Need to know libc type/ver(1)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Changing Libc requires GCC rebuild!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most notably, used architecture, ABI is used for building libc and
libgcc. This means that:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Whatever architecture configuration modifications are performed
during application build, originally built libc and libgcc are still
going to be used.&lt;/li&gt;
  &lt;li&gt;Any change needed necessitates rebuild for both libc and libgcc.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;cross-compilation-toolkit-install-directory-contents&quot;&gt;Cross-Compilation Toolkit Install Directory Contents&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;GCC requires binutils names without prefix&lt;/li&gt;
  &lt;li&gt;GCC cross-compiler naming prefix - Autoconf system canonical name -
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;arch&amp;gt;-&amp;lt;vendor&amp;gt;-&amp;lt;os&amp;gt;-&amp;lt;libc/abi&amp;gt;&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Standard C++ library considered as a build-up to C library&lt;/li&gt;
  &lt;li&gt;GCC library headers&lt;/li&gt;
  &lt;li&gt;Linker scripts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;potential-use-cases&quot;&gt;Potential Use Cases&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Build GCC using prebuilt Glibc - Won’t work&lt;/li&gt;
  &lt;li&gt;Build newer GCC than the one used on target - Works, although libgcc
compatibility not guaranteed.&lt;/li&gt;
  &lt;li&gt;Build with newer Glibc than the one used on target - Works,
execution risky.&lt;/li&gt;
  &lt;li&gt;Using toolchain built for different machine - Works, execution not
guaranteed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://bootlin.com/pub/conferences/2016/elce/petazzoni-toolchain-anatomy/petazzoni-toolchain-anatomy.pdf&quot;&gt;bootlin_cctc_slides&lt;/a&gt; : “Anatomy of Cross-Compilation Toolchains”
presentation slides.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://youtu.be/Pbt330zuNPc&quot;&gt;bootlin_cctc_rec&lt;/a&gt; : “Anatomy of Cross-Compilation Toolchains”
presentation recording.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Submodel-Options.html&quot;&gt;gcc_mach-dep-opt&lt;/a&gt; : GCC machine-dependent options - Machine
architecture, ABI, etc.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gcc.gnu.org/install/configure.html&quot;&gt;gcc_build-config&lt;/a&gt; : GCC build - Configuration options.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://bootlin.com/doc/training/embedded-linux/embedded-linux-slides.pdf&quot;&gt;bootlin_emblin_slides&lt;/a&gt; : General information on cross-compilers.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html&quot;&gt;tldp_so&lt;/a&gt; : Naming, version info on shared libraries.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.redhat.com/blog/2019/08/01/how-the-gnu-c-library-handles-backward-compatibility/&quot;&gt;redhat_lib-if-vers&lt;/a&gt; : How library does interface versioning.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/System-Type.html#System-Type&quot;&gt;autoconf_gcc-prefix&lt;/a&gt; : Cross-compiler GCC prefix format.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gcc.gnu.org/releases.html&quot;&gt;gcc_releases&lt;/a&gt; : GCC release history.&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Marko Oklobdžija</name></author><category term="analysis" /><category term="cross-compilation" /><category term="gcc" /><category term="linux" /><category term="libc" /><summary type="html">arm-linux-gnueabihf, almost usable for all ARM platforms.</summary></entry><entry><title type="html">Cross-compile Program for Raspbian</title><link href="https://kibihrchak.github.io/guides/2020/05/23/raspbian-cross-compile.html" rel="alternate" type="text/html" title="Cross-compile Program for Raspbian" /><published>2020-05-23T00:00:00+00:00</published><updated>2020-05-23T00:00:00+00:00</updated><id>https://kibihrchak.github.io/guides/2020/05/23/raspbian-cross-compile</id><content type="html" xml:base="https://kibihrchak.github.io/guides/2020/05/23/raspbian-cross-compile.html">&lt;p&gt;“Hello, Raspbian from a more capable build machine!\n”&lt;/p&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;

&lt;ol id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; id=&quot;markdown-toc-table-of-contents&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#cross-compilation-toolchain-selection&quot; id=&quot;markdown-toc-cross-compilation-toolchain-selection&quot;&gt;Cross-Compilation Toolchain Selection&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#environmentproject-setup-procedure&quot; id=&quot;markdown-toc-environmentproject-setup-procedure&quot;&gt;Environment/Project Setup Procedure&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#building-the-project&quot; id=&quot;markdown-toc-building-the-project&quot;&gt;Building The Project&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#resources&quot; id=&quot;markdown-toc-resources&quot;&gt;Resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#to-do&quot; id=&quot;markdown-toc-to-do&quot;&gt;To-Do&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;Goal is to set up a cross-compilation environment on an Ubuntu-based
machine and build a “Hello, world!” CMake project for the target.&lt;/p&gt;

&lt;p&gt;Setup used for testing is -&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Component&lt;/th&gt;
      &lt;th&gt;Value&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Build OS&lt;/td&gt;
      &lt;td&gt;Ubuntu 20.04 LTS&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Target OS&lt;/td&gt;
      &lt;td&gt;Raspbian Buster Lite, February 2020&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Target platform&lt;/td&gt;
      &lt;td&gt;Raspberry Pi 3 Model B&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;cross-compilation-toolchain-selection&quot;&gt;Cross-Compilation Toolchain Selection&lt;/h2&gt;

&lt;p&gt;Here, the main point is to obtain the cross-compilation toolchain for
RPi. The important thing is that this toolchain produces binaries which
are compatible with the execution environment. This is a topic to be
covered, but for now following toolchains will work:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Source&lt;/th&gt;
      &lt;th&gt;GCC version&lt;/th&gt;
      &lt;th&gt;Source&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/raspberrypi/tools&quot;&gt;toolchain_rpi&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;4.9.3&lt;/td&gt;
      &lt;td&gt;Raspberry Pi Foundation&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/Pro/raspi-toolchain&quot;&gt;toolchain_pro&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;8.3.0&lt;/td&gt;
      &lt;td&gt;Alternative build by Pro&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;RPi repo has several toolchains. Select one per &lt;a href=&quot;https://deardevices.com/2019/04/18/how-to-crosscompile-raspi/&quot;&gt;this
article&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;environmentproject-setup-procedure&quot;&gt;Environment/Project Setup Procedure&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Checkout this repo with test CMake projects - &lt;a href=&quot;https://github.com/kibihrchak/hello-vscode-cmake&quot;&gt;GitHub
link&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Set up the RPi test project per its readme.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;building-the-project&quot;&gt;Building The Project&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Run configure/build for CMake (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;project&amp;gt;/build$ cmake .. &amp;amp;&amp;amp; make&lt;/code&gt;).&lt;/li&gt;
  &lt;li&gt;Built binaries are in CMake subproject subdirectories.&lt;/li&gt;
  &lt;li&gt;We can verify they have been cross compiled by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&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;lt;project&amp;gt;/build/hello-raspbian-cross-pi-gcc$ file HelloRaspbianCrossPiGcc 
HelloRaspbianCrossPiGcc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, with debug_info, not stripped
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/raspberrypi/tools&quot;&gt;toolchain_rpi&lt;/a&gt; : Overview of MCU and the ESP32-based boards.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Pro/raspi-toolchain&quot;&gt;toolchain_pro&lt;/a&gt; : Page with pretty much everything on ESP32.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/kibihrchak/hello-vscode-cmake&quot;&gt;hello-vscode-cmake&lt;/a&gt; : Repo with test CMake project.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/&quot;&gt;pro-toolchain-build&lt;/a&gt; : Article on building a GCC toolchain for RPi.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cmake.org/cmake/help/v3.17/manual/cmake-toolchains.7.html#cross-compiling-for-linux&quot;&gt;cmake-cross-compile&lt;/a&gt; : How to setup CMake project for cross
compilation.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://deardevices.com/2019/04/18/how-to-crosscompile-raspi/&quot;&gt;deardevices_rpi-cross-compile&lt;/a&gt; : How to setup RPi provided
toolchains.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;to-do&quot;&gt;To-Do&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Checklist for toolchain suitability for the given target.&lt;/li&gt;
&lt;/ol&gt;</content><author><name>Marko Oklobdžija</name></author><category term="guides" /><category term="rpi" /><category term="cmake" /><category term="raspbian" /><category term="cross-compilation" /><summary type="html">“Hello, Raspbian from a more capable build machine!\n”</summary></entry><entry><title type="html">Git Guide</title><link href="https://kibihrchak.github.io/guides/2020/05/15/git.html" rel="alternate" type="text/html" title="Git Guide" /><published>2020-05-15T00:00:00+00:00</published><updated>2020-05-15T00:00:00+00:00</updated><id>https://kibihrchak.github.io/guides/2020/05/15/git</id><content type="html" xml:base="https://kibihrchak.github.io/guides/2020/05/15/git.html">&lt;p&gt;Some tips and tricks on Git collected here and there.&lt;/p&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;

&lt;ol id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; id=&quot;markdown-toc-table-of-contents&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#credentials-management&quot; id=&quot;markdown-toc-credentials-management&quot;&gt;Credentials Management&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#line-endings-configuration&quot; id=&quot;markdown-toc-line-endings-configuration&quot;&gt;Line Endings Configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;credentials-management&quot;&gt;Credentials Management&lt;/h2&gt;

&lt;p&gt;The question addressed here is - What I need to do to get my credentials
stored in a safe way, and avoid getting prodded for them every time I
access a remote like GitHub. And, switching to SSH key pair
authentication is either inconvenient or not possible.&lt;/p&gt;

&lt;p&gt;The procedure is this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Set up low-risk credentials - This is not Git-specific topic, but
useful nevertheless. The idea is to use access tokens instead of an
account password when accessing the site repo (GitHub, TFS). These
tokens may have limited permitted operations scope, thus lowering
damage done by them being exposed. Process here is:
    &lt;ol&gt;
      &lt;li&gt;Find a way to generate a token on the used remote - Eg. for
GitHub that can be done over
&lt;a href=&quot;https://github.com/settings/tokens&quot;&gt;https://github.com/settings/tokens&lt;/a&gt;.&lt;/li&gt;
      &lt;li&gt;Use generated token instead of the account password when
accessing that site repos.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;See what credential helpers are available for Git installation -
    &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;$ git help -a | grep credential-
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Some common options here are:&lt;/p&gt;

    &lt;table&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Helper&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cache&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;In-memory temporary storage&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;store&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Plaintext file (usually &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.git-credentials&lt;/code&gt;)&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;manager&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Windows Credential Store&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wincred&lt;/code&gt;&lt;/td&gt;
          &lt;td&gt;Deprecated in favor of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;manager&lt;/code&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/li&gt;
  &lt;li&gt;Set the credential helper -
    &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;$ git config --global credential.helper &amp;lt;helper&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;More info on this topic -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage&quot;&gt;Credentials configuration manpage&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://git-scm.com/docs/gitcredentials&quot;&gt;Pro Git book chapter on credentials&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;line-endings-configuration&quot;&gt;Line Endings Configuration&lt;/h2&gt;

&lt;p&gt;Ok, this is a common topic but still worth reiterating. Basically, aim
is to get a consistent line endings for text files, both in the
repository and in the working directory. These would be:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;All LF in the repo.&lt;/li&gt;
  &lt;li&gt;On Windows machine, all CRLF except for the files marked as LF (eg.
Bash scripts).&lt;/li&gt;
  &lt;li&gt;On Linux machine, all LF except for the files marked as CRLF (eg.
Visual Studio project file).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Steps to do this are:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Set line ending conversion for commit/checkout:
    &lt;ol&gt;
      &lt;li&gt;(on Windows) Set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.autocrlf&lt;/code&gt;, so that all checked out text
files have CRLF newline -
        &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;$ git config --global core.autocrlf true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;(on other LF-using platforms) These platforms do not require
conversion from Git default LF line endings, so:
        &lt;ol&gt;
          &lt;li&gt;See that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.autocrlf&lt;/code&gt; is unset or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; as this option
is intended for Windows use -
            &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;$ git config --get core.autocrlf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;            &lt;/div&gt;
          &lt;/li&gt;
          &lt;li&gt;In addition, check that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core.eol&lt;/code&gt; is unset or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;native&lt;/code&gt; as
we will be using native line endings -
            &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;$ git config --get core.eol
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;            &lt;/div&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Set repo configuration for files that should keep their line endings
regardless of the platform (eg. Bash scripts when checked out on
Windows, or Visual Studio project when checked out on Linux):
    &lt;ol&gt;
      &lt;li&gt;Create &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.gitattributes&lt;/code&gt; file in the root directory for files to
be configured.&lt;/li&gt;
      &lt;li&gt;State expected line endings for required paths, eg. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.sln text
eol=crlf&lt;/code&gt;.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Renormalize line endings, and commit renormalized endings (if there
is any) -
    &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;(repo)$ git add --renormalize .
(repo)$ git commit -m &quot;Renormalize line endings&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;More info on this topic -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings&quot;&gt;GitHub on line endings&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.hanselman.com/blog/CarriageReturnsAndLineFeedsWillUltimatelyBiteYouSomeGitTips.aspx&quot;&gt;Scott Hanselman on line ending in Git&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf&quot;&gt;StackOvervflow question on LF/CRLF warnings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Marko Oklobdžija</name></author><category term="guides" /><category term="git" /><summary type="html">Some tips and tricks on Git collected here and there.</summary></entry><entry><title type="html">Visual Studio Code and CMake (and Other Tools)</title><link href="https://kibihrchak.github.io/articles/2020/05/14/vscode-cmake.html" rel="alternate" type="text/html" title="Visual Studio Code and CMake (and Other Tools)" /><published>2020-05-14T00:00:00+00:00</published><updated>2020-05-14T00:00:00+00:00</updated><id>https://kibihrchak.github.io/articles/2020/05/14/vscode-cmake</id><content type="html" xml:base="https://kibihrchak.github.io/articles/2020/05/14/vscode-cmake.html">&lt;p&gt;Visual Studio Code and C/C++ project development? Let’s see how they
work together.&lt;/p&gt;

&lt;h2 id=&quot;separation-of-paths&quot;&gt;Separation of Paths&lt;/h2&gt;

&lt;p&gt;When started with C/C++ software development, I didn’t give much thought
on the integration of components that make an IDE. Basically, what I did
is to fire it up, create a project which automagically set up build
configurations, altogether with toolchain, sources and includes
configuration, and then - code away! Code assistance operations like
disabling inactive code lines, code completion, jump to definition
worked out of the box, as well as highlighting of syntax and compile
errors.&lt;/p&gt;

&lt;p&gt;This mode of operation translated seamlessly to the MCU embedded
development, with every vendor providing a complete tool ecosystem for
creating a firmware to be executed on their hardware platform portfolio.
But, on the other hand, Linux application development diverged in the
other area, one with clear demarcation between the code editor, and the
build system. There, former was seen as independent from the latter, and
furthermore, oblivious to the configuration provided by it. And, even
with the editor providing facilities as aforementioned code assistance
and highlighting, it was often a manual process to keep its perception
of software project configuration in line with the build system’s one.
This led to being wary of these “assistance” tools as they could provide
a false image on the project code, and went as far as ditching them
altogether and demoting the code editor to a intelligent text editor at
best, dumb notepad at worst.&lt;/p&gt;

&lt;h2 id=&quot;enter-vs-code&quot;&gt;Enter VS Code&lt;/h2&gt;

&lt;p&gt;There were previous interests for regaining this connection between a
development environment and a code editor, but with short longevity.
This state of affairs went on as I got introduced to a
&lt;a href=&quot;https://code.visualstudio.com/&quot;&gt;VS Code&lt;/a&gt;. I’ve ditched it first as a
coding hipsters kind of a tool, especially seeing it in light of web
development where it first took ahold. Instead, I’ve stuck rather to a
proven Vim text editing environment. But, gradually I transitioned to
VS Code, mostly driven by liking of its workspace management and a
suitable enough Vim extension. With time it became my main file projects
management tool, providing almost all-in-one environment for needed
operations.&lt;/p&gt;

&lt;p&gt;So, with that in mind I’ve revisited the old topic of bridging a gap
between a code editor and a the build system. The question was, can
Visual Studio Code be connected with a C/C++ set up console-driven build
system, and assist in the code development while relying on the project
configuration specified outside of it?&lt;/p&gt;

&lt;h2 id=&quot;setting-the-stage&quot;&gt;Setting The Stage&lt;/h2&gt;

&lt;p&gt;First topic to clarify was, what would be the assumed build system to
attach to? &lt;a href=&quot;https://cmake.org/&quot;&gt;CMake&lt;/a&gt; here came out as a first
candidate, as it is a popular-enough project
configure/build/test/package toolkit, and with which I had most previous
experience. As for the other options, plain Makefiles are also a good
option but more suitable for simpler task specification, and other
toolkits I haven’t considered at all.&lt;/p&gt;

&lt;p&gt;Second topic was, what would be the expectations from the integration?
From the top of the head first would be code assistance aligned with
selected build configuration, that is with selected source files to be
built, included includes and libraries, and project defines. Next in
line would be interface for running build system tasks, then
configuration of the debugger so that a debug session can be ran from
VS Code. As a last addition, integration with code writing assistance
tools, namely a formatter and a static analysis would be great, with
latter again aligned to the current build configuration.&lt;/p&gt;

&lt;p&gt;For formatting and static analysis choice fell on the Clang toolkit,
&lt;a href=&quot;https://clang.llvm.org/docs/ClangFormat.html&quot;&gt;ClangFormat&lt;/a&gt; and
&lt;a href=&quot;https://clang.llvm.org/extra/clang-tidy/&quot;&gt;Clang-Tidy&lt;/a&gt;, mostly because
they’re good free tools, with configuration specifiable in config files,
and with good preexisting integration to VS Code and CMake.&lt;/p&gt;

&lt;h2 id=&quot;add-extensions-to-the-mix&quot;&gt;Add Extensions to The Mix&lt;/h2&gt;

&lt;p&gt;Basically, to get things running all I needed were two extensions for
VS Code -
&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ms-vscode.cpptools&lt;/code&gt;&lt;/a&gt;
for code assistance and formatting, and
&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ms-vscode.cmake-tools&lt;/code&gt;&lt;/a&gt;
for CMake integration. With them, and with other prerequisite packages
installed in the evaluation VM (gdb, clang-format, clang-tidy), I was
set to go.&lt;/p&gt;

&lt;h2 id=&quot;initial-impressions&quot;&gt;Initial Impressions&lt;/h2&gt;

&lt;p&gt;In short, positive. Code assistance works for the opened projects, even
if CMake contains subprojects with same-named symbols. Interface also
works without a hitch - Configuring project, building it, running
particular subproject. Debugging, too, non-compiled code gets ignored
just fine.&lt;/p&gt;

&lt;p&gt;For the additional tools, VS Code invokes formatting per given
configuration, while static analysis is enabled through CMake and ran
before the compilation unit build. What made me smile is that the
reported analysis findings are shown in the code editor window
altogether with squiggly lines.&lt;/p&gt;

&lt;h2 id=&quot;what-next&quot;&gt;What Next?&lt;/h2&gt;

&lt;p&gt;Well, good initial findings are there, but there’s still that nagging
feeling about disjuncture between the build system and code editor.
Guess it will need some additional test projects and the use of this
integration on the actual projects to dispel that impression.&lt;/p&gt;

&lt;p&gt;If you want to check it out, current VS Code workspace with test
projects I have hosted on GitHub - &lt;a href=&quot;https://github.com/kibihrchak/hello-vscode-cmake&quot;&gt;here’s a repo
link&lt;/a&gt;.&lt;/p&gt;</content><author><name>Marko Oklobdžija</name></author><category term="articles" /><category term="development-environment" /><category term="vs-code" /><category term="cmake" /><category term="clang" /><category term="static-analysis" /><summary type="html">Visual Studio Code and C/C++ project development? Let’s see how they work together.</summary></entry><entry><title type="html">Heltec ESP32 Door Lock Notifier</title><link href="https://kibihrchak.github.io/guides/2019/08/11/heltec-esp32-door-lock-notifier.html" rel="alternate" type="text/html" title="Heltec ESP32 Door Lock Notifier" /><published>2019-08-11T00:00:00+00:00</published><updated>2019-08-11T00:00:00+00:00</updated><id>https://kibihrchak.github.io/guides/2019/08/11/heltec-esp32-door-lock-notifier</id><content type="html" xml:base="https://kibihrchak.github.io/guides/2019/08/11/heltec-esp32-door-lock-notifier.html">&lt;p&gt;Did I turn on the notification that my apartment door is locked?!&lt;/p&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;

&lt;ol id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; id=&quot;markdown-toc-table-of-contents&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#esp32&quot; id=&quot;markdown-toc-esp32&quot;&gt;ESP32&lt;/a&gt;    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#heltec-wifi-lora-32&quot; id=&quot;markdown-toc-heltec-wifi-lora-32&quot;&gt;Heltec WiFi LoRa 32&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#arduino-ide&quot; id=&quot;markdown-toc-arduino-ide&quot;&gt;(Arduino) IDE&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#door-lock-notifier&quot; id=&quot;markdown-toc-door-lock-notifier&quot;&gt;Door Lock Notifier&lt;/a&gt;    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#development-decisions&quot; id=&quot;markdown-toc-development-decisions&quot;&gt;Development Decisions&lt;/a&gt;        &lt;ol&gt;
          &lt;li&gt;&lt;a href=&quot;#detect-door-lockunlock&quot; id=&quot;markdown-toc-detect-door-lockunlock&quot;&gt;Detect Door Lock/Unlock&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#connection-to-ifttt-server&quot; id=&quot;markdown-toc-connection-to-ifttt-server&quot;&gt;Connection to IFTTT Server&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#module-autonomy&quot; id=&quot;markdown-toc-module-autonomy&quot;&gt;Module Autonomy&lt;/a&gt;&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#system-components&quot; id=&quot;markdown-toc-system-components&quot;&gt;System Components&lt;/a&gt;        &lt;ol&gt;
          &lt;li&gt;&lt;a href=&quot;#notification-mechanism&quot; id=&quot;markdown-toc-notification-mechanism&quot;&gt;Notification Mechanism&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#notifier&quot; id=&quot;markdown-toc-notifier&quot;&gt;Notifier&lt;/a&gt;&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#results&quot; id=&quot;markdown-toc-results&quot;&gt;Results&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#resources&quot; id=&quot;markdown-toc-resources&quot;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;About a year ago I’ve bought 2 Heltec’s ESP32 modules, and after
checking them out if they work put them in a drawer where they stayed
ever since. Thought it would be good to dust them off and give them a
try, especially that I haven’t worked with Espressif microcontrollers
before.&lt;/p&gt;

&lt;p&gt;After some initial research on the MCU/module, an idea came to me to
make as a mini learning project a door lock notifier. Ever once in a
while I have that “did I lock the door or not?” moment with the
apartment door, so that would be a good place to put the these modules
to use.&lt;/p&gt;

&lt;h2 id=&quot;esp32&quot;&gt;ESP32&lt;/h2&gt;

&lt;p&gt;First, onto ESP32. In short, this is an MCU with 32b CPU and a whole
bunch of peripherals, most notably integrated WiFi/BT module. Quick
overview can be found on a &lt;a href=&quot;https://en.wikipedia.org/wiki/ESP32&quot;&gt;Wiki page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Its predecessor was ESP8266, most notably known through
&lt;a href=&quot;https://www.nodemcu.com/index_en.html&quot;&gt;NodeMcu&lt;/a&gt;. For a comparison what has changed, there’s a
&lt;a href=&quot;https://www.cnx-software.com/2016/03/25/esp8266-and-esp32-differences-in-one-single-table/&quot;&gt;comparison with ESP8266&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As for the ESP32-relevant information, the best repository is the
&lt;a href=&quot;http://esp32.net/&quot;&gt;esp32.net&lt;/a&gt;. There you can find -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://esp32.net/#Hardware&quot;&gt;Chip/module portfolio&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://esp32.net/#Development&quot;&gt;How to do the development&lt;/a&gt; - Arduino IDE,
ESP-IDF&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to this, TRM can be found on the &lt;a href=&quot;https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf&quot;&gt;Espressif official
webpage&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;heltec-wifi-lora-32&quot;&gt;Heltec WiFi LoRa 32&lt;/h3&gt;

&lt;p&gt;Module that I have at hands is the &lt;a href=&quot;https://heltec.org/project/wifi-lora-32/&quot;&gt;Heltec’s WiFi LoRa 32
module&lt;/a&gt;. Here’s how it looks live -&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/guides/2019-08-11-heltec-esp32-door-lock-notifier/heltec-wifi-lora-32.jpg&quot; alt=&quot;Heltec WiFi LoRa 32&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In addition to all the ESP32 goodies, it also incorporates the following
features, first and the last found to be useful for this project -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A small OLED display&lt;/li&gt;
  &lt;li&gt;SX1276/1278 LoRa chip&lt;/li&gt;
  &lt;li&gt;Lithium battery interface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Useful stuff on the module (pinout, schematics, lib examples) can be
found on Heltec repos -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series&quot;&gt;Schematics, pinouts, general libraries examples&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/HelTecAutomation/Heltec_ESP32&quot;&gt;Module-specific examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;arduino-ide&quot;&gt;(Arduino) IDE&lt;/h3&gt;

&lt;p&gt;Next, the question is regarding the IDE for ESP32 modules, which one can
be used. There are two reasonable options -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Using Heltec’s ESP-IDF&lt;/li&gt;
  &lt;li&gt;Using Arduino IDE&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve went with the second option because it seemed as a faster way to
perform some quick prototyping. Here are some resources on setting up
the work environment -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/HelTecAutomation/Heltec_ESP32&quot;&gt;Arduino board, library setup&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino&quot;&gt;How to use it from VS Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;door-lock-notifier&quot;&gt;Door Lock Notifier&lt;/h2&gt;

&lt;p&gt;As for the mini project, the concept is following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Let the module somehow detect that the door has locked/unlocked.&lt;/li&gt;
  &lt;li&gt;Upon detecting the change, connect to local Internet-enabled WiFi
AP, through it to the IFTTT server, and send a POST request
containing the update message.&lt;/li&gt;
  &lt;li&gt;IFTTT will then using its Telegram bot generate a new message in the
messenger.&lt;/li&gt;
  &lt;li&gt;This message can then be observed via phone.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s an overview of the system components -&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/guides/2019-08-11-heltec-esp32-door-lock-notifier/connection-diagram.png&quot; alt=&quot;connection diagram&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;development-decisions&quot;&gt;Development Decisions&lt;/h3&gt;

&lt;h4 id=&quot;detect-door-lockunlock&quot;&gt;Detect Door Lock/Unlock&lt;/h4&gt;

&lt;p&gt;First question that appeared was - How to detect door lock/unlock event?&lt;/p&gt;

&lt;p&gt;The preferred way would be to use the movement of the lock deadbolt to
determine the transition between locked/unlocked state. This has a
benefit that the perceived state can quite certainly correspond to the
actual state.&lt;/p&gt;

&lt;p&gt;As for detecting this transition, the straightforward way would be to
use a micro switch installed in the door frame, so that it gets closed
by a deadbolt going in the frame. But, the cheaper and faster option for
the prototyping purpose is to use the fact that deadbolts are made of
metal in order to be strong enough. Metal deadbolt, being conductive,
can itself serve as a part of a switch. Additional hardware would then
require just two additional leaf contacts leading to the used Heltec
board pins. Here’s how it looks like from side -&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/guides/2019-08-11-heltec-esp32-door-lock-notifier/deadbolt-sketch.jpg&quot; alt=&quot;connection diagram&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;connection-to-ifttt-server&quot;&gt;Connection to IFTTT Server&lt;/h4&gt;

&lt;p&gt;For connecting to the IFTTT server &lt;a href=&quot;https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi/examples/WiFiClient&quot;&gt;WiFi Client example
sketch&lt;/a&gt; has been used, spiced up with &lt;a href=&quot;https://techtutorialsx.com/2017/11/18/esp32-arduino-https-get-request/&quot;&gt;the example on how
to do HTTPS connection&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;module-autonomy&quot;&gt;Module Autonomy&lt;/h4&gt;

&lt;p&gt;As the module is running on a battery, it would be preferable to lower
its power consumption so that it can operate for the extended period of
time. Of course, connecting it on an USB adapter would be the best
solution, but there were none close to the door and stretching the
cables over the wall wasn’t an option.&lt;/p&gt;

&lt;p&gt;Fortunately, ESP32 supports several power models, one of them being a
deep-sleep one, with -&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;~6.5uA current consumption&lt;/li&gt;
  &lt;li&gt;RTC memory persistence&lt;/li&gt;
  &lt;li&gt;External wake-up source&lt;/li&gt;
  &lt;li&gt;And most importantly for fast prototyping, Arduino example sketch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, the solution was to use the door lock detection switch as a wake-up
source, and set the wake-up level opposite of the last read out. &lt;a href=&quot;https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/DeepSleep/ExternalWakeUp&quot;&gt;Deep
sleep Arduino example&lt;/a&gt; has been used as a basis for
it.&lt;/p&gt;

&lt;h3 id=&quot;system-components&quot;&gt;System Components&lt;/h3&gt;

&lt;h4 id=&quot;notification-mechanism&quot;&gt;Notification Mechanism&lt;/h4&gt;

&lt;p&gt;Notification chain for IFTTT looks like -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Set up web request with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;esp32_reading&lt;/code&gt; event name.&lt;/li&gt;
  &lt;li&gt;Send message to Telegram private chat with IFTTT bot with following
format:
    &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;What: {{EventName}}&amp;lt;br&amp;gt;
When: {{OccurredAt}}&amp;lt;br&amp;gt;
Door status: {{Value1}}&amp;lt;br&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;notifier&quot;&gt;Notifier&lt;/h4&gt;

&lt;p&gt;Hardware outline is this -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Connect Heltec board to battery and leaf-contact simulating wires.&lt;/li&gt;
  &lt;li&gt;Use breadboard to hold everything together.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s how it looks like -&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/guides/2019-08-11-heltec-esp32-door-lock-notifier/hw-setup.jpg&quot; alt=&quot;hw-setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here is the connection table for the used pins based on the &lt;a href=&quot;https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series&quot;&gt;pinout
diagram&lt;/a&gt;:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Pin&lt;/th&gt;
      &lt;th&gt;Use&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;GND&lt;/td&gt;
      &lt;td&gt;Leaf wire 1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;0 (PRG button)&lt;/td&gt;
      &lt;td&gt;Leaf wire 2&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;As for the Arduino sketch, it’s uploaded to the &lt;a href=&quot;https://github.com/kibihrchak/door-lock-notifier&quot;&gt;GitHub
repo&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;results&quot;&gt;Results&lt;/h3&gt;

&lt;p&gt;Here’s the live demonstration - &lt;a href=&quot;https://www.youtube.com/watch?v=mfEv6WS8OTA&quot;&gt;YouTube
video&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;During the use, two main observed issues were:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Sporadic triggering.&lt;/li&gt;
  &lt;li&gt;Battery drain.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/ESP32&quot;&gt;esp32-wiki&lt;/a&gt; : Overview of MCU and the ESP32-based boards.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://esp32.net/&quot;&gt;esp32-net&lt;/a&gt; : Page with pretty much everything on ESP32.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nodemcu.com/index_en.html&quot;&gt;node-mcu&lt;/a&gt; : NodeMcu page.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.cnx-software.com/2016/03/25/esp8266-and-esp32-differences-in-one-single-table/&quot;&gt;esp-comparison-table&lt;/a&gt; : ESP8266/ESP32 comparison table.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://esp32.net/#Hardware&quot;&gt;esp32-hardware&lt;/a&gt; : Comprehensive overview of ESP32 chips and
modules.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://esp32.net/#Development&quot;&gt;esp32-development&lt;/a&gt; : Comprehensive overview of ESP32 development
tools.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf&quot;&gt;esp32-trm&lt;/a&gt; : ESP32 technical reference manual.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://heltec.org/project/wifi-lora-32/&quot;&gt;heltec-wifi-lora-32&lt;/a&gt; : Heltec WiFi LoRa 32 module info page.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series&quot;&gt;module-resources&lt;/a&gt; : Module schematic, pinout.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md&quot;&gt;esp32-arduino-install&lt;/a&gt; : Arduino setup for ESP32 boards.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/HelTecAutomation/Heltec_ESP32&quot;&gt;heltec-esp32-arduino-lib&lt;/a&gt; : Installation procedure for Heltec ESP32
Arduino library.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino&quot;&gt;arduino-vscode-extension&lt;/a&gt; : VS Code Arduino extension.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi/examples/WiFiClient&quot;&gt;wifi-sketch&lt;/a&gt; : ESP32 WiFi client sample sketch.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://techtutorialsx.com/2017/11/18/esp32-arduino-https-get-request/&quot;&gt;https-get-request&lt;/a&gt; : Guide how to create GET request over HTTPS.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/DeepSleep/ExternalWakeUp&quot;&gt;deep-sleep-sketch&lt;/a&gt; : ESP32 deep sleep sample sketch.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/kibihrchak/door-lock-notifier&quot;&gt;sketch-repo&lt;/a&gt; : Sketch repo.&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Marko Oklobdžija</name></author><category term="guides" /><category term="embedded" /><category term="heltec" /><category term="esp32" /><category term="ifttt" /><summary type="html">Did I turn on the notification that my apartment door is locked?!</summary></entry></feed>