Open IP Camera Forum

Development => uCLinux => Topic started by: changosurf on June 03, 2013, 08:47:43 pm

Title: need help creating a custom BSP using buildroot
Post by: changosurf on June 03, 2013, 08:47:43 pm
Id like to try building an updated kernel using the buildroot tool.
However, I need help figuring out how to go about creating a 'vendor package' for the NUC745/W90N745 chip.
I have the old BSP for the 2.4 kernel, but Im not sure how to go about trying to 'patch' it into a newer kernel. Can someone please provide me with some basic instructions on how this process works? which files from the BSP need to be ported over to the new kernel, and what needs to be done to integrate them into the newer build?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 04, 2013, 05:00:08 am
I'm in the progress of porting the 2.6 BSP to the git version of the kernel.  It's fairly involved, so unless you have experience writing kernel code it's going to drive you crazy.

I haven't posted my code yet as the port is incomplete, and without any way I can boot to userspace I'm kind of stuck as anything more I port I can't test (e.g. USB support or MTD partitions.)

The real problem is that once you get a recent kernel up and running, there seems to be no way to generate FLAT binaries required by a no-MMU kernel (all the binaries come out in ELF format which is unusable without an MMU.)  buildroot certainly doesn't support this any longer, but they have said they welcome any patches.

I don't foresee any problems porting the rest of the NUC700-series support code to the latest kernel myself, so if you're willing to help, it would be fantastic if you could figure out how to get buildroot to compile FLAT binaries instead of ELF, since this is really what's holding me up and I'm rather stuck on it.  Not to mention that once the NUC700 is supported natively by the kernel, FLAT binary support in buildroot will be required to build any sort of userspace programs without using the Nuvoton/Winbond BSP.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 04, 2013, 06:17:09 am
I would be glad to help.
I'll start looking into the ZFLAT issue right away.
Im just barely starting to learn about buildroot & its internals, so it will take me a little bit of time to get up to speed. But I will definitely start by focusing on the ZFLAT build problem.

But, if you don't mind, could you please try to explain the overall process of how the BSP code is 'ported' from one kernel to another? This is the main concept Im struggling with; I dont know where to start, what files need to be modified, how to integrate such a port into a kernel build (via buildroot or a git pull, a manual kernel source download, etc.), and basically what the primary/key objectives are in the porting process...

I understand that there is a small subset of files & folders that are specific to our processor (such as vendors/nuvoton, arch/arm/*nuc700*, etc). I understand that these source files contain platform-specific code, but Im not clear on how to integrate those files into the kernel build, and how to make the build configuration correctly 'point to' and integrate those files/directories into the actual build...

BTW,I feel comfortable digging into kernel code, but I do lack experience working with it (which is one of my main motivations for working with this project; to learn more about kernel coding & embedded system development). So, I wouldn't mind 'going crazy' analyzing a bunch of source code in order to try to get the BSP ported to a newer kernel, since I'd consider it a great challenge. I just need some help, tips, & advice on how to get started...


EDIT:
I just performed a quick search and took a look at the configuration options for building the toolchain/uclibc in buildroot. it *appears* that there are options for disabling MMU support, and also for enabling 'elf2flt' functionality. Have you tried these options? if not, how can we go about setting a test build? can you please send me your build config?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 06, 2013, 04:18:02 am
Sure I'd be happy to help - I just don't want to waste effort having two people work on porting the kernel and nobody working on getting userspace up and running!

Briefly, you add options to the appropriate Kconfig file so that they appear in 'make menuconfig' or similar.  In our case we're adding a new architecture, so the file will be in the arch/arm/ directory.  Adding the appropriate option allows you to select the new architecture in the kernel config.  This then sets some variables which are passed through to the Makefile, and in there you basically have things that say "if this option is set, compile this file too".

In those files you then implement certain functions the kernel always calls (like a function to print a message very early in the boot process), as well as certain data structures which describe which devices are always present on your platform (in this case things like the built in UARTs and USB ports on the processor itself.)

As for the ZFLAT support, yes I've tried those options but they break with weird compile errors I have yet to figure out.  Someone from the OpenWRT team pointed me at a very old version of buildroot which is supposed to have working ZFLAT support (which could be ported to the latest buildroot) but I haven't had a chance to test it yet.  It's at https://github.com/milkymist/openwrt-milkymist/

The buildroot developers seem quite happy to accept patches to get ZFLAT working again, as well as test configurations they can add to their regular test suite so they can avoid breaking it again.  It is my hope to get an NUC745 config added to buildroot they can use for regular testing to make sure it doesn't break again.

I will try to post my buildroot config and associated NUC700 patches for buildroot this weekend so you can start experimenting.  It seems this is actually an even greater challenge than porting the kernel code itself!
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 07, 2013, 07:35:15 pm
That sounds great; I'll be waiting for your patches/config.

userspace seems alot easier doesnt it?
up until recently, I had a working build environment for the 3.1 kernel (listed in the sticky post in this forum). unfortunately, that build environment was 'damaged' and I could no longer successfullly compile the 3.1 kernel. The repositories listed in the sticky post no longer work (it seems that this project is almost abandoned?). So, I havent been able to 'start from scratch' using the instructions listed here on the forum..

but, during the time I had a compilable kernel, I was working toward building a userspace package that would include webserver & mjpg camera streaming utitlity. The only problem was the stepper motor control. Recently, there was a 'breakthrough' on this, and I was finally able to get some code that would run the motors (more info on this is available in the hacking/mod forum). Unfortunately, I lost my build environment and now Im trying to start over with buildroot.

Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 09, 2013, 02:46:52 am
Userspace would be easier if it was possible to actually compile a program!  But since it's currently not possible to compile ZFLAT binaries with buildroot, it's a bit of a stumbling block.

I've cleaned up some of the kernel code and I'm pushing it to GitHub here: https://github.com/Malvineous/linux-nuc700

If you just want to boot a kernel to see whether it works, try this one (http://www.shikadi.net/files/buildroot/2013-06-09.zImage).  Just use the "mt" command in the bootloader, and TFTP it onto the device with something like this:
Code: [Select]
tftp -v -m binary 192.168.0.25 -c put zImage

There's still more stuff I have to finish cleaning up (e.g. USB and Ethernet support) so the kernel is still a little incomplete.  The kernel zImage above has all this stuff compiled in it though.

I'll have a go at preparing my buildroot patches next.
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 09, 2013, 03:15:17 am
And here are my buildroot patches: https://github.com/Malvineous/buildroot-openipcam

You should be able to clone the nuc700 branch of that repo and use the nuc745_defconfig to build it all.  That config will pull the kernel source in from the git repo in my previous post, so you shouldn't have to do anything special there.

But I haven't tested it, so let me know if it breaks :-)
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 09, 2013, 07:39:39 pm
cool.
a couple of questions:
1) what toolchain did you use to compile the nuc700 branch?

2) what exactly do I need to do to apply the buildroot patches? how should I use that repository? I apologize, but I need instructions. Im not clear on what to do with the files in that repo.
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 10, 2013, 01:55:37 am
buildroot automatically downloads and compiles the necessary toolchain, so you don't need one installed on your system already.

If you clone the buildroot repository, that should be pretty much all you need.  If you follow the buildroot manual (http://buildroot.uclibc.org/downloads/manual/manual.html) all you should need to do is select the nuc700 "defconfig", run "make" and then some hours later end up with a working firmware.

Of course this is how it's supposed to work, but since the no-MMU support is a bit flakey, it will most likely just fail somewhere in the build process and then the real work begins, figuring out how to fix it!
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 10, 2013, 05:09:26 am
ok, I cloned the buildroot repo, ran 'make menuconfig', selected the relevant options (target arch, nommu, processor, etc), ran make, and ran into the following errors:
Code: [Select]
buildroot-openipcam/output/host/usr/arm-buildroot-linux-uclibcgnueabi/bin/ld: cannot find crti.o: No such file or directory
buildroot-openipcam/output/host/usr/arm-buildroot-linux-uclibcgnueabi/bin/ld: cannot find crtn.o: No such file or directory

any ideas on how to solve this?
FYI, I found this which I believe describes a similar problem:
http://stackoverflow.com/questions/3346173/why-is-a-gcc-cross-compile-not-building-crti-o (http://stackoverflow.com/questions/3346173/why-is-a-gcc-cross-compile-not-building-crti-o)

however, Im not clear on how to apply that solution this this problem with buildroot.

Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 10, 2013, 04:34:07 pm
Did you switch to the nuc700 branch before compiling?  This is an error that should be fixed by one of my additional commits in that branch.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 10, 2013, 04:47:32 pm
here's what I did:
Code: [Select]
#inside my working directory
git clone https://github.com/Malvineous/buildroot-openipcam
cd buildroot-openipcam
make clean #just in case
make nuc745_defconfig
make
#...compilation begins
# bombs on missing crti.o/crtn.o errors
any other ideas?

I'm starting over from scratch right now, deleting/re-cloning the repo to see if it fixes the problem.
FYI, Im building on a 64bit machine (though I dont believe it should even matter, since its cross-compiling for a different arch).

EDIT:
i just tried starting all over, deleted the local copy of the repo, re-cloned it, and ran 'make nu745_defconfig' and 'make', but I still get the same error.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 11, 2013, 04:43:10 am
I tried digging through all of the config & makefiles, trying to find the source of the problem with the missing files. I got about as far as seeing that the problem appears to arise in the uClibc build, where there are a few different sets of conditions that determine whether or not to build the crt*.o objects.

I googled the issue, yet I couldnt find much except for some info that indicated that those object libraries are associated with CTOR/DTOR C constructor/destructor routines associated with ELF binary files (I might be incorrect about this though). Since its related to ELF, I dont know if compilation of those objects is necessary.

In any case, I tried editing the uclibc.mk file in {build_dir}/toolchain/uClibc folder, and commenting out the line that tries to include those files in the linkage (@ around line 440). The build was able to progress further, but then failed again with the same error at a later step.

So, I can't seem to find the right place in the build process to enable the compilation of those crt*.o files...
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 12, 2013, 04:53:14 am
You shouldn't have to delete-reclone the repo, you can use a variant of 'git reset' to return it to a fresh state.  You can also run "make O=/path/to/output/dir" to put all the build fluff and the output images in a folder separate to the git repo.  Then cleaning it is as simple as deleting that folder.

You must have the correct branch given that 'make nuc745_defconfig' works.  Try running "git branch" and confirm it says "nuc700" and not "master".  I've updated the default config so try a 'git pull' before going again, however I don't think this will affect your issue.

If you don't have any luck I'll try to build it from scratch this weekend to see if I can replicate the issue.  In the mean time, going into the uclibc config ('make uclibc-menuconfig') and under 'General Library Settings' the option 'Support global constructors and destructors' should be disabled.  If it's not, either the uclibc settings aren't being picked up or I haven't yet told buildroot to force that setting off for ARM7TDMI platforms.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 12, 2013, 06:00:54 am
tried everything you suggested:
- reset the repo using 'git reset'
- ran the 'git branch' command and verified that I was on the nuc745 branch
- 'make clean && make nuc745_defconfig'
- 'make uclibc-menuconfig' and verified that the 'Support global constructors...' option was DISABLED
- 'make' and still ran into the same errors 'cannot find crti.o/crtn.o...'

so Im pretty much stuck, it seems there's something broken somewhere within the makefiles/config files...
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 13, 2013, 03:16:43 am
Sorry my mistake, I left one file out of the repository thinking it was a patch left over that I had applied, but actually it was a patch buildroot is supposed to apply to uclibc so it belongs in the repo.

If you do another 'git pull' and try again hopefully this time you'll get further along.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 13, 2013, 04:11:36 am
tried again, this time I *believe* that I got further along, though now Im running into this error:
Code: [Select]
>>> zlib 1.2.7 Building
/usr/bin/make -j1 -C /data/local/apps/openipcam/build/malv/buildroot-openipcam/output/build/zlib-1.2.7
make[1]: Entering directory `/data/local/apps/openipcam/build/malv/buildroot-openipcam/output/build/zlib-1.2.7'
/data/local/apps/openipcam/build/malv/buildroot-openipcam/output/host/usr/bin/ccache /data/local/apps/openipcam/build/malv/buildroot-openipcam/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -pipe -Os  -Wl,-elf2flt -DBR_BINFMT_FLAT   -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf -DHAVE_HIDDEN -o example example.o -L. libz.a
/data/local/apps/openipcam/build/malv/buildroot-openipcam/output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld.real: error: no memory region specified for loadable section `.ARM.extab'

So, now its a problem with zlib...
any ideas?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 14, 2013, 04:32:47 am
Ok, so now you've gotten as far as I have.  It's not a problem with zlib, it's just that in your case zlib happens to be the first thing that experiences this problem.  The error you see (about ".ARM.extab") is actually the output from elf2flt, when it tries to convert the ELF output from the compiler to the FLAT binary format.

This is the point I haven't been able to get past, so now your work can begin, if you are willing to help :-)

If you just want to see stuff happen, you should be able to run 'make linux' or similar (see "make help" for details) to just compile the kernel itself, as that part does work.  Of course the kernel panics shortly after bootup because it can't run 'init', since you either haven't compiled it or it's not in FLAT format because of the above problem.
Title: Re: need help creating a custom BSP using buildroot
Post by: TheUberOverLord on June 14, 2013, 08:39:50 am
Ok, so now you've gotten as far as I have.  It's not a problem with zlib, it's just that in your case zlib happens to be the first thing that experiences this problem.  The error you see (about ".ARM.extab") is actually the output from elf2flt, when it tries to convert the ELF output from the compiler to the FLAT binary format.

This is the point I haven't been able to get past, so now your work can begin, if you are willing to help :-)

If you just want to see stuff happen, you should be able to run 'make linux' or similar (see "make help" for details) to just compile the kernel itself, as that part does work.  Of course the kernel panics shortly after bootup because it can't run 'init', since you either haven't compiled it or it's not in FLAT format because of the above problem.
Have you seen this?

http://git.buildroot.net/buildroot/commit/?id=57c05432917de3b9aec293d713acafde01ac9b07 (http://git.buildroot.net/buildroot/commit/?id=57c05432917de3b9aec293d713acafde01ac9b07)

http://buildroot-busybox.2317881.n4.nabble.com/git-commit-arch-toolchain-Introduce-binary-format-FLAT-types-td44668.html (http://buildroot-busybox.2317881.n4.nabble.com/git-commit-arch-toolchain-Introduce-binary-format-FLAT-types-td44668.html)

Don
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 14, 2013, 06:36:42 pm
Thanks for the tip!  Yes I have seen those commits, unfortunately they only affect two variants of FLAT formats which I believe won't work on the processor used by our cameras (plus I got heaps of other compiler errors when I tried to use those formats instead.)  The only variant I am aware of (normal/plain FLAT) isn't affected by those commits.

At any rate those commits are in the buildroot repo I posted that @changosurf is using.
Title: Re: need help creating a custom BSP using buildroot
Post by: TheUberOverLord on June 14, 2013, 07:00:40 pm
Thanks for the tip!  Yes I have seen those commits, unfortunately they only affect two variants of FLAT formats which I believe won't work on the processor used by our cameras (plus I got heaps of other compiler errors when I tried to use those formats instead.)  The only variant I am aware of (normal/plain FLAT) isn't affected by those commits.

At any rate those commits are in the buildroot repo I posted that @changosurf is using.

You are very welcome.

I wonder if the errors could be related to these other options not being also set properly?

All segments are linked into one memory region.

Allow for the data and text segments to be separated and placed in different regions of memory.

Allow to load and link individual FLAT binaries at run time.

As mentioned here: http://buildroot-busybox.2317881.n4.nabble.com/git-commit-arch-toolchain-Introduce-binary-format-FLAT-types-td44668.html (http://buildroot-busybox.2317881.n4.nabble.com/git-commit-arch-toolchain-Introduce-binary-format-FLAT-types-td44668.html)

Don
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 14, 2013, 07:45:32 pm
I might be wrong, but doesnt this error have something to do with the actual linker script, and not so much the elf2flt stuff? I found some related posts and stackoverflow & some other sites that mention this as being a problem with the design of the actual linker commands within the linker script. Apparently, there needs to be a designated segment of memory that is attached to that section, or something to this effect.

Again, Im not an expert *at all* on this subject. In fact, Im currently in the process of trying to read up on the ld command language in order to try to understand how this works. I was able to dig into the linker script and verify that there was in fact an '.ARM.extab.' section, which apparently is meant to handle 'exception unwinding.'

if someone is more knowledgeable on this subject, please jump in, correct me, and fill us in on how this actually works and why ld is failing & barking about the "no memory region specified for loadable section `.ARM.extab'"...
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 14, 2013, 10:30:01 pm
Well if you're not an expert at this then that makes two of us :-)  Where did you find the linker script that mentions ".ARM.extab"?  I couldn't find it.

If this section is used for exception unwinding then that makes sense that it's missing, because that's a C++ feature along with constructors and destructors (which if you remember you had to disable support for in the uclibc config.)  So I'm not sure whether the problem is that this section is supposed to be present, or whether elf2flt is supposed to cope when it's missing.

I did find these notes on building ARM7 FLAT binaries (http://uldp.home.at/uclinux_doc_3.html) which talk about modifying the linker script, but as I couldn't find the script I haven't tested any of this.

@TheUberOverLoad: Thanks again for jumping in and helping out - the more people looking at this the better!  I don't think those other options are related to the error.  The options that were added are of "choice" type - this means of the options you listed, you can only pick one of them.  We are picking the first one ("One memory region") as I believe that's the only one that works.  The others may also work one day, but from what I've read they will require a bit more effort to get working - so I figure start with the one that's the most likely to work.  My understanding was that the other options were added to make use of some advanced features of the Blackfin processor, but since these cameras have a NUC745 CPU and not a Blackfin, we may not be able to support those other options.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 15, 2013, 12:58:46 am
a couple of quick notes:
within the toolchain output directory, 'output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/', the file 'ld' is a bash script that you can open up and inspect, and 'ld.real' is a binary file, yet which also contains an embedded set of 'plain text' linking commands (you can run 'cat ld.real', and after skipping through a bunch of the binary output, you'll be able to see the command section that Im talking about; it's about half way through the file).

the file which contains the 'ARM.extab' sections is the 'ld.real' binary file. the 'ld' bash script doesnt contain any references to 'ARM.extab'

the 'ld' script contains a reference to the elf2flt option & control structures that handle the condition when the '-elf2flt' switch is used...

the 'ld.real' executable, on the other hand, doesnt contain any references to 'elf2flt'.

Could it be that perhaps the build is somehow misconfigured, and pointing to 'ld.real' instead of 'ld', which would know how to handle the elf2flt switch? (I still dont really have a firm understanding of how all of this works, so I realize that this might be way off)

if not, then whats the purpose of ld.real, and/or its relationship to the ld script?


googling the 'ARM.extab' error, you'll find a few different results.
the one I was referring to was this one:
http://stackoverflow.com/questions/13625245/error-in-cross-compilation-in-case-of-using-new-and-delete (http://stackoverflow.com/questions/13625245/error-in-cross-compilation-in-case-of-using-new-and-delete)



Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 15, 2013, 01:58:52 am
Hmm, so it looks like possibly disabling exceptions might help then?

I would guess "ld.real" is the actual linker program, and "ld" is a script which pretends to be the linker so it can manipulate the command line passed to the linker, or something like that.  This would be because the compiler calls the linker directly, so there's no way of influencing how the linker is called.  By making a script take the place of the linker, the compiler will call the script instead, which can do whatever it wants and then call the real linker when it is happy.

I wouldn't worry too much about the difference between "ld" and "ld.real".  Of course if you need to change the way the linker runs, the "ld" script is likely the place to do it!

I don't believe it's a problem with the -elf2flt switch, because if something didn't understand that it would produce an "unknown command line parameter" error instead.  So I'm confident the correct linker is being called, but quite possibly it is using a linker script that is not compatible with our platform.  The question there is how to change it, and to what?
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 15, 2013, 02:06:32 am
ok, i get it...yeah, after I posted my last message, I realized that the 'ld' file was just a wrapper script for the 'real ld'  & the elf2flt utility. So, now Im currently studying the ld script in order to try to figure out whats going and why its bombing. I think the  error is definitely somewhere within that script. As a test, I modified the zlib makefile and removed the '-elf2flt' switch from the compiler flags. It was able to make it through the zlib build, but then it bombed elsewhere further down the line.

So, like you said, something is broken during that transition from the compiler to the elf2flt 'shim' and then to the actual linker. And, as you stated, if elf2flt was the problem, it would have barked during the conversion, yet it seems to succeed with no issues. so, it seems like its most likely due to the wrapper script; something's not working like its supposed to within that script.

Again, I need to get a better understanding of the internals of the gnu linker, and also how the wrapper (and elf2flt) go about performing the conversion from elf to flat...
thoughts/feedback?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 15, 2013, 04:21:50 am
When you remove the elf2flt option it produces an ELF binary successfully and then continues on with the build, not calling elf2flt at all.  You can actually remove the elf2flt option in the buildroot config, and then the entire build will complete successfully, but with ELF binaries instead of FLAT ones.  So the only problem in the entire build process is the elf2flt conversion.

I have just tried the suggestion on one of the Stack Overflow answers, to pass -fno-exceptions and -fno-rtti to gcc.  It didn't make a difference, warning that these are meant for C++ programs anyway and we're only compiling C stuff.

I'm not sure the ld script is at "fault", but I think the solution lies in that area.  I think we probably need to supply a custom linker script somehow.  You should be able to do that without editing any scripts, hopefully just passing the right command-line parameter.
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 15, 2013, 04:27:54 am
Oh, just discovered the "ld" script you are referring to, which calls "ld.real", is actually supplied by elf2flt.  It is what handles the "-W,-elf2flt" linker option.  The source for this script is in buildroot/toolchain/elf2flt/elf2flt/ld-elf2flt.in

I guess tweaking this to produce the right linker script is the best bet...
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 15, 2013, 04:28:05 am
ok, makes sense.
looking at the ld script, it looks like it passes a default linker script if the user doesnt supply one as an argument. The default script is located at 'output/host/usr/arm-buildroot-linux-uclibcgnueabi/lib/elf2flt.ld'...if you have some ability to read&understand linker scripts, then you might be able to decipher what's going on...i do see mention of ctors/dtors, which could have been causing the initial problem during the build?

Anyway, perhaps if we modify or simply substitute that script with a working version, we might be good to go...I just wish i was more up to speed and knowledgeable on the subject of linking & the ld command language :(
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 15, 2013, 04:42:34 am
Yes, just looking at that script now.  Based on the suggestions from your earlier link (http://stackoverflow.com/questions/13625245/error-in-cross-compilation-in-case-of-using-new-and-delete) I tried adding "*(.ARM.extab*)" to that file, before the gnu.linkonce.s.* line.  I also added this:

Code: [Select]
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx*) } > flatmem
__exidx_end = .;

Just before the .bss line/section.  It fixed the extab errors, but now there are new ones:

Code: [Select]
ERROR: reloc type R_ARM_PREL31 unsupported in this context
ERROR: reloc type R_ARM_NONE unsupported in this context
ERROR: reloc type R_ARM_PREL31 unsupported in this context
ERROR: reloc type R_ARM_PREL31 unsupported in this context
ERROR: reloc type R_ARM_PREL31 unsupported in this context
ERROR: reloc type R_ARM_PREL31 unsupported in this context
ERROR: reloc type R_ARM_PREL31 unsupported in this context
...

Not sure what that is trying to tell me...
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 15, 2013, 04:45:15 am
cool, well at least we're making some kind of progress, looks like we're almost right on top of the problem. Question: does the older, working 2.4 version of uclinux that's part of the BSP also use elf2flt? If so, perhaps we could source a linker script from there?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 15, 2013, 04:50:04 am
Good question.  The 2.4 BSP seems to use much the same linker script - no extab/exidx sections.  So I guess there must be some way to compile code without these sections?  There is some mention that elf2flt needs to be updated to handle the different sections produced by new versions of GCC, so I'm not sure whether it will be possible to avoid producing these sections, or whether we will have to update elf2flt.
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 15, 2013, 05:25:40 am
ok, so now Ive jumped into the actual source code for elf2flt.
It does appear that the elf2flt utility is rather old/obsolete, and it looks like it has pretty much been abandoned.. Perhaps youre right, and its going to be necessary to update elf2flt (I even read on some message list that someone gave up on it and created their own elf-flat converter...). Its going to be slow-going on my end, Im playing a large amount of catch-up on this, as Im pretty clueless on how most of this low-level stuff works.

the elf2flt source code is in the 'output/toolchain/elf2flt' folder

btw, there's an option for elf2flt for 'loading to ram', any idea what that could be used for, and if it could have something to do with these issues?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 15, 2013, 05:42:52 am
Not sure, but it could be used to control XIP (execute in place), which is where the executable file is run directly from the filesystem in flash without loading it into RAM first, saving memory (since the flash can be accessed just like RAM anyway.)

I'm experimenting with compiler flags at the moment, in the hope that the right combination of flags might cause these sections to be omitted, so elf2flt doesn't complain about them.  I'll post back if I have any luck - at the moment I have done a clean build and now binutils won't compile because it doesn't like the -W,elf2flt option (because elf2flt hasn't been installed yet...no idea how I got it to compile the first time!)
Title: Re: need help creating a custom BSP using buildroot
Post by: changosurf on June 22, 2013, 10:47:54 pm
Any updates on this?
did you have any luck finding a solution via the compiler flags?

FYI, don't know if this will help, but while I was looking into a solution for building an XIP kernel, I found the following code in the file ./linux-3.1/arch/arm/kernel/vmlinux.lds.S @around line 52:
Code: [Select]
/DISCARD/ : {
*(.ARM.exidx.exit.text)
*(.ARM.extab.exit.text)
ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
ARM_EXIT_DISCARD(EXIT_TEXT)
ARM_EXIT_DISCARD(EXIT_DATA)
EXIT_CALL
#ifndef CONFIG_HOTPLUG
*(.ARM.exidx.devexit.text)
*(.ARM.extab.devexit.text)
#endif
#ifndef CONFIG_MMU
*(.fixup)
*(__ex_table)
#endif
#ifndef CONFIG_SMP_ON_UP
*(.alt.smp.init)
#endif
*(.discard)
*(.discard.*)
}
although this set of linker commands appears to be specific to the kernel build, perhaps that /DISCARD/ directive might be the key we're looking for. Apparently, it is meant to 'discard' those input sections from the final linked output. Could this be a possible solution?
Title: Re: need help creating a custom BSP using buildroot
Post by: Malvineous on June 29, 2013, 06:56:54 pm
Sorry I haven't had a chance to get back to this for a couple of weeks.  I was hoping the buildroot team could tell me why buildroot was trying to compile binutils for the target when it's not required and I haven't selected it, but I haven't heard back.

I'm not sure that discarding those sections would be a solution - the error is complaining that the sections aren't there - so they must already be discarded somewhere.

I did change the linker script to keep those sections, but then I got the errors in my earlier post which have me pretty stumped.  Maybe the solution is to modify elf2flt so that it is able to cope if those sections are missing?