- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use Eclipse to program an application using the lcd. My qsys system uses an sdram controller. I receive a single error in the alt_main.c which was generated in the bsp.
The error states undefined reference to main. It occurs in the return line of the code extern int main (int, char **, char **); void alt_main (void) { #ifndef ALT_NO_EXIT int result;
# endif
/* ALT LOG - please see HAL/sys/alt_log_printf.h for details */ ALT_LOG_PRINT_BOOT("[alt_main.c] Entering alt_main, calling alt_irq_init.\r\n"); /* Initialize the interrupt controller. */ alt_irq_init (NULL); /* Initialize the operating system */ ALT_LOG_PRINT_BOOT("[alt_main.c] Done alt_irq_init, calling alt_os_init.\r\n"); ALT_OS_INIT(); /* * Initialize the semaphore used to control access to the file descriptor * list. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Done OS init, calling alt_sem_create.\r\n"); ALT_SEM_CREATE (&alt_fd_list_lock, 1); /* Initialize the device drivers/software components. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling alt_sys_init.\r\n"); alt_sys_init(); ALT_LOG_PRINT_BOOT("[alt_main.c] Done alt_sys_init.\r\n"); #if !defined(ALT_USE_DIRECT_DRIVERS) && (defined(ALT_STDIN_PRESENT) || defined(ALT_STDOUT_PRESENT) || defined(ALT_STDERR_PRESENT)) /* * Redirect stdio to the apropriate devices now that the devices have * been initialized. This is only done if the user has requested these * devices be present (not equal to /dev/null) and if direct drivers * aren't being used. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Redirecting IO.\r\n"); alt_io_redirect(ALT_STDOUT, ALT_STDIN, ALT_STDERR); #endif
#ifndef ALT_NO_C_PLUS_PLUS /* * Call the C++ constructors */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling C++ constructors.\r\n"); _do_ctors (); #endif/* ALT_NO_C_PLUS_PLUS */ #if !defined(ALT_NO_C_PLUS_PLUS) && !defined(ALT_NO_CLEAN_EXIT) && !defined(ALT_NO_EXIT) /* * Set the C++ destructors to be called at system shutdown. This is only done * if a clean exit has been requested (i.e. the exit() function has not been * redefined as _exit()). This is in the interest of reducing code footprint, * in that the atexit() overhead is removed when it's not needed. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling atexit.\r\n"); atexit (_do_dtors); #endif
/* * Finally, call main(). The return code is then passed to a subsequent * call to exit() unless the application is never supposed to exit. */ ALT_LOG_PRINT_BOOT("[alt_main.c] Calling main.\r\n"); #ifdef ALT_NO_EXIT main (alt_argc, alt_argv, alt_envp); #else
result = main (alt_argc, alt_argv, alt_envp); close(STDOUT_FILENO); exit (result); #endif
ALT_LOG_PRINT_BOOT("[alt_main.c] After main - we should not be here?.\r\n"); } This error does not occur when using on-chip memory, however that won't be sufficient for the project according to eclipse. How should I approach fixing the error?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It seems that the problem isn't the SDRAM controller, Rather, make sure that the c file containing your "main" is correctly added to your project. Check the following line in the Makefile of your project : # Paths to C, C++, and assembly source files. C_SRCS := ... regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
This code has been tested with the BeMicroMax and it will be help you to test your SDRAM memory : We assume that you are set your memory controller with QSYS : In my case the memory controller is mapped at the address : (0x800000)# define SDRAM_BASE (0x800000)# define SDRAM_BASE_MUX (SDRAM_BASE + 0x2000) /** Offset for the exception */ /** Variables */ uint32_t u32AddrSram = 0; uint16_t u16Value = 0; uint16_t u16ReadSramValue = 0; /** example for write and read only one byte at the time in the sram */ for( u32AddrSram = 0; u32AddrSram< 100 ; u32addrsram += 0x08) { /** Write Data */ alt_printf("\n*** SDRAM WRITE[%x] VALUE = %x \n\r ", (SDRAM_BASE_MUX + u32AddrSram) , (uint8_t)(u16Value)); iowr_8direct(SDRAM_BASE_MUX, (uint16_t)u32AddrSram, (uint8_t)u16Value); /** Read Data */ u16ReadSramValue = iord_8direct(SDRAM_BASE_MUX, u32AddrSram); alt_printf("\n*** SDRAM READ[%x] VALUE = %x \n\r ", (SDRAM_BASE_MUX + u32AddrSram), u16ReadSramValue); /** Change the value */ u16Value++; } /** example for write and read only 2bytes at the time in the sram */ u16Value = 0xA000; for( u32AddrSram = 0; u32AddrSram< 100 ; u32addrsram += 0x10) { /** Write Data */ alt_printf("\n*** SDRAM WRITE[%x] VALUE = %x \n\r ", (SDRAM_BASE_MUX + u32AddrSram) , (uint16_t)(u16Value)); iowr_16direct(SDRAM_BASE_MUX, (uint16_t)u32AddrSram, (uint16_t)u16Value); /** Read Data */ u16ReadSramValue = iord_16direct(SDRAM_BASE_MUX, u32AddrSram); alt_printf("\n*** SDRAM READ[%x] VALUE = %x \n\r ", (SDRAM_BASE_MUX + u32AddrSram), u16ReadSramValue); /** Change the value */ u16Value++; } /*** Result for Byte */ *** SDRAM WRITE[802000] VALUE = 0 *** SDRAM READ[802000] VALUE = 0 *** SDRAM WRITE[802008] VALUE = 1 *** SDRAM READ[802008] VALUE = 1 *** SDRAM WRITE[802010] VALUE = 2 *** SDRAM READ[802010] VALUE = 2 *** SDRAM WRITE[802018] VALUE = 3 *** SDRAM READ[802018] VALUE = 3 *** SDRAM WRITE[802020] VALUE = 4 *** SDRAM READ[802020] VALUE = 4 *** SDRAM WRITE[802028] VALUE = 5 *** SDRAM READ[802028] VALUE = 5 *** SDRAM WRITE[802030] VALUE = 6 *** SDRAM READ[802030] VALUE = 6 *** SDRAM WRITE[802038] VALUE = 7 *** SDRAM READ[802038] VALUE = 7 *** SDRAM WRITE[802040] VALUE = 8 *** SDRAM READ[802040] VALUE = 8 *** SDRAM WRITE[802048] VALUE = 9 *** SDRAM READ[802048] VALUE = 9 *** SDRAM WRITE[802050] VALUE = a *** SDRAM READ[802050] VALUE = a *** SDRAM WRITE[802058] VALUE = b *** SDRAM READ[802058] VALUE = b *** SDRAM WRITE[802060] VALUE = c *** SDRAM READ[802060] VALUE = c /** result for 2bytes read */ *** SDRAM WRITE[802000] VALUE = a000 *** SDRAM READ[802000] VALUE = a000 *** SDRAM WRITE[802010] VALUE = a001 *** SDRAM READ[802010] VALUE = a001 *** SDRAM WRITE[802020] VALUE = a002 *** SDRAM READ[802020] VALUE = a002 *** SDRAM WRITE[802030] VALUE = a003 *** SDRAM READ[802030] VALUE = a003 *** SDRAM WRITE[802040] VALUE = a004 *** SDRAM READ[802040] VALUE = a004 *** SDRAM WRITE[802050] VALUE = a005 *** SDRAM READ[802050] VALUE = a005 *** SDRAM WRITE[802060] VALUE = a006 *** SDRAM READ[802060] VALUE = a006
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