Sysprogs forums › Forums › Other tools & products › Help using toolchain on custom hardware.
- This topic has 2 replies, 2 voices, and was last updated 11 years, 2 months ago by kkeeley.
-
AuthorPosts
-
September 12, 2013 at 02:03 #640kkeeleyParticipant
Hi,
I have been building my own hardware using a 68000 CPU for many years and have always written my code in assembly. I have recently decided that it would be good to finally start writing my programs in a higher language like C and after a lot of problems building the GNU toolchain I found/downloaded and installed the “Prebuilt GNU toolchain for m68k-elf” from this site. The first trials I did was to convert some of my existing assembly code to work with this assembler and then tested the output on both my emulated environment and my hardware, the results where successful and promising. Next step is to get C code compiling correctly for my environment and this is where I’m not getting the results I’m looking for.
The problem I’m having is that the compiler appears to be trying to use prebuilt libraries and this causes the code to either fail to compile or the code won’t run correctly for my system when I run the code in my emulated environment.
Can anybody provide me examples of the command options to use for gcc/as/ld to prevent them from using any prebuilt libraries and only use the files I provide the source for or to at least compile correctly for my hardware.
I have tried options like these but I’m still not getting the results I’m after.
GCC FLAGS = -nostdinc -nostdlib -nodefaultlibs -Wall -mc68000 -mpcrel
LD FLAGS = -s -Os –gc-sections -nostdlib -nodefaultlibsThanks
KennethSeptember 17, 2013 at 21:15 #2627ketParticipantHi,
Those flags should normally avoid using any not explicitly specified libraries. It is hard to say more without even seeing a single error message you are having.
Of course another thing to remember with cross-compilation is that the shared libraries used for building and running are not necessarily the same.September 17, 2013 at 23:12 #2628kkeeleyParticipantHi Ket,
Thank you for your response. To help every one understand a bit more about what I’m trying to do I will try to explain my hardware setup and what I’m currently trying to program.Firstly the hardware is currently based on a 68000 CPU although I am thinking of upgrading it to a 68030 or 68040 at some point, mainly so I can get the memory management unit and access more memory space. The system currently has 1Mb or RAM located at 0x000000 and 256K of Flash ROM located at 0xFC0000 it also has a dual serial interface used for as a terminal interface and an ATA interface connected to a hard drive for storage that are currently located in the 0x800000 range. I have programmed a number of features into the ROM that allows basic system access, ie displaying characters and strings on the terminal, getting characters from the terminal, reading and writing sectors from the hard drive, etc, these are all provide via Trap routines.
At this time I have the ROM configured to upon power up or reset it will preform a checksum on the ROM followed by testing the first 4KB of RAM if both these test past it will initialize the serial interface and ATA interface. The ROM is also able to look for a master boot sector on a hard drive and if it finds a valid one it will load it into RAM and then run it. The master boot sector can handle checking and loading from different partitions on the hard drive. All of these codes have been written in pure assembly.
Now I wish to actually write standalone executable files that either the ROM or the boot sector code can load from the hard drive into RAM and execute. Basically the start of a very basic operating system. This is where I’m looking for a bit of help, I’m looking for help on what settings/options I need to use with the compiler and linker to allow the programs to work correctly with my hardware. From what I have found so far I am going to have to write my own C runtime library to allow C code to access my hardware in a standard way.
If anybody could help provide me samples on how to compile/link my own C runtime library and then how to use that with a simple hello world program that I can then run on my hardware, that would be great. The sample code doesn’t have to be complete, the more import part I feel is the compiler/linker options to build the files correctly.
Hope this makes more sense now.
Kenneth
-
AuthorPosts
- You must be logged in to reply to this topic.