the-modem-distro / pinephone_modem_sdk

Pinephone Modem SDK: Tools to build your own bootloader, kernel and rootfs
GNU General Public License v3.0
590 stars 63 forks source link

Add more documentation on how to get started modifying the firmware. #140

Open CoderThomasB opened 1 year ago

CoderThomasB commented 1 year ago

I wanted to try and modify the custom firmware but I couldn't find where the files with the code that determines how the modem works. There are quite a few markdown docs on how to build and install the firmware but not many on how the internal modem software works and how to modify it and add new features.

I opened this issue to discuss adding more documentation on how the files are structured and what each one does. E.g where is the code that handles SMSs? How does the modem interface with the SOC and modem manager?

Biktorgj commented 1 year ago

The 'glue' that makes the modem work as a modem (and messages, time syncing etc.) is Openqti: https://github.com/the-modem-distro/meta-qcom/tree/kirkstone/recipes-modem/openqti

Anything specific I can help with?

CoderThomasB commented 1 year ago

I've updated the issue with a bit more detail on what this issue is about.

Biktorgj commented 1 year ago

Hope this helps a bit: openqti

As I said in the previous response, openqti is what makes everything work. Once the system is booted and the ADSP firmware is loaded, all the "modem" things are handled by it.

If you're diving into the source, openqti.c is that spawns the proxies, AT command server, scheduler etc. If you wanted, for example, to add a new command to the SMS functionality, you should go to commands.c and commands.h That is the command parser, rmnet_proxy will intercept any incoming message to its fake number and redirect it to sms.c, which will then go to command.c to check if whatever you sent it matches some available command. If it does, then command.c will do whatever it has to do and add a message to the queue indicating the result of the command (or the command not found message).

On a practical level, if you wanted to add a "Hello world" command, you'd start adding it here, and then add a case for it in this switch, following the same pattern as the other commands there.

I should do a cleanup of all that too...