Forum Discussion
NiosV
Hi I am in the process of converting a MAX10 Nios2 design to a MAX10 NiosV. It boots from Flash loaded into DDR
All is good with the compiling apart from I need to convert the elf file to a hex file.
Nios2 was done with Eclipse tools and it created the script
alt-file-convert.exe -I elf32-littlenios2 -O hex --input=app.elf --output=mem_init/ext_flash.hex --base=0x44000000 --end=0x45ffffff --reset=0x44430000 --out-data-width=8 --boot="C:\intelfpga_lite\23.1std\nios2eds\components\altera_nios2\boot_loader_cfi.srec"
Now i have to use NiosV command line to do the same, but the alt-file-convert.exe command doesnt exist.
I think it may be something like this:
elf2flash --input=sw/app/build/app.elf --output=sw/app/build/mem_init/ext_flash.hex --epcs –-offset 0x0 --end=0x45ffffff --boot="C:/intelFPGA_lite/23.1std/niosv/components/bootloader/niosv_g_bootloader"
Note the --base and --reset that alt-file-convert.exe used can't be used with elf2flash - is that
correct?
32 Replies
- NGord
Occasional Contributor
I dont think I should have "--epcs" mode set for QSPI?
if I remove that then I can add "--base" and "--reset".
That only leaves "--out-data-width=8" - I take it I dont need that for QSPI either
Also "-I elf32-littlenios2" and "-O hex" are superfluous for elf2flash I take it. - tehjingy_Altera
Regular Contributor
Hi
Could you try the command below:
nios2-elf-objcopy -O ihex file.elf output_file.hex
Regards
Jingyang, Teh
- NGord
Occasional Contributor
nios2-elf-objcopy is not recognised by niosv command shell.
Moreover I got elf2flash to create a hexfile but when I use 'convert programming file' in Quartus to create a pof file for qspi programming , I discover that the hexfile isnt Intel format which it meeds to be for it to work!So I reiterate:
What is the NiosV equivalent of the Nios2 command?:
alt-file-convert.exe -I elf32-littlenios2 -O hex --input=app.elf --output=mem_init/ext_flash.hex --base=0x44000000 --end=0x45ffffff --reset=0x44430000 --out-data-width=8 --boot="C:\intelfpga_lite\23.1std\nios2eds\components\altera_nios2\boot_loader_cfi.srec"
- NGord
Occasional Contributor
It seems elf2flash creates an s-record file which is no good .
I need an equivalent for alt-file-convert.exe which created an Intel hex file!!!
I think I can use a 3rd party hex editor to convert between s-records and Intel Hex though, I can try that.
elf2hex creates an Intel hex file but doesnt allow a bootloader to be added, although the command line doesnt complain when I add it!
I tried it and it created a file 78MB which is an order of magnitude bigger than it should be.
It seems to me Nios V toolset isnt ready for me to replace Nios II .
Moreover Platform designer in the Pro version of Quartus has a BSP editor. Thats all very well but Quartus Pro doesnt support MAX10!!
- tehjingy_Altera
Regular Contributor
Hi
The nios2-elf-obj is available under the nios2 command shell.
To launch you can use the nios2-elf-objcopy.exe shown below:
Regards
Jingyang, Teh
- tehjingy_Altera
Regular Contributor
Hi
Any update on this case?
Have you managed to locate the exe in your windows system?
Regards
Jingyang, Teh
- NGord
Occasional Contributor
Thats the point I am trying to use Nios V not Nios II !!!!!
Please try reading the thread.
- tehjingy_Altera
Regular Contributor
Hi
Sorry for the confusion.
For the NiosV there is a new tool to be used for creating the hex for bootloader.
The command tool to used is :
elf2flash --input software/app/debug/<Nios V application>.elf \
--output flash.srec --reset <reset offset + base address of GSFI AVL MEM> \
--base <base address of GSFI AVL MEM> \
--end <end address of GSFI AVL MEM>
riscv-none-embed-objcopy --input-target srec --output-target ihex \
flash.srec <Nios V application>.hex
Instead of one command to generate the hex it is separated into 2 steps.
Regards
Jingyang, Teh
- NGord
Occasional Contributor
Thats great - just what I wanted..
One more thing:
My Nios2 haad use of Exception Vector set within Platform designer.
For Nios V it must be set with the Nios V command shell because MAX10 doesnt have a BSP editor!
Any advice how I do that with the niosv-bsp command?- NGord
Occasional Contributor
Sorry I was bit hasty there..
riscv-none-embed-objcopy doesnt exist in Quartus 23.1 std/lite edition.. The documentation is incorrect.
- tehjingy_Altera
Regular Contributor
Hi
For the NiosV they make the exception vector editable in the BSP Editor.
You are able to change the exception vector in the BSP Editor under the BSP linker script.
Which doc you referring to that uses the riscv-none-embed-objcopy ?
Regards
Jingyang, Teh
- NGord
Occasional Contributor
riscv-none-embed-objcopy is in your reply dated 20th June.
Once again, I repeat, BSP editor is only available in Quartus Pro and Quartus Pro doesnt support MAX10!!
Nios V isnt properly supported it seems - if you want me to migrate from Nios2 to NiosV then Intel need to sort the tools out.- NGord
Occasional Contributor
Here is the answer to one issue..
https://www.intel.com/content/www/us/en/support/programmable/articles/000092029.html?wapkw=riscv32-unknown-elf-objcopyStill an answer to this..
One more thing:
My Nios2 had use of Exception Vector which was enabled in the NiosII IP within Platform designer.
For Nios V it must be set with the Nios V command shell because only Quartus Pro has BSP editor in Platform Designer and Quartus Pro doesnt support MAX10.!
Any advice how I do that with the niosv-bsp command?
- tehjingy_Altera
Regular Contributor
Hi
For the Max10 that is using the FPGA Std/lite.
You could launch the BSP-editor manually using the command line.
Launch the niosv-command shell and enter the command "niosv-bsp-editor"
If you could not find the niosv-command shell, it is located here.
Regards
Jingyang, Teh
- NGord
Occasional Contributor
Thats useful - however with all the above I still cant run NiosV Hello.
On the other hand NiosII Hello works just fine on the same Platform Design and hardware.
I am using MAX10M40 .
I am booting from Internal Flash(UFM) into External Ram. The Hello example is too big perversely to be loaded into internal RAM.
I create the BSP:
niosv-bsp -c --sopcinfo=hw/q_sys.sopcinfo --type=hal sw/bsp_hal/settings.bsp
I use niosv-bsp-editor as you suggested to check/edit settings and regenerate.
I add app:
niosv-app --bsp-dir=sw/bsp_hal --app-dir=sw/app_hal --srcs=sw/app_hal/hello.c
cmake:
cmake -S ./sw/app_hal -G "Unix Makefiles" -B sw/app_hal/build
make:
make -C sw/app_hal/build
create srec file and append bootloader file:
elf2flash --input=sw/app_hal/build/app_hal.elf --output=sw/app_hal/build/mem_init/onchip_mem.srec --reset=0x4a000020 --base=0x4a000000 --width=8 --end=0x4a06ffff --boot="C:/intelFPGA_lite/23.1std/niosv/components/bootloader/niosv_g_bootloader.srec"
convert to hex:
riscv32-unknown-elf-objcopy --input-target srec --output-target ihex sw/app_hal/build/mem_init/onchip_mem.srecsw/app_hal/build/mem_init/altera_onchip_flash.hex
I add the hex file to UFM and add the .sof file in "Convert Programming files" to create a pof file.
I program my device but nothing appears on juart-terminal.
Furthermore you cant enable debug on the NiosV because it requires Single Uncompressed Image with Memory initialisation
so it seems.
If I do that it reduces the amount of UFM available such that its insufficient to hold the Hello program!
I know its stupid isn't it.
In practice I would be using QSPI for softawre storage which worked great for NiosII but because that didnt work with NiosV I wanted to try something very simple.
Has anyone got NiosV to work properly?
- tehjingy_Altera
Regular Contributor
Hi
Have not tried out on the MAX10 before, however I did managed to run the hello world on other boards
Could you try just booting the hello world elf from the memory itself instead of using the bootloader method?
I followed the steps from the link below on getting the hello world running in other boards.
Regards
Jingyang, Teh
Before you try booting it from the flash .
Have you tried running it from the
- NGord
Occasional Contributor
I tried that - it seems to load ok (- my DDR is at 2000000) do you see anything wrong? Nothing still on the terminal.
[niosv-shell] C:\Users\nigelg\Documents\max10_minuet_niosV_hello1\top_project> niosv-download sw/app_hal/build/app_hal.elf
INFO: Generating OpenOCD config file. Running "openocd-cfg-gen C:\Users\nigelg\AppData\Local\Temp\tmpgv_staf3\niosv.cfg".
INFO: Starting OpenOCD. Running "openocd -c tcl_port disabled -c gdb_port 0 -c telnet_port 0 -f C:\Users\nigelg\AppData\Local\Temp\tmpgv_staf3\niosv.cfg".
[OpenOCD output] Open On-Chip Debugger 0.11.0-R22.4
[OpenOCD output] Licensed under GNU GPL v2
[OpenOCD output] For bug reports, read
[OpenOCD output] http://openocd.org/doc/doxygen/bugs.html
[OpenOCD output] Info : only one transport option; autoselect 'jtag'
[OpenOCD output] Info : Application name is OpenOCD.20240703094844
[OpenOCD output] Info : Attempting to find 'USB-BlasterII [USB-1]'
[OpenOCD output]
[OpenOCD output] Info : Cable 1: device_name=(null), hw_name=USB-BlasterII, server=(null), port=USB-1, chain_id=0000000000ad69d0, persistent_id=1, chain_type=1, features=14336, server_version_info=(null)
[OpenOCD output] Info : TAP position 0 (310D0DD) has 2 SLD nodes
[OpenOCD output] Info : node 0 idcode=08986E00 position_n=0
[OpenOCD output] Info : node 1 idcode=0C006E00 position_n=0
[OpenOCD output] Info : Discovered 1 TAP devices
[OpenOCD output] Info : Detected device (tap_position=0) device_id=0310d0dd, instruction_length=10, features=4, device_name=10M40D(A|C)
[OpenOCD output] Info : Found an Intel device at tap_position 0.Currently assuming it is SLD Hub
[OpenOCD output] Info : This adapter doesn't support configurable speed
[OpenOCD output] Info : JTAG tap: tap_0310D0DD.0 tap/device found: 0x0310d0dd (mfg: 0x06e (Altera), part: 0x310d, ver: 0x0)
[OpenOCD output] Info : JTAG tap: tap_0310D0DD.0 Parent Tap found: 0x0310d0dd (mfg: 0x06e (Altera), part: 0x310d, ver: 0x0)
[OpenOCD output] Info : Virtual Tap/SLD node 0x08986E00 found at tap position 0 vtap position 0
[OpenOCD output] Info : datacount=2 progbufsize=8
[OpenOCD output] Info : Examined RISC-V core; found 1 harts
[OpenOCD output] Info : hart 0: XLEN=32, misa=0x40001100
[OpenOCD output] Info : starting gdb server for tap_0310D0DD.0.niosv_0.cpu on 0
[OpenOCD output] Info : Listening on port 64525 for gdb connections
INFO: Found gdb port 64525
[OpenOCD output] Ready for Remote Connections
[OpenOCD output] Info : tcl server disabled
[OpenOCD output] Info : Listening on port 64526 for telnet connections
INFO: Found telnet port 64526
INFO: OpenOCD is ready.
INFO: Loading image via GDB. Running "riscv32-unknown-elf-gdb -batch -ex set arch riscv:rv32 -ex set remotetimeout 60 -ex target extended-remote localhost:64525 -ex load sw/app_hal/build/app_hal.elf -ex set $mstatus &= ~(0x00000088)".
The target architecture is set to "riscv:rv32".
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x44001004 in ?? ()
Loading section .exceptions, size 0x284 lma 0x20000000
Loading section .text, size 0x18170 lma 0x20000284
Loading section .rodata, size 0xfb0 lma 0x20018400
Loading section .rwdata, size 0x1cc0 lma 0x200193b0
Start address 0x200002e8, load size 110692
Transfer rate: 79 KB/sec, 11069 bytes/write.
[Inferior 1 (Remote target) detached][niosv-shell] C:\Users\nigelg\Documents\max10_minuet_niosV_hello1\top_project> juart-terminal
juart-terminal: connected to hardware target using JTAG UART on cable
juart-terminal: "USB-BlasterII [USB-1]", device 1, instance 0
juart-terminal: (Use the IDE stop button or Ctrl-C to terminate)
- tehjingy_Altera
Regular Contributor
Hi
Is it possible that you share me your bsp settings and a screenshot of your Platform Designer "Address Map" tab?
From the looks of it the elf is set to launch at address 0x20 000 000 where as your ddr is set to 0x2 000 000.
Could you double check your linker settings in the bsp settings?
Regards
Jingyang, Teh
- NGord
Occasional Contributor
Sorry - DDR is at 20000000 - my typo.
bsp settings attached
It can only be one of 2 things..
i)NiosV isnt running
ii)NiosV is running but the jtag UART isnt.- NGord
Occasional Contributor
This is a problem as well!
It never rains when it pours!
I need ALTPLL and it fails in Quartus23 - going to try the suggested fix.https://gemrtos.com/gemrtosdocs/why-do-i-get-a-fatal-error-when-creating-an-altpll-ip/
- tehjingy_Altera
Regular Contributor
Hi
Taking a look at your BSP Settings. The address looks ok.
The linker is set to boot from 0x20000000 .
Instead of creating a project you could just add your project into the IDE and create a debug configuration.
https://www.intel.com/content/www/us/en/docs/programmable/730783/22-1std/importing-project.html
Once you imported you could create the debug connection.
Take note to select "Ashling RISC-V (auto-detect) Hardware Debugging"
Then in the debugger tab you could select the NiosV processor in the core selection.
Please note to close the juart-terminal if you have open before opening a debugging connection.
If you are able to see the logs in the terminal from the project you created. That means the elf is working.
From the the debugger could you try taking a look at the address map of 0x20000000. To see if the bootloader have copied the code over to the memory space?
Regards
Jingyang, Teh
- NGord
Occasional Contributor
I havent found any way for Ashling IDE to give me a reliable error free build, even using 24.1.1 "import niosv cmake project"
The only method that work consistently error free is by using niosv-shell with:-
> cmake -S ./sw/app_hal -G "Unix Makefiles" -B sw/app_hal/build
> make -C sw/app_hal/build
Nios2 was never this troublesome.The same software and the same hardware worked just fine, but there I was using Quartus 18, not Quartus 23.1.1.
Maybe I will try Nios2 with Quartus 23.1.1 tomorrow to see what happens
If you can get a NiosV Hello working on a MAX10 development board on Windows 10 with WSL V1 , I would love to know.- NGord
Occasional Contributor
Nios2 with the same design works ok on Quartus 23.1.1.