Я пишу эмулятор видеоигр для Arduino Nano ESP32 (MCU ESP32-S3), используя C++, VS. Кодируйте с помощью PlatformIO и Arduino Framework. Кросс-компиляция выполняется с помощью xtensa-esp32s3-elf-g++ с моего компьютера Debian на плату разработчика.
Я тестирую свою программу на различных ПЗУ, извлеченных из игровых картриджей. Эти ПЗУ «переведены» в файлы .cpp, поэтому я получаю массив байтов, который будет выполняться эмулируемым процессором.
Вот как переменные определены в этом «файле ROM .cpp» объявлены в соответствующем заголовочном файле (.h):
Код: Выделить всё
extern uint8_t rom[];
extern const int rom_size;
extern const char bios_name[];
extern const char rom_name[];
Переменные определяются следующим образом в файле ROM:< /p>
Код: Выделить всё
const int rom_size = ROM_SIZE;
const char bios_name[] = BIOS_NAME;
const char rom_name[] = ROM_NAME;
uint8_t rom[ROM_SIZE] = {
Сегодня я перешел с одного ПЗУ на другое. Затем я получил эту ошибку компоновщика:
Код: Выделить всё
/home/gregoire/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pio/build/arduino_nano_esp32/src/travolta.cpp.o:(.literal._Z5setupv+0xc): undefined reference to `bios_name'
/home/gregoire/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pio/build/arduino_nano_esp32/src/travolta.cpp.o:(.literal._Z5setupv+0x14): undefined reference to `rom_name'
/home/gregoire/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pio/build/arduino_nano_esp32/src/travolta.cpp.o:(.literal._Z5setupv+0x1c): undefined reference to `rom_size'
collect2: error: ld returned 1 exit status
*** [.pio/build/arduino_nano_esp32/firmware.elf] Error 1
Код: Выделить всё
Building in release mode
xtensa-esp32s3-elf-g++ -o .pio/build/arduino_nano_esp32/firmware.elf -mlongcalls -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -Wl,--wrap=esp_log_write -Wl,--wrap=esp_log_writev -Wl,--wrap=log_printf -Wl,--wrap=longjmp -Wl,--undefined=uxTopUsedPriority -T memory.ld -T sections.ld -T esp32s3.rom.ld -T esp32s3.rom.api.ld -T esp32s3.rom.libgcc.ld -T esp32s3.rom.newlib.ld -T esp32s3.rom.version.ld -T esp32s3.rom.newlib-time.ld -T esp32s3.peripherals.ld -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u include_esp_phy_override -u ld_include_highint_hdl -u start_app -u start_app_other_cores -u __ubsan_include -u __assert_func -u vfs_include_syscalls_impl -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -Wl,-Map="/home/gregoire/Documents/PlatformIO/Projects/Travolta/.pio/build/arduino_nano_esp32/firmware.map" .pio/build/arduino_nano_esp32/FrameworkArduinoVariant/dfu_callbacks.cpp.o .pio/build/arduino_nano_esp32/FrameworkArduinoVariant/double_tap.c.o .pio/build/arduino_nano_esp32/FrameworkArduinoVariant/io_pin_remap.cpp.o .pio/build/arduino_nano_esp32/FrameworkArduinoVariant/variant.cpp.o .pio/build/arduino_nano_esp32/src/cartridge_rip.cpp.o .pio/build/arduino_nano_esp32/src/mnemonics.cpp.o
Чтобы избавиться от этой ошибки, мне пришлось добавить ключевое слово extern к определениям трех проблемных переменных:
Код: Выделить всё
extern const int rom_size = ROM_SIZE;
extern const char bios_name[] = BIOS_NAME;
extern const char rom_name[] = ROM_NAME;
uint8_t rom[ROM_SIZE] = {
Код: Выделить всё
esptool.py v4.5.1
Creating esp32s3 image...
Merged 2 ELF sections
Successfully created esp32s3 image.
Более того, компоновщик мне не нужно добавлять это ключевое слово в переменную rom....
Возможно, я упустил что-то очевидное, но что?
Подробнее здесь: https://stackoverflow.com/questions/785 ... etimes-not
Мобильная версия