g2gps opened a new pull request, #8643:
URL: https://github.com/apache/nuttx/pull/8643
I'm working on implementing SV32 support (from #8602). I've opened a PR for
my current WIP as a draft, as the implementation is not working as expected.
With my current implantation, I'm able to go through the mapping for the IO,
kflash, ksram and pgram sections and enable the MMU, in `qemu_rv_mm_init()`.
From there, execution continues into and through `nx_start`, until `
nxmsg_initialize`. At which point the program falls over when accessing the
global variable `g_msgfreelist` members.
On inspecting with GDB, I can see that the initial values for the list have
changed from when they were originally set with `struct list_node g_msgfreelist
= LIST_INITIAL_VALUE(g_msgfreelist);`. Curiously, these changes occur during
the both before and after the MMU is enabled. Including if I set the values
again, just before using them (like this):
```
void nxmsg_initialize(void)
{
FAR struct msgbuf_s *msg;
g_msgfreelist.next = &g_msgfreelist;
g_msgfreelist.prev = &g_msgfreelist;
msg = (FAR struct msgbuf_s *)kmm_malloc(sizeof(*msg) *
CONFIG_PREALLOC_MQ_MSGS);
if (msg)
{
int i;
for (i = 0; i < CONFIG_PREALLOC_MQ_MSGS; i++)
{
list_add_tail(&g_msgfreelist, &msg->node);
msg++;
}
}
}
```
Obviously, something is incorrect either which the MMU mapping, or the
linker script setup. However, I can't seem to see the issue. Possibly @pussuw
could give me some pointers?
If you want to build locally, I'm using the compiler suggested in the readme
(`https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz`).
I'm building like this:
```
make distclean
/tools/configure.sh rv-virt:knsh32
make -j 16
make export
cd ../apps
./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
make import
cd ../nuttx
```
Then running qemu with:
```
qemu-system-riscv32 -semihosting -s -S -M virt,aclint=on -cpu rv32 -smp 1
-bios none -kernel nuttx -nographic -serial mon:stdio
```
I'm then using `gdb-multiarch` to debug.
You'll need to apply the following to the 'apps' repo, in order to get the
correct elf format, when linking. This would have to be amended as a separate
PR, once resolved.
```
diff --git a/import/Make.defs b/import/Make.defs
index 0405e412b..7b6fb7ed5 100644
--- a/import/Make.defs
+++ b/import/Make.defs
@@ -90,5 +90,6 @@ endif
# ELF module definitions
-LDELFFLAGS = -r -e _start -Bstatic
+LDELFFLAGS = -melf32lriscv
+LDELFFLAGS += -r -e _start -Bstatic
LDELFFLAGS += $(addprefix -T,$(call
CONVERT_PATH,$(TOPDIR)/scripts/gnu-elf.ld))
```
Keep in mind that i've 'hacked in' support, to try and get things going,
there isn't support for both SV32 and SV39 ATM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]