NuttShell (NSH)
nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard
nsh>
nsh> ls -l /mnt/sdcard/hello
-rw-rw-rw- 1792 /mnt/sdcard/hello
nsh>
nsh> /mnt/sdcard/hello
nsh: /mnt/sdcard/hello: command not found
#elf flagsCELFFLAGS = $(CFLAGS) -mlong-callsLDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/libelf/gnu-elf.ld -nostdlib
nsh> /mnt/sdcard/hellobuiltin_loadbinary: ERROR: FIOC_FILENAME ioctl failed: 88exec: ERROR: Failed to load program '/mnt/sdcard/hello': 88
nsh: /mnt/sdcard/hello: command not found
You could put some debug output in the elf_loadbinary() in elf.c to see if it is ever called. I bet that it is not.Greg
Yes, you're right. This function is never called, and it's no have any declaration in disassembly of nuttx
elf_symvalue: SHN_UNDEF: Exported symbol "puts" not foundelf_relocate: Section 2 reloc 0: Failed to get value of symbol[18]: -2elf_loadbinary: Failed to bind symbols program binary: -2exec: ERROR: Failed to load program '/mnt/sdcard/hello': 2ERROR: execv failed: 2
How i understand, is this due to wrong library connection?
#if defined(CONFIG_LIBC_EXECFUNCS) && defined(CONFIG_EXECFUNCS_SYMTAB)const struct symtab_s CONFIG_EXECFUNCS_SYMTAB[1];const int nsym = sizeof(CONFIG_EXECFUNCS_SYMTAB) / sizeof(struct symtab_s);#endif
...
//in nsh_main()
/* Make sure that we are using our symbol table */
#if defined(CONFIG_LIBC_EXECFUNCS) && defined(CONFIG_EXECFUNCS_SYMTAB) exec_setsymtab(CONFIG_EXECFUNCS_SYMTAB, nsym); // by default exec_setsymtab(CONFIG_EXECFUNCS_SYMTAB, 0);#endif
NuttShell (NSH)nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcardnsh>
nsh> /mnt/sdcard/helloGetting ready to say "Hello, world"
Hello, world!It has been said.
argc = 1argv = 0x200046e4argv[0] = (0x200046ec) "<noname>"argv[1] = 0x0Goodbye, world!
It's required a small change in nsh_main.c file:
#if defined(CONFIG_LIBC_EXECFUNCS) && defined(CONFIG_EXECFUNCS_SYMTAB)const struct symtab_s CONFIG_EXECFUNCS_SYMTAB[1];const int nsym = sizeof(CONFIG_EXECFUNCS_SYMTAB) / sizeof(struct symtab_s);#endif
...
//in nsh_main()/* Make sure that we are using our symbol table */#if defined(CONFIG_LIBC_EXECFUNCS) && defined(CONFIG_EXECFUNCS_SYMTAB)exec_setsymtab(CONFIG_EXECFUNCS_SYMTAB, nsym); // by default exec_setsymtab(CONFIG_EXECFUNCS_SYMTAB, 0);#endif
But, ho i realize for run some of difficult apps, with many of Nuttx advantages, on a BluePill, need many of optimisation work.
вторник, 13 марта 2018 г., 17:37:44 UTC+3 пользователь patacongo написал:How i understand, is this due to wrong library connection?This is a symbol table problem. In order to link ELF binaries into the system, you must have a symbol table that contains the address mapping of all symbols exported by the base system to the loaded modules.You set the symbol table with:void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols)How you create the symbol table is up to you. You will have to be very careful with the STM32F103-Minimum because there is not a lot of FLASH memory for large symbol tables. The ELF examples in apps/examples all create a symbol table with just enough symbols to run the examples.There is a tool in nuttx/tools called mksymtab.c that might be useful to you. There are .csv files in the sytem that describe interfaces (may not all be up to date):$ find . -name "*.csv"
./libc/libc.csv
./libc/math.csv
./syscall/syscall.csvThese .cvs files can be used by mksymtab.c to create huge symbol tables which you can then manually pare down to fit. Usage of mksymtab.c is described in nuttx/tools/README.txt.Greg