- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I have problem using HAL api..
I just want to open device using alt_flash_open_dev() just like in "Simple Flash Access" of "The HAL Api Reference", but it always returns 0x0. Do I have to call something else before alt_flash_open_dev()? I am using NiosII Evaluation Kit to do all this. I inserted the code calling the HAL function in the sample project:"hello_led", and chose "Debug as Nios II Hardware". What might be possibly wrong?Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No there is nothing you need to call before alt_flash_open_dev.
The fact that it returns 0 means either you've got the name wrong, or there is no flash of that name in your system. The easy way to check this is to look in your system.h file for the name you're passing to alt_flash_open_dev, if it's not there then you have one of the two problems I've described, if it is then we have a more interesting problem.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you rugbybloke, I appreciate your response.
I am still suffering the problem. I am calling: alt_flash_open_dev("/dev/ext_flash"); system.h has:# define EXT_FLASH_NAME "/dev/ext_flash" So, I think I have the name right. I toggled few break points in alt_find_dev(). There seems to be no device registered in the alt_llist* list. For this reason, I tried calling alt_sys_init() right before alt_flash_open_dev(). when I did this, the devices then seem to be registered in the list. Using memory dump, I found below devices in the list: /dev/ext_flash, /dev/epcs_controller, /dev/jtag_uart, /dev/uart1, /dev/null but still, alt_flash_open_dev() fails, & returns 0x0 (I am still checking why this happen). Am I getting any closer? or totally going the wrong way...?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fuji,
One clue is that you mention you are modifying the "Hello LED" example. This software example is designed in part to show a very minimal (low memory usage) application. As such, several of the software library options are turned off... if this is the case it may be causing the flash problem. To see if this is the case, right-click your project in the IDE and select 'system library properties' On this screen, ensure that 'small C library' and 'reduced device drivers' are not checked. The Nios II software developer handbook should discuss what these options do... but if I remember correctly, they may prevent use of the flash routines to save code-space, if selected.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Jesse,
I have checked 'system library properties', but both 'small C library' and 'reduced device drivers' were not selected. I guess I should try modifing other projects. Then, may be I can find out what is my problem.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found something new.
Changing "int alt_main(void)" to "int main(void)" in modified Hello_Led project made it to call alt_sys_init() automatically before main function. And, devices seemed to be registered in the alt_llist* list. But, alt_flash_open_dev() still fails. However, when I let a person who has the "NiosII Development Kit Cyclone II Edition" board (I am using "NiosII Evaluation Kit Cyclone Edition") do the samething, then, it seemed to work just fine(alt_flash_open_dev is returning other than 0).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using the Cyclone edition and a custom board and the flash works for me.
I have two suggestions: 1) Make sure you're not using a project where the flash is used for program storage. Check your system.h file for a# define ALT_TEXT_DEVICE FLASH, which means your program code is stored there. If you're putting your code in flash and booting it or running it from there the flash driver will not be available. It took me a while to figure this out because it's done with macros in a weird way. I think this may not be your problem, though, since you do see the device in the list after the alt_sys_init. 2) Try setting a breakpoint in alt_flash_cfi_init, which is called from alt_sys_init, and stepping through the flash driver initialization. On our target board we had some pin assignments wrong and it led to the flash not initializing properly. Andrew- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you queisser,
As for (1), I don't have ALT_TEXT_DEVICE_FLASH defined in system.h. Instead, I have "#define ALT_TEXT_DEVICE SDRAM". So, I think this is not the problem. However, I have "#define ALT_EXCEPTIONS_DEVICE EXT_FLASH". May be this could cause a problem? I will try (2), may be I can find something. But it is hard to think that the pin assignments of the evaluation kit board are wrong...- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I haven't found my solution to this problem,
but meantime, I referred to the data sheet of the Am29LV640MH, and made my own drivers to work & access ext_flash. All I can say for now is that there are no hardware & configuration problem.. I wouldn't like to deal with this any further, but If I find something new, I post it here. Thanks to queisser, Jesse, rugbybloke, I've learned many things from this problem.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page