-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize bootargs for system emulation #534
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarks
Benchmark suite | Current: 4c73b1a | Previous: 08146d9 | Ratio |
---|---|---|---|
Dhrystone |
1336 Average DMIPS over 10 runs |
1329 Average DMIPS over 10 runs |
0.99 |
Coremark |
942.606 Average iterations/sec over 10 runs |
942.861 Average iterations/sec over 10 runs |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
src/riscv.c
Outdated
const char *name, | ||
int newlen) | ||
{ | ||
/* FIXME: assume RAM is enough */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if we need to consider the case of the preallocated memory being smaller than the required size to extend the DTB. Ideally, we can assume this won't happen.
assert(node > 0); | ||
|
||
len = strlen(bootargs) + 1; | ||
buf = malloc(len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include an assertion or verify the return value of malloc, as it may fail.
31d4a5d
to
bb84d6b
Compare
tools/bin_to_c.c
Outdated
// | ||
// bin_to_c - convert binary data into c-compatible data tables | ||
// | ||
// Written by Larry Bank | ||
// Copyright (c) 2009 BitBank Software, Inc. | ||
// Change history | ||
// 2/1/09 - Started the project | ||
// 11/6/15 - converted to Linux | ||
// 7/29/20 - tailored to Arduino FLASH data output | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use C-style comments.
- Put the original copyright notice: https://github.com/bitbank2/bin_to_c/blob/master/LICENSE and keep "Written by Larry Bank" and "Copyright (c) 2015 BitBank Software, Inc."
- Remove the change history for short.
mk/system.mk
Outdated
BIN_TO_C := $(OUT)/bin_to_c | ||
$(BIN_TO_C): tools/bin_to_c.c | ||
$(Q)$(CC) -Wall -o $@ $^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename from bin_to_c
to bin2c
for consistency.
0be4792
to
c15ee4c
Compare
Thank @RinHizakura for contributing! |
Customize bootargs for system emulation
The submodules are built locally, which may lead to build failures. Specifically, the dtc submodule fails to build when using GCC versions 11.4.0 or 12.3.0 with optimization levels set to -O0 or with debug flag -g. This is a critical issue, as it can disable the debug mode. To address this, optimization levels and debug level build are introduced to stabilize the pull request changes. The compiled error: /usr/bin/ld: /tmp/cc2eaHdM.ltrans0.ltrans.o: in function fdt_del_node': <artificial>:(.text+0x279f0): undefined reference to fdt_node_end_offset_' collect2: error: ld returned 1 exit status Note: I have only used gcc 11.4.0 and gcc 12.3.0 to test this out. Github runners should test other compilers. After bisecting, the original cause was found after sysprog21#534.
As discussed in #527: The device tree is coupled with the hardware design of rv32emu itself, so if the user wants to customize the device tree, he/she still needs to be based on a template. Therefore, embedding the DT template in the emulator can be more appropriate, and we can allow the user to tweak parts of the device tree from specific options.
To accomplish this, we first use bin_to_c to include DTB in the emulator binary itself and use libfdt to modify the property.
You can verify the effect of this change by running the following command to see the difference.