Moving Out

Finally after a long wait, we found a decent apartment. Actually the apartment found us. We stopped searching after a while since nobody responded to our requests. And out of the blue a friend messaged in the morning that he is vacating his apartment and offered us to take over. What a relief it was! Now after completing most of the formalities and an informal meeting with the actual landlord, we started the planning to move out. It’s a fully furnished flat and we thought moving out would be easy. But nothing is easy here as I’ve learned in past year and a half. Fortunately the same friend provided a contact who can help us with movement. We had to pack most of the stuff apart from bigger furniture like Sofas and Beds and Kitchen platform etc. By end of three days hard work, we packed most of the items in around 40 boxes/bags. That was too much. We were anticipating that the helper guy would carry all the stuff and the moving would be a piece of cake. Finally the day came, Saturday as we decided. The morning was great, since I had to rush again to buy some more bags to pack some remaining stuff. The scheduled time was 12.00 noon for relocation, and I got an message around 11.00 from Alton (the moving helper) that he is running behind the schedule and would not be able to make it at 12.00 noon, but moving at 14.00 was still possible. We were okay with that since we also got a breathing time. I got a little nap and got up at 13.45 in an anticipation of his message, but at 14.15 got another message from him that he has a problem with the earlier shifting and would not be possible to leave them for some time. At 15.45 another message came that the other clients had trouble finding the keys to the apartment and since their stuff is still lying in his truck, they are going to make a decision what to do at 16.15. I messaged him at 16.30, no reply, the biggest WTF moment since we were all packed and nothing to do. I started sending messages to the local whatsapp group to get help with relocation. A nice guy replied with couple of contacts who can help with relocation, but i was little skeptical working with them since I had no idea what would they charge and weather they would help me immediately (or worse the next day – Sunday, when mostly nobody works). Nevertheless, I made a call to Tania – the freelancer who helps in relocation, and she was speaking very nice English (step-1 was easy ;-). Then we estimated the time to relocate based on our stuff and distance. She offered a helper and let me know the charges. I consulted with Bijal and thought to appoint her. Meanwhile I received an apology message from Alton that he was really sorry for keeping us waited. I was frustrated and but had a hope that next day will be better. Meanwhile I got a message from Sebastian – the new tenant, that we do not need to do the cleaning and painting of the apartment as they are anyway going to do that. So nice of him, but out of respect, we wanted to clean the apartment if not paint, so we started off with Bathroom and cleaned it just like new. And then we were really tired.

So to celebrate our last evening at this home, we went to Burger King and had my favorite Country Veggie burger – and it is delicious as always. Went back home in time and started unpacking few of the boxes to get minimal bedding setup and some clothes, such a hassle.

Next day we all woke up in time, and cleaned most of the windows, which was much harder than I thought before. And then we were waiting with hopes that Tania would not disappoint us, and she did not. She gave my address to Pete, a helper who would do the heavy lifting stuff and I can give him a hand to free him faster. Pete rang the bell sharp at 10.00 as discussed. Wow, the moment we have been waiting for since a day. He climbed till the forth floor and one of the first questions he asked was: at what floor we are moving in? I answered that at 1st floor and he said: Jackpot. I can understand that. So both of us started moving the boxes and stuff, and by 40 minutes, all stuff was on the ground floor at the entrance. Meanwhile Tania had arrived at 10.30 on appointed time and started loading everything on truck. That was very professional. I fetched the new apartment keys and we were off to the new destination.

I also called Sebastian if he could come to the apartment and collect the keys from Bijal, since I was in the truck with Tania and Pete and asked Bijal to stay at home, hand over the keys then take S-Bahn to the new apartment. The ride in truck reminded me of my hostel commute days – me sitting in the middle seat (not actually a seat but a sponge sheet) between Tania and Pete, saving myself from the gear shifting. And we discussed the demonetization (?) to my surprise that both Tania and Pete were very well informed about the stuff going on in India. And Pete was extremely against that move, and sounded like Anti-Modi, that he had no trust in him and considered the demonetization as a open theft from the poor people. I tried to reason him with all my efforts but I could not convince him that it was a bitter good move. So with our small talks (not really) we reached to the destination, started unloading and carrying stuff to the apartment. That was quicker than I anticipated and we departed after I made the payment. It reduced down to half the price that I had decided with Alton – and I was happy about it.

While carrying the stuff to the apartment, I met first few new neighbors and flaunted my basic German skills (by saying that my German is not good – in German :() and they reply that their English is worse than my German :) Then I met an interesting man at the front garden, who was working on his laptop and looked to me in his early 50s. I just introduced myself in a bit German and he spoke very softly and slowly, just like my teacher in my German class and later on during our conversation I figured that he is actually a pysicst, working as a software engineer and teaching German to the refugees in Berlin. Wow. Few moments later, while I was lying on the bed, Bijal and her mom arrived at the nearest station and I went to pick them up. And finally we moved in, officially.

Such a busy day! – Dr Mashoor Gulati ;-)

Advertisements

Adventure JS

I got introduced to Node.JS from one of my colleagues from Electronics department. He likes to hack around in his spare time and has built a really cool web based tool which can interact with a device via serial console (which makes his day to day life easier). And the tool was developed using Node.JS. It was pretty impressive to see what Node.JS can do in very short time. So this is going to be my next adventure. And I found a really really nice free e-book which can be found here.

I have some ideas where I want to use this. Let’s hope my affair lasts longer than it usually last with new stuffs.

Happy hacking!

Playing with rpmsg on iMX7d

Lately it has been rare that I get to work on some kernel related problems. One of such task was to get “rpmsg” sample modules running on custom iMX7d board. There are many tutorials available, from NXP as well as from other vendors building iMX7d based SoM. So I was a bit confident to get it running pretty soon. But it ended up a bit more complicated than I thought.

First of all, “rpmsg” is a framework which allows main CPU to communicate with another CPU in a system. For example, iMX7d SoC has 2 cores of Cortex-A7 and one Cortex-M4. If you want to establish a communication channel between Cortex-A and Cortex-M, “rpmsg” framework is handy. The framework is based on “virtio” subsystem which I am not much familiar with at the moment. However, I browsed quite some code while debugging the problem that I was running into.

So, as I said, my task was to run a simple rpmsg ping-pong application (or a driver module). The ping-pong application has two parts: 1) Running on Cortex-M and 2) Running on Cortex-A. The software part on Cortex-A is a Linux kernel module. The software part on Cortex-M can either be a bare-metal software code compiled for Cortex-M or a full fledged FreeRTOS code (the entire toolchain for Cortex-M4 with FreeRTOS and demo examples are available from NXP). I used the FreeRTOS based demo example code.

The flow would be something like this:

  1. Initialize the Cortex-M4 before booting linux kernel (i.e. can be done from u-boot)
  2. Boot up Linux kernel
  3. Load ping-pong module from Linux user-space.

As soon as the module is loaded from user-space, the rpmsg communication channel will be initialized and sample data transfer will be started between Cortex-A and Cortex-M.

These looked pretty easy since most of the stuff is readily available (i.e. Cortex-M application, rpmsg framework and ping pong driver in linux kernel etc). I enabled the rpmsg and ping-pong module in linux kernel, and loaded the modules from user-space and boom, nothing on console or on dmesg. Then I figured that I missed enabling the “rpmsg” device node in DTS. I enabled it and rebooted the kernel, wow, kernel did not even boot. The usual debugging started by enabling the debugs (early printk) and for early init calls.  The culprit was rpmsg platform driver for imx (arch/arm/mach-imx/imx_rpmsg.c). The platform driver maps a region of address range which is used as a shared memory between Cortex-M and Cortex-A. So next logical step was to check that how does that not fail for iMX7D sabresd board (and boards from other vendors). Then I found that there is a dedicated device-tree for Cortex-M4. I could notice that in that device tree file, the usable memory (RAM) was reduced, and some portion of that left out memory was used as shared memory between Cortex-A and Cortex-M. I tried to make similar change on the device tree file for our platform and the crash was gone. But now I could see the warning (kernel trace caused by WARN_ON) pointing to a failure in ioremap, which was obvious since I was using wrong memory range in imx rpmsg platform driver. So I made following change:

--- a/arch/arm/mach-imx/imx_rpmsg.c
+++ b/arch/arm/mach-imx/imx_rpmsg.c
@@ -290,8 +290,8 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
                        ret |= of_device_is_compatible(np, "fsl,imx6sx-rpmsg");
                        if (ret) {
                                /* hardcodes here now. */
-                               rpdev->vring[0] = 0xBFFF0000;
-                               rpdev->vring[1] = 0xBFFF8000;
+                               rpdev->vring[0] = 0x9FFF0000;
+                               rpdev->vring[1] = 0x9FFF8000;
                        }
                } else {
                        break;

With this change, the warning was gone, and rpmsg driver was successfully registered as I could see in the dmesg. However, the loading ping-pong module still did not initialize the communication between two cores. I wondered in disbelief and checked the sysfs entries to see if rpmsg device is present or not. I found that rpmsg was registered as a bus driver as well as a device under virtio bus. So I could see a device listing under virtio bus, but no device under rpmsg bus. By looking into code somewhat deeper, I could see that a device under rpmsg bus is registered when an rpmsg endpoint is created and an initial communication is established successfully (by NS Announcement message exchange). This happens in rpmsg_create_channel() routine which is invoked within a callback registered while creating an endpoint. So, the problem was now about the missing communication message between M4 and A7. This took me a while to figure out, but I was a bit relieved that I am not missing any patch in kernel which might have caused missing device registration.

Wandering here and there in code for a while, I thought of looking at the code of FreeRTOS example and thought may be something needs to be changed there, related to memory mapping. And bingo, I had to adjust the memory mapping which I did change in kernel side but not on FreeRTOS side. The memory addresses are hard-coded and should be changed in middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c file (VRING0_BASE and VRING1_BASE). With this change, I rebuilt the example binary, loaded it via uboot, rebooted linux kernel and wow, I could see an initial message exchange, but the entire buffer was filled with 0x00 to my surprise. I had no clue why this was the case, and then I wasted almost my entire day in putting debug prints and adding more debug code in rpmsg, virtio, virtio-ring drivers, in FreeRTOS middleware and platform driver but no luck. With extreme frustration, I decided to make one last change in device-tree file. Our platform has 512 MB of RAM (starting from address range 0x80000000). Since I am using 0x9FFF0000 as a starting range for shared buffer between the cores, I had initially limited the usable memory like this:

+/ {
+       memory {
+               linux,usable-memory = <0x80000000 0x10000000>;
+       };
+};

Logically I thought this should work since, I am mocking Linux MM that system has 256 MB of RAM than 512 MB. And I could safely ioremap address starting from 0x9FFF0000. But to my surprise this never worked. I had to change the mapping to following to get the example running (which was a bit satisfying and a bit discouraging since I wasted entire day):

+/ {
+       memory {
+               linux,usable-memory = <0x80000000 0x1FF00000>;
+       };
+};

This is still a puzzle to me, but I plan to post a question on NXP community to get this answered. If I get the answer, I will update the post.

Overall a good exercise of code browsing and learning something new about rpmsg and virtio framework.

Happy debugging.

Sending attachments via Linux command line

I tried with sendmail, and sendemail (notice the “e” in sendemail). Could not find the option for sending attachments in sendmail, and sendemail requires “from” field to send the email.

So here is the result from stackoverflow.com, nice and dandy:

echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.com

Usual updates

I was on leave for a week and a half due to back pain suggested by doctors. Today is the last day of that boring imparted vacation. In the morning I visited a doctor again, and she suggested to take rest again for a week. I feel bad since I am much better now and can resume work from tomorrow. So I have decided to go against this mandatory rest and would resume the work to see if the back is really better. Otherwise would visit doctor again on Friday.

So what I have done this whole duration: I decided to start my Android developer course on Udemy to which I registered a couple of months back. Learning android programming was my hobby but I could never start it systematically. (Everytime I had some ideas for which I wanted to make an app, and start programming randomly in Android – just learning the things which I required. And in that process, I never finished any of my apps and never actually learned the real android programming). This course from Udemy was on discount and I got to enroll for just 10 Euros. I finished 4 sessions and I feel great. At least I know something very basic but in a systematic way.

And during this process, I encountered so many problems with Linux. First of all, the JDK installation, setting up correct Android emulator, the option for installing KVM modules and on top of all, the highly unstable Android Studio for Linux. I cannot decide to whom to blame, Android Studio OR the new “Wayland” (replacement of Xorg). To point out one of the problems, newer version of Android studio has introduced this new layout, called Constrained Layout. I liked it very much since it provides a great freedom in arranging the widgets. However, most of the work needs to be done using drag/drop with mouse. That is where the you need a solid native GUI framework (usually from OS). On Linux, the mouse used to stop working properly as soon as I start playing around with “Constrained Layout” in Android studio. I have no option other than restarting the studio. This is pathetic. As soon as I close the studio, mouse starts working as usual. Then I thought of giving Windows a try. I installed Android studio on windows, and viola, only once executable bundle. Just click next, next and next, you are done. No need of installing separate JDK, setting the path, no need to download special emulator packages. And on top of that, there was no bug in accessing “Constrained Layout”. Mouse just worked as expected. I can now feel the pain of people who want to do real work and don’t want to dive into the hassles of OS issues. After these 15 years, this is the first crack in my love with Linux – just due to this sluggish/buggy/slow GUI and due to lack of standardized GUI framework. I feel that my Windows 8 boots faster than my Fedora 25 (with latest updates installed, WTF)

Anyway, Android’s latest version (Developers edition) O has been rolled out today. My phone is still running KitKat 4.4.2 (shame shame)! Samsung is announcing next phone on 29th of this month, and would be cursing Google on this roll out of O :-O. Samsung is the slowest among all in rolling out the updates. I wish to buy some cheaper motorola device now, g5+ mostly, just to get newest of android, because I like stock android: OnePlus is a cousin of Samsung in terms of updates, and Pixel is overpriced just like iPhone. So that’s the android story.

I started reading the Satya na Prayogo: an autobiography of Mahatma Gandhi. I have no words to explain his brutal honesty, his simplicity, his courage, his faith on God and above all his love for truth. My respect towards him has grown immensely while reading this book. I always felt that I do not know much about him being a guy sharing the birthplace with him ;-) I have heard lots and lots of people cursing him, abusing him and opposing to his views on his ways/methodology of freedom movement. Sometimes I used get carried away with those thoughts but deep inside, I always felt that I don’t know much about Gandhiji and how can I be judgmental about him. Reading his biography is an eye-opener. His thoughts are filled with purity and social service was his motto. He was extremist I think. His experiments were really absurd and hard to understand but the intentions were pure. Respect to him!

And finally winter is getting over leaving some signs of coming Spring. Days are longer and brighter now. Get to see the Sun more, feeling more positive. Hope to get back go work from tomorrow, and finish my android course soon ;-)

Have a nice day (to?, me ;-)!

Create a .desktop entry for Gnome Shell

I don’t want to forget this, so here is my sample entry which I created for Android Studio.

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Android Studio
Exec=/home/random/Downloads/Softwares/android-studio/bin/studio.sh
Icon=/home/random/Downloads/Softwares/android-studio/bin/studio.png

Save this file as android-studio.desktop at ~/.local/share/applications. Now it will be visible in the list of application and you can also “search” by pressing <win> / <mod> key.

Frustrating

#include <iostream>
using namespace std;
int main() {
int p = 77778;
long square = p*p;
cout << p << " " << square << endl;
return 0;
}

Let’s waste some time in figuring out the problem. SMH!