FatFS, F_Write and integer

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: FatFS, F_Write and integer

Post by Tectu »

This looks odd... Is it a problem for you to .zip me your entire project? You can PM me or send it to my mail: joel at unormal dot org. I'm not quite sure if this might be one of the well known toolchain issues.


~ Tectu
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: FatFS, F_Write and integer

Post by Tectu »

I just found a couple of minutes to test it out. Using sprintf with the two stub files provided works without any problems for me. What I did is adding the stubs.c file to the CSRC list in the Makefile and also making sure that it finds the header file of it. Then, include <string.h> in the object you want to use sprintf. Then, just call sprintf :D

I guess this is one of those annoying toolchain issues. Many people have issues with mostly string related stuff. I can recommend you using this toolchain because I can guarantee that it works for 100%. I've recommended this one to many people and everyone ended up happily :)
It even comes with precompiles binaries for Windows, Mac OSX and Linux.

Keep me up to date!


~ Tectu
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: FatFS, F_Write and integer

Post by Ramazzukk »

Thank you very much for your generous effort!

I installed gcc-arm-none-eabi-4_7-2012q4-20121208-win32.exe and set the properties of my project under C/C++ Build -> Discovery Options (see discovery.jpeg). Is it OK there? I'am struggling! I was glad I got it work in the first place, I didn't really know what I where doing :D !

It seems, that the path isn't correctly set, yet. Its still on the Yagarto-Tools, somehow. Are there other paths to adjust? I'am lost at the moment. This is complex for a newbie, so thank you again for your support!


Code: Select all

14:11:52 **** Incremental Build of configuration Default for project stm32audio ****
make -j all

arm-none-eabi-gcc -c -mcpu=cortex-m4 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -ffunction-sections -fdata-sections -fno-common  -Wall -Wextra -Wstrict-prototypes -Wa,-alms=build/lst/main.lst -DHAVE_CONFIG_H -DFPM_ARM -DCORTEX_USE_FPU=FALSE  -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/main.o.d -mthumb -DTHUMB -I. -I../../os/ports/common/ARMCMx/CMSIS/include -I../../os/ports/common/ARMCMx -I../../os/ports/GCC/ARMCMx -I../../os/ports/GCC/ARMCMx/STM32F4xx -I../../os/kernel/include -I./libmad/ -I../../ext/fatfs/src -I../../os/hal/include -I../../os/hal/platforms/STM32F4xx -I../../os/hal/platforms/STM32 -I../../os/hal/platforms/STM32/GPIOv2 -I../../boards/ST_STM32F4_DISCOVERY -I../../os/various main.c -o build/obj/main.o
main.c: In function 'uitoa':
main.c:97:5: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
main.c:115:5: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
main.c: In function 'getadc':
main.c:214:7: warning: unused variable 'fstr' [-Wunused-variable]
main.c:212:8: warning: variable 'floatval' set but not used [-Wunused-but-set-variable]
In file included from main.c:270:0:
mad.c: In function 'input':
mad.c:71:5: warning: implicit declaration of function 'EVAL_AUDIO_VolumeCtl' [-Wimplicit-function-declaration]
mad.c:96:11: warning: unused variable 'fr' [-Wunused-variable]
mad.c: In function 'header':
mad.c:113:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
mad.c:119:3: warning: implicit declaration of function 'Codec_AudioInterface_Init' [-Wimplicit-function-declaration]
mad.c: In function 'output':
mad.c:202:3: warning: implicit declaration of function 'Audio_MAL_Play' [-Wimplicit-function-declaration]
mad.c:175:7: warning: unused variable 'i' [-Wunused-variable]
mad.c:174:13: warning: variable 'write_buf' set but not used [-Wunused-but-set-variable]
mad.c:166:28: warning: unused parameter 'data' [-Wunused-parameter]
mad.c:167:33: warning: unused parameter 'header' [-Wunused-parameter]
mad.c: In function 'error':
mad.c:217:25: warning: unused parameter 'frame' [-Wunused-parameter]
mad.c: In function 'decode':
mad.c:242:14: warning: unused variable 'i' [-Wunused-variable]
main.c: In function 'Mp3PlayAllFiles':
main.c:292:3: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
main.c:292:3: warning: incompatible implicit declaration of built-in function 'sprintf' [enabled by default]
main.c: In function 'main':
main.c:576:11: warning: variable 'rc' set but not used [-Wunused-but-set-variable]

arm-none-eabi-gcc   build/obj/crt0.o build/obj/vectors.o build/obj/chcore.o build/obj/chcore_v7m.o build/obj/nvic.o build/obj/chsys.o build/obj/chdebug.o build/obj/chlists.o build/obj/chvt.o build/obj/chschd.o build/obj/chthreads.o build/obj/chdynamic.o build/obj/chregistry.o build/obj/chsem.o build/obj/chmtx.o build/obj/chcond.o build/obj/chevents.o build/obj/chmsg.o build/obj/chmboxes.o build/obj/chqueues.o build/obj/chmemcore.o build/obj/chheap.o build/obj/chmempools.o build/obj/hal.o build/obj/adc.o build/obj/can.o build/obj/ext.o build/obj/gpt.o build/obj/i2c.o build/obj/icu.o build/obj/mac.o build/obj/pal.o build/obj/pwm.o build/obj/sdc.o build/obj/serial.o build/obj/spi.o build/obj/uart.o build/obj/usb.o build/obj/tm.o build/obj/mmc_spi.o build/obj/serial_usb.o build/obj/rtc.o build/obj/stm32_dma.o build/obj/hal_lld.o build/obj/adc_lld.o build/obj/can_lld.o build/obj/ext_lld.o build/obj/gpt_lld.o build/obj/i2c_lld.o build/obj/icu_lld.o build/obj/mac_lld.o build/obj/pwm_lld.o build/obj/serial_lld.o build/obj/spi_lld.o build/obj/uart_lld.o build/obj/pal_lld.o build/obj/board.o build/obj/diskio.o build/obj/ff.o build/obj/syscall.o build/obj/stm32f4_discovery_audio_codec.o build/obj/bit.o build/obj/decoder.o build/obj/fixed.o build/obj/frame.o build/obj/huffman.o build/obj/layer12.o build/obj/layer3.o build/obj/stream.o build/obj/synth.o build/obj/timer.o build/obj/version.o build/obj/chprintf.o build/obj/main.o build/obj/stubs.o   -mcpu=cortex-m4 -nostartfiles -T./STM32F407xG.ld -Wl,-Map=build/ch.map,--cref,--no-warn-mismatch,--gc-sections  -mno-thumb-interwork -mthumb   -o build/ch.elf
c:/yagarto/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb/v7m\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\thumb\v7m\newlib\libc\reent/../../../../../../../newlib-1.20.0/newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1
Attachments
Discovery.JPG
Discovery.JPG (76.43 KiB) Viewed 6452 times
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: FatFS, F_Write and integer

Post by Tectu »

Sorry, I don't use any IDE when doing STM32 related development. I'm also not on windows. Can you please send me your project folder as a zip per e-mail, or is that a problem because of licensing etc?
Did you uninstall Yagarto? Can you paste me the output of arm-none-eabi-gcc -v ?
Otherwise I'll catch the next train and I'll be there in 60 minutes ;-)


~ Tectu
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: FatFS, F_Write and integer

Post by Ramazzukk »

The appropriate action would be me coming to you! And bring some expensive bottle of whatever you are drinking with me. But I think that is (for now) not necessary!

I have to try a little, maybe I will solve it with another function like yours, maybe I can get it to work another way. My code is not very professional, so I would embarass myself if I postet it here. I try to get an MP3-Player working with Code from here:

http://jjmz.free.fr/?p=102#comments

In the end, I plan to assemble a product like this for my toddler-daughter: http://www.hoerbert.com/

As it is my experience in the past, the learning effect is the highest when I get stuff working myself (with the kind help of people like you), and endless google-hours of searching.

Are you a professional, working on that stuff on a daily basis? And you use a linux-environment then?
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: FatFS, F_Write and integer

Post by Tectu »

Don't worry about the expensive bottle, I'm always happy to help :)

Of course you will gain experience when doing a function for your purpose yourself, but on the other hand, understanding the magic to bring sprintf() to work will give you toolchain related experiences ;-)
I am working with this stuff on a daily base and also on my dayjob, but I am far far away from being a professional. Since you seem to have a daughter in that age range, I guess you're about twice as old as I am.
Anyways... to keep going this forward, we need to make sure that you got rid of YAGRATO. Therefore, you need to make sure that you uninstall it. Afterwards, you can confirm that you use the new proper toolchain when arm-none-eabi-gcc -v gives an output similar to the one below and nothing of YAGRATO is mentioned in it.

Code: Select all

[tectu@TecTop ~]$ arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/home/tectu/projects/resources/arm-toolchain/bin/../libexec/gcc/arm-none-eabi/4.6.2/lto-wrapper
Target: arm-none-eabi
Configured with: /home/build/work/jenkins-daily-build/src/gcc/configure --build=i686-linux-gnu --host=i686-linux-gnu --target=arm-none-eabi --prefix=/home/build/work/jenkins-daily-build/install-linux --enable-languages=c,c++ --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-lto --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-sysroot=/home/build/work/jenkins-daily-build/install-linux/arm-none-eabi --with-gmp=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-mpfr=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-mpc=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-ppl=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-cloog=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-libelf=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-extra-multilibs=armv6-m,armv7-m,armv7e-m,armv7-r
Thread model: single
gcc version 4.6.2 20120613 (release) [ARM/embedded-4_6-branch revision 188521] (GNU Tools for ARM Embedded Processors)


Also, make your MP3 player cooler than the one linked by adding a touchscreen xD

~ Tectu
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: FatFS, F_Write and integer

Post by Ramazzukk »

I'm 32, not soooo old :D. Don't worry, you will get there quick yourself!

Changing the Toolchain would be a proper solution, of course. On the other hand, a function float to char would solve the chprintf-Problem as well. I need the conversion to monitor an accumulator discharge courve, with your help I can do that now. Since I have not unlimited time at hand, I have to prioritise. I can output an integer to an SD-Card, and do the calculation vie CSV->Excel. Easy.

I will try the other Toolchain, an will keep you postet. But first I have to flaten my Laptop (to have a clean basis). Reinstall all the stuff, test it, etc, etc.. It can go a while though (Weeks-Months).

Do you use Linux? What distro? Is it hard to get it to work? Can you flash an STM32F4Discovery?
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: FatFS, F_Write and integer

Post by Ramazzukk »

And no display for the Player is needed. Just buttons. With 2 years od age my daughter can't read, and there are plenty of displays in my household anyway, so back to the roots is better IMHO :mrgreen: . But interesting link altogether, maybe for a future project unknown yet!
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: FatFS, F_Write and integer

Post by Tectu »

The linux distribution I'm using is ArchLinux, but it's really anything else but for linux beginners. If you want to change to linux, then I highly recommend you using linux mint. I know plenty of windows users who wanted to change and I installed mint all of them. Everyone ended up happily :)
There's an important thing: Install the debian edition of mint, not the ubuntu.

Flashing and debugging your STM32F4 Discovery under linux is no problem at all.

We can head for a coffee - or the expensive bottle of whatever, if you're not so used to linux so I can show you everything.


~ Tectu
Ramazzukk
Posts: 25
Joined: Sun Jan 06, 2013 2:19 pm

Re: FatFS, F_Write and integer

Post by Ramazzukk »

The offer is very generous! For the moment, I'm not ready to port all my stuff to linux. Maybe when I'm done with that MP3-Project. The most important thing to work out right out for me ist getting the PCB and roughly the code ready.

My plan is to use the STM32F4discovery-board as it is and hook up a piggyback-board with a dc-dc-regulator and an external amplifier. The girl is growing fast, so I have to produce results ! :mrgreen:

In the last years, several times I installed different Linux-distros, but unfortunately always some stuff didn't work or was unbelivable complicated to get to work (graphics, network, etc.).. Nowadays it shouldn't be such a problem, but I haven't that much time at hand anymore.

Thank you very much for your help so far. :P

When I'm done, I hope I can provide some stuff here to!
Post Reply