How to implement Position-Independent Code for microcontroller (MCUs) is a question which has been asked countless and countless of times all over the Internet. The answers and “solutions” are usually whippersnappering comments dropping a couple of key terms they probably just googled up without any kind of intrinsic knowledge about how the system should be working.
Sometimes the answer is “OK I got it working” followed by eternal silence from people asking clarifications. In other words, it looks like the task is very difficult and once people get it to work, it is so valuable they want to hide the details. In a way I cannot blame them much; it took me 6 months of half-time work every now and then to understand everything.
So, some 6 months ago I set myself a goal: “Create a portable solution where an intelligent bootloader can boot firmware images from any address in flash on Cortex-M0 or Cortex-M4 platform.” Finally, as of today 2022-01-16, I consider I have solved the problem in an intelligent and understandable way.
Funnily, I think I am the only person on planet Earth who has made available readily working example code and documented the code in a way I am doing now in this post.
Those impatient can explore the fully working STM32CubeIde codes at GitHub, for Cortex-M0: https://github.com/usvi/F070RB-BL-FW and for Cortex-M4: https://github.com/usvi/L432KC-BL-FW . (One might ask why one would use this kind of bloated stock configuration for developing on MCUs. Believe me, I’m doing it here only for pedagogical reasons. This way it is easier for noobs having the needed evaluation boards to verify that the code is working.)
The set of code I have created is a proof-of-concept, working for the C language. There might, and I underline, might be unforeseen problems when amount of global variable gets absurdly high. In any case, comments and criticism is more than welcome.
If you are ready to dive into the deep end of Cortex-M boot process, PIC constructs, esoteric debugging and linker script optimizations, continue reading…
Recently I described my friend that I was working with Position-Independent Code on a Cortex-M0 and Cortex-M4 environment. To my surprise, he was more interested about “why” and not “how”. I think before revealing the nitty-gritty details of this domain, I can give readers an overview about things.
Last week I got a task to basically resurrect an old MC9S08DZ60 based project. There was no official build environment, only a flaky, undocumented Windows XP virtual machine. So I got my hands dirty and started trying to get Freescale CodeWarrior 6.3 to run on Windows 10.
My earlier gateway box, the Lanner NCA-1010B decided to stop working, leaving everything as a messy chaos. I gobbled up my retired Zotac Zbox and hastily built a makeshift router.
A long term solution was however needed. I had heard good things from this no-bullshit-geeky Swiss company called PC Engines GmbH. They make a board called APU2E0, among other things. It is a AMD GX-412TC-based SOC product with 2 Intel i211AT NICs. And it does not have regular monitor connections. Instead, there is a DB9 serial port for installation purposes.
The board’s sister version is pictured below for reference.
Remember my old war horse, the Samsung SCX-3205 black & white printer/scanner? I recently moved in to a house. My girlfriend did not want printer near TV (with my ESXi shoebox) anymore, so I had to invent something else.
I had old Raspberry Pi 2 Model B v. 1.1 around, so I thought I should hook it up with the printer. Unfortunately I ended up compiling the necessary drivers myself because Alpine Linux did not have anything relevant. (I don’t blame them, this is quite outdated and rare.)
Have you ever wondered if you could print from your Windows 10 machine to a CUPS printer on your local network? It might be actually quite easy. See this documentation about how I did it with my black & white Samsung SCX-3205 printer.
I am one of those people who are perfectly fine with old style dumb 3G phones. But unfortunately some people are reluctant to communicate nowadays with regular phone calls, SMS or IRC, so I basically need to keep Android at hand for running WhatsApp.
Recently I found a way to run Android x86 7.1 on VMware ESXi 6.7. After a lot of teeth grinding, I was able to get WhatsApp running inside it. And after enormous test and debug efforts, I was even able to authorize WhatsApp Web clients. But with a lot of hoop-running. Extremely lot.
I chose Android x86 7.1 because it seems to be working completely for my desired purposes without (much) graphical glitches. For example 8.1 has horrible glitches which actually make many parts of initial setup widgets invisible 😀 . I chose VMware ESXi 6.7 as host because it is of the most stable main branch of the hypervisor. Host hardware is Intel NUC8i7HVK with 32GB RAM.
This is the list of articles of the whole operation (split due to big amount of screenshots):
In my previous blog post I described how I fixed my Asus Strix GTX 970 DirectCU II OC graphics card by changing fans and thermal paste. I noticed 7% increase in measured performance. What I left out from the post that I also discovered and observed other methods for increasing the GPU performance.
Fallout 4 came out on year 2015. Before this, a realization came out, being that my old rig could not handle the new game in its current state. What a bummer. But there was a silver lining. Or bronze. Or at least iron, I swear.
A Finnish computer shop had a bundle campaign: Asus Strix GTX 970 DirectCU II OC graphics card + Samsung 850 EVO 250GB for 399 EUR. I considered this a deal and bought the bundle. I think they might have had free game voucher also in the mix, but Google evades me on this.
The GPU arrived and it had many problems, it seemed. First there were instability problems with strange block garbage. These cleared after I ditched my “high-quality” Intel DZ77GA-70K motherboard for Asrock Z77 Extreme4.
One issue was still present, being absolutely horrible fan noise. This had been present from the start. Seriously. You buy the thing, take it out of the box, run some stress on it, and the whole thing rattles like it is going to give out functional smoke any minute.
The thing is, that I was able to fix it. There is video about the results here, check it out first. Then we show you how we did it.