-
-
Notifications
You must be signed in to change notification settings - Fork 799
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
Integrate with Renode Simulation Framework for load and debug #3401
Comments
Cc. @PiotrZierhoffer @pdp7 @pgielda @mgielda |
Currently the |
I've successfully made it work with no changes to PlatformIO Core, just by configuring the right bits on the project On Mac, I've installed Renode and made a link from `` to My [env:hifive1]
platform = sifive
framework = zephyr
board = hifive1
monitor_speed = 115200
# Settings to integrate with Renode upload and debug
upload_command = renode -e "include @scripts/single-node/sifive_fe310.resc" -e "machine StartGdbServer 3333 True" -e "sysbus LoadELF @$SOURCE" -e "start"
debug_tool = custom
debug_port = localhost:3333
debug_server = renode
-e
include @scripts/single-node/sifive_fe310.resc
-e
machine StartGdbServer 3333 True
debug_extra_cmds =
monitor start And the integration for both running/uploading and also debugging worked perfectly as seen below: |
@carlosedp thanks for the great research! It can be easy integrated in PlatformIO. It will look for you as:
We will back soon to this issue! |
Nice thing is that Renode has support for more boards that are also supported by PlatformIO: https://renode.readthedocs.io/en/latest/introduction/supported-boards.html |
Hey @ivankravets, I'm still fine-tuning the parameters and let you know. |
Hi @carlosedp glad to see this! I already had an integration with pio written up internally and was thinking how to make this public, so glad you went along and did this ;) We were busy with the Renode 1.9 relase which just went out this week - https://github.com/renode/renode/releases/tag/v1.9.0 - but now that it's past, happy to support this effort - @PiotrZierhoffer bringing to your attention. |
Hi @mgielda , The only thing which we need for PlatformIO Core is a default GDB init config. See examples: The rest integration work should be done on the dev-platform side (https://github.com/platformio/platform-sifive), if we mean SiFive. We will help with this. So, what should be In the example above which works for @carlosedp if was: GDB_RENODE_INIT_CONFIG = """
define pio_reset_halt_target
monitor reset halt
end
define pio_reset_run_target
monitor reset
end
target extended-remote $DEBUG_PORT
monitor init
$LOAD_CMDS
pio_reset_halt_target
$INIT_BREAK
monitor start
""" We plan to release PIO Core 4.3.0 next week. So, it would be great to have support for Renode. |
In my config, I've been able to both build/upload and debug. Also connect to the simulation over console (via telnet) with: [env:hifive1]
platform = sifive
board = hifive1
framework = zephyr
## ----- Settings below are for Antmicro Renode integration ----- ##
# Monitor port for Renode integration
monitor_port = socket://localhost:1234
# Upload settings for Renode integration
upload_command = renode $UPLOAD_FLAGS
upload_flags =
-e include @scripts/single-node/sifive_fe310.resc
-e machine StartGdbServer 3333 True
-e emulation CreateServerSocketTerminal 1234 \"externalUART\"
-e connector Connect uart0 externalUART
-e sysbus LoadELF @$SOURCE
-e start
# Debug settings for Renode integration
debug_tool = custom
debug_port = localhost:3333
debug_server = renode
-e include @scripts/single-node/sifive_fe310.resc
-e machine StartGdbServer 3333 True
-e emulation CreateServerSocketTerminal 1234 "externalUART"
-e connector Connect uart0 externalUART
debug_extra_cmds =
monitor start Works perfectly. Do you folks think on any additional features that could be included? One thing I couldn't address that maybe @PiotrZierhoffer and @mgielda could help is to restart the debugging and "reset" the simulated board. Is it possible withou issuing a |
Guys, I'm seeing some problems debugging the console application on Renode. On PlatformIO debug console I see the output below that I understand combined both PlatformIO and Renode outputs:
And it doesn't reach my breakpoint a couple lines below and stops here: This is my code: #include <zephyr.h>
#include <version.h>
#include <string.h>
#include <sys/printk.h>
#include <console/console.h>
void main(void)
{
printk("Hello! I'm running Zephyr %s on %s, a %s board.\n\n ", KERNEL_VERSION_STRING, CONFIG_BOARD, CONFIG_ARCH);
console_getline_init();
printk("Enter a line finishing with Enter:\n");
while (1)
{
printk("> ");
char *s = console_getline();
printk("Typed line: %s\n", s);
printk("Last char was: 0x%x\n", s[strlen(s) - 1]);
}
} The weird thing is that I got it working a while back, now it doesn't anymore. I tried removing Renode cache dir but same thing...any ideas? |
Found it! I had to add
Then it worked fine. I think @mgielda might need to point the debug commands since the logs show some commands as not existing like @ivankravets during the debug, if I hover on some variables or defines I get some errors like shown here: |
As for "init" and "reset" those seem to be openocd commands, send via gdb using "monitor"command (its a transport to underlying server, not part of the GDB spec). Since its openocd-specific it does not do anything in Renode. You could potentially define functions like that in your renode script to get rid of the error and potentially do something when they're executed. |
I've successfully made the integration to use STM32F4 with Arduino: ; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:disco_f407vg]
platform = ststm32
board = disco_f407vg
framework = arduino
## ----- Settings below are for Antmicro Renode integration ----- ##
# Monitor port for Renode integration
monitor_port = socket://localhost:1234
monitor_speed = 115200
# Upload settings for Renode integration
# Here we use uart2 that is the default UART attached in Arduino
# We have to open the UART2 window since the detfault is opening uart4
upload_command = renode $UPLOAD_FLAGS
upload_flags =
-e include @scripts/single-node/stm32f4_discovery.resc
-e machine StartGdbServer 3333 True
-e emulation CreateServerSocketTerminal 1234 \"externalUART\"
-e connector Connect uart2 externalUART
-e showAnalyzer uart2
-e sysbus LoadELF @$SOURCE
-e start
# Debug settings for Renode integration
debug_tool = custom
debug_port = localhost:3333
debug_server = renode
--hide-log
-e include @scripts/single-node/stm32f4_discovery.resc
-e machine StartGdbServer 3333 True
-e emulation CreateServerSocketTerminal 1234 "externalUART"
-e connector Connect uart2 externalUART
-e showAnalyzer uart2
debug_extra_cmds =
monitor start
@ivankravets, I understand we need a new GDB script without the On customizing the ini for Renode upload and debug, I think we need some parameters to be flexible depending on the board. For example on the HiFive1, we use the script Also on HiFive1 the default UART is We could have customized the |
We are accidentaly working on a Monitor function called "alias" that will allow for custom commands to be easily defined "per script" or even "per machine". Stay tuned. |
Hi @carlosedp -- just heads up that the alias feature is now in Renode master branch. It allows you to define anything as an alias, e.g.: |
Sorry for the delay from our side. We follow this thread, thanks for the ideas! I tried yesterday Renode on my Mac and found a few issues:
I've never used Mono/C#, I'm a noob here. Sorry. @pgielda please help with the next questions as for the renode.zip archive:
Thanks! P.S: @carlosedp did great work! His work and article helped me a lot to realize that it should be a very easy integrated Renode into PlatformIO. Yes, it works now. The only what we want to do - to automate everything. The developer set in project |
Hey @ivankravets About your issues: we never focused on Mono from brew as it used to be quite old and we needed a relatively fresh release. That's why our docs point to Mono website. Apparently, they do not have consistent packaging policies here. We can definitely revisit that - using Mono from brew would be, in general, much easier. We will look at the startup scripts to make it work. If you stumble upon similar problems in future, please feel free to let us know via Renode issues. And regarding the questions you asked:
|
A few updates from PlatformIO side: 1. Renode package & CDNWe publish Renode package into our CDN (currently, we use @bintray). It is much faster than Github's Amazon S3. PlatformIO will automatically install Renode on the user machine into an isolated environment depending on the host machine. We have own package manager and dev-platform declares own dependencies. For example, SiFive dev-platform can use Renode 1.9 where St STM32 Renode 1. PlatformIO resolves this automatically. We prepared packages and deployed them to https://bintray.com/beta/#/platformio/dl-packages/tool-renode?tab=files 2. GDB ConfigurationWe added this GDB configuration for our PIO Unified Debugger. When user press "start debugging " or run from CLI Please check this configuration https://github.com/platformio/platformio-core/blob/develop/platformio/commands/debug/initcfgs.py#L127 If you will have any changes later, please inform us or do PR. A shortcut GDB command named 3. Renode's GDB server stateWe had the problem with running Renode in the background. It's indeed our issue. The only we start GDB server, we try to connect to it. We have had problems with existing debugging server before which we support (J-Link, OpenOCD, pyOCD, etc.). Renode has different behavior. It starts the process and tries to download something from the Internet (my firewall reports me). So, and... the only when it downloaded dependencies, it starts GDB server. I'm not an expert here. Maybe it makes sense to start a socket server at the beginning and buffer income commands as openOCD and other tools do. Nevertheless, it's not a blocker for us. We did a workaround and introduced support for server.ready_pattern. Currently, it is set to 4. Renode loggingA simple quesiton - how to reduce logging? For example, to show everything below INFO+? Like, errors, warning, info, but not debug... 5. UART ConsoleI have not managed to get output in telnet from this example https://github.com/platformio/platform-sifive/tree/develop/examples/zephyr-synchronization What is the correct configuration? I used this [env:hifive1-revb]
platform = https://github.com/platformio/platform-sifive.git
framework = zephyr
board = hifive1-revb
build_type = debug
monitor_speed = 115200
debug_init_break = tbreak bg_thread_main
debug_tool = renode pio debug --interface gdb -x .pioinit
# and
nc localhost 1234 The configuration for Renode server is default by SiFive dev-platform => https://github.com/platformio/platform-sifive/blob/develop/platform.py#L105 We have not released SiFive dev-platform yet. It would be good to close all the questions before. Then we can add support for Kendryte and STM32. Thanks in advance! |
Hey Ivan, thanks for the release! The sifive-platform release required to support this right? Also the integration with Renode is only for Debug and not Upload? To reduce the amount of logs, just pass To get the console, I've used:
But faced the problem from #3421. I've successfully added integration to the Kendryte K210 using FreeRTOS. One problem tho is that PIO tried to upload The complete config became: ; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:sipeed-maix-go]
platform = kendryte210
board = sipeed-maix-go
framework = kendryte-freertos-sdk
## ----- Settings below are for Antmicro Renode integration ----- ##
# Monitor port for Renode integration
monitor_port = socket://localhost:1234
monitor_speed = 115200
# Upload settings for Renode integration
upload_port = /dev/ttyUSB0
upload_command = renode $UPLOAD_FLAGS
upload_flags =
-e include @scripts/single-node/kendryte_k210.resc
-e machine StartGdbServer 3333 True
-e logLevel 3 ; Loglevel = Errors
-e emulation CreateServerSocketTerminal 1234 \"externalUART\"
-e connector Connect uart externalUART
; -e sysbus LoadELF @$SOURCE ; Does not work on K210-FreeRTOS
-e sysbus LoadELF @$PROJECT_BUILD_DIR/$PIOENV/$PROGNAME".elf"
-e start
# Debug settings for Renode integration
debug_tool = custom
debug_port = localhost:3333
debug_server = renode
--hide-log
-e include @scripts/single-node/kendryte_k210.resc
-e machine StartGdbServer 3333 True
-e logLevel 3 ;Loglevel = Errors
-e emulation CreateServerSocketTerminal 1234 "externalUART"
-e connector Connect uart externalUART
debug_extra_cmds =
monitor start |
Hi @ivankravets, any news on this? Can I help with something? |
Sorry for the delay. We will back soon to this issue. |
What kind of issue is this?
What is Renode?
Renode is an open source software development framework with commercial support from Antmicro that lets you develop, debug and test multi-node device systems reliably, scalably and effectively.
Renode is a fantastic tool to simulate applications on multiple boards. As an example, it supports boards from STMicro and some RISC-V boards like SiFive HiFive1, Kendryte K210 and many more.
Full board list: https://renode.readthedocs.io/en/latest/introduction/supported-boards.html
This integration would be the best of both worlds where one can develop in PlatformIO and debug/simulate on Renode without requiring hardware. Renode is available for Windows, Mac and Linux just adjusting the execution path.
I've started testing the available options and identified Renode can be started as a Telnet server (over a choosen port) and issued commands to it.
As an example to run the HiFive 1 ZephyrOS Hello World project, I did (on MacOS):
/Applications/Renode.app/Contents/MacOS/macos_run.command -P 1234
telnet 1234
include @scripts/single-node/sifive_fe310.resc
machine StartGdbServer 3333 True
sysbus LoadELF @/Users/cdepaula/Documents/PlatformIO/Projects/200303-171147-zephyr-hello-world/.pio/build/hifive1/firmware.elf
start
To start over, issue the command
Clear
on Renode console.Another option is loading Renode with command line execute parameters as:
I successfully integrated the PlatformIO debugger to an existing instance of Renode by adding
debug_port = localhost:3333
toplatformio.ini
on my project. Added a test breakpoint and interacted with the debugging on the simulation:/Applications/Renode.app/Contents/MacOS/macos_run.command -P 1234
telnet 1234
include @scripts/single-node/sifive_fe310.resc
machine StartGdbServer 3333 True
From there, I clicked the debugger "Play" and PlatformIO built and loaded my application into Renode.
Continued the breakpoint:
I just was not able to "Reset" and start over via debugging or software without issuing the
Clear
command on Renode and loading everything from start (it's fast though).I'm wiling to help writing this support if I can get some tips.
The text was updated successfully, but these errors were encountered: