A developer personal journal

A pretty small window from me to the world

site  contact   history  index 

Experience Building Neovim in RiscV64 Banana Pi BPI-F3

September 21, 2024 — Andres H

Hmm. It had been a while from my last post, but I received not too much time ago a riscv SBC. I was pretty excited, to just check it out but after testing out spacemiT bianbuOS I was dissapointed about the performance.

I decided to try and install terminal based code editor such as neovim/helix, but after apt-get returned no results for the architecture, I was pretty surprised but I thought (meh it has to be that at this moment that is not the focus). So I just decided "why not experiment building from source some fun stuff", so I tried to compile helix-editor as Rust was available for riscv, then when trying to compile hit a wall as kernel 6.1.15 had a nasty error and well had to be patched at kernel level, then I had to decide, should I continue? should I wait for a new kernel to be released? I chose the second.

Then while waiting (at the time of this blog post yet we are all waiting for kernel 6.6 to be released for this SBC) I decided to try a different editor, something maybe not that uncommon like and I jump ahead and tried to build Neovim

danaus@bananapif3 
                                 ----------------- 
      █ █ █ █ █ █ █ █ █ █ █      OS: Armbian (24.5.0-trunk) riscv64 
     ███████████████████████     Host: spacemit k1-x deb1 board 
   ▄▄██                   ██▄▄   Kernel: 6.1.15-legacy-k1 
   ▄▄██    ███████████    ██▄▄   Uptime: 6 mins 
   ▄▄██   ██         ██   ██▄▄   Packages: 1292 (dpkg) 
   ▄▄██   ██         ██   ██▄▄   Shell: bash 5.2.15 
   ▄▄██   ██         ██   ██▄▄   Resolution: 1680x1050 
   ▄▄██   █████████████   ██▄▄   DE: GNOME 45.2 
   ▄▄██   ██         ██   ██▄▄   WM: Mutter 
   ▄▄██   ██         ██   ██▄▄   WM Theme: Adwaita 
   ▄▄██   ██         ██   ██▄▄   Theme: Flat-Remix-GTK-Light-Solid [GTK2/3] 
   ▄▄██                   ██▄▄   Icons: Flat-Remix-Green-Light [GTK2/3] 
     ███████████████████████     Terminal: x-terminal-emul 
      █ █ █ █ █ █ █ █ █ █ █      CPU: Spacemit X60 (8) @ 1.600GHz 
                                 Memory: 652MiB / 3805MiB 

                                                         

And as I stated before, I let the output of an attempt to install neovim from repository.

danaus@bananapif3:~$ sudo apt-get install neovim
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package neovim is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'neovim' has no installation candidate

I went ahead to neovim's repo and selected 0.10 release and read the docs about building it.

First tried quick install so lets build prerequisites as the docs suggested:

sudo apt-get install ninja-build gettext cmake unzip curl build-essential

Then quickly continue on clonning the repo and try to make the installation.

git clone https://github.com/neovim/neovim
cd neovim 
git switch release-0.10
make CMAKE_BUILD_TYPE=RelWithDebInfo

But it was not able to complete. Here is the summary:

FAILED: build/src/luajit-stamp/luajit-install /home/danaus/neovim/.deps/build/src/luajit-stamp/luajit-install 
cd /home/danaus/neovim/.deps/build/src/luajit && /usr/bin/gmake -j CFLAGS=-fPIC CFLAGS+=-DLUA_USE_APICHECK CFLAGS+=-funwind-tables CCDEBUG+=-g Q= CC=/usr/bin/cc PREFIX=/home/danaus/neovim/.deps/usr install && /usr/bin/cmake -E touch /home/danaus/neovim/.deps/build/src/luajit-stamp/luajit-install
gmake[1]: Entering directory '/home/danaus/neovim/.deps/build/src/luajit'
==== Building LuaJIT 2.1 ====
/usr/bin/gmake -C src
gmake[2]: Entering directory '/home/danaus/neovim/.deps/build/src/luajit/src'
lj_arch.h:69:2: error: #error "Architecture not supported (in this version), see: https://luajit.org/status.html#architectures"
   69 | #error "Architecture not supported (in this version), see: https://luajit.org/status.html#architectures"
      |  ^~~~~
lj_arch.h:443:2: error: #error "No target architecture defined"
  443 | #error "No target architecture defined"
      |  ^~~~~
Makefile:270: *** Unsupported target architecture.  Stop.
gmake[2]: Leaving directory '/home/danaus/neovim/.deps/build/src/luajit/src'
gmake[1]: *** [Makefile:125: src/luajit] Error 2
gmake[1]: Leaving directory '/home/danaus/neovim/.deps/build/src/luajit'
[56/120] Performing configure step for 'treesitter_query'
-- The C compiler identification is GNU 13.2.0
........
ninja: build stopped: subcommand failed.
make: *** [Makefile:87: deps] Error 1

Quick inspection, and Eureka I needed some deps and use the manual installation with external dependencies (easy piece, right?). For Neovim version 0.10 I will need to install:

libuv libluv libvterm luajit lua-lpeg lua-mpack msgpack-c tree-sitter tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium

Let's go ahead. And try to install most of things.

sudo apt-get install lua5.1 
sudo apt-get install lua-luv lua-luv-dev

No issues, next install LuaJit

danaus@bananapif3:~/neovim$ sudo apt-get install luajit
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package luajit is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'luajit' has no installation candidate

So as stated before it seems that there is no native riscv64 LuaJit then I cannot continue. Hmm pretty annoying. Checking the source of LuaJit yet riscv64 is not supported. I decided to search for a port of the library. And I was very very lucky that already there is one available here, just not easy to find.

git clone https://github.com/plctlab/LuaJIT.git
cd LuaJIT/
danaus@bananapif3:~/LuaJIT$ git branch
* riscv64-v2.1-branch
sudo make install

Waiting a while gave me the following:

ln -sf luajit-2.1.1725179068 /usr/local/bin/luajit
==== Successfully installed LuaJIT 2.1.1725179068 to /usr/local ====

Then to check if my deps were helping me to progress in the build process I decided to try a compile on neovim again

danaus@bananapif3:~/neovim$ cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_BUNDLED=OFF -DUSE_BUNDLED_LIBVTERM=ON -DUSE_BUNDLED_LUAJIT=OFF
-- Found GNU Make at /usr/bin/gmake
-- CMAKE_BUILD_TYPE=RelWithDebInfo
-- Found Luajit: /usr/local/lib/libluajit-5.1.so  
-- Could NOT find Lua (missing: LUA_LIBRARIES LUA_INCLUDE_DIR) (Required is exact version "5.1")
-- Configuring done (1.5s)
-- Generating done (0.2s)
-- Build files have been written to: /home/danaus/neovim/.deps

Pretty rookie mistake Lua was missing but I am pretty sure I had installed, I soon realize that I had installed runtime instead of dev files.

sudo apt-get install liblua5.1-0-dev

Another try.

danaus@bananapif3:~/neovim$ cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_BUNDLED=OFF -DUSE_BUNDLED_LIBVTERM=ON -DUSE_BUNDLED_LUAJIT=OFF
-- Found GNU Make at /usr/bin/gmake
-- CMAKE_BUILD_TYPE=RelWithDebInfo
-- Found Lua: /usr/lib/riscv64-linux-gnu/liblua5.1.so;/usr/lib/riscv64-linux-gnu/libm.so (found suitable exact version "5.1.5") 
-- Configuring done (1.4s)
-- Generating done (0.1s)
-- Build files have been written to: /home/danaus/neovim/.deps
danaus@bananapif3:~/neovim$ cmake --build .deps
....
[28/28] Completed 'treesitter'

Yeah, dependencies completed. I crossed my fingers and then attemped the final build.

cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
And just for fun
sudo make install
....
[0/2] Re-checking globbed directories...
[2/3] Install the project...
-- Install configuration: "Debug"
-- Set runtime path of "/usr/local/bin/nvim" to ""

Even lua worked

Success!


Tags: tech

A bootcamp advisor experience

September 05, 2023 — Andres H

Long time without a new post well, I was pretty busy these past months, after the release of shellcms_b, I got involved in a project being a advisor in a C# bootcamp. And oh boy it was really a experience you won't imagine how many questions students could have, I believe I just recall my first days as a developer so much energy to use so much to say, new things to try and things that I just wanted to learn.

When I entered first in the class I was traveling to Cordoba here in Colombia, but well having the experience of being far away while listening the classic programming introduction to a language, the history, and so on so forth, then inmediatly a hands on, and a huge amount of questions just arised, students jumped in the editor right away and oh no, I did not have either a stable internet connection or a proper laptop.

So it became clear to me that I will need to be in a better position for next session. But again it was a little hard as it required me to connect in both Zoom and Discord just to assist people, but oh oh, I was in the middle of nowhere and the laptop I brought had not either .NET not a proper Zoom Client, even so I was able to assist people with my cellphone.

Well then it became clear that even when I bring the laptop to experience the goods of shellcms_b I did not have a proper copy of my files, and that was a revelation, that my experiment for shellcms_b will require more preparations from my side before jumping in. Sadly because of that I wasn't able to properly post here regularly, I did not want to redo all the posts. I got sick with some tropical variant of flu. So I didn't feel well enough to work 35C degree there were more than enough to keep me from doing extra job besides work.

For the end of that week I tried to install .net in my Manjaro old laptop, it worked pretty well even there and I was able to properly write and follow up code for the bootcamp session with helix editor instead of vscode.

Then I saw an opening, that really I could not be as productive as I wanted but at least I will have the oportunity to help with the code debugging thanks to the .net SDK installed.

After returning properly to my home office routine I wanted to set some goals:

  • Properly setting another environment for c# development in my personal computer.
  • Giving a talk to the students.
  • Work in the port of shellCMS_b to Powershell.

For the first time it was pretty easy as I had already VS Community in my computer I just needed the proper repository quick Git clone and everything was set

Second point was pretty daunting I hadn't ever give a talk, I am just a Chemical Engineer with not that wide idea of the world, but Git even if its wide its used everyday so I tried to make a short presentation in spanish based on various videos with basic stuff. Nothing too complex I did not want to overwelm people, I tried to be very concise when trying to use a branch strategy and on how to push branches to remotes. The fun fact with that talk was that I really wanted to show them things that I considered very basic, and then most of them had not even installed git before the session. That was both frustrating but also a reiminder that the level of the talk should be less bold. I had to change on the fly most of the topics getting in pretty nasty errors because I had not prepared well enough for that basic talk

After the talk, I felt that I needet to give the students a proper explanation and how to get out of that common issues that as developers we face a lot of times, handling unexpected situations, and properly addressing them even after the fact. So I created a youtube video in the old computer (yes an old intel i3 second gen), so I tried OBS for the first time and realized that nowadays technology for recording is amazing (In my times using virtualDub was the way and everything was very complicated to do). I just followed my own notes and recorded for an hour and a half, sent it to the students and they were happy with the session.

I decided in between the bootcamp to attempt to port shellcms_b to Powershell, I had done some progress and I hope I will continue with it also, wanted to style shellcms_b also for BlazeUI CSS framework and at least other two, just to be able to figure out important parts of the code for the style and eventually create a commandline with golang (yes golang) to pack everything.

Then I swtiched jobs (yes pretty funny stuff in my life in these past months) and of course as always as you are leaving a job place they will ask you to try to solve all problems at once just because. So I had even less time to stay behind classes for the bootcamp and getting out of my job, just to have to do the same but in the new job, pretty fun weeks.

I then gave my final talk to the bootcamp students on benchmarking, they did not seem that enthusiastic for that topic (probably because they were finishing at the end of that week) but even so, there was a fantastic way to feel less pressure and to go through all the points I wanted to show.

Finally at the graduation day I was there they were very happy. I could conclude that really most of them just went to the class to see a teacher doing everything and not all of them were very interested in really learning. That felt a little sad, because I am sure me and the other advisors were pretty energic on that idea, but well at the end I think if someone got pretty interested in the topic and tried to explore more about .net and C# we can pat our shoulders, that should be enough.

For now I finally could return to regularly posting here and trying to make my life easier with shellcms_b and have fun. As a side note, when I had been in very far places, where mobile phone internet signal is not that strong and we have only 3G network, I tried to load up this blog and the response time was amazing so I will not cease posting, I have discovered that the purpose for this continues to shine even in 2023.


Tags: general

About this blog (Part 2)

May 03, 2023 — Andres H

I had split this into two entries, one for the purpose itself and this one more about the technical side of things once I discussed why this blog is what is it.

At the end of my thought process I decided that I will make posts via a CMS called shellCMS that is a fork from bashblog but instead of using markdown it will let you use html, so as stated by shellCMS creator it will allow you to use your favorite WYSIWYG editor.

So I started then to look through the shellCMS documentation, pros and cons, finally I decided to give it a try, so I went ahead and downloaded the package from the author's website blog post. A very small package less than 1Mb uncompressed (It reminded me back in the 1.44mb era of floppy disks), so it is pretty portable, I had Ubuntu installed on my system so no issues from that side as it is intented to work with linux bash.

Until that everything seemed pretty smooth. I jump into the demo folders and go inside the www/news path and go over the cms_config folder opened the config file, checked the basics of the config file. I did not have seamonkey composer installed, so I made a tweak to change the editor to vscode just to see the tags of the base on the template. Then tried to start shellcms by doing ./shellcms www/news post with high expectatives. But was received by an error:

./shellcms: line 1630: [: /media/.../shellcms/geany: binary operator expected EDITOR='geany -i' PWD='/media/.../shellcms/www/news' EDITOR variable in 'config' file is invalid, aborting

The ... notation there is just the path to the shellcms installation folder. Well my first impression was "Oh its reading the wrong config file" and went to a folder 1 level up to the config file in the www folder, changed it and tested again, same issue. I Thought that it was that some weird issue with visual studio code was happening so switched to gedit then to helix and then to vi nothing worked.

At that point I just decided ok the application is complaining about geany, I want to post to my blog and its not time to be stubborn lets install geany. And after a sudo apt-get install after I had a pretty simple IDE that it wasn't WYSIWYG but at that point I wanted to see the cms working, but no luck either, I verified the documentation about the requirements for the editor, the instance awareness that it was required before trying to use shellcms. But there was no switch, no file nothing that could make the shellCMS editor to start. So I did the only thing I could ask the developer of the software in a Puppy Linux Discussion Forum Post on the EasyOS category. After discussion I ended inspecting the bash file itself. And oh no I had passed the boundary, the path of no return for a developer.

You could check in the link to the discussion forum the details on the issue, but at the end of the day there was a variable overwrite that stoped the shell from reading the variable on the config file, and then there was an issue with the validation of editors with instance aware switches, they will require a solution like suggested in the thread of using a wrapper script for geany or just to install seamonkey. But at that point I had been already triggered by that little monster-like bug that was going against the documentation

Let's be clear I consider myself a senior developer so I am not afraid of touching someone else's code. I knew for a fact that it was not an intended error and as always, you could overlook some details and you will not expect someone to use all the options besides the suggested path. So I went ahead and fix it. I made a change on the bash script so it could support editors with their respective "new instance" syntax. Then I forgot about the root cause beign that there was an internal overwrite of the configuration file in favor of the initialization of the variables at the begining of the script.

Now after sending the update to the software developer, the thrilling experience of fixing bugs in this software and just learning something new drove me to another path, the path of tweaking.

I decided to modify shellcms to support other custom styles besides just simple css, my next target was to make shellCMS to support bulma, and then I had a very different monster ahead one thing is fix a bug another is to change the template of a cms that was coded inside the cms code itself. So I decided to create a fork of shellCMS and create shellCMS_bulma it is called like the original software because it is not yet a very fundamental and total change to the original ideas logic of the original cms. But after some work I was able to edit my first post and get a very good result. The only tradeoff its the size of the bulma.css file but it fit my needs pretty well so I was happy with the result.

So it was very good excercise and journal to be here posting to my website from my very basic yet pretty customizable software. For shellcms_bulma I encourage to use a text editor or IDE like vscode, geany, helix so you could use all the bells and whistles from bulma css framework when creating a post it just abstract enough of the html syntax to be good to use.

I will finally comment about the infrastructure, as you had already seen this is a static website so basic infrastucture is needed but nothing special at all, you could check Github pages or cloudflare pages or Azure Web apps to see more about hosting, but almost any platform of cloud could host a static website, even you could with your computer (that is a more advanced topic that I will not cover in this post). I just grab the files and uploaded to the server and it was all, no pipelines, no build time, no waiting. And it worked pretty well at the first try, so my adventure had a nice end.

For the foreseeable future I plan to port shellcms_bulma to windows powershell just for fun and to enable windows users to use this software (when you travel its highly likely to have a windows pc near than a linux one so I prefer to give it a try)


Tags: shellcms_bulma

About this blog (Part 1)

May 02, 2023 — Andres H

This blog was built from the very begining as a side project for myself just to keep things that I want to share with the world but maybe I just didn't find a very efficient way of doing it

So I went ahead and I decided to adventure myself in the long adventure for a developer of choosing something that fit its actual needings, and let's be honest what could go wrong? (right?)

Here is a list of what were my requirements when I decided to create the blog:

  • I was sure it will a very small blog with not too much bells and whistles, so it required to be lightweight.
  • I needed to be very cheap to host (I had tried to use free hosts in the past, have very poor experiences with them).
  • As for now I did not want any related with money, I just wanted to share my thoughts.
  • Even if I do not need a catchy name I yet wanted something that was not just random numbers and words or maybe a very long name.
  • I wanted to be offline editable, so I could travel and share thoughts without the needed of fancy hardware.

But once you start doing your research the muffled js sounds huge ammount of possiblities flood you, and if you knew frontend developers, backend ones and so, you will get quickly overwelmed by them. There is a not ever ending Fear of missing out (FOMO) regarding the equilibrium between which technologies to use and the needs for a developer to keep creating new things. I thing that partially blind us when trying to choose. And as expected you wil try to deviate from your real objective.

After several days of thinking and seeking possibilities (thanks Youtube), I tried to see and demo some alternatives: Strapi, Wordpress, Ghost, Grav. When spending time on them, I was amazed at first as they were very rich, and seemed to have thought very well how to help you to elaborate content in very seamless ways. But then I started to check how to configure them and I started to realize that maybe again I was (as every dev at some point) overengineering the problem. What separated my needs from these alternatives?: User management and extensions If you are a comercial CMS of course you are looking to attract customers to your bussiness model, and you will offer them as much flexibility as the think they will need. But at some point you will be in the tradeoff between simplicity and learning curve.

At the list of checks that I had made before the first point whas stumbling pretty hard. Points 3 and 5 then put me back on track again. I was looking to keep the site very simple. Then I went the totally opposite direction. I went ahead and try to build a custom solution for my own use. So I decided to give a try to building a website from scratch.

Then it came to realization that I am not a frontend engineer, and more a backend one, so presentation it is not on my priority list, eventually I saw myself trying to set up a backend on golang, but for the frontend of the site I was somewhat struggling. Then I just thought:

  • Do I really need a backend for the blog?
  • Do I really need a database for this?
  • If I wanted to share my thoughts and maybe some specific pictures, how much space does that need?

Then a memory from the past just came to my mind. At my elementary school I did a course on internet stuff (here at South America by the 90's so try to imagine just modem internet 56k in some very specific places but that story is for another post). On that course we were teach about the basics of creating a website, I remember using old macromedia dreamweaver (6 version I think), and styling it with some stuff posted at DynamicDrive (yeah, very old stuff, and yet this site its alive) that was pretty interesting site back in the day, and it was pretty fast, it didn't require too much bandwith to load and it somewhat remembered me the kind of needs that I had.

The beauty of the simplicity (that every good backend developer appreciates) came to the light of my currently non-existent blog. I was chasing something like that. So I decided to apply "Keep it simple stupid (KISS)" strategy for this blog, and try to make a concious effort of what I should and should be not worrying about:

  • If I want to share my thoughts. Appeareance is a nice-to-have but not a must.
  • If I am the only one intended to write in this blog, I do not need anything besides writing
  • Dynamic drive needed javascript because they want to help people build a website but what interactivity do I need in a blog, it is just for reading!
  • A Minimum viable product (MVP) will only require me writing posts anything else could be solved later. I do not need forums, If someone reaches me through contact email/forum/github I could simply answer from that platform when I got the opportunity, I am not selling anything.
  • Sites nowadays used a lot of cookies, popups, ads, mailing lists, and nosense that people really hates when trying to read (Check this website to understand what I mean). I do not want that on my site, even that remote possibility is against what I want.
  • If I am going to be traveling I need my site to be as light as it could so It could load from everywhere and could be changed with not that much effort.
  • What about security? That is also a rabbit hole, once you have a backend and an API you will have to be applying a lot of security practices to avoid losing access to your website, beign hacked, leave security holes (in things like comments to your posts).

What I was supposed to do then? That tradeoff made me suffer for a while. I did not remember that writing a blog was that nightmare. Then again a blast from the past came to my rescue. I had read a lot of blogs like the powershell one it is very light and it is not intrusive at all. I think they use a database but I came closer to my objective. Then the final flashback of realization came to my mind, Puppy Linux creator had a blog that I visited almost everyday (because sometimes I work in old computers because of my travels and having a portable linux is a good idea, check it if you are interested), that blog matched almost all my needs. So I decided to vist it again that day and check if he talked about how he built the blog. Then I came across shellCMS. And as most of the time in the software blog my problem was a thing that everyone already thought back then, and it was solved with software already.

Now I had a starting point. I could write my posts generate a static website, and if I really wanted it could use a css file to fit my needs better but I could start right away.


Tags: shellcms_bulma