mbed drivers for a NUCLEO_WB55RG board - arm

When creating an mbed application, is it possible to see the code that is used for the specific device?
E.g., for the NUCLEO_WB55RG I would like to see the ST drivers that are used.
I took a look in the mbed docs but did not see anything regarding that.

If you have the source, of course you can "see" it. Check your link map to see what is included in the build or use a debugger to step "in-to" the third-party code - if the source is available it should be shown as you enter it.
Moreover any of the code included that is open-source, you will be able to access the source, even if it is delivered to you as object code. For example in your case, from https://os.mbed.com/platforms/ST-Nucleo-WB55RG/ follow the link https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/README.md

Related

Create a shared library for multiple applications for ARM cortex-m4

I'm trying to create project which contains a drivers library and two separate application (Booltloader + app), now I want to share the drives library between the two apps in order to save space on the flash...
I saw this tutorial for IAR, but I must use Keil uvision5 and I didnt find anything helpful online.
Anyone can guide me through this?
thanks!
Splitting the code into three parts (bootloader, library, application) most likely is too much. I think it is better to combine the bootloader and the drivers in a single binary. While calling the application, the bootloader can provide information necessary to use the drivers.
A word of caution, though: a solution like this is way more tricky than just compiling the drivers in the application. Depending on the driver functions, there may be no true benefit on flash usage. In particular, if many drivers are not necessary, they will just occupy the flash instead of getting optimized-out.

Creating new epaper library for atmega32 without arduino

i want to create new library for my e-paper using atmega32 and eclipse enviroment. What do i have to know about it moreover how it works. I dont want to use arduino libraries, want to write it on my own. How to best start making it? I know how to use SPI, what commands do i have to send to display, but do i have to have any drivers which are necessarily? Is any possibilty to program it using only this module:
https://www.waveshare.com/1.54inch-e-paper-module-b.htm
and SPI? Or it is necessary to have some drivers to do it?
Your question a little bit strange, because "driver" is usually piece of code, written by a third person. So, answer is yes - it is always possible to do it from scratch, without using third-side software.
First what you need to know is what type of controller being used in that display, to get technical documentation (datasheet). Unfortunately, there is no such information, but there is a link to the specification document: https://www.waveshare.com/w/upload/9/9e/1.54inch-e-paper-b-specification.pdf
Read it carefully. For example at page 8 you can find the list of commands, which are used to control the display, and below the detailed description of the commands.
At pages 24, 25 you can find initialization sequence, and reference flowchart.
If any doubts, you can download and investigate how third-party libraries are done. For example here: https://github.com/waveshare/e-Paper

Basic functionalities of QEMU

I have been trying to create a new "Custom machine" for QEMU and trying to understand the code structure of QEMU. There is a lot of help for QEMU's internal code structure like TCG etc.
But I want to understand the functions or inherited functions and syntax used to write a custom machine. For example SYS_BUS_DEVICE, what is the definition of this? What are the usages, how to use etc.
I am not sure if my question is even right or SYS_BUS_DEVICE is a user definition. Can someone clarify this? Or point me to any documentation which describes the custom machine development.
Every time I try to look for such code structure I end up with QEMU internal code. Are they both same? Is definitions like SYS_BUS_DEVICE is internal to QEMU?
SYS_BUS_DEVICE is a QOM object used to define devices on a bus. It's part of the object model. What documentation we have for developers can be found at: https://qemu.readthedocs.io/en/latest/devel/index.html (specifically https://qemu.readthedocs.io/en/latest/devel/qom.html).

How can I inject or dynamically load an c function into another c program

I want to build an interface in a c program which is running on an embedded system. This should accept some bytecode that represents a c function. This code will then be loaded into the memory and executed. This will then be something like remotely inject code into a running app. The only difference here is that i can implement, or change the running code and provide an interface.
The whole thing should be used to inject test code on a target system.
My current problem is that I do not know how to build such a byte code out of an existing c function. Mapping and executing this is no problem if I would knew the start address of the function.
Currently I am working with Ubuntu for testing purposes, this allows me to try some techniques which are not possible in the embedded system (according to missing operating system libs).
I build an shared object and used dlopen() and dlsym() to run this function. This works fine, the problem is just that i do not have such functions in the embedded system. I read something about loading a shared object into memory and run it, but i could not find examples for that. (see http://www.nologin.org/Downloads/Papers/remote-library-injection.pdf)
I also took a simple byte code that just print hello world in stdout. I stored this code in memory using mmap() and execute it. This also worked fine. Here the problem is that I don't know how to create such a byte code, I just used an hello world example form the internet. (see https://www.daniweb.com/programming/software-development/threads/353077/store-binary-code-in-memory-then-execute-it)
I also found something here: https://stackoverflow.com/a/12139145/2479996 which worked very well. But here i need a additional linker script, already for such a simple program.
Further I looked at this post: https://stackoverflow.com/a/9016439/2479996
According to that answer my problem would be solved with the "X11 project".
But I did not really find much about that, maybe some of you can provide me a link.
Is there another solution to do that? Did I miss something? Or can someone provide me another solution to this?
I hope I did not miss something.
Thanks in advance
I see no easy solution. The closest that I am aware of is GCC's JIT backend (libgccjit). Here is a blog post about it.
As an alternative, you could using a scripting language for that code that needs to be injected. For instance, ChaiScript or Lua. In this question, there is a summary of options. As you are on an embedded device, the overhead might be significant, though.
If using an LLVM based backend instead of GCC is possible, you can have a look at Cling. It is a C++ interpreter based on LLVM and Clang. In my personal experience, it was not always stable, but it is used in production in CERN. I would except that the dynamic compilation features are more advanced in LLVM than in GCC.

How to install library from source code, without any config nor Makefile?

Sorry for what is likely a simple question -- still getting a handle on Linux.
I've been attempting to install the 'FreeMODBUS' library, however judging from the website, it is somewhat outdated. The download link leads to nowhere, however the source code is still accessible via Sourceforge as a .zip download. In the past I've only dealt with libraries that come via .tar, however the bigger issue is that there seems to be no config, makefile nor README detailing the installation process.
Additionally I tried including all of the source code and header files supplied within my Eclipse project. I was hoping that this would be the lazy man's solution to all of my problems -- or at the very least I could compile the .so file myself -- however I'm still getting 'undefined reference to [Function]' errors. From what I understand this is a linking issue. To the best of my knowledge all inclusions are correctly set up.
Is this library deprecated, or is there a step to the process that I'm overlooking? Thanks!
Some superfluous project information:
I'm using modbus for a C project. The network is ideally going to be setup so that a number of modbus enabled devices are configured on a single daisy chained RS-485 hub -- therein containing all our modbus communications to a single comm port in a rather complex system.
The problem however is that popular open source modbus library, 'libmodbus', doesn't appear to lend itself to this configuration. In order to instantiate a modbus node instance, it requires the comm port to be passed, as opposed to the unit's modbus id.

Resources