Anybody using e2 Studio with R4?

This is my first post in this forum so please excuse me if this should be in the "Software" area. (couldn't really decide)
Anyway I just got my R4 WiFi and really wanted to dive into the guts of it.
I love the eclipse IDE so looks like e2 Studio was the way to go.
I found an example online about creating a "Bare Metal Blinky Project" and
seems like my code should work but of course it doesn't.
I'm not asking for help there yet, I''l keep trying to get that LED blinking. I think it could be the configuration of the clocks or GPIO not happening as expected.

The other interesting thing I encountered is uploading the code.
I discovered using bossac.exe do the job (almost)
I can use the command "bossac -a --port=COM15" to get the board into upload mode with the 1200 baud trick.
Then "bossac -d --port=COM15 -U -e -w test02.bin -R" will upload my code but ONLY after I have used the Arduino IDE to upload "something" first.
After that initial upload bossac commands work fine UNTIL I power the board off. (weird huh)
Then I'll get "No Device found on COM15" error.
I can tell the first command gets the board into upload mode because the LED is fading in & out but the second command fails after a power cycle.

So I'm really interested in hearing from others who may have tried e2 Studio and uploading code from the command line.
Thanks
Eric

Update: 12/31/2023
The problem uploading the code can be resolved by using the arduino-cli tool instead of issuing the bossac commands. unfortunately this would require installing the entire Arduino IDE, the R4 board support and the arduino-cli tool.
I also tried compiling my 4 lines of e2 Studio/bsl code using the arduino IDE and it blinks the LED nicely. So still investigating why I can't get this simple program to run using e2 Studio.

Update 1/7/2024 Happy New Year
After a great deal of experimentation I have finally got something working.
I found some of the FSP related files that the Arduino IDE installs to support the R4 board.
Tried using the linker scripts fsp.ld and memory_regions.ld that Arduino IDE uses (which generated tons of error & warning messages) like a missing library libfsp.a and other incorrect values.
Eventually with LOTs of tweaks and modifications I'm now able to compile and execute code on the R4 using e2 studio.
I'm sorry to admit that my knowledge of linker scripts is minimal but I'm guessing the Arduino people have loaded a bootloader on the microcontroller so the executable code needs to be loaded to a different address.
There's also some properties in the configuration.xml file that needed to be adjusted manually as I couldn't find a way in the e2 Studio configuration IDE that set them.
The good news in now I can simply copy my "Blinky" project with all the adjustments, and use that copy as a starting point for further development.

Update 1/9/2024
After a couple more days of messing around I reduced the project modifications to adding a single
line to a linker script file named memory_regions.ld
"FLASH_IMAGE_START = 0x4000;"
Of course that file gets re-built with each build so a couple more mods were necessary.

So I now have my LED blinking and have a very basic UART running, but no interrupts will fire. On to trying to figure out why interrupts will not work.

Update 1/12/2024
I'm very excited to have found a solution !!! (it came to me while lying in bed awake at 3:30am ).
A call the arm function __enable_irq(); did the trick!! (yay!!!)
I'm assuming the Arduino bootloader passes control over to the user's program with interrupts disabled.

Update 2/5/2024
Read all about my experience with this here:
https://sites.google.com/site/ericmklaus/projects-1/arduino-r4-wifi
Instructions and sample projects included.

1 Like

Are there performance improvements between Arduino IDE and the e2 studio?

I'd have to say yes and no....
(I'm assuming you're referring to the performance of the resulting code)

The Arduino IDE and the Arduino Programming Language provide a code wrapper around many commonly used functions like digital I/O and serial communication that make programming super easy but may add a bit of unnecessary code overhead to your project.
When using e2 Studio you might encounter quite a steep learning curve since you'll need to become familiar with the Renesas FSP (Flexible Software Package) in order to get these functions to work.
Doing that will allow you to produce code that's more concise and hopefully just a bit faster. The Arduino IDE actually uses the FSP under it's hood.
If you instead are asking about the performance of the IDE's compiling and building your particular project I'm afraid I can't really say.
Both IDEs use the same build system "under the hood" so that should be about the same. The eclipse/e2 Studio user interface provides a lot more features and options than the Arduino IDE so it's quite a bit slower to load up.
Hope this helps.

1 Like

I was interested in Arduino performance. If I program a sketch using registers on Arduino IDE, would there be any difference? A more technical question: Are libraries still compatible?

If you include them. All the Arduino stuff is just C and C++ files. It's just that they're included in the main.cpp where nobody ever notices them. There's no reason you can't include all those same libraries in another build environment as long as the compiler supports everything. Since Arduino tends to use older GCC compilers that's usually not a problem unless you want to use something from the stone age.