Skip to content

Commit

Permalink
fix(device): init_flash should be called only once
Browse files Browse the repository at this point in the history
init_flash should be put in init_device and called only once during
multiple difftest runs. At every difftest run, only load_flash_contents
should be called.
  • Loading branch information
poemonsense committed Oct 29, 2024
1 parent 9ab6c83 commit f01d4eb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions src/cpu/difftest/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
#include <cpu/cpu.h>
#include <difftest.h>

extern void init_flash();
extern void load_flash_contents(const char *flash_img);


#ifdef CONFIG_LARGE_COPY
#ifndef CONFIG_USE_SPARSEMM
static void* nemu_large_memcpy(void *dest, const void *src, size_t n) {
Expand Down Expand Up @@ -107,7 +105,6 @@ void difftest_load_flash(void *flash_bin, size_t f_size){
printf("nemu does not enable flash fetch!\n");
#else
load_flash_contents((const char *)flash_bin);
init_flash();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ void init_device() {
IFDEF(CONFIG_HAS_AUDIO, init_audio());
IFDEF(CONFIG_HAS_DISK, init_disk());
IFDEF(CONFIG_HAS_SDCARD, init_sdcard());
IFDEF(CONFIG_HAS_FLASH, init_flash());
#ifndef CONFIG_SHARE
IFDEF(CONFIG_HAS_FLASH, load_flash_contents(CONFIG_FLASH_IMG_PATH));
IFDEF(CONFIG_HAS_FLASH, init_flash());
#endif

#ifndef CONFIG_SHARE
Expand Down

0 comments on commit f01d4eb

Please sign in to comment.