Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EEPROM image generator #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dracc
Copy link

@dracc dracc commented Feb 19, 2020

As suggested in xqemu/xqemu-manager#57 , here comes an EEPROM image (generator).

@GXTX
Copy link

GXTX commented Apr 7, 2020

Looks good! Any chance you can add build instructions to the readme?

eepromgen.c Outdated

int main() {
size_t i;
FILE* eepromFile = fopen("./eeprom.bin", "wb");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid the ./ prefix. It will break some platforms.

eepromgen.c Outdated
fwrite(default_eeprom, 1, 256, eepromFile);
fclose(eepromFile);
} else {
printf("Opening eeprom.bin for write failed!\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fprintf(stderr, ...

eepromgen.c Outdated
fwrite(default_eeprom, 1, 256, eepromFile);
fclose(eepromFile);
} else {
printf("Opening eeprom.bin for write failed!\n");
Copy link
Member

@JayFoxRox JayFoxRox May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd suggest to have const char* path = "eeprom.bin"; for the fopen(path, "wb") and then use "Creating '%s' failed.", path

eepromgen.c Outdated
size_t i;
FILE* eepromFile = fopen("./eeprom.bin", "wb");
if (eepromFile) {
fwrite(default_eeprom, 1, 256, eepromFile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could should check if all 256 bytes were written probably.
At very least an assert would be good

eepromgen.c Outdated
};

int main() {
size_t i;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, not sure why I added that one in the first place. Has since been removed.

eepromgen.c Outdated
#include <stddef.h>

/* Bunnies eeprom */
const unsigned char default_eeprom[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Make this static

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants