Closed jensschroer closed 7 years ago
Are you passing the "-mstrict-align" option to GCC? If not, then GCC is allowed to emit unaligned accesses (they're marked as slow, not illegal). If your compiler is too old to understand that option then you should be safe, but you might want to update to the latest release as we've fixed a handful of bugs.
I am using the Zephyr 0.9.1 SDK. It contains gcc version 6.1.0
Tried to add the -mstrict-align
option but the compiler does not seem to know the option.
For completeness, gcc -v output
> /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/riscv32-zephyr-elf/riscv32-zephyr-elf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/riscv32-zephyr-elf/riscv32-zephyr-elf-gcc
COLLECT_LTO_WRAPPER=/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/riscv32-zephyr-elf/../../libexec/riscv32-zephyr-elf/gcc/riscv32-zephyr-elf/6.1.0/lto-wrapper
Target: riscv32-zephyr-elf
Configured with: ../../../../../../work-shared/gcc-6.x.riscv32-r0/git/configure --build=x86_64-linux --host=x86_64-pokysdk-linux --target=riscv32-zephyr-elf --prefix=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr --exec_prefix=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr --bindir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/bin/riscv32-zephyr-elf --sbindir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/bin/riscv32-zephyr-elf --libexecdir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/libexec/riscv32-zephyr-elf --datadir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/share --sysconfdir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/etc --sharedstatedir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/com --localstatedir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/var --libdir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/lib/riscv32-zephyr-elf --includedir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/include --oldincludedir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/include --infodir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/share/info --mandir=/opt/zephyr-sdk/2.2/sysroots/x86_64-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/workdir/poky/build-zephyr-riscv32/tmp/sysroots/x86_64-nativesdk-pokysdk-linux --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=riscv32-zephyr-elf- --without-local-prefix --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/not/exist/usr/include/c++/6.1.0 --with-build-time-tools=/workdir/poky/build-zephyr-riscv32/tmp/sysroots/x86_64-linux/usr/riscv32-zephyr-elf/bin --without-long-double-128 --enable-poison-system-directories --with-mpfr=/workdir/poky/build-zephyr-riscv32/tmp/sysroots/x86_64-nativesdk-pokysdk-linux --with-mpc=/workdir/poky/build-zephyr-riscv32/tmp/sysroots/x86_64-nativesdk-pokysdk-linux --disable-static --enable-nls --enable-initfini-array --without-headers --without-headers --enable-plugin --enable-plugin
Thread model: posix
gcc version 6.1.0 (GCC)
@palmer-dabbelt I have also tried now the latest gcc from riscv toolchain (version 7.1.0) but still get the memory misaligned issue, even using the -mstrict-align
option.
Any suggestions?
/opt/riscv/bin/riscv32-unknown-elf-gcc -v Using built-in specs. COLLECT_GCC=/opt/riscv/bin/riscv32-unknown-elf-gcc COLLECT_LTO_WRAPPER=/opt/riscv/libexec/gcc/riscv32-unknown-elf/7.1.1/lto-wrapper Target: riscv32-unknown-elf Configured with: /home/schroer/code/riscv-gnu-toolchain/riscv-gcc/configure --target=riscv32-unknown-elf --prefix=/opt/riscv --disable-shared --disable-threads --enable-languages=c,c++ --with-system-zlib --enable-tls --with-newlib --with-headers=/opt/riscv/riscv32-unknown-elf/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --enable-checking=yes --disable-multilib --with-abi=ilp32d --with-arch=rv32g 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow' Thread model: single gcc version 7.1.1 20170509 (GCC)
Can you try compiling the app without optimization? Updating the prj_hifive1.conf with CONFIG_DEBUG=y should do the trick.
I'm also observing some issues with crypto tests running on riscv32 platform, when compiling with default optimization options as set by the zephyr build system, the tests fail with wrong computation results. Without optimization the tests pass. On other platforms this issue is not observed. I've also updated to latest gcc and still same result.
The same issue with CONFIG_DEBUG=y
@jensschroer Can you try with latest commits from git@github.com:fractalclone/zephyr-riscv.git ? There was a bug in context-restore upon exiting from ISR and this was causing execution errors from time to time. This was notably the origin of the issues I've observed while running crypto tests.
However, you will have to use latest zephyr 0.9.1 SDK since I have rebased zephyr-riscv repo from zephyr mainline repo. Link can be obtained from zephyr-riscv README.md
Alright, found finally out the root cause of this issue. It is caused by two options in the .config: CONFIG_NET_L2_ETHERNET=y and CONFIG_ETH_ENC28J60=n
The IP stack start up is trying to load a L2 interface, but since none is configured it tries access an invalid memory address, which results in above error.
@fractalclone thank you for the help. I will close this issue.
I am trying to get the samples/net/dhcpv4_client/ working on hifive1 board, using the branch provided by @palmer-dabbelt .
I use the following for the prj_hifive1.conf file (copied from arduino 101 disabled a few things for debugging):
Compiling the code with the current zephyr SDK and uploading it onto the board using the freedom-e-sdk works fine.
However, when opening ttyUSB1 with screen I get the following error:
Disassembling the code shows:
The function prepare_message is in
subsys/net/ip/dhcpv4.c
I found an old and closed bug in JIRA, just linking it here for reference as it sounded similiar: https://jira.zephyrproject.org/browse/ZEP-955
Not sure how to proceed at this point. Appreciate any hints / advice.