Okay, I have zero experience with C, and programming in general. So thank you in advance for your patience...
I am modifying a u-boot file and have run into a problem. The program is already written, I am simply trying to add a function to the code. I have pulled a function from the file and simply modified it, hoping to get the results I need, so if you see things that you think don't belong in this function, you are probably right.
I am attempting to have a function that overwrites an existing file and makes it a specific size (1088 bytes) and contain only zeroes.
This is the function as defined in the top of the program
Code:
int clear_recovery_instructions_file(const char* file, char value) {
lcd_is_enabled = 0;
("mmcinit 0; fatsave mmc 1:2 0x%08x %s 1088", &value, file);
lcd_is_enabled = 1;
return value;
And here I am calling it below
Code:
if ((key & HOME_KEY) && (cursor == CLEAR_RECOVERY_INSTRUCTIONS)) { //clear boot count and reset BCB
const char* file = "BCB";
{clear_recovery_instructions_file (file, '0x400');}
udelay(RESET_TICK);
highlight_boot_line(cursor, HIGHLIGHT_GREEN);
do {udelay(RESET_TICK);} while (tps65921_keypad_keys_pressed(&key)); //wait for release
}
As you can see, I merely want the overwrite to occur if the user selects the Clear Recovery Instructions option in the bootloader menu.
As it stands, if I manually change the file size in the device terminal, after selecting the option in the bootloader, the file size stays at whatever I manually put it to instead of 1088.
Any help would be appreciated. I am sure there is garbage in the above code, as some of it I understand and some of it I don't. If I didn't understand what it was in the existing overwrite function I lifted the code from, I left it in. For instance, I believe the %s option indicates a string, and so may be useless or harmful as is. I left it in in case it referenced the 0's I woud like the file filled with.
Thanks!