Troubleshooting Data Abort Error While Debugging U-Boot on mcimx6ul-evk in QEMU
I am trying to debug U-Boot code in Ubuntu 18.04 using the mcimx6ul-evk board in QEMU. I have successfully compiled QEMU and U-Boot using arm-linux-gnueabihf-. When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the get_cpu_rev function:
struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR; 2cfg = readl(&scu->config) & 3;
This triggers a data_abort error. The log displays "Invalid read at addr 0xA00004, size 4, region '(null)', reason: rejected."
Here are the relevant commands and output from my environment:
./configure --prefix=/home/book/qemu/qemu-7.2.0_build --target-list=arm-softmmu,arm-linux-user --enable-debug --enable-debug --python=/usr/bin/python3.7 Using './build' as the directory for build output The Meson build system Version: 0.61.5 Source dir: /home/book/qemu/qemu-7.2.0 Build dir: /home/book/qemu/qemu-7.2.0/build Build type: native build Project name: qemu Project version: 7.2.0 C compiler for the host machine: cc -m64 -mcx16 (gcc 7.5.0 "cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0") C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.30 Host machine cpu family: x86_64 Host machine cpu: x86_64 Program scripts/symlink-install-tree.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/scripts/symlink-install-tree.py) Program sh found: YES (/bin/sh) Program python3 found: YES (/usr/bin/python3.7) Program bzip2 found: YES (/bin/bzip2) Program iasl found: NO Compiler for C supports link arguments -Wl,-z,relro: YES Compiler for C supports link arguments -Wl,-z,now: YES C++ compiler for the host machine: c++ -m64 -mcx16 (gcc 7.5.0 "c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0") C++ linker for the host machine: c++ -m64 -mcx16 ld.bfd 2.30 Compiler for C++ supports link arguments -Wl,--warn-common: YES Program cgcc found: NO Library m found: YES Run-time dependency threads found: YES Library util found: YES Run-time dependency appleframeworks found: NO (tried framework) Found pkg-config: /usr/bin/pkg-config (0.29.1) Run-time dependency gio-2.0 found: YES 2.56.4 Program gdbus-codegen found: YES (/usr/bin/gdbus-codegen) Run-time dependency gio-unix-2.0 found: YES 2.56.4 Run-time dependency pixman-1 found: YES 0.34.0 Run-time dependency zlib found: YES 1.2.11 Has header "libaio.h" : NO Run-time dependency liburing found: NO (tried pkgconfig) Run-time dependency libnfs found: NO (tried pkgconfig) Run-time dependency appleframeworks found: NO (tried framework) Run-time dependency appleframeworks found: NO (tried framework) Run-time dependency libseccomp found: NO (tried pkgconfig) Has header "cap-ng.h" : NO Run-time dependency xkbcommon found: YES 0.8.2 Run-time dependency slirp found: NO (tried pkgconfig) Has header "libvdeplug.h" : NO Run-time dependency libpulse found: YES 11.1 Run-time dependency alsa found: YES 1.1.3 Run-time dependency jack found: NO (tried pkgconfig) Run-time dependency sndio found: NO (tried pkgconfig) Run-time dependency spice-protocol found: NO (tried pkgconfig) Run-time dependency spice-server found: NO (tried pkgconfig) Library rt found: YES Run-time dependency libiscsi found: NO (tried pkgconfig) Run-time dependency libzstd found: NO (tried pkgconfig) Run-time dependency virglrenderer found: NO (tried pkgconfig) Run-time dependency blkio found: NO (tried pkgconfig) Run-time dependency libcurl found: NO (tried pkgconfig) Run-time dependency libudev found: YES 237 Library mpathpersist found: NO Run-time dependency ncursesw found: YES 6.1.20180127 Has header "brlapi.h" : NO Run-time dependency sdl2 found: YES 2.0.8 Run-time dependency sdl2_image found: NO (tried pkgconfig) Library rados found: NO Has header "rbd/librbd.h" : NO Run-time dependency glusterfs-api found: NO (tried pkgconfig) Run-time dependency libssh found: NO (tried pkgconfig) Has header "bzlib.h" : NO Has header "lzfse.h" : NO Has header "sys/soundcard.h" : YES Run-time dependency epoxy found: NO (tried pkgconfig) Has header "epoxy/egl.h" with dependency epoxy: NO Run-time dependency gnutls found: NO (tried pkgconfig) Run-time dependency gnutls found: NO (tried pkgconfig) libgcrypt-config found: NO need ['>=1.8'] Run-time dependency libgcrypt found: NO (tried config-tool) Run-time dependency nettle found: NO (tried pkgconfig) Run-time dependency gmp found: NO (tried pkgconfig) Run-time dependency gtk+-3.0 found: NO (tried pkgconfig) Run-time dependency libpng found: NO (tried pkgconfig) Run-time dependency libjpeg found: NO (tried pkgconfig) Has header "sasl/sasl.h" : NO Has header "security/pam_appl.h" : NO Has header "snappy-c.h" : NO Has header "lzo/lzo1x.h" : NO Has header "numa.h" : NO Library ibumad found: NO Has header "rdma/rdma_cma.h" : NO Library ibverbs found: NO Run-time dependency xencontrol found: NO (tried pkgconfig) Library xenstore found: NO Library xenctrl found: NO Library xendevicemodel found: NO Library xenforeignmemory found: NO Library xengnttab found: NO Library xenevtchn found: NO Library xentoolcore found: NO Run-time dependency libcacard found: NO (tried pkgconfig) Run-time dependency u2f-emu found: NO (tried pkgconfig) Run-time dependency canokey-qemu found: NO (tried pkgconfig) Run-time dependency libusbredirparser-0.5 found: NO (tried pkgconfig) Run-time dependency libusb-1.0 found: NO (tried pkgconfig) Run-time dependency libpmem found: NO (tried pkgconfig) Run-time dependency libdaxctl found: NO (tried pkgconfig) Run-time dependency libkeyutils found: NO (tried pkgconfig) Checking for function "gettid" : NO Run-time dependency libselinux found: NO (tried pkgconfig) Run-time dependency fuse3 found: NO (tried pkgconfig) Run-time dependency libbpf found: NO (tried pkgconfig) Has header "sys/epoll.h" : YES Has header "linux/magic.h" : YES Has header "valgrind/valgrind.h" : NO Has header "linux/btrfs.h" : YES Has header "libdrm/drm.h" : YES Has header "pty.h" : YES Has header "sys/disk.h" : NO Has header "sys/ioccom.h" : NO Has header "sys/kcov.h" : NO Checking for function "close_range" : NO Checking for function "accept4" : YES Checking for function "clock_adjtime" : YES Checking for function "dup3" : YES Checking for function "fallocate" : YES Checking for function "posix_fallocate" : YES Checking for function "posix_memalign" : YES Checking for function "_aligned_malloc" : NO Checking for function "valloc" : YES Checking for function "memalign" : YES Checking for function "ppoll" : YES Checking for function "preadv" : YES Checking for function "pthread_fchdir_np" : NO Checking for function "sendfile" : YES Checking for function "setns" : YES Checking for function "unshare" : YES Checking for function "syncfs" : YES Checking for function "sync_file_range" : YES Checking for function "timerfd_create" : YES Checking for function "copy_file_range" : YES Checking for function "getifaddrs" : YES Checking for function "openpty" with dependency -lutil: YES Checking for function "strchrnul" : YES Checking for function "system" : YES Header <byteswap.h> has symbol "bswap_32" : YES Header <sys/epoll.h> has symbol "epoll_create1" : YES Header <linux/falloc.h> has symbol "FALLOC_FL_PUNCH_HOLE" : YES Header <linux/falloc.h> has symbol "FALLOC_FL_KEEP_SIZE" : YES Header <linux/falloc.h> has symbol "FALLOC_FL_ZERO_RANGE" : YES Has header "linux/fiemap.h" : YES Header <linux/fs.h> has symbol "FS_IOC_FIEMAP" : YES Checking for function "getrandom" : YES Header <sys/random.h> has symbol "GRND_NONBLOCK" : YES Header <sys/inotify.h> has symbol "inotify_init" : YES Header <sys/inotify.h> has symbol "inotify_init1" : YES Header <machine/bswap.h> has symbol "bswap32" : NO Header <sys/prctl.h> has symbol "PR_SET_TIMERSLACK" : YES Header <linux/rtnetlink.h> has symbol "IFLA_PROTO_DOWN" : YES Header <sys/sysmacros.h> has symbol "makedev" : YES Header <getopt.h> has symbol "optreset" : NO Header <netinet/in.h> has symbol "IPPROTO_MPTCP" : NO Header <sys/mount.h> has symbol "FSCONFIG_SET_FLAG" : NO Checking whether type "struct sigevent" has member "sigev_notify_thread_id" : NO Checking whether type "struct stat" has member "st_atim" : YES Checking for type "struct iovec" : YES Checking for type "struct utmpx" : YES Checking for type "struct mmsghdr" : YES Header <linux/vm_sockets.h> has symbol "AF_VSOCK" : YES Program scripts/minikconf.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/scripts/minikconf.py) Configuring arm-softmmu-config-target.h using configuration Configuring arm-softmmu-config-devices.mak with command Reading depfile: /home/book/qemu/qemu-7.2.0/build/meson-private/arm-softmmu-config-devices.mak.d Configuring arm-softmmu-config-devices.h using configuration Configuring arm-linux-user-config-target.h using configuration Program scripts/make-config-poison.sh found: YES (/home/book/qemu/qemu-7.2.0/scripts/make-config-poison.sh) Run-time dependency capstone found: NO (tried pkgconfig) Library fdt found: NO Configuring config-host.h using configuration Program scripts/hxtool found: YES (/home/book/qemu/qemu-7.2.0/scripts/hxtool) Program scripts/shaderinclude.pl found: YES (/usr/bin/env perl /home/book/qemu/qemu-7.2.0/scripts/shaderinclude.pl) Program scripts/qapi-gen.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/scripts/qapi-gen.py) Program scripts/qemu-version.sh found: YES (/home/book/qemu/qemu-7.2.0/scripts/qemu-version.sh) Executing subproject libvhost-user libvhost-user| Project name: libvhost-user libvhost-user| Project version: undefined libvhost-user| C compiler for the host machine: cc -m64 -mcx16 (gcc 7.5.0 "cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0") libvhost-user| C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.30 libvhost-user| Dependency threads found: YES unknown (cached) libvhost-user| Dependency glib-2.0 found: YES 2.56.4 (overridden) libvhost-user| Build targets in project: 10 libvhost-user| Subproject libvhost-user finished. Executing subproject libvduse libvduse| Project name: libvduse libvduse| Project version: undefined libvduse| C compiler for the host machine: cc -m64 -mcx16 (gcc 7.5.0 "cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0") libvduse| C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.30 libvduse| Build targets in project: 11 libvduse| Subproject libvduse finished. Program scripts/decodetree.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/scripts/decodetree.py) Program ../scripts/modules/module_block.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/block/../scripts/modules/module_block.py) Program ../scripts/block-coroutine-wrapper.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/block/../scripts/block-coroutine-wrapper.py) Program scripts/modinfo-collect.py found: YES (/home/book/qemu/qemu-7.2.0/scripts/modinfo-collect.py) Program scripts/modinfo-generate.py found: YES (/home/book/qemu/qemu-7.2.0/scripts/modinfo-generate.py) Program nm found: YES Program scripts/undefsym.py found: YES (/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/scripts/undefsym.py) Program scripts/feature_to_c.sh found: YES (/bin/sh /home/book/qemu/qemu-7.2.0/scripts/feature_to_c.sh) Configuring 50-edk2-i386-secure.json using configuration Configuring 50-edk2-x86_64-secure.json using configuration Configuring 60-edk2-aarch64.json using configuration Configuring 60-edk2-arm.json using configuration Configuring 60-edk2-i386.json using configuration Configuring 60-edk2-x86_64.json using configuration Program qemu-keymap found: NO Program sphinx-build-3 sphinx-build found: NO Program bash found: YES 4.4.20 (/bin/bash) Program diff found: YES (/usr/bin/diff) Program dbus-daemon found: YES (/usr/bin/dbus-daemon) Did not find CMake 'cmake' Found CMake: NO Run-time dependency gvnc-1.0 found: NO (tried pkgconfig and cmake) Program initrd-stress.sh found: YES (/home/book/qemu/qemu-7.2.0/tests/migration/initrd-stress.sh) Build targets in project: 492 qemu 7.2.0 Directories Install prefix : /home/book/qemu/qemu-7.2.0_build BIOS directory : share/qemu firmware path : share/qemu-firmware binary directory : /home/book/qemu/qemu-7.2.0_build/bin library directory : /home/book/qemu/qemu-7.2.0_build/lib/x86_64-linux-gnu module directory : lib/x86_64-linux-gnu/qemu libexec directory : /home/book/qemu/qemu-7.2.0_build/libexec include directory : /home/book/qemu/qemu-7.2.0_build/include config directory : /home/book/qemu/qemu-7.2.0_build/etc local state directory : /home/book/qemu/qemu-7.2.0_build/var Manual directory : /home/book/qemu/qemu-7.2.0_build/share/man Doc directory : /home/book/qemu/qemu-7.2.0_build/share/doc Build directory : /home/book/qemu/qemu-7.2.0/build Source path : /home/book/qemu/qemu-7.2.0 GIT submodules : ui/keycodemapdb tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 dtc Host binaries git : git make : make python : /usr/bin/python3.7 (version: 3.7) sphinx-build : NO iasl : NO genisoimage : /usr/bin/genisoimage Configurable features Documentation : NO system-mode emulation : YES user-mode emulation : YES block layer : YES Install blobs : YES module support : NO fuzzing support : NO Audio drivers : pa oss Trace backends : log D-Bus display : NO QOM debugging : NO vhost-kernel support : YES vhost-net support : YES vhost-user support : YES vhost-user-crypto support : YES vhost-user-blk server support: YES vhost-vdpa support : YES build guest agent : YES Compilation host CPU : x86_64 host endianness : little C compiler : cc -m64 -mcx16 Host C compiler : cc -m64 -mcx16 C++ compiler : c++ -m64 -mcx16 CFLAGS : -O0 -g CXXFLAGS : -O0 -g QEMU_CFLAGS : -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong QEMU_CXXFLAGS : -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong QEMU_OBJCFLAGS : QEMU_LDFLAGS : -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--warn-common profiler : NO link-time optimization (LTO) : NO PIE : YES static build : NO malloc trim support : YES membarrier : NO debug stack usage : NO mutex debugging : YES memory allocator : system avx2 optimization : YES avx512f optimization : NO gprof enabled : NO gcov : NO thread sanitizer : NO CFI support : NO strip binaries : NO sparse : NO mingw32 support : NO Targets and accelerators KVM support : NO HAX support : NO HVF support : NO WHPX support : NO NVMM support : NO Xen support : NO TCG support : YES TCG backend : native (x86_64) TCG plugins : YES TCG debug enabled : YES target list : arm-softmmu arm-linux-user default devices : YES out of process emulation : YES vfio-user server : NO Block layer support coroutine backend : ucontext coroutine pool : YES Block whitelist (rw) : Block whitelist (ro) : Use block whitelist in tools : NO VirtFS support : NO build virtiofs daemon : NO Live block migration : YES replication support : YES bochs support : YES cloop support : YES dmg support : YES qcow v1 support : YES vdi support : YES vvfat support : YES qed support : YES parallels support : YES FUSE exports : NO VDUSE block exports : YES Crypto TLS priority : NORMAL GNUTLS support : NO libgcrypt : NO nettle : NO AF_ALG support : NO rng-none : NO Linux keyring : YES Dependencies SDL support : YES SDL image support : NO GTK support : NO pixman : YES 0.34.0 VTE support : NO slirp support : NO libtasn1 : NO PAM : NO iconv support : YES curses support : YES virgl support : NO blkio support : NO curl support : NO Multipath support : NO PNG support : NO VNC support : YES VNC SASL support : NO VNC JPEG support : NO OSS support : YES sndio support : NO ALSA support : YES 1.1.3 PulseAudio support : YES 11.1 JACK support : NO brlapi support : NO vde support : NO netmap support : NO l2tpv3 support : YES Linux AIO support : NO Linux io_uring support : NO ATTR/XATTR support : YES RDMA support : NO PVRDMA support : NO fdt support : internal libcap-ng support : NO bpf support : NO spice protocol support : NO rbd support : NO smartcard support : NO U2F support : NO libusb : NO usb net redir : NO OpenGL support (epoxy) : NO GBM : NO libiscsi support : NO libnfs support : NO seccomp support : NO GlusterFS support : NO TPM support : YES libssh support : NO lzo support : NO snappy support : NO bzip2 support : NO lzfse support : NO zstd support : NO NUMA host support : NO capstone : NO libpmem support : NO libdaxctl support : NO libudev : YES 237 FUSE lseek : NO selinux : NO Subprojects libvduse : YES libvhost-user : YES User defined options Native files : config-meson.cross optimization : 0 prefix : /home/book/qemu/qemu-7.2.0_build debug_mutex : true vfio_user_server : disabled Found ninja-1.8.2 at /usr/bin/ninja Running postconf script '/usr/bin/python3.7 /home/book/qemu/qemu-7.2.0/scripts/symlink-install-tree.py'I've tested multiple versions of QEMU (7.2.0/4.1.1) and U-Boot (u-boot-fslc-2016.05/u-boot-fslc-2023.10/uboot-imx-rel_imx_4.1.15_2.1.0_ga). When I run qemu-system-arm -M help, the Supported machines list includes mcimx6ul-evk.As a beginner, I'm quite confused and can't figure out where the problem lies. Any help would be greatly appreciated!
Quoted 7 lines · Guy
I am trying to debug U-Boot code in Ubuntu 18.04 using the mcimx6ul-evk board in QEMU. I have successfully compiled QEMU and U-Boot using arm-linux-gnueabihf-. When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the
get_cpu_revfunction:struct
scu_regs*scu = (structscu_regs*)SCU_BASE_ADDR; 2cfg =readl(&scu->config)& 3;This triggers a
data_aborterror. The log displays "Invalid read at addr0xA00004, size 4, region '(null)', reason: rejected."
This is because QEMU does not model any device at that address. What do you think is supposed to be there? The Cortex-A9 has a snoop-control-register at that offset from PERIPHBASE, but as far as I am aware the Cortex-A7 which the mcimx6ul-evk board uses does not have any SCU registers.
Quoted 1 line
I've tested multiple versions of QEMU (7.2.0/4.1.1) and U-Boot (u-boot-fslc-2016.05/u-boot-fslc-2023.10/uboot-imx-rel_imx_4.1.15_2.1.0_ga). When I run qemu-system-arm -M help, the Supported machines list includes mcimx6ul-evk.
By the way, 7.2 is now a moderately older version of QEMU. It won't fix this problem, but in general if you're building from source anyway you should use the most recent version.
-- PMM
Furthermore, I also tested a precompiled qemu-system-arm.exe in windows (the -version command shows the same 7.2.0 version of QEMU, although I'm not sure if there were any differences in the compilation process) to debug the same U-Boot code, and I did not encounter the error at the get_cpu_rev step. How can this situation be explained? Quite confused.
On Fri, 30 Aug 2024 at 05:11, Guy <[email protected]> wrote:
>
> I am trying to debug U-Boot code in Ubuntu 18.04 using the mcimx6ul-evk board in QEMU. I have successfully compiled QEMU and U-Boot using arm-linux-gnueabihf-. When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the get_cpu_rev function:
>
> struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR;
> 2cfg = readl(&scu->config) & 3;
>
> This triggers a data_abort error. The log displays "Invalid read at addr 0xA00004, size 4, region '(null)', reason: rejected."
This is because QEMU does not model any device at that address. What do you think is supposed to be there? The Cortex-A9 has a snoop-control-register at that offset from PERIPHBASE, but as far as I am aware the Cortex-A7 which the mcimx6ul-evk board uses does not have any SCU registers.
> I've tested multiple versions of QEMU (7.2.0/4.1.1) and U-Boot (u-boot-fslc-2016.05/u-boot-fslc-2023.10/uboot-imx-rel_imx_4.1.15_2.1.0_ga). When I run qemu-system-arm -M help, the Supported machines list includes mcimx6ul-evk.
By the way, 7.2 is now a moderately older version of QEMU. It won't fix this problem, but in general if you're building from source anyway you should use the most recent version.
-- PMM
When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the get_cpu_rev function:
struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR;
cfg = readl(&scu->config) & 3;
This triggers a data_abort error. The log displays
----------------
IN: get_cpu_rev
0x87802786:
OBJD-T: 5968
Invalid read at addr 0xA00004, size 4, region '(null)', reason: rejected
----------------
Furthermore, I also tested a precompiled qemu-system-arm.exe in windows (the -version command shows the same 7.2.0 version of QEMU, although I'm not sure if there were any differences in the compilation process) to debug the same U-Boot code, and I did not encounter the data_abort error at the get_cpu_rev step. The log displays
----------------
IN: get_cpu_rev
0x87802786:
OBJD-T: 5968
scu: unimplemented device read (size 4, offset 0x0004)
----------------
I wonder how the differences between these two situations arise? Could it be relationships on compilation options?
------------------------------------
On Fri, 30 Aug 2024 at 05:11, Guy <[email protected]> wrote:
>
> I am trying to debug U-Boot code in Ubuntu 18.04 using the mcimx6ul-evk board in QEMU. I have successfully compiled QEMU and U-Boot using arm-linux-gnueabihf-. When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the get_cpu_rev function:
>
> struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR;
> 2cfg = readl(&scu->config) & 3;
>
> This triggers a data_abort error. The log displays "Invalid read at addr 0xA00004, size 4, region '(null)', reason: rejected."
This is because QEMU does not model any device at that address. What do you think is supposed to be there? The Cortex-A9 has a snoop-control-register at that offset from PERIPHBASE, but as far as I am aware the Cortex-A7 which the mcimx6ul-evk board uses does not have any SCU registers.
> I've tested multiple versions of QEMU (7.2.0/4.1.1) and U-Boot (u-boot-fslc-2016.05/u-boot-fslc-2023.10/uboot-imx-rel_imx_4.1.15_2.1.0_ga). When I run qemu-system-arm -M help, the Supported machines list includes mcimx6ul-evk.
By the way, 7.2 is now a moderately older version of QEMU. It won't fix this problem, but in general if you're building from source anyway you should use the most recent version.
-- PMM
Quoted 6 lines · Guy
When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the
get_cpu_revfunction:struct
scu_regs*scu = (structscu_regs*)SCU_BASE_ADDR; cfg =readl(&scu->config)& 3;
Quoted 8 lines
This triggers a
data_aborterror. The log displays----------------
IN:get_cpu_rev0x87802786:
OBJD-T: 5968
Invalid read at addr0xA00004, size 4, region '(null)', reason: rejected
----------------
The problem here is that the guest code thinks it can read from this address, and QEMU thinks there is no device there. To figure out which one is wrong, you need to look at the data sheet for the SoC to see whether it says there's anything at that address.
Quoted 8 lines
Furthermore, I also tested a precompiled qemu-system-arm.exe in windows (the -version command shows the same 7.2.0 version of QEMU, although I'm not sure if there were any differences in the compilation process) to debug the same U-Boot code, and I did not encounter the
data_aborterror at theget_cpu_revstep. The log displays----------------
IN:get_cpu_rev0x87802786:
OBJD-T: 5968
scu: unimplemented device read (size 4, offset0x0004)
----------------
I think these can't be the same versions of QEMU. This second one seems to have been patched to treat this area of memory as "there should be a device here, but we don't implement it, so warn about it but return 0". Where does this one come from?
thanks
-- PMM
I got the exe from a repository on gitee.com. But there is no source code.
Furthermore, I see the A7MPCORE in the fsl-imx6ul.c of the qemu source code:
C
/* * A7MPCORE */ object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", 1, &error_abort); object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL, &error_abort); sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR); sbd = SYS_BUS_DEVICE(&s->a7mpcore); d = DEVICE(&s->cpu); sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(d, ARM_CPU_IRQ)); sysbus_connect_irq(sbd, 1, qdev_get_gpio_in(d, ARM_CPU_FIQ)); sysbus_connect_irq(sbd, 2, qdev_get_gpio_in(d, ARM_CPU_VIRQ)); sysbus_connect_irq(sbd, 3, qdev_get_gpio_in(d, ARM_CPU_VFIQ));
The FSL_IMX6UL_A7MPCORE_ADDR is defined in fsl-imx6ul.h as part of enum FslIMX6ULMemoryMap:FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000,This memory region is the same as the address where a data_abort occurs in get_cpu_rev. I see that the code for A7MPCORE above calls sysbus_mmio_map to perform what appears to be a memory mapping operation on the FSL_IMX6UL_A7MPCORE_ADDR address (I'm not sure of the exact function of sysbus_mmio_map). I want to know if this operation is sufficient to prevent errors when reading this address range in get_cpu_rev? If not, what additional operations are needed? Thank you very much for this discussion on my question.
-----------------------------------
On Mon, 2 Sept 2024 at 07:10, Guy <[email protected]> wrote:
>
> When I attempt to run U-Boot and debug it with GDB, I encounter an issue in the get_cpu_rev function:
>
> struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR;
> cfg = readl(&scu->config) & 3;
>
> This triggers a data_abort error. The log displays
>
> ----------------
> IN: get_cpu_rev
> 0x87802786:
> OBJD-T: 5968
> Invalid read at addr 0xA00004, size 4, region '(null)', reason: rejected
> ----------------
The problem here is that the guest code thinks it can read from this address, and QEMU thinks there is no device there. To figure out which one is wrong, you need to look at the data sheet for the SoC to see whether it says there's anything at that address.
> Furthermore, I also tested a precompiled qemu-system-arm.exe in windows (the -version command shows the same 7.2.0 version of QEMU, although I'm not sure if there were any differences in the compilation process) to debug the same U-Boot code, and I did not encounter the data_abort error at the get_cpu_rev step. The log displays >
> ----------------
> IN: get_cpu_rev
> 0x87802786:
> OBJD-T: 5968
> scu: unimplemented device read (size 4, offset 0x0004)
> ----------------
I think these can't be the same versions of QEMU. This second one seems to have been patched to treat this area of memory as "there should be a device here, but we don't implement it, so warn about it but return 0". Where does this one come from?
thanks
-- PMM
Quoted 24 lines · Guy
I got the exe from a repository on gitee.com. But there is no source code. Furthermore, I see the A7MPCORE in the
fsl-imx6ul.cof the qemu source code:C
/*
* A7MPCORE */ object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", 1, &error_abort); object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL, &error_abort); sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR); sbd = SYS_BUS_DEVICE(&s->a7mpcore); d = DEVICE(&s->cpu); sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(d, ARM_CPU_IRQ)); sysbus_connect_irq(sbd, 1, qdev_get_gpio_in(d, ARM_CPU_FIQ)); sysbus_connect_irq(sbd, 2, qdev_get_gpio_in(d, ARM_CPU_VIRQ)); sysbus_connect_irq(sbd, 3, qdev_get_gpio_in(d, ARM_CPU_VFIQ));
Quoted 6 lines
The
FSL_IMX6UL_A7MPCORE_ADDRis defined infsl-imx6ul.has part of enum FslIMX6ULMemoryMap:
FSL_IMX6UL_A7MPCORE_ADDR=0x00A00000,This memory region is the same as the address where a
data_abortoccurs inget_cpu_rev.
Yes, but the s->a7mpcore object's MemoryRegion doesn't have anything at its address 0. This is an object of TYPE_A15MPCORE_PRIV, and in its source in hw/cpu/15mpcore.c the comment says what it provides:
/* Memory map (addresses are offsets from PERIPHBASE):
* 0x0000-0x0fff -- reserved
* 0x1000-0x1fff -- GIC Distributor
* 0x2000-0x3fff -- GIC CPU interface
* 0x4000-0x4fff -- GIC virtual interface control for this CPU
* 0x5000-0x51ff -- GIC virtual interface control for CPU 0
* 0x5200-0x53ff -- GIC virtual interface control for CPU 1
* 0x5400-0x55ff -- GIC virtual interface control for CPU 2
* 0x5600-0x57ff -- GIC virtual interface control for CPU 3
* 0x6000-0x7fff -- GIC virtual CPU interface
*/
Note in particular that offsets 0x0000-0x0fff are reserved :
there is nothing there.
A15 and A7 are the same in this regard -- the A7 CPU TRM does not describe any device at offset 0 from PERIPHBASE.
So the question remains: what does the guest code want to see here? To answer the question you need to look at the imx6UL SoC's reference manual to see if it documents anything there. If it does, then we know what we need to emulate in QEMU. If it does not, then this is a bug in u-boot that should probably be fixed there.
thanks
-- PMM