Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

overriding HAL functions

Hello,

I have a question about overriding HAL functions in my code. I am attempting to make character output with printf() non-blocking. But with the combination of options that I need to use to build my BSP, I discovered that the ALT_WRITE() function in HAL\src\alt_write.c is always passing a hard-coded 0 for the "flags" byte in its call to ALT_DRIVER_WRITE(). So character output is always blocking. I noticed this comment in alt_write.c:

To provide your own implementation of a HAL function, include the file in your Nios II IDE application project. When building the executable, the Nios II IDE finds your function first, and uses it in place of the HAL version.

So I wrote my own version of ALT_WRITE() which is non-blocking and put it in my application project. It worked perfectly for a while. Now for some reason when I build the project, it is back to using the HAL version of ALT_WRITE() and ignoring the one in my application. Any idea why? How does the linker decide which function to use?

Thanks.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Sounds silly but did you clean the syslib and rebuild? I think the IDE caches things and sometimes it causes problems. I know I have to occasionally rebuild my syslib and project.

    Bill
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Bill,

    I have tried doing a clean build of both the BSP and the app, and that doesn't fix it. I did verify that my version of alt_write.c is being compiled as part of the app.

    I wish I knew what happened between the time it worked and the time it stopped working. I was making changes to other (unrelated) code in the app...

    Thanks,

    John