Skip to content

Commit

Permalink
chg: Add support to use custom size of flash memory in bsim_qemu !minor
Browse files Browse the repository at this point in the history
  • Loading branch information
lcgamboa committed Aug 26, 2023
1 parent 5ed5ad7 commit 09fdccd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/boards/board_C3_DevKitC.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class cboard_C3_DevKitC : public bsim_qemu {
lxString MGetPinName(int pin) override;
int MGetPinCount(void) override;
void PinsExtraConfig(int cfg) override;
unsigned int DBGGetROMSize(void) override { return 4194304; };
};

#endif /* BOARD_C3_DevKitC_H */
1 change: 1 addition & 0 deletions src/boards/board_DevKitC.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class cboard_DevKitC : public bsim_qemu {
lxString MGetPinName(int pin) override;
int MGetPinCount(void) override;
void PinsExtraConfig(int cfg) override;
unsigned int DBGGetROMSize(void) override { return 4194304; };
};

#endif /* BOARD_DevKitC_H */
22 changes: 11 additions & 11 deletions src/boards/bsim_qemu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void bsim_qemu::EvThreadRun(CThread& thread) {
if (fout) {
unsigned char buffer[1024];
memset(buffer, 0, 1024);
for (int r = 0; r < 4096; r++) {
for (unsigned int r = 0; r < (DBGGetROMSize() / 1024); r++) {
fwrite(buffer, 1024, sizeof(char), fout);
}
fclose(fout);
Expand All @@ -502,7 +502,7 @@ void bsim_qemu::EvThreadRun(CThread& thread) {
fseek(fin, 0, SEEK_SET);
printf("PICSimLab: qemu ESP32 image size is %li \n", size);

if (size != 4194304) {
if (size != DBGGetROMSize()) {
char dname[2048];

printf("PICSimLab: Loading application to address 0x%X\n", application_offset);
Expand Down Expand Up @@ -643,7 +643,7 @@ void bsim_qemu::EvThreadRun(CThread& thread) {
if (fout) {
unsigned char buffer[1024];
memset(buffer, 0, 1024);
for (int r = 0; r < 4096; r++) {
for (unsigned int r = 0; r < (DBGGetROMSize() / 1024); r++) {
fwrite(buffer, 1024, sizeof(char), fout);
}
fclose(fout);
Expand All @@ -661,7 +661,7 @@ void bsim_qemu::EvThreadRun(CThread& thread) {
fseek(fin, 0, SEEK_SET);
printf("PICSimLab: qemu ESP32-C3 image size is %li \n", size);

if (size != 4194304) {
if (size != DBGGetROMSize()) {
char dname[2048];

printf("PICSimLab: Loading application to address 0x%X\n", application_offset);
Expand Down Expand Up @@ -1031,11 +1031,11 @@ void bsim_qemu::MDumpMemory(const char* fname) {
fname_bak[i] = '/';
}
#endif
char* buff = new char[4194304];
qemu_picsimlab_flash_dump(0, buff, 4194304);
char* buff = new char[DBGGetROMSize()];
qemu_picsimlab_flash_dump(0, buff, DBGGetROMSize());
FILE* fout = fopen(fname_bak, "wb");
if (fout) {
fwrite(buff, 4194304, 1, fout);
fwrite(buff, DBGGetROMSize(), 1, fout);
fclose(fout);
}
delete[] buff;
Expand All @@ -1047,11 +1047,11 @@ void bsim_qemu::MDumpMemory(const char* fname) {
fname_[i] = '/';
}
#endif
char* buff = new char[4194304];
qemu_picsimlab_flash_dump(0, buff, 4194304);
char* buff = new char[DBGGetROMSize()];
qemu_picsimlab_flash_dump(0, buff, DBGGetROMSize());
FILE* fout = fopen(fname_, "wb");
if (fout) {
fwrite(buff, 4194304, 1, fout);
fwrite(buff, DBGGetROMSize(), 1, fout);
fclose(fout);
}
delete[] buff;
Expand All @@ -1063,7 +1063,7 @@ void bsim_qemu::MDumpMemory(const char* fname) {

int bsim_qemu::DebugInit(int dtyppe) // argument not used in picm only mplabx
{
return 0; //! mplabxd_init (this, Window1.Get_debug_port ()) - 1;
return 0; //! mplabxd_init (this, Window1.Get_debug_port ()) - 1;
}

void bsim_qemu::pins_reset(void) {
Expand Down

0 comments on commit 09fdccd

Please sign in to comment.