I was told to use this driver to flash a binary to some chip via I2C.
I'm not interested in customizing the driver or modifying in any way really, I'm just hoping to learn enough to use the max77958_update_action_mtp function:
max77958_update_action_mtp(struct max77958_dev *max77958,
const u8 *action_bin, int fw_bin_len)
to flash a binary (action_bin) to some i2c device (max77958).
I am a complete noob to embedded development and c programming, but from what I can understand I need to manage the following:
- Include this driver in some other c file and resolve any missing dependencies (done)
- Create some
max77958_devand pass the pointer to this function as the first argument. - Open the binary as a
const u8and pass the pointer as the second argument.
Have I misunderstood the steps I need to finish?
Assuming I have understood the steps I need to take correctly:
Step 1
I managed to find all the header files in my system under /usr/src/linux-headers-5.4.0-122-generic/ other than one called <linux/wakelock.h> which from what I can tell is some Android specific header, so I commented it out and will try to remove anything the compiler complains about as I shouldn't need anything Android related.
Step 2
Does it look like there is some default max77958_dev struct that I can use? Following the definition of the struct in VS Code, I can see its definition is located here but I'm too much of a noob in c to understand if something here helps me create a default max77958_dev struct with some default values or if I have to somehow know all of the correct values and create one myself.
I'm also quite oblivious as to how the Ubuntu PC would connect to this I2C device. I assume I can get some USB-2-I2C dongle from FTDI or the like, but how would my C code know to communicate via this dongle to the I2C slave?
Step 3
I think I can figure out how to read in a binary file, but it seems strange that this is a const u8. The binary is surely larger than 8 bits. Guessing this is a lack of understanding of pointers, but can someone clarify how exactly I should introduce a binary file to this function?